import { i as sc, g as _f, o as dp, n as yi, a as Nt, s as pp, r as Ko, b as Ni, c as Te, d as P, t as ac, e as mp, f as vf, h as Si, j as Oa, k as Ta, l as gp, T as _p, p as vp, q as oc, v as zi, w as lc, x as Gi, y as Ui, z as xf, A as bf, B as As, E as Ba, C as qc, D as xp, F as Ef, G as cc, H as bp, I as Yc, J as Ep, K as yp, L as Nn, M as yf, N as $a, O as Sp, P as Mp, Q as Ap, R as Tp, S as Sf, U as wp, V as Dp, W as Mf, X as uc, Y as Rp, Z as Cp, _ as Pp, $ as Lp, a0 as Ip, a1 as Fp, a2 as Np, a3 as Af, a4 as Up, a5 as ei, a6 as kr, a7 as Op, a8 as Bp, a9 as kp, aa as Hp, ab as zp, ac as Gp, ad as Tf, ae as wf, af as vr, ag as Vp, ah as hc, ai as Wp, aj as Lt, ak as Xp, al as mn, am as Df, an as $o, ao as jp, ap as qp, aq as Sn, ar as Yp, as as Rf, at as Zp, au as Kp, av as $p, aw as Jp, ax as Cf, ay as $r, az as wt, aA as Qp, aB as Zc, aC as em, aD as Kt, aE as Hr, aF as zr, aG as st, aH as Jo, aI as Dt, aJ as tm, aK as pt, aL as Yt, aM as Mt } from "./render-DdxPsMjd.js";
function Pf(i) {
  throw new Error("https://svelte.dev/e/lifecycle_outside_component");
}
const nm = [];
function im(i, e = !1, t = !1) {
  return ma(i, /* @__PURE__ */ new Map(), "", nm, null, t);
}
function ma(i, e, t, n, r = null, s = !1) {
  if (typeof i == "object" && i !== null) {
    var a = e.get(i);
    if (a !== void 0) return a;
    if (i instanceof Map) return (
      /** @type {Snapshot<T>} */
      new Map(i)
    );
    if (i instanceof Set) return (
      /** @type {Snapshot<T>} */
      new Set(i)
    );
    if (sc(i)) {
      var o = (
        /** @type {Snapshot<any>} */
        Array(i.length)
      );
      e.set(i, o), r !== null && e.set(r, o);
      for (var l = 0; l < i.length; l += 1) {
        var c = i[l];
        l in i && (o[l] = ma(c, e, t, n, null, s));
      }
      return o;
    }
    if (_f(i) === dp) {
      o = {}, e.set(i, o), r !== null && e.set(r, o);
      for (var u of Object.keys(i))
        o[u] = ma(
          // @ts-expect-error
          i[u],
          e,
          t,
          n,
          null,
          s
        );
      return o;
    }
    if (i instanceof Date)
      return (
        /** @type {Snapshot<T>} */
        structuredClone(i)
      );
    if (typeof /** @type {T & { toJSON?: any } } */
    i.toJSON == "function" && !s)
      return ma(
        /** @type {T & { toJSON(): any } } */
        i.toJSON(),
        e,
        t,
        n,
        // Associate the instance with the toJSON clone
        i
      );
  }
  if (i instanceof EventTarget)
    return (
      /** @type {Snapshot<T>} */
      i
    );
  try {
    return (
      /** @type {Snapshot<T>} */
      structuredClone(i)
    );
  } catch {
    return (
      /** @type {Snapshot<T>} */
      i
    );
  }
}
function fc(i, e, t) {
  if (i == null)
    return e(void 0), t && t(void 0), yi;
  const n = Nt(
    () => i.subscribe(
      e,
      // @ts-expect-error
      t
    )
  );
  return n.unsubscribe ? () => n.unsubscribe() : n;
}
const Ji = [];
function rm(i, e) {
  return {
    subscribe: Ts(i, e).subscribe
  };
}
function Ts(i, e = yi) {
  let t = null;
  const n = /* @__PURE__ */ new Set();
  function r(o) {
    if (pp(i, o) && (i = o, t)) {
      const l = !Ji.length;
      for (const c of n)
        c[1](), Ji.push(c, i);
      if (l) {
        for (let c = 0; c < Ji.length; c += 2)
          Ji[c][0](Ji[c + 1]);
        Ji.length = 0;
      }
    }
  }
  function s(o) {
    r(o(
      /** @type {T} */
      i
    ));
  }
  function a(o, l = yi) {
    const c = [o, l];
    return n.add(c), n.size === 1 && (t = e(r, s) || yi), o(
      /** @type {T} */
      i
    ), () => {
      n.delete(c), n.size === 0 && t && (t(), t = null);
    };
  }
  return { set: r, update: s, subscribe: a };
}
function Gr(i, e, t) {
  const n = !Array.isArray(i), r = n ? [i] : i;
  if (!r.every(Boolean))
    throw new Error("derived() expects stores as input, got a falsy value");
  const s = e.length < 2;
  return rm(t, (a, o) => {
    let l = !1;
    const c = [];
    let u = 0, h = yi;
    const d = () => {
      if (u)
        return;
      h();
      const v = e(n ? c[0] : c, a, o);
      s ? a(v) : h = typeof v == "function" ? v : yi;
    }, m = r.map(
      (v, b) => fc(
        v,
        (p) => {
          c[b] = p, u &= ~(1 << b), l && d();
        },
        () => {
          u |= 1 << b;
        }
      )
    );
    return l = !0, d(), function() {
      Ko(m), h(), l = !1;
    };
  });
}
function sm(i) {
  let e;
  return fc(i, (t) => e = t)(), e;
}
let Us = !1, Qo = /* @__PURE__ */ Symbol();
function Kc(i, e, t) {
  const n = t[e] ??= {
    store: null,
    source: Ni(void 0),
    unsubscribe: yi
  };
  if (n.store !== i && !(Qo in t))
    if (n.unsubscribe(), n.store = i ?? null, i == null)
      n.source.v = void 0, n.unsubscribe = yi;
    else {
      var r = !0;
      n.unsubscribe = fc(i, (s) => {
        r ? n.source.v = s : Te(n.source, s);
      }), r = !1;
    }
  return i && Qo in t ? sm(i) : P(n.source);
}
function am() {
  const i = {};
  function e() {
    ac(() => {
      for (var t in i)
        i[t].unsubscribe();
      mp(i, Qo, {
        enumerable: !1,
        value: !0
      });
    });
  }
  return [i, e];
}
function om(i) {
  var e = Us;
  try {
    return Us = !1, [i(), Us];
  } finally {
    Us = e;
  }
}
const lm = (
  // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
  globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
    /** @param {string} html */
    createHTML: (i) => i
  })
);
function cm(i) {
  return (
    /** @type {string} */
    lm?.createHTML(i) ?? i
  );
}
function Lf(i) {
  var e = vf("template");
  return e.innerHTML = cm(i.replaceAll("<!>", "<!---->")), e.content;
}
function Mr(i, e) {
  var t = (
    /** @type {Effect} */
    Oa
  );
  t.nodes === null && (t.nodes = { start: i, end: e, a: null, t: null });
}
// @__NO_SIDE_EFFECTS__
function Ct(i, e) {
  var t = (e & _p) !== 0, n = (e & vp) !== 0, r, s = !i.startsWith("<!>");
  return () => {
    r === void 0 && (r = Lf(s ? i : "<!>" + i), t || (r = /** @type {TemplateNode} */
    Ta(r)));
    var a = (
      /** @type {TemplateNode} */
      n || gp ? document.importNode(r, !0) : r.cloneNode(!0)
    );
    if (t) {
      var o = (
        /** @type {TemplateNode} */
        Ta(a)
      ), l = (
        /** @type {TemplateNode} */
        a.lastChild
      );
      Mr(o, l);
    } else
      Mr(a, a);
    return a;
  };
}
// @__NO_SIDE_EFFECTS__
function um(i, e, t = "svg") {
  var n = !i.startsWith("<!>"), r = `<${t}>${n ? i : "<!>" + i}</${t}>`, s;
  return () => {
    if (!s) {
      var a = (
        /** @type {DocumentFragment} */
        Lf(r)
      ), o = (
        /** @type {Element} */
        Ta(a)
      );
      s = /** @type {Element} */
      Ta(o);
    }
    var l = (
      /** @type {TemplateNode} */
      s.cloneNode(!0)
    );
    return Mr(l, l), l;
  };
}
// @__NO_SIDE_EFFECTS__
function If(i, e) {
  return /* @__PURE__ */ um(i, e, "svg");
}
function Xn(i = "") {
  {
    var e = Si(i + "");
    return Mr(e, e), e;
  }
}
function mr() {
  var i = document.createDocumentFragment(), e = document.createComment(""), t = Si();
  return i.append(e, t), Mr(e, t), i;
}
function Ke(i, e) {
  i !== null && i.before(
    /** @type {Node} */
    e
  );
}
class ka {
  /** @type {TemplateNode} */
  anchor;
  /** @type {Map<Batch, Key>} */
  #e = /* @__PURE__ */ new Map();
  /**
   * Map of keys to effects that are currently rendered in the DOM.
   * These effects are visible and actively part of the document tree.
   * Example:
   * ```
   * {#if condition}
   * 	foo
   * {:else}
   * 	bar
   * {/if}
   * ```
   * Can result in the entries `true->Effect` and `false->Effect`
   * @type {Map<Key, Effect>}
   */
  #n = /* @__PURE__ */ new Map();
  /**
   * Similar to #onscreen with respect to the keys, but contains branches that are not yet
   * in the DOM, because their insertion is deferred.
   * @type {Map<Key, Branch>}
   */
  #t = /* @__PURE__ */ new Map();
  /**
   * Keys of effects that are currently outroing
   * @type {Set<Key>}
   */
  #i = /* @__PURE__ */ new Set();
  /**
   * Whether to pause (i.e. outro) on change, or destroy immediately.
   * This is necessary for `<svelte:element>`
   */
  #r = !0;
  /**
   * @param {TemplateNode} anchor
   * @param {boolean} transition
   */
  constructor(e, t = !0) {
    this.anchor = e, this.#r = t;
  }
  /**
   * @param {Batch} batch
   */
  #s = (e) => {
    if (this.#e.has(e)) {
      var t = (
        /** @type {Key} */
        this.#e.get(e)
      ), n = this.#n.get(t);
      if (n)
        oc(n), this.#i.delete(t);
      else {
        var r = this.#t.get(t);
        r && (this.#n.set(t, r.effect), this.#t.delete(t), r.fragment.lastChild.remove(), this.anchor.before(r.fragment), n = r.effect);
      }
      for (const [s, a] of this.#e) {
        if (this.#e.delete(s), s === e)
          break;
        const o = this.#t.get(a);
        o && (zi(o.effect), this.#t.delete(a));
      }
      for (const [s, a] of this.#n) {
        if (s === t || this.#i.has(s)) continue;
        const o = () => {
          if (Array.from(this.#e.values()).includes(s)) {
            var c = document.createDocumentFragment();
            xf(a, c), c.append(Si()), this.#t.set(s, { effect: a, fragment: c });
          } else
            zi(a);
          this.#i.delete(s), this.#n.delete(s);
        };
        this.#r || !n ? (this.#i.add(s), lc(a, o, !1)) : o();
      }
    }
  };
  /**
   * @param {Batch} batch
   */
  #a = (e) => {
    this.#e.delete(e);
    const t = Array.from(this.#e.values());
    for (const [n, r] of this.#t)
      t.includes(n) || (zi(r.effect), this.#t.delete(n));
  };
  /**
   *
   * @param {any} key
   * @param {null | ((target: TemplateNode) => void)} fn
   */
  ensure(e, t) {
    var n = (
      /** @type {Batch} */
      Ui
    ), r = bf();
    if (t && !this.#n.has(e) && !this.#t.has(e))
      if (r) {
        var s = document.createDocumentFragment(), a = Si();
        s.append(a), this.#t.set(e, {
          effect: Gi(() => t(a)),
          fragment: s
        });
      } else
        this.#n.set(
          e,
          Gi(() => t(this.anchor))
        );
    if (this.#e.set(n, e), r) {
      for (const [o, l] of this.#n)
        o === e ? n.unskip_effect(l) : n.skip_effect(l);
      for (const [o, l] of this.#t)
        o === e ? n.unskip_effect(l.effect) : n.skip_effect(l.effect);
      n.oncommit(this.#s), n.ondiscard(this.#a);
    } else
      this.#s(n);
  }
}
function At(i, e, t = !1) {
  var n = new ka(i), r = t ? Ba : 0;
  function s(a, o) {
    n.ensure(a, o);
  }
  As(() => {
    var a = !1;
    e((o, l = 0) => {
      a = !0, s(l, o);
    }), a || s(-1, null);
  }, r);
}
function $c(i, e) {
  return e;
}
function hm(i, e, t) {
  for (var n = [], r = e.length, s, a = e.length, o = 0; o < r; o++) {
    let h = e[o];
    lc(
      h,
      () => {
        if (s) {
          if (s.pending.delete(h), s.done.add(h), s.pending.size === 0) {
            var d = (
              /** @type {Set<EachOutroGroup>} */
              i.outrogroups
            );
            el(i, cc(s.done)), d.delete(s), d.size === 0 && (i.outrogroups = null);
          }
        } else
          a -= 1;
      },
      !1
    );
  }
  if (a === 0) {
    var l = n.length === 0 && t !== null;
    if (l) {
      var c = (
        /** @type {Element} */
        t
      ), u = (
        /** @type {Element} */
        c.parentNode
      );
      Mp(u), u.append(c), i.items.clear();
    }
    el(i, e, !l);
  } else
    s = {
      pending: new Set(e),
      done: /* @__PURE__ */ new Set()
    }, (i.outrogroups ??= /* @__PURE__ */ new Set()).add(s);
}
function el(i, e, t = !0) {
  var n;
  if (i.pending.size > 0) {
    n = /* @__PURE__ */ new Set();
    for (const a of i.pending.values())
      for (const o of a)
        n.add(
          /** @type {EachItem} */
          i.items.get(o).e
        );
  }
  for (var r = 0; r < e.length; r++) {
    var s = e[r];
    if (n?.has(s)) {
      s.f |= Nn;
      const a = document.createDocumentFragment();
      xf(s, a);
    } else
      zi(e[r], t);
  }
}
var Jc;
function tl(i, e, t, n, r, s = null) {
  var a = i, o = /* @__PURE__ */ new Map(), l = (e & Sf) !== 0;
  if (l) {
    var c = (
      /** @type {Element} */
      i
    );
    a = c.appendChild(Si());
  }
  var u = null, h = Ef(() => {
    var g = t();
    return sc(g) ? g : g == null ? [] : cc(g);
  }), d, m = /* @__PURE__ */ new Map(), v = !0;
  function b(g) {
    (x.effect.f & yf) === 0 && (x.pending.delete(g), x.fallback = u, fm(x, d, a, e, n), u !== null && (d.length === 0 ? (u.f & Nn) === 0 ? oc(u) : (u.f ^= Nn, us(u, null, a)) : lc(u, () => {
      u = null;
    })));
  }
  function p(g) {
    x.pending.delete(g);
  }
  var f = As(() => {
    d = /** @type {V[]} */
    P(h);
    for (var g = d.length, _ = /* @__PURE__ */ new Set(), T = (
      /** @type {Batch} */
      Ui
    ), A = bf(), M = 0; M < g; M += 1) {
      var C = d[M], y = n(C, M), E = v ? null : o.get(y);
      E ? (E.v && qc(E.v, C), E.i && qc(E.i, M), A && T.unskip_effect(E.e)) : (E = dm(
        o,
        v ? a : Jc ??= Si(),
        C,
        y,
        M,
        r,
        e,
        t
      ), v || (E.e.f |= Nn), o.set(y, E)), _.add(y);
    }
    if (g === 0 && s && !u && (v ? u = Gi(() => s(a)) : (u = Gi(() => s(Jc ??= Si())), u.f |= Nn)), g > _.size && xp(), !v)
      if (m.set(T, _), A) {
        for (const [R, q] of o)
          _.has(R) || T.skip_effect(q.e);
        T.oncommit(b), T.ondiscard(p);
      } else
        b(T);
    P(h);
  }), x = { effect: f, items: o, pending: m, outrogroups: null, fallback: u };
  v = !1;
}
function Jr(i) {
  for (; i !== null && (i.f & Sp) === 0; )
    i = i.next;
  return i;
}
function fm(i, e, t, n, r) {
  var s = (n & wp) !== 0, a = e.length, o = i.items, l = Jr(i.effect.first), c, u = null, h, d = [], m = [], v, b, p, f;
  if (s)
    for (f = 0; f < a; f += 1)
      v = e[f], b = r(v, f), p = /** @type {EachItem} */
      o.get(b).e, (p.f & Nn) === 0 && (p.nodes?.a?.measure(), (h ??= /* @__PURE__ */ new Set()).add(p));
  for (f = 0; f < a; f += 1) {
    if (v = e[f], b = r(v, f), p = /** @type {EachItem} */
    o.get(b).e, i.outrogroups !== null)
      for (const E of i.outrogroups)
        E.pending.delete(p), E.done.delete(p);
    if ((p.f & Nn) !== 0)
      if (p.f ^= Nn, p === l)
        us(p, null, t);
      else {
        var x = u ? u.next : l;
        p === i.effect.last && (i.effect.last = p.prev), p.prev && (p.prev.next = p.next), p.next && (p.next.prev = p.prev), ci(i, u, p), ci(i, p, x), us(p, x, t), u = p, d = [], m = [], l = Jr(u.next);
        continue;
      }
    if ((p.f & $a) !== 0 && (oc(p), s && (p.nodes?.a?.unfix(), (h ??= /* @__PURE__ */ new Set()).delete(p))), p !== l) {
      if (c !== void 0 && c.has(p)) {
        if (d.length < m.length) {
          var g = m[0], _;
          u = g.prev;
          var T = d[0], A = d[d.length - 1];
          for (_ = 0; _ < d.length; _ += 1)
            us(d[_], g, t);
          for (_ = 0; _ < m.length; _ += 1)
            c.delete(m[_]);
          ci(i, T.prev, A.next), ci(i, u, T), ci(i, A, g), l = g, u = A, f -= 1, d = [], m = [];
        } else
          c.delete(p), us(p, l, t), ci(i, p.prev, p.next), ci(i, p, u === null ? i.effect.first : u.next), ci(i, u, p), u = p;
        continue;
      }
      for (d = [], m = []; l !== null && l !== p; )
        (c ??= /* @__PURE__ */ new Set()).add(l), m.push(l), l = Jr(l.next);
      if (l === null)
        continue;
    }
    (p.f & Nn) === 0 && d.push(p), u = p, l = Jr(p.next);
  }
  if (i.outrogroups !== null) {
    for (const E of i.outrogroups)
      E.pending.size === 0 && (el(i, cc(E.done)), i.outrogroups?.delete(E));
    i.outrogroups.size === 0 && (i.outrogroups = null);
  }
  if (l !== null || c !== void 0) {
    var M = [];
    if (c !== void 0)
      for (p of c)
        (p.f & $a) === 0 && M.push(p);
    for (; l !== null; )
      (l.f & $a) === 0 && l !== i.fallback && M.push(l), l = Jr(l.next);
    var C = M.length;
    if (C > 0) {
      var y = (n & Sf) !== 0 && a === 0 ? t : null;
      if (s) {
        for (f = 0; f < C; f += 1)
          M[f].nodes?.a?.measure();
        for (f = 0; f < C; f += 1)
          M[f].nodes?.a?.fix();
      }
      hm(i, M, y);
    }
  }
  s && Ap(() => {
    if (h !== void 0)
      for (p of h)
        p.nodes?.a?.apply();
  });
}
function dm(i, e, t, n, r, s, a, o) {
  var l = (a & Ep) !== 0 ? (a & yp) === 0 ? Ni(t, !1, !1) : Yc(t) : null, c = (a & bp) !== 0 ? Yc(r) : null;
  return {
    v: l,
    i: c,
    e: Gi(() => (s(e, l ?? t, c ?? r, o), () => {
      i.delete(n);
    }))
  };
}
function us(i, e, t) {
  if (i.nodes)
    for (var n = i.nodes.start, r = i.nodes.end, s = e && (e.f & Nn) === 0 ? (
      /** @type {EffectNodes} */
      e.nodes.start
    ) : t; n !== null; ) {
      var a = (
        /** @type {TemplateNode} */
        Tp(n)
      );
      if (s.before(n), n === r)
        return;
      n = a;
    }
}
function ci(i, e, t) {
  e === null ? i.effect.first = t : e.next = t, t === null ? i.effect.last = e : t.prev = e;
}
function nl(i, e, t, n, r) {
  var s = e.$$slots?.[t], a = !1;
  s === !0 && (s = e[t === "default" ? "children" : t], a = !0), s === void 0 || s(i, a ? () => n : n);
}
function pm(i, e, ...t) {
  var n = new ka(i);
  As(() => {
    const r = e() ?? null;
    n.ensure(r, r && ((s) => r(s, ...t)));
  }, Ba);
}
function mm(i, e, t) {
  var n = new ka(i);
  As(() => {
    var r = e() ?? null;
    n.ensure(r, r && ((s) => t(s, r)));
  }, Ba);
}
const gm = () => performance.now(), Mn = {
  // don't access requestAnimationFrame eagerly outside method
  // this allows basic testing of user code without JSDOM
  // bunder will eval and remove ternary when the user's app is built
  tick: (
    /** @param {any} _ */
    (i) => requestAnimationFrame(i)
  ),
  now: () => gm(),
  tasks: /* @__PURE__ */ new Set()
};
function Ff() {
  const i = Mn.now();
  Mn.tasks.forEach((e) => {
    e.c(i) || (Mn.tasks.delete(e), e.f());
  }), Mn.tasks.size !== 0 && Mn.tick(Ff);
}
function _m(i) {
  let e;
  return Mn.tasks.size === 0 && Mn.tick(Ff), {
    promise: new Promise((t) => {
      Mn.tasks.add(e = { c: i, f: t });
    }),
    abort() {
      Mn.tasks.delete(e);
    }
  };
}
function vm(i, e, t, n, r, s) {
  var a = null, o = (
    /** @type {TemplateNode} */
    i
  ), l = new ka(o, !1);
  As(() => {
    const c = e() || null;
    var u = c === "svg" ? Dp : void 0;
    if (c === null) {
      l.ensure(null, null);
      return;
    }
    return l.ensure(c, (h) => {
      if (c) {
        if (a = vf(c, u), Mr(a, a), n) {
          var d = a.appendChild(Si());
          n(a, d);
        }
        Oa.nodes.end = a, h.before(a);
      }
    }), () => {
    };
  }, Ba), ac(() => {
  });
}
function xm(i, e) {
  var t = void 0, n;
  Mf(() => {
    t !== (t = e()) && (n && (zi(n), n = null), t && (n = Gi(() => {
      uc(() => (
        /** @type {(node: Element) => void} */
        t(i)
      ));
    })));
  });
}
function Nf(i) {
  var e, t, n = "";
  if (typeof i == "string" || typeof i == "number") n += i;
  else if (typeof i == "object") if (Array.isArray(i)) {
    var r = i.length;
    for (e = 0; e < r; e++) i[e] && (t = Nf(i[e])) && (n && (n += " "), n += t);
  } else for (t in i) i[t] && (n && (n += " "), n += t);
  return n;
}
function bm() {
  for (var i, e, t = 0, n = "", r = arguments.length; t < r; t++) (i = arguments[t]) && (e = Nf(i)) && (n && (n += " "), n += e);
  return n;
}
function Em(i) {
  return typeof i == "object" ? bm(i) : i ?? "";
}
const Qc = [...` 	
\r\f \v\uFEFF`];
function ym(i, e, t) {
  var n = i == null ? "" : "" + i;
  if (e && (n = n ? n + " " + e : e), t) {
    for (var r of Object.keys(t))
      if (t[r])
        n = n ? n + " " + r : r;
      else if (n.length)
        for (var s = r.length, a = 0; (a = n.indexOf(r, a)) >= 0; ) {
          var o = a + s;
          (a === 0 || Qc.includes(n[a - 1])) && (o === n.length || Qc.includes(n[o])) ? n = (a === 0 ? "" : n.substring(0, a)) + n.substring(o + 1) : a = o;
        }
  }
  return n === "" ? null : n;
}
function eu(i, e = !1) {
  var t = e ? " !important;" : ";", n = "";
  for (var r of Object.keys(i)) {
    var s = i[r];
    s != null && s !== "" && (n += " " + r + ": " + s + t);
  }
  return n;
}
function Ja(i) {
  return i[0] !== "-" || i[1] !== "-" ? i.toLowerCase() : i;
}
function Sm(i, e) {
  if (e) {
    var t = "", n, r;
    if (Array.isArray(e) ? (n = e[0], r = e[1]) : n = e, i) {
      i = String(i).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
      var s = !1, a = 0, o = !1, l = [];
      n && l.push(...Object.keys(n).map(Ja)), r && l.push(...Object.keys(r).map(Ja));
      var c = 0, u = -1;
      const b = i.length;
      for (var h = 0; h < b; h++) {
        var d = i[h];
        if (o ? d === "/" && i[h - 1] === "*" && (o = !1) : s ? s === d && (s = !1) : d === "/" && i[h + 1] === "*" ? o = !0 : d === '"' || d === "'" ? s = d : d === "(" ? a++ : d === ")" && a--, !o && s === !1 && a === 0) {
          if (d === ":" && u === -1)
            u = h;
          else if (d === ";" || h === b - 1) {
            if (u !== -1) {
              var m = Ja(i.substring(c, u).trim());
              if (!l.includes(m)) {
                d !== ";" && h++;
                var v = i.substring(c, h).trim();
                t += " " + v + ";";
              }
            }
            c = h + 1, u = -1;
          }
        }
      }
    }
    return n && (t += eu(n)), r && (t += eu(r, !0)), t = t.trim(), t === "" ? null : t;
  }
  return i == null ? null : String(i);
}
function ri(i, e, t, n, r, s) {
  var a = i.__className;
  if (a !== t || a === void 0) {
    var o = ym(t, n, s);
    o == null ? i.removeAttribute("class") : e ? i.className = o : i.setAttribute("class", o), i.__className = t;
  } else if (s && r !== s)
    for (var l in s) {
      var c = !!s[l];
      (r == null || c !== !!r[l]) && i.classList.toggle(l, c);
    }
  return s;
}
function Qa(i, e = {}, t, n) {
  for (var r in t) {
    var s = t[r];
    e[r] !== s && (t[r] == null ? i.style.removeProperty(r) : i.style.setProperty(r, s, n));
  }
}
function Dn(i, e, t, n) {
  var r = i.__style;
  if (r !== e) {
    var s = Sm(e, n);
    s == null ? i.removeAttribute("style") : i.style.cssText = s, i.__style = e;
  } else n && (Array.isArray(n) ? (Qa(i, t?.[0], n[0]), Qa(i, t?.[1], n[1], "important")) : Qa(i, t, n));
  return n;
}
function il(i, e, t = !1) {
  if (i.multiple) {
    if (e == null)
      return;
    if (!sc(e))
      return Rp();
    for (var n of i.options)
      n.selected = e.includes(tu(n));
    return;
  }
  for (n of i.options) {
    var r = tu(n);
    if (Cp(r, e)) {
      n.selected = !0;
      return;
    }
  }
  (!t || e !== void 0) && (i.selectedIndex = -1);
}
function Mm(i) {
  var e = new MutationObserver(() => {
    il(i, i.__value);
  });
  e.observe(i, {
    // Listen to option element changes
    childList: !0,
    subtree: !0,
    // because of <optgroup>
    // Listen to option element value attribute changes
    // (doesn't get notified of select value changes,
    // because that property is not reflected as an attribute)
    attributes: !0,
    attributeFilter: ["value"]
  }), ac(() => {
    e.disconnect();
  });
}
function tu(i) {
  return "__value" in i ? i.__value : i.value;
}
const hs = /* @__PURE__ */ Symbol("class"), pr = /* @__PURE__ */ Symbol("style"), Uf = /* @__PURE__ */ Symbol("is custom element"), Of = /* @__PURE__ */ Symbol("is html"), Am = Af ? "option" : "OPTION", Tm = Af ? "select" : "SELECT";
function wm(i, e) {
  e ? i.hasAttribute("selected") || i.setAttribute("selected", "") : i.removeAttribute("selected");
}
function In(i, e, t, n) {
  var r = Bf(i);
  r[e] !== (r[e] = t) && (e === "loading" && (i[Pp] = t), t == null ? i.removeAttribute(e) : typeof t != "string" && kf(i).includes(e) ? i[e] = t : i.setAttribute(e, t));
}
function Dm(i, e, t, n, r = !1, s = !1) {
  var a = Bf(i), o = a[Uf], l = !a[Of], c = e || {}, u = i.nodeName === Am;
  for (var h in e)
    h in t || (t[h] = null);
  t.class ? t.class = Em(t.class) : t.class = null, t[pr] && (t.style ??= null);
  var d = kf(i);
  for (const g in t) {
    let _ = t[g];
    if (u && g === "value" && _ == null) {
      i.value = i.__value = "", c[g] = _;
      continue;
    }
    if (g === "class") {
      var m = i.namespaceURI === "http://www.w3.org/1999/xhtml";
      ri(i, m, _, n, e?.[hs], t[hs]), c[g] = _, c[hs] = t[hs];
      continue;
    }
    if (g === "style") {
      Dn(i, _, e?.[pr], t[pr]), c[g] = _, c[pr] = t[pr];
      continue;
    }
    var v = c[g];
    if (!(_ === v && !(_ === void 0 && i.hasAttribute(g)))) {
      c[g] = _;
      var b = g[0] + g[1];
      if (b !== "$$")
        if (b === "on") {
          const T = {}, A = "$$" + g;
          let M = g.slice(2);
          var p = zp(M);
          if (Up(M) && (M = M.slice(0, -7), T.capture = !0), !p && v) {
            if (_ != null) continue;
            i.removeEventListener(M, c[A], T), c[A] = null;
          }
          if (p)
            ei(M, i, _), kr([M]);
          else if (_ != null) {
            let C = function(y) {
              c[g].call(this, y);
            };
            c[A] = Op(M, i, C, T);
          }
        } else if (g === "style")
          In(i, g, _);
        else if (g === "autofocus")
          Bp(
            /** @type {HTMLElement} */
            i,
            !!_
          );
        else if (!o && (g === "__value" || g === "value" && _ != null))
          i.value = i.__value = _;
        else if (g === "selected" && u)
          wm(
            /** @type {HTMLOptionElement} */
            i,
            _
          );
        else {
          var f = g;
          l || (f = kp(f));
          var x = f === "defaultValue" || f === "defaultChecked";
          if (_ == null && !o && !x)
            if (a[g] = null, f === "value" || f === "checked") {
              let T = (
                /** @type {HTMLInputElement} */
                i
              );
              const A = e === void 0;
              if (f === "value") {
                let M = T.defaultValue;
                T.removeAttribute(f), T.defaultValue = M, T.value = T.__value = A ? M : null;
              } else {
                let M = T.defaultChecked;
                T.removeAttribute(f), T.defaultChecked = M, T.checked = A ? M : !1;
              }
            } else
              i.removeAttribute(g);
          else x || d.includes(f) && (o || typeof _ != "string") ? (i[f] = _, f in a && (a[f] = Hp)) : typeof _ != "function" && In(i, f, _);
        }
    }
  }
  return c;
}
function Rm(i, e, t = [], n = [], r = [], s, a = !1, o = !1) {
  Fp(r, t, n, (l) => {
    var c = void 0, u = {}, h = i.nodeName === Tm, d = !1;
    if (Mf(() => {
      var v = e(...l.map(P)), b = Dm(
        i,
        c,
        v,
        s,
        a,
        o
      );
      d && h && "value" in v && il(
        /** @type {HTMLSelectElement} */
        i,
        v.value
      );
      for (let f of Object.getOwnPropertySymbols(u))
        v[f] || zi(u[f]);
      for (let f of Object.getOwnPropertySymbols(v)) {
        var p = v[f];
        f.description === Np && (!c || p !== c[f]) && (u[f] && zi(u[f]), u[f] = Gi(() => xm(i, () => p))), b[f] = p;
      }
      c = b;
    }), h) {
      var m = (
        /** @type {HTMLSelectElement} */
        i
      );
      uc(() => {
        il(
          m,
          /** @type {Record<string | symbol, any>} */
          c.value,
          !0
        ), Mm(m);
      });
    }
    d = !0;
  });
}
function Bf(i) {
  return (
    /** @type {Record<string | symbol, unknown>} **/
    // @ts-expect-error
    i.__attributes ??= {
      [Uf]: i.nodeName.includes("-"),
      [Of]: i.namespaceURI === Lp
    }
  );
}
var nu = /* @__PURE__ */ new Map();
function kf(i) {
  var e = i.getAttribute("is") || i.nodeName, t = nu.get(e);
  if (t) return t;
  nu.set(e, t = []);
  for (var n, r = i, s = Element.prototype; s !== r; ) {
    n = Ip(r);
    for (var a in n)
      n[a].set && t.push(a);
    r = _f(r);
  }
  return t;
}
function iu(i, e, t = e) {
  var n = /* @__PURE__ */ new WeakSet();
  Gp(i, "input", async (r) => {
    var s = r ? i.defaultValue : i.value;
    if (s = eo(i) ? to(s) : s, t(s), Ui !== null && n.add(Ui), await Tf(), s !== (s = e())) {
      var a = i.selectionStart, o = i.selectionEnd, l = i.value.length;
      if (i.value = s ?? "", o !== null) {
        var c = i.value.length;
        a === o && o === l && c > l ? (i.selectionStart = c, i.selectionEnd = c) : (i.selectionStart = a, i.selectionEnd = Math.min(o, c));
      }
    }
  }), // If we are hydrating and the value has since changed,
  // then use the updated value from the input instead.
  // If defaultValue is set, then value == defaultValue
  // TODO Svelte 6: remove input.value check and set to empty string?
  Nt(e) == null && i.value && (t(eo(i) ? to(i.value) : i.value), Ui !== null && n.add(Ui)), wf(() => {
    var r = e();
    if (i === document.activeElement) {
      var s = (
        /** @type {Batch} */
        Ui
      );
      if (n.has(s))
        return;
    }
    eo(i) && r === to(i.value) || i.type === "date" && !r && !i.value || r !== i.value && (i.value = r ?? "");
  });
}
function eo(i) {
  var e = i.type;
  return e === "number" || e === "range";
}
function to(i) {
  return i === "" ? null : +i;
}
function ru(i, e) {
  return i === e || i?.[hc] === e;
}
function Ha(i = {}, e, t, n) {
  var r = (
    /** @type {ComponentContext} */
    vr.r
  ), s = (
    /** @type {Effect} */
    Oa
  );
  return uc(() => {
    var a, o;
    return wf(() => {
      a = o, o = [], Nt(() => {
        i !== t(...o) && (e(i, ...o), a && ru(t(...a), i) && e(null, ...a));
      });
    }), () => {
      let l = s;
      for (; l !== r && l.parent !== null && l.parent.f & Vp; )
        l = l.parent;
      const c = () => {
        o && ru(t(...o), i) && e(null, ...o);
      }, u = l.teardown;
      l.teardown = () => {
        c(), u?.();
      };
    };
  }), i;
}
function Cm(i = !1) {
  const e = (
    /** @type {ComponentContextLegacy} */
    vr
  ), t = e.l.u;
  if (!t) return;
  let n = () => mn(e.s);
  if (i) {
    let r = 0, s = (
      /** @type {Record<string, any>} */
      {}
    );
    const a = Df(() => {
      let o = !1;
      const l = e.s;
      for (const c in l)
        l[c] !== s[c] && (s[c] = l[c], o = !0);
      return o && r++, r;
    });
    n = () => P(a);
  }
  t.b.length && Wp(() => {
    su(e, n), Ko(t.b);
  }), Lt(() => {
    const r = Nt(() => t.m.map(Xp));
    return () => {
      for (const s of r)
        typeof s == "function" && s();
    };
  }), t.a.length && Lt(() => {
    su(e, n), Ko(t.a);
  });
}
function su(i, e) {
  if (i.l.s)
    for (const t of i.l.s) P(t);
  e();
}
const Pm = {
  get(i, e) {
    if (!i.exclude.includes(e))
      return i.props[e];
  },
  set(i, e) {
    return !1;
  },
  getOwnPropertyDescriptor(i, e) {
    if (!i.exclude.includes(e) && e in i.props)
      return {
        enumerable: !0,
        configurable: !0,
        value: i.props[e]
      };
  },
  has(i, e) {
    return i.exclude.includes(e) ? !1 : e in i.props;
  },
  ownKeys(i) {
    return Reflect.ownKeys(i.props).filter((e) => !i.exclude.includes(e));
  }
};
// @__NO_SIDE_EFFECTS__
function Lm(i, e, t) {
  return new Proxy(
    { props: i, exclude: e },
    Pm
  );
}
const Im = {
  get(i, e) {
    let t = i.props.length;
    for (; t--; ) {
      let n = i.props[t];
      if ($r(n) && (n = n()), typeof n == "object" && n !== null && e in n) return n[e];
    }
  },
  set(i, e, t) {
    let n = i.props.length;
    for (; n--; ) {
      let r = i.props[n];
      $r(r) && (r = r());
      const s = $o(r, e);
      if (s && s.set)
        return s.set(t), !0;
    }
    return !1;
  },
  getOwnPropertyDescriptor(i, e) {
    let t = i.props.length;
    for (; t--; ) {
      let n = i.props[t];
      if ($r(n) && (n = n()), typeof n == "object" && n !== null && e in n) {
        const r = $o(n, e);
        return r && !r.configurable && (r.configurable = !0), r;
      }
    }
  },
  has(i, e) {
    if (e === hc || e === Cf) return !1;
    for (let t of i.props)
      if ($r(t) && (t = t()), t != null && e in t) return !0;
    return !1;
  },
  ownKeys(i) {
    const e = [];
    for (let t of i.props)
      if ($r(t) && (t = t()), !!t) {
        for (const n in t)
          e.includes(n) || e.push(n);
        for (const n of Object.getOwnPropertySymbols(t))
          e.includes(n) || e.push(n);
      }
    return e;
  }
};
function Fm(...i) {
  return new Proxy({ props: i }, Im);
}
function Ee(i, e, t, n) {
  var r = !Rf || (t & Zp) !== 0, s = (t & Yp) !== 0, a = (t & $p) !== 0, o = (
    /** @type {V} */
    n
  ), l = !0, c = () => (l && (l = !1, o = a ? Nt(
    /** @type {() => V} */
    n
  ) : (
    /** @type {V} */
    n
  )), o);
  let u;
  if (s) {
    var h = hc in i || Cf in i;
    u = $o(i, e)?.set ?? (h && e in i ? (g) => i[e] = g : void 0);
  }
  var d, m = !1;
  s ? [d, m] = om(() => (
    /** @type {V} */
    i[e]
  )) : d = /** @type {V} */
  i[e], d === void 0 && n !== void 0 && (d = c(), u && (r && jp(), u(d)));
  var v;
  if (r ? v = () => {
    var g = (
      /** @type {V} */
      i[e]
    );
    return g === void 0 ? c() : (l = !0, g);
  } : v = () => {
    var g = (
      /** @type {V} */
      i[e]
    );
    return g !== void 0 && (o = /** @type {V} */
    void 0), g === void 0 ? o : g;
  }, r && (t & qp) === 0)
    return v;
  if (u) {
    var b = i.$$legacy;
    return (
      /** @type {() => V} */
      (function(g, _) {
        return arguments.length > 0 ? ((!r || !_ || b || m) && u(_ ? v() : g), g) : v();
      })
    );
  }
  var p = !1, f = ((t & Kp) !== 0 ? Df : Ef)(() => (p = !1, v()));
  s && P(f);
  var x = (
    /** @type {Effect} */
    Oa
  );
  return (
    /** @type {() => V} */
    (function(g, _) {
      if (arguments.length > 0) {
        const T = _ ? P(f) : r && s ? Sn(g) : g;
        return Te(f, T), p = !0, o !== void 0 && (o = T), g;
      }
      return Jp && p || (x.f & yf) !== 0 ? f.v : P(f);
    })
  );
}
function Hf(i) {
  vr === null && Pf(), Rf && vr.l !== null ? Um(vr).m.push(i) : Lt(() => {
    const e = Nt(i);
    if (typeof e == "function") return (
      /** @type {() => void} */
      e
    );
  });
}
function Nm(i) {
  vr === null && Pf(), Hf(() => () => Nt(i));
}
function Um(i) {
  var e = (
    /** @type {ComponentContextLegacy} */
    i.l
  );
  return e.u ??= { a: [], b: [], m: [] };
}
const Om = [
  { color: "red", primary: 600, secondary: 100 },
  { color: "green", primary: 600, secondary: 100 },
  { color: "blue", primary: 600, secondary: 100 },
  { color: "yellow", primary: 500, secondary: 100 },
  { color: "purple", primary: 600, secondary: 100 },
  { color: "teal", primary: 600, secondary: 100 },
  { color: "orange", primary: 600, secondary: 100 },
  { color: "cyan", primary: 600, secondary: 100 },
  { color: "lime", primary: 500, secondary: 100 },
  { color: "pink", primary: 600, secondary: 100 }
], au = {
  inherit: "inherit",
  current: "currentColor",
  transparent: "transparent",
  black: "#000",
  white: "#fff",
  slate: {
    50: "#f8fafc",
    100: "#f1f5f9",
    200: "#e2e8f0",
    300: "#cbd5e1",
    400: "#94a3b8",
    500: "#64748b",
    600: "#475569",
    700: "#334155",
    800: "#1e293b",
    900: "#0f172a",
    950: "#020617"
  },
  gray: {
    50: "#f9fafb",
    100: "#f3f4f6",
    200: "#e5e7eb",
    300: "#d1d5db",
    400: "#9ca3af",
    500: "#6b7280",
    600: "#4b5563",
    700: "#374151",
    800: "#1f2937",
    900: "#111827",
    950: "#030712"
  },
  zinc: {
    50: "#fafafa",
    100: "#f4f4f5",
    200: "#e4e4e7",
    300: "#d4d4d8",
    400: "#a1a1aa",
    500: "#71717a",
    600: "#52525b",
    700: "#3f3f46",
    800: "#27272a",
    900: "#18181b",
    950: "#09090b"
  },
  neutral: {
    50: "#fafafa",
    100: "#f5f5f5",
    200: "#e5e5e5",
    300: "#d4d4d4",
    400: "#a3a3a3",
    500: "#737373",
    600: "#525252",
    700: "#404040",
    800: "#262626",
    900: "#171717",
    950: "#0a0a0a"
  },
  stone: {
    50: "#fafaf9",
    100: "#f5f5f4",
    200: "#e7e5e4",
    300: "#d6d3d1",
    400: "#a8a29e",
    500: "#78716c",
    600: "#57534e",
    700: "#44403c",
    800: "#292524",
    900: "#1c1917",
    950: "#0c0a09"
  },
  red: {
    50: "#fef2f2",
    100: "#fee2e2",
    200: "#fecaca",
    300: "#fca5a5",
    400: "#f87171",
    500: "#ef4444",
    600: "#dc2626",
    700: "#b91c1c",
    800: "#991b1b",
    900: "#7f1d1d",
    950: "#450a0a"
  },
  orange: {
    50: "#fff7ed",
    100: "#ffedd5",
    200: "#fed7aa",
    300: "#fdba74",
    400: "#fb923c",
    500: "#f97316",
    600: "#ea580c",
    700: "#c2410c",
    800: "#9a3412",
    900: "#7c2d12",
    950: "#431407"
  },
  amber: {
    50: "#fffbeb",
    100: "#fef3c7",
    200: "#fde68a",
    300: "#fcd34d",
    400: "#fbbf24",
    500: "#f59e0b",
    600: "#d97706",
    700: "#b45309",
    800: "#92400e",
    900: "#78350f",
    950: "#451a03"
  },
  yellow: {
    50: "#fefce8",
    100: "#fef9c3",
    200: "#fef08a",
    300: "#fde047",
    400: "#facc15",
    500: "#eab308",
    600: "#ca8a04",
    700: "#a16207",
    800: "#854d0e",
    900: "#713f12",
    950: "#422006"
  },
  lime: {
    50: "#f7fee7",
    100: "#ecfccb",
    200: "#d9f99d",
    300: "#bef264",
    400: "#a3e635",
    500: "#84cc16",
    600: "#65a30d",
    700: "#4d7c0f",
    800: "#3f6212",
    900: "#365314",
    950: "#1a2e05"
  },
  green: {
    50: "#f0fdf4",
    100: "#dcfce7",
    200: "#bbf7d0",
    300: "#86efac",
    400: "#4ade80",
    500: "#22c55e",
    600: "#16a34a",
    700: "#15803d",
    800: "#166534",
    900: "#14532d",
    950: "#052e16"
  },
  emerald: {
    50: "#ecfdf5",
    100: "#d1fae5",
    200: "#a7f3d0",
    300: "#6ee7b7",
    400: "#34d399",
    500: "#10b981",
    600: "#059669",
    700: "#047857",
    800: "#065f46",
    900: "#064e3b",
    950: "#022c22"
  },
  teal: {
    50: "#f0fdfa",
    100: "#ccfbf1",
    200: "#99f6e4",
    300: "#5eead4",
    400: "#2dd4bf",
    500: "#14b8a6",
    600: "#0d9488",
    700: "#0f766e",
    800: "#115e59",
    900: "#134e4a",
    950: "#042f2e"
  },
  cyan: {
    50: "#ecfeff",
    100: "#cffafe",
    200: "#a5f3fc",
    300: "#67e8f9",
    400: "#22d3ee",
    500: "#06b6d4",
    600: "#0891b2",
    700: "#0e7490",
    800: "#155e75",
    900: "#164e63",
    950: "#083344"
  },
  sky: {
    50: "#f0f9ff",
    100: "#e0f2fe",
    200: "#bae6fd",
    300: "#7dd3fc",
    400: "#38bdf8",
    500: "#0ea5e9",
    600: "#0284c7",
    700: "#0369a1",
    800: "#075985",
    900: "#0c4a6e",
    950: "#082f49"
  },
  blue: {
    50: "#eff6ff",
    100: "#dbeafe",
    200: "#bfdbfe",
    300: "#93c5fd",
    400: "#60a5fa",
    500: "#3b82f6",
    600: "#2563eb",
    700: "#1d4ed8",
    800: "#1e40af",
    900: "#1e3a8a",
    950: "#172554"
  },
  indigo: {
    50: "#eef2ff",
    100: "#e0e7ff",
    200: "#c7d2fe",
    300: "#a5b4fc",
    400: "#818cf8",
    500: "#6366f1",
    600: "#4f46e5",
    700: "#4338ca",
    800: "#3730a3",
    900: "#312e81",
    950: "#1e1b4b"
  },
  violet: {
    50: "#f5f3ff",
    100: "#ede9fe",
    200: "#ddd6fe",
    300: "#c4b5fd",
    400: "#a78bfa",
    500: "#8b5cf6",
    600: "#7c3aed",
    700: "#6d28d9",
    800: "#5b21b6",
    900: "#4c1d95",
    950: "#2e1065"
  },
  purple: {
    50: "#faf5ff",
    100: "#f3e8ff",
    200: "#e9d5ff",
    300: "#d8b4fe",
    400: "#c084fc",
    500: "#a855f7",
    600: "#9333ea",
    700: "#7e22ce",
    800: "#6b21a8",
    900: "#581c87",
    950: "#3b0764"
  },
  fuchsia: {
    50: "#fdf4ff",
    100: "#fae8ff",
    200: "#f5d0fe",
    300: "#f0abfc",
    400: "#e879f9",
    500: "#d946ef",
    600: "#c026d3",
    700: "#a21caf",
    800: "#86198f",
    900: "#701a75",
    950: "#4a044e"
  },
  pink: {
    50: "#fdf2f8",
    100: "#fce7f3",
    200: "#fbcfe8",
    300: "#f9a8d4",
    400: "#f472b6",
    500: "#ec4899",
    600: "#db2777",
    700: "#be185d",
    800: "#9d174d",
    900: "#831843",
    950: "#500724"
  },
  rose: {
    50: "#fff1f2",
    100: "#ffe4e6",
    200: "#fecdd3",
    300: "#fda4af",
    400: "#fb7185",
    500: "#f43f5e",
    600: "#e11d48",
    700: "#be123c",
    800: "#9f1239",
    900: "#881337",
    950: "#4c0519"
  }
};
Om.reduce((i, { color: e, primary: t, secondary: n }) => ({
  ...i,
  [e]: {
    primary: au[e][t],
    secondary: au[e][n]
  }
}), {});
var ou = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Bm(i) {
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
}
var no, lu;
function km() {
  if (lu) return no;
  lu = 1;
  var i = function(x) {
    return e(x) && !t(x);
  };
  function e(f) {
    return !!f && typeof f == "object";
  }
  function t(f) {
    var x = Object.prototype.toString.call(f);
    return x === "[object RegExp]" || x === "[object Date]" || s(f);
  }
  var n = typeof Symbol == "function" && Symbol.for, r = n ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
  function s(f) {
    return f.$$typeof === r;
  }
  function a(f) {
    return Array.isArray(f) ? [] : {};
  }
  function o(f, x) {
    return x.clone !== !1 && x.isMergeableObject(f) ? b(a(f), f, x) : f;
  }
  function l(f, x, g) {
    return f.concat(x).map(function(_) {
      return o(_, g);
    });
  }
  function c(f, x) {
    if (!x.customMerge)
      return b;
    var g = x.customMerge(f);
    return typeof g == "function" ? g : b;
  }
  function u(f) {
    return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(f).filter(function(x) {
      return Object.propertyIsEnumerable.call(f, x);
    }) : [];
  }
  function h(f) {
    return Object.keys(f).concat(u(f));
  }
  function d(f, x) {
    try {
      return x in f;
    } catch {
      return !1;
    }
  }
  function m(f, x) {
    return d(f, x) && !(Object.hasOwnProperty.call(f, x) && Object.propertyIsEnumerable.call(f, x));
  }
  function v(f, x, g) {
    var _ = {};
    return g.isMergeableObject(f) && h(f).forEach(function(T) {
      _[T] = o(f[T], g);
    }), h(x).forEach(function(T) {
      m(f, T) || (d(f, T) && g.isMergeableObject(x[T]) ? _[T] = c(T, g)(f[T], x[T], g) : _[T] = o(x[T], g));
    }), _;
  }
  function b(f, x, g) {
    g = g || {}, g.arrayMerge = g.arrayMerge || l, g.isMergeableObject = g.isMergeableObject || i, g.cloneUnlessOtherwiseSpecified = o;
    var _ = Array.isArray(x), T = Array.isArray(f), A = _ === T;
    return A ? _ ? g.arrayMerge(f, x, g) : v(f, x, g) : o(x, g);
  }
  b.all = function(x, g) {
    if (!Array.isArray(x))
      throw new Error("first argument should be an array");
    return x.reduce(function(_, T) {
      return b(_, T, g);
    }, {});
  };
  var p = b;
  return no = p, no;
}
var Hm = km();
const zm = /* @__PURE__ */ Bm(Hm);
var rl = function(i, e) {
  return rl = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
    t.__proto__ = n;
  } || function(t, n) {
    for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
  }, rl(i, e);
};
function za(i, e) {
  if (typeof e != "function" && e !== null)
    throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
  rl(i, e);
  function t() {
    this.constructor = i;
  }
  i.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
}
var ot = function() {
  return ot = Object.assign || function(e) {
    for (var t, n = 1, r = arguments.length; n < r; n++) {
      t = arguments[n];
      for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && (e[s] = t[s]);
    }
    return e;
  }, ot.apply(this, arguments);
};
function Gm(i, e) {
  var t = {};
  for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && e.indexOf(n) < 0 && (t[n] = i[n]);
  if (i != null && typeof Object.getOwnPropertySymbols == "function")
    for (var r = 0, n = Object.getOwnPropertySymbols(i); r < n.length; r++)
      e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, n[r]) && (t[n[r]] = i[n[r]]);
  return t;
}
function io(i, e, t) {
  if (t || arguments.length === 2) for (var n = 0, r = e.length, s; n < r; n++)
    (s || !(n in e)) && (s || (s = Array.prototype.slice.call(e, 0, n)), s[n] = e[n]);
  return i.concat(s || Array.prototype.slice.call(e));
}
function ro(i, e) {
  var t = e && e.cache ? e.cache : Zm, n = e && e.serializer ? e.serializer : qm, r = e && e.strategy ? e.strategy : Xm;
  return r(i, {
    cache: t,
    serializer: n
  });
}
function Vm(i) {
  return i == null || typeof i == "number" || typeof i == "boolean";
}
function Wm(i, e, t, n) {
  var r = Vm(n) ? n : t(n), s = e.get(r);
  return typeof s > "u" && (s = i.call(this, n), e.set(r, s)), s;
}
function zf(i, e, t) {
  var n = Array.prototype.slice.call(arguments, 3), r = t(n), s = e.get(r);
  return typeof s > "u" && (s = i.apply(this, n), e.set(r, s)), s;
}
function Gf(i, e, t, n, r) {
  return t.bind(e, i, n, r);
}
function Xm(i, e) {
  var t = i.length === 1 ? Wm : zf;
  return Gf(i, this, t, e.cache.create(), e.serializer);
}
function jm(i, e) {
  return Gf(i, this, zf, e.cache.create(), e.serializer);
}
var qm = function() {
  return JSON.stringify(arguments);
}, Ym = (
  /** @class */
  (function() {
    function i() {
      this.cache = /* @__PURE__ */ Object.create(null);
    }
    return i.prototype.get = function(e) {
      return this.cache[e];
    }, i.prototype.set = function(e, t) {
      this.cache[e] = t;
    }, i;
  })()
), Zm = {
  create: function() {
    return new Ym();
  }
}, so = {
  variadic: jm
}, tt;
(function(i) {
  i[i.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE", i[i.EMPTY_ARGUMENT = 2] = "EMPTY_ARGUMENT", i[i.MALFORMED_ARGUMENT = 3] = "MALFORMED_ARGUMENT", i[i.EXPECT_ARGUMENT_TYPE = 4] = "EXPECT_ARGUMENT_TYPE", i[i.INVALID_ARGUMENT_TYPE = 5] = "INVALID_ARGUMENT_TYPE", i[i.EXPECT_ARGUMENT_STYLE = 6] = "EXPECT_ARGUMENT_STYLE", i[i.INVALID_NUMBER_SKELETON = 7] = "INVALID_NUMBER_SKELETON", i[i.INVALID_DATE_TIME_SKELETON = 8] = "INVALID_DATE_TIME_SKELETON", i[i.EXPECT_NUMBER_SKELETON = 9] = "EXPECT_NUMBER_SKELETON", i[i.EXPECT_DATE_TIME_SKELETON = 10] = "EXPECT_DATE_TIME_SKELETON", i[i.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE", i[i.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS", i[i.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE", i[i.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE", i[i.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR", i[i.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR", i[i.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT", i[i.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT", i[i.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR", i[i.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR", i[i.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR", i[i.MISSING_OTHER_CLAUSE = 22] = "MISSING_OTHER_CLAUSE", i[i.INVALID_TAG = 23] = "INVALID_TAG", i[i.INVALID_TAG_NAME = 25] = "INVALID_TAG_NAME", i[i.UNMATCHED_CLOSING_TAG = 26] = "UNMATCHED_CLOSING_TAG", i[i.UNCLOSED_TAG = 27] = "UNCLOSED_TAG";
})(tt || (tt = {}));
var Tt;
(function(i) {
  i[i.literal = 0] = "literal", i[i.argument = 1] = "argument", i[i.number = 2] = "number", i[i.date = 3] = "date", i[i.time = 4] = "time", i[i.select = 5] = "select", i[i.plural = 6] = "plural", i[i.pound = 7] = "pound", i[i.tag = 8] = "tag";
})(Tt || (Tt = {}));
var Ar;
(function(i) {
  i[i.number = 0] = "number", i[i.dateTime = 1] = "dateTime";
})(Ar || (Ar = {}));
function cu(i) {
  return i.type === Tt.literal;
}
function Km(i) {
  return i.type === Tt.argument;
}
function Vf(i) {
  return i.type === Tt.number;
}
function Wf(i) {
  return i.type === Tt.date;
}
function Xf(i) {
  return i.type === Tt.time;
}
function jf(i) {
  return i.type === Tt.select;
}
function qf(i) {
  return i.type === Tt.plural;
}
function $m(i) {
  return i.type === Tt.pound;
}
function Yf(i) {
  return i.type === Tt.tag;
}
function Zf(i) {
  return !!(i && typeof i == "object" && i.type === Ar.number);
}
function sl(i) {
  return !!(i && typeof i == "object" && i.type === Ar.dateTime);
}
var Kf = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, Jm = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
function Qm(i) {
  var e = {};
  return i.replace(Jm, function(t) {
    var n = t.length;
    switch (t[0]) {
      // Era
      case "G":
        e.era = n === 4 ? "long" : n === 5 ? "narrow" : "short";
        break;
      // Year
      case "y":
        e.year = n === 2 ? "2-digit" : "numeric";
        break;
      case "Y":
      case "u":
      case "U":
      case "r":
        throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");
      // Quarter
      case "q":
      case "Q":
        throw new RangeError("`q/Q` (quarter) patterns are not supported");
      // Month
      case "M":
      case "L":
        e.month = ["numeric", "2-digit", "short", "long", "narrow"][n - 1];
        break;
      // Week
      case "w":
      case "W":
        throw new RangeError("`w/W` (week) patterns are not supported");
      case "d":
        e.day = ["numeric", "2-digit"][n - 1];
        break;
      case "D":
      case "F":
      case "g":
        throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");
      // Weekday
      case "E":
        e.weekday = n === 4 ? "long" : n === 5 ? "narrow" : "short";
        break;
      case "e":
        if (n < 4)
          throw new RangeError("`e..eee` (weekday) patterns are not supported");
        e.weekday = ["short", "long", "narrow", "short"][n - 4];
        break;
      case "c":
        if (n < 4)
          throw new RangeError("`c..ccc` (weekday) patterns are not supported");
        e.weekday = ["short", "long", "narrow", "short"][n - 4];
        break;
      // Period
      case "a":
        e.hour12 = !0;
        break;
      case "b":
      // am, pm, noon, midnight
      case "B":
        throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");
      // Hour
      case "h":
        e.hourCycle = "h12", e.hour = ["numeric", "2-digit"][n - 1];
        break;
      case "H":
        e.hourCycle = "h23", e.hour = ["numeric", "2-digit"][n - 1];
        break;
      case "K":
        e.hourCycle = "h11", e.hour = ["numeric", "2-digit"][n - 1];
        break;
      case "k":
        e.hourCycle = "h24", e.hour = ["numeric", "2-digit"][n - 1];
        break;
      case "j":
      case "J":
      case "C":
        throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");
      // Minute
      case "m":
        e.minute = ["numeric", "2-digit"][n - 1];
        break;
      // Second
      case "s":
        e.second = ["numeric", "2-digit"][n - 1];
        break;
      case "S":
      case "A":
        throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");
      // Zone
      case "z":
        e.timeZoneName = n < 4 ? "short" : "long";
        break;
      case "Z":
      // 1..3, 4, 5: The ISO8601 varios formats
      case "O":
      // 1, 4: milliseconds in day short, long
      case "v":
      // 1, 4: generic non-location format
      case "V":
      // 1, 2, 3, 4: time zone ID or city
      case "X":
      // 1, 2, 3, 4: The ISO8601 varios formats
      case "x":
        throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead");
    }
    return "";
  }), e;
}
var eg = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
function tg(i) {
  if (i.length === 0)
    throw new Error("Number skeleton cannot be empty");
  for (var e = i.split(eg).filter(function(d) {
    return d.length > 0;
  }), t = [], n = 0, r = e; n < r.length; n++) {
    var s = r[n], a = s.split("/");
    if (a.length === 0)
      throw new Error("Invalid number skeleton");
    for (var o = a[0], l = a.slice(1), c = 0, u = l; c < u.length; c++) {
      var h = u[c];
      if (h.length === 0)
        throw new Error("Invalid number skeleton");
    }
    t.push({ stem: o, options: l });
  }
  return t;
}
function ng(i) {
  return i.replace(/^(.*?)-/, "");
}
var uu = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, $f = /^(@+)?(\+|#+)?[rs]?$/g, ig = /(\*)(0+)|(#+)(0+)|(0+)/g, Jf = /^(0+)$/;
function hu(i) {
  var e = {};
  return i[i.length - 1] === "r" ? e.roundingPriority = "morePrecision" : i[i.length - 1] === "s" && (e.roundingPriority = "lessPrecision"), i.replace($f, function(t, n, r) {
    return typeof r != "string" ? (e.minimumSignificantDigits = n.length, e.maximumSignificantDigits = n.length) : r === "+" ? e.minimumSignificantDigits = n.length : n[0] === "#" ? e.maximumSignificantDigits = n.length : (e.minimumSignificantDigits = n.length, e.maximumSignificantDigits = n.length + (typeof r == "string" ? r.length : 0)), "";
  }), e;
}
function Qf(i) {
  switch (i) {
    case "sign-auto":
      return {
        signDisplay: "auto"
      };
    case "sign-accounting":
    case "()":
      return {
        currencySign: "accounting"
      };
    case "sign-always":
    case "+!":
      return {
        signDisplay: "always"
      };
    case "sign-accounting-always":
    case "()!":
      return {
        signDisplay: "always",
        currencySign: "accounting"
      };
    case "sign-except-zero":
    case "+?":
      return {
        signDisplay: "exceptZero"
      };
    case "sign-accounting-except-zero":
    case "()?":
      return {
        signDisplay: "exceptZero",
        currencySign: "accounting"
      };
    case "sign-never":
    case "+_":
      return {
        signDisplay: "never"
      };
  }
}
function rg(i) {
  var e;
  if (i[0] === "E" && i[1] === "E" ? (e = {
    notation: "engineering"
  }, i = i.slice(2)) : i[0] === "E" && (e = {
    notation: "scientific"
  }, i = i.slice(1)), e) {
    var t = i.slice(0, 2);
    if (t === "+!" ? (e.signDisplay = "always", i = i.slice(2)) : t === "+?" && (e.signDisplay = "exceptZero", i = i.slice(2)), !Jf.test(i))
      throw new Error("Malformed concise eng/scientific notation");
    e.minimumIntegerDigits = i.length;
  }
  return e;
}
function fu(i) {
  var e = {}, t = Qf(i);
  return t || e;
}
function sg(i) {
  for (var e = {}, t = 0, n = i; t < n.length; t++) {
    var r = n[t];
    switch (r.stem) {
      case "percent":
      case "%":
        e.style = "percent";
        continue;
      case "%x100":
        e.style = "percent", e.scale = 100;
        continue;
      case "currency":
        e.style = "currency", e.currency = r.options[0];
        continue;
      case "group-off":
      case ",_":
        e.useGrouping = !1;
        continue;
      case "precision-integer":
      case ".":
        e.maximumFractionDigits = 0;
        continue;
      case "measure-unit":
      case "unit":
        e.style = "unit", e.unit = ng(r.options[0]);
        continue;
      case "compact-short":
      case "K":
        e.notation = "compact", e.compactDisplay = "short";
        continue;
      case "compact-long":
      case "KK":
        e.notation = "compact", e.compactDisplay = "long";
        continue;
      case "scientific":
        e = ot(ot(ot({}, e), { notation: "scientific" }), r.options.reduce(function(l, c) {
          return ot(ot({}, l), fu(c));
        }, {}));
        continue;
      case "engineering":
        e = ot(ot(ot({}, e), { notation: "engineering" }), r.options.reduce(function(l, c) {
          return ot(ot({}, l), fu(c));
        }, {}));
        continue;
      case "notation-simple":
        e.notation = "standard";
        continue;
      // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
      case "unit-width-narrow":
        e.currencyDisplay = "narrowSymbol", e.unitDisplay = "narrow";
        continue;
      case "unit-width-short":
        e.currencyDisplay = "code", e.unitDisplay = "short";
        continue;
      case "unit-width-full-name":
        e.currencyDisplay = "name", e.unitDisplay = "long";
        continue;
      case "unit-width-iso-code":
        e.currencyDisplay = "symbol";
        continue;
      case "scale":
        e.scale = parseFloat(r.options[0]);
        continue;
      case "rounding-mode-floor":
        e.roundingMode = "floor";
        continue;
      case "rounding-mode-ceiling":
        e.roundingMode = "ceil";
        continue;
      case "rounding-mode-down":
        e.roundingMode = "trunc";
        continue;
      case "rounding-mode-up":
        e.roundingMode = "expand";
        continue;
      case "rounding-mode-half-even":
        e.roundingMode = "halfEven";
        continue;
      case "rounding-mode-half-down":
        e.roundingMode = "halfTrunc";
        continue;
      case "rounding-mode-half-up":
        e.roundingMode = "halfExpand";
        continue;
      // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
      case "integer-width":
        if (r.options.length > 1)
          throw new RangeError("integer-width stems only accept a single optional option");
        r.options[0].replace(ig, function(l, c, u, h, d, m) {
          if (c)
            e.minimumIntegerDigits = u.length;
          else {
            if (h && d)
              throw new Error("We currently do not support maximum integer digits");
            if (m)
              throw new Error("We currently do not support exact integer digits");
          }
          return "";
        });
        continue;
    }
    if (Jf.test(r.stem)) {
      e.minimumIntegerDigits = r.stem.length;
      continue;
    }
    if (uu.test(r.stem)) {
      if (r.options.length > 1)
        throw new RangeError("Fraction-precision stems only accept a single optional option");
      r.stem.replace(uu, function(l, c, u, h, d, m) {
        return u === "*" ? e.minimumFractionDigits = c.length : h && h[0] === "#" ? e.maximumFractionDigits = h.length : d && m ? (e.minimumFractionDigits = d.length, e.maximumFractionDigits = d.length + m.length) : (e.minimumFractionDigits = c.length, e.maximumFractionDigits = c.length), "";
      });
      var s = r.options[0];
      s === "w" ? e = ot(ot({}, e), { trailingZeroDisplay: "stripIfInteger" }) : s && (e = ot(ot({}, e), hu(s)));
      continue;
    }
    if ($f.test(r.stem)) {
      e = ot(ot({}, e), hu(r.stem));
      continue;
    }
    var a = Qf(r.stem);
    a && (e = ot(ot({}, e), a));
    var o = rg(r.stem);
    o && (e = ot(ot({}, e), o));
  }
  return e;
}
var Os = {
  "001": [
    "H",
    "h"
  ],
  419: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  AC: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  AD: [
    "H",
    "hB"
  ],
  AE: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  AF: [
    "H",
    "hb",
    "hB",
    "h"
  ],
  AG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  AI: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  AL: [
    "h",
    "H",
    "hB"
  ],
  AM: [
    "H",
    "hB"
  ],
  AO: [
    "H",
    "hB"
  ],
  AR: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  AS: [
    "h",
    "H"
  ],
  AT: [
    "H",
    "hB"
  ],
  AU: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  AW: [
    "H",
    "hB"
  ],
  AX: [
    "H"
  ],
  AZ: [
    "H",
    "hB",
    "h"
  ],
  BA: [
    "H",
    "hB",
    "h"
  ],
  BB: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BD: [
    "h",
    "hB",
    "H"
  ],
  BE: [
    "H",
    "hB"
  ],
  BF: [
    "H",
    "hB"
  ],
  BG: [
    "H",
    "hB",
    "h"
  ],
  BH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  BI: [
    "H",
    "h"
  ],
  BJ: [
    "H",
    "hB"
  ],
  BL: [
    "H",
    "hB"
  ],
  BM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BN: [
    "hb",
    "hB",
    "h",
    "H"
  ],
  BO: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  BQ: [
    "H"
  ],
  BR: [
    "H",
    "hB"
  ],
  BS: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BT: [
    "h",
    "H"
  ],
  BW: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  BY: [
    "H",
    "h"
  ],
  BZ: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CA: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  CC: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CD: [
    "hB",
    "H"
  ],
  CF: [
    "H",
    "h",
    "hB"
  ],
  CG: [
    "H",
    "hB"
  ],
  CH: [
    "H",
    "hB",
    "h"
  ],
  CI: [
    "H",
    "hB"
  ],
  CK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CL: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  CM: [
    "H",
    "h",
    "hB"
  ],
  CN: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  CO: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  CP: [
    "H"
  ],
  CR: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  CU: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  CV: [
    "H",
    "hB"
  ],
  CW: [
    "H",
    "hB"
  ],
  CX: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CY: [
    "h",
    "H",
    "hb",
    "hB"
  ],
  CZ: [
    "H"
  ],
  DE: [
    "H",
    "hB"
  ],
  DG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  DJ: [
    "h",
    "H"
  ],
  DK: [
    "H"
  ],
  DM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  DO: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  DZ: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  EA: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  EC: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  EE: [
    "H",
    "hB"
  ],
  EG: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  EH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  ER: [
    "h",
    "H"
  ],
  ES: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  ET: [
    "hB",
    "hb",
    "h",
    "H"
  ],
  FI: [
    "H"
  ],
  FJ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  FK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  FM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  FO: [
    "H",
    "h"
  ],
  FR: [
    "H",
    "hB"
  ],
  GA: [
    "H",
    "hB"
  ],
  GB: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GD: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GE: [
    "H",
    "hB",
    "h"
  ],
  GF: [
    "H",
    "hB"
  ],
  GG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GH: [
    "h",
    "H"
  ],
  GI: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GL: [
    "H",
    "h"
  ],
  GM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GN: [
    "H",
    "hB"
  ],
  GP: [
    "H",
    "hB"
  ],
  GQ: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  GR: [
    "h",
    "H",
    "hb",
    "hB"
  ],
  GT: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  GU: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GW: [
    "H",
    "hB"
  ],
  GY: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  HK: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  HN: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  HR: [
    "H",
    "hB"
  ],
  HU: [
    "H",
    "h"
  ],
  IC: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  ID: [
    "H"
  ],
  IE: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IL: [
    "H",
    "hB"
  ],
  IM: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IN: [
    "h",
    "H"
  ],
  IO: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IQ: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  IR: [
    "hB",
    "H"
  ],
  IS: [
    "H"
  ],
  IT: [
    "H",
    "hB"
  ],
  JE: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  JM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  JO: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  JP: [
    "H",
    "K",
    "h"
  ],
  KE: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  KG: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  KH: [
    "hB",
    "h",
    "H",
    "hb"
  ],
  KI: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KM: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  KN: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KP: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  KR: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  KW: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  KY: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KZ: [
    "H",
    "hB"
  ],
  LA: [
    "H",
    "hb",
    "hB",
    "h"
  ],
  LB: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  LC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  LI: [
    "H",
    "hB",
    "h"
  ],
  LK: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  LR: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  LS: [
    "h",
    "H"
  ],
  LT: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  LU: [
    "H",
    "h",
    "hB"
  ],
  LV: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  LY: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  MA: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  MC: [
    "H",
    "hB"
  ],
  MD: [
    "H",
    "hB"
  ],
  ME: [
    "H",
    "hB",
    "h"
  ],
  MF: [
    "H",
    "hB"
  ],
  MG: [
    "H",
    "h"
  ],
  MH: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  ML: [
    "H"
  ],
  MM: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  MN: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  MO: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  MP: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MQ: [
    "H",
    "hB"
  ],
  MR: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  MS: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  MT: [
    "H",
    "h"
  ],
  MU: [
    "H",
    "h"
  ],
  MV: [
    "H",
    "h"
  ],
  MW: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MX: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  MY: [
    "hb",
    "hB",
    "h",
    "H"
  ],
  MZ: [
    "H",
    "hB"
  ],
  NA: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  NC: [
    "H",
    "hB"
  ],
  NE: [
    "H"
  ],
  NF: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NI: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  NL: [
    "H",
    "hB"
  ],
  NO: [
    "H",
    "h"
  ],
  NP: [
    "H",
    "h",
    "hB"
  ],
  NR: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NU: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NZ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  OM: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  PA: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  PE: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  PF: [
    "H",
    "h",
    "hB"
  ],
  PG: [
    "h",
    "H"
  ],
  PH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  PK: [
    "h",
    "hB",
    "H"
  ],
  PL: [
    "H",
    "h"
  ],
  PM: [
    "H",
    "hB"
  ],
  PN: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  PR: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  PS: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  PT: [
    "H",
    "hB"
  ],
  PW: [
    "h",
    "H"
  ],
  PY: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  QA: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  RE: [
    "H",
    "hB"
  ],
  RO: [
    "H",
    "hB"
  ],
  RS: [
    "H",
    "hB",
    "h"
  ],
  RU: [
    "H"
  ],
  RW: [
    "H",
    "h"
  ],
  SA: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SB: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SC: [
    "H",
    "h",
    "hB"
  ],
  SD: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SE: [
    "H"
  ],
  SG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SH: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  SI: [
    "H",
    "hB"
  ],
  SJ: [
    "H"
  ],
  SK: [
    "H"
  ],
  SL: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SM: [
    "H",
    "h",
    "hB"
  ],
  SN: [
    "H",
    "h",
    "hB"
  ],
  SO: [
    "h",
    "H"
  ],
  SR: [
    "H",
    "hB"
  ],
  SS: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  ST: [
    "H",
    "hB"
  ],
  SV: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  SX: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  SY: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SZ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  TA: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  TC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  TD: [
    "h",
    "H",
    "hB"
  ],
  TF: [
    "H",
    "h",
    "hB"
  ],
  TG: [
    "H",
    "hB"
  ],
  TH: [
    "H",
    "h"
  ],
  TJ: [
    "H",
    "h"
  ],
  TL: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  TM: [
    "H",
    "h"
  ],
  TN: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  TO: [
    "h",
    "H"
  ],
  TR: [
    "H",
    "hB"
  ],
  TT: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  TW: [
    "hB",
    "hb",
    "h",
    "H"
  ],
  TZ: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  UA: [
    "H",
    "hB",
    "h"
  ],
  UG: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  UM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  US: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  UY: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  UZ: [
    "H",
    "hB",
    "h"
  ],
  VA: [
    "H",
    "h",
    "hB"
  ],
  VC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VE: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  VG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VI: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VN: [
    "H",
    "h"
  ],
  VU: [
    "h",
    "H"
  ],
  WF: [
    "H",
    "hB"
  ],
  WS: [
    "h",
    "H"
  ],
  XK: [
    "H",
    "hB",
    "h"
  ],
  YE: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  YT: [
    "H",
    "hB"
  ],
  ZA: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  ZM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  ZW: [
    "H",
    "h"
  ],
  "af-ZA": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "ar-001": [
    "h",
    "hB",
    "hb",
    "H"
  ],
  "ca-ES": [
    "H",
    "h",
    "hB"
  ],
  "en-001": [
    "h",
    "hb",
    "H",
    "hB"
  ],
  "en-HK": [
    "h",
    "hb",
    "H",
    "hB"
  ],
  "en-IL": [
    "H",
    "h",
    "hb",
    "hB"
  ],
  "en-MY": [
    "h",
    "hb",
    "H",
    "hB"
  ],
  "es-BR": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-ES": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-GQ": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "fr-CA": [
    "H",
    "h",
    "hB"
  ],
  "gl-ES": [
    "H",
    "h",
    "hB"
  ],
  "gu-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "hi-IN": [
    "hB",
    "h",
    "H"
  ],
  "it-CH": [
    "H",
    "h",
    "hB"
  ],
  "it-IT": [
    "H",
    "h",
    "hB"
  ],
  "kn-IN": [
    "hB",
    "h",
    "H"
  ],
  "ml-IN": [
    "hB",
    "h",
    "H"
  ],
  "mr-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "pa-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "ta-IN": [
    "hB",
    "h",
    "hb",
    "H"
  ],
  "te-IN": [
    "hB",
    "h",
    "H"
  ],
  "zu-ZA": [
    "H",
    "hB",
    "hb",
    "h"
  ]
};
function ag(i, e) {
  for (var t = "", n = 0; n < i.length; n++) {
    var r = i.charAt(n);
    if (r === "j") {
      for (var s = 0; n + 1 < i.length && i.charAt(n + 1) === r; )
        s++, n++;
      var a = 1 + (s & 1), o = s < 2 ? 1 : 3 + (s >> 1), l = "a", c = og(e);
      for ((c == "H" || c == "k") && (o = 0); o-- > 0; )
        t += l;
      for (; a-- > 0; )
        t = c + t;
    } else r === "J" ? t += "H" : t += r;
  }
  return t;
}
function og(i) {
  var e = i.hourCycle;
  if (e === void 0 && // @ts-ignore hourCycle(s) is not identified yet
  i.hourCycles && // @ts-ignore
  i.hourCycles.length && (e = i.hourCycles[0]), e)
    switch (e) {
      case "h24":
        return "k";
      case "h23":
        return "H";
      case "h12":
        return "h";
      case "h11":
        return "K";
      default:
        throw new Error("Invalid hourCycle");
    }
  var t = i.language, n;
  t !== "root" && (n = i.maximize().region);
  var r = Os[n || ""] || Os[t || ""] || Os["".concat(t, "-001")] || Os["001"];
  return r[0];
}
var ao, lg = new RegExp("^".concat(Kf.source, "*")), cg = new RegExp("".concat(Kf.source, "*$"));
function rt(i, e) {
  return { start: i, end: e };
}
var ug = !!String.prototype.startsWith && "_a".startsWith("a", 1), hg = !!String.fromCodePoint, fg = !!Object.fromEntries, dg = !!String.prototype.codePointAt, pg = !!String.prototype.trimStart, mg = !!String.prototype.trimEnd, gg = !!Number.isSafeInteger, _g = gg ? Number.isSafeInteger : function(i) {
  return typeof i == "number" && isFinite(i) && Math.floor(i) === i && Math.abs(i) <= 9007199254740991;
}, al = !0;
try {
  var vg = td("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  al = ((ao = vg.exec("a")) === null || ao === void 0 ? void 0 : ao[0]) === "a";
} catch {
  al = !1;
}
var du = ug ? (
  // Native
  function(e, t, n) {
    return e.startsWith(t, n);
  }
) : (
  // For IE11
  function(e, t, n) {
    return e.slice(n, n + t.length) === t;
  }
), ol = hg ? String.fromCodePoint : (
  // IE11
  function() {
    for (var e = [], t = 0; t < arguments.length; t++)
      e[t] = arguments[t];
    for (var n = "", r = e.length, s = 0, a; r > s; ) {
      if (a = e[s++], a > 1114111)
        throw RangeError(a + " is not a valid code point");
      n += a < 65536 ? String.fromCharCode(a) : String.fromCharCode(((a -= 65536) >> 10) + 55296, a % 1024 + 56320);
    }
    return n;
  }
), pu = (
  // native
  fg ? Object.fromEntries : (
    // Ponyfill
    function(e) {
      for (var t = {}, n = 0, r = e; n < r.length; n++) {
        var s = r[n], a = s[0], o = s[1];
        t[a] = o;
      }
      return t;
    }
  )
), ed = dg ? (
  // Native
  function(e, t) {
    return e.codePointAt(t);
  }
) : (
  // IE 11
  function(e, t) {
    var n = e.length;
    if (!(t < 0 || t >= n)) {
      var r = e.charCodeAt(t), s;
      return r < 55296 || r > 56319 || t + 1 === n || (s = e.charCodeAt(t + 1)) < 56320 || s > 57343 ? r : (r - 55296 << 10) + (s - 56320) + 65536;
    }
  }
), xg = pg ? (
  // Native
  function(e) {
    return e.trimStart();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(lg, "");
  }
), bg = mg ? (
  // Native
  function(e) {
    return e.trimEnd();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(cg, "");
  }
);
function td(i, e) {
  return new RegExp(i, e);
}
var ll;
if (al) {
  var mu = td("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  ll = function(e, t) {
    var n;
    mu.lastIndex = t;
    var r = mu.exec(e);
    return (n = r[1]) !== null && n !== void 0 ? n : "";
  };
} else
  ll = function(e, t) {
    for (var n = []; ; ) {
      var r = ed(e, t);
      if (r === void 0 || nd(r) || Mg(r))
        break;
      n.push(r), t += r >= 65536 ? 2 : 1;
    }
    return ol.apply(void 0, n);
  };
var Eg = (
  /** @class */
  (function() {
    function i(e, t) {
      t === void 0 && (t = {}), this.message = e, this.position = { offset: 0, line: 1, column: 1 }, this.ignoreTag = !!t.ignoreTag, this.locale = t.locale, this.requiresOtherClause = !!t.requiresOtherClause, this.shouldParseSkeletons = !!t.shouldParseSkeletons;
    }
    return i.prototype.parse = function() {
      if (this.offset() !== 0)
        throw Error("parser can only be used once");
      return this.parseMessage(0, "", !1);
    }, i.prototype.parseMessage = function(e, t, n) {
      for (var r = []; !this.isEOF(); ) {
        var s = this.char();
        if (s === 123) {
          var a = this.parseArgument(e, n);
          if (a.err)
            return a;
          r.push(a.val);
        } else {
          if (s === 125 && e > 0)
            break;
          if (s === 35 && (t === "plural" || t === "selectordinal")) {
            var o = this.clonePosition();
            this.bump(), r.push({
              type: Tt.pound,
              location: rt(o, this.clonePosition())
            });
          } else if (s === 60 && !this.ignoreTag && this.peek() === 47) {
            if (n)
              break;
            return this.error(tt.UNMATCHED_CLOSING_TAG, rt(this.clonePosition(), this.clonePosition()));
          } else if (s === 60 && !this.ignoreTag && cl(this.peek() || 0)) {
            var a = this.parseTag(e, t);
            if (a.err)
              return a;
            r.push(a.val);
          } else {
            var a = this.parseLiteral(e, t);
            if (a.err)
              return a;
            r.push(a.val);
          }
        }
      }
      return { val: r, err: null };
    }, i.prototype.parseTag = function(e, t) {
      var n = this.clonePosition();
      this.bump();
      var r = this.parseTagName();
      if (this.bumpSpace(), this.bumpIf("/>"))
        return {
          val: {
            type: Tt.literal,
            value: "<".concat(r, "/>"),
            location: rt(n, this.clonePosition())
          },
          err: null
        };
      if (this.bumpIf(">")) {
        var s = this.parseMessage(e + 1, t, !0);
        if (s.err)
          return s;
        var a = s.val, o = this.clonePosition();
        if (this.bumpIf("</")) {
          if (this.isEOF() || !cl(this.char()))
            return this.error(tt.INVALID_TAG, rt(o, this.clonePosition()));
          var l = this.clonePosition(), c = this.parseTagName();
          return r !== c ? this.error(tt.UNMATCHED_CLOSING_TAG, rt(l, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
            val: {
              type: Tt.tag,
              value: r,
              children: a,
              location: rt(n, this.clonePosition())
            },
            err: null
          } : this.error(tt.INVALID_TAG, rt(o, this.clonePosition())));
        } else
          return this.error(tt.UNCLOSED_TAG, rt(n, this.clonePosition()));
      } else
        return this.error(tt.INVALID_TAG, rt(n, this.clonePosition()));
    }, i.prototype.parseTagName = function() {
      var e = this.offset();
      for (this.bump(); !this.isEOF() && Sg(this.char()); )
        this.bump();
      return this.message.slice(e, this.offset());
    }, i.prototype.parseLiteral = function(e, t) {
      for (var n = this.clonePosition(), r = ""; ; ) {
        var s = this.tryParseQuote(t);
        if (s) {
          r += s;
          continue;
        }
        var a = this.tryParseUnquoted(e, t);
        if (a) {
          r += a;
          continue;
        }
        var o = this.tryParseLeftAngleBracket();
        if (o) {
          r += o;
          continue;
        }
        break;
      }
      var l = rt(n, this.clonePosition());
      return {
        val: { type: Tt.literal, value: r, location: l },
        err: null
      };
    }, i.prototype.tryParseLeftAngleBracket = function() {
      return !this.isEOF() && this.char() === 60 && (this.ignoreTag || // If at the opening tag or closing tag position, bail.
      !yg(this.peek() || 0)) ? (this.bump(), "<") : null;
    }, i.prototype.tryParseQuote = function(e) {
      if (this.isEOF() || this.char() !== 39)
        return null;
      switch (this.peek()) {
        case 39:
          return this.bump(), this.bump(), "'";
        // '{', '<', '>', '}'
        case 123:
        case 60:
        case 62:
        case 125:
          break;
        case 35:
          if (e === "plural" || e === "selectordinal")
            break;
          return null;
        default:
          return null;
      }
      this.bump();
      var t = [this.char()];
      for (this.bump(); !this.isEOF(); ) {
        var n = this.char();
        if (n === 39)
          if (this.peek() === 39)
            t.push(39), this.bump();
          else {
            this.bump();
            break;
          }
        else
          t.push(n);
        this.bump();
      }
      return ol.apply(void 0, t);
    }, i.prototype.tryParseUnquoted = function(e, t) {
      if (this.isEOF())
        return null;
      var n = this.char();
      return n === 60 || n === 123 || n === 35 && (t === "plural" || t === "selectordinal") || n === 125 && e > 0 ? null : (this.bump(), ol(n));
    }, i.prototype.parseArgument = function(e, t) {
      var n = this.clonePosition();
      if (this.bump(), this.bumpSpace(), this.isEOF())
        return this.error(tt.EXPECT_ARGUMENT_CLOSING_BRACE, rt(n, this.clonePosition()));
      if (this.char() === 125)
        return this.bump(), this.error(tt.EMPTY_ARGUMENT, rt(n, this.clonePosition()));
      var r = this.parseIdentifierIfPossible().value;
      if (!r)
        return this.error(tt.MALFORMED_ARGUMENT, rt(n, this.clonePosition()));
      if (this.bumpSpace(), this.isEOF())
        return this.error(tt.EXPECT_ARGUMENT_CLOSING_BRACE, rt(n, this.clonePosition()));
      switch (this.char()) {
        // Simple argument: `{name}`
        case 125:
          return this.bump(), {
            val: {
              type: Tt.argument,
              // value does not include the opening and closing braces.
              value: r,
              location: rt(n, this.clonePosition())
            },
            err: null
          };
        // Argument with options: `{name, format, ...}`
        case 44:
          return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(tt.EXPECT_ARGUMENT_CLOSING_BRACE, rt(n, this.clonePosition())) : this.parseArgumentOptions(e, t, r, n);
        default:
          return this.error(tt.MALFORMED_ARGUMENT, rt(n, this.clonePosition()));
      }
    }, i.prototype.parseIdentifierIfPossible = function() {
      var e = this.clonePosition(), t = this.offset(), n = ll(this.message, t), r = t + n.length;
      this.bumpTo(r);
      var s = this.clonePosition(), a = rt(e, s);
      return { value: n, location: a };
    }, i.prototype.parseArgumentOptions = function(e, t, n, r) {
      var s, a = this.clonePosition(), o = this.parseIdentifierIfPossible().value, l = this.clonePosition();
      switch (o) {
        case "":
          return this.error(tt.EXPECT_ARGUMENT_TYPE, rt(a, l));
        case "number":
        case "date":
        case "time": {
          this.bumpSpace();
          var c = null;
          if (this.bumpIf(",")) {
            this.bumpSpace();
            var u = this.clonePosition(), h = this.parseSimpleArgStyleIfPossible();
            if (h.err)
              return h;
            var d = bg(h.val);
            if (d.length === 0)
              return this.error(tt.EXPECT_ARGUMENT_STYLE, rt(this.clonePosition(), this.clonePosition()));
            var m = rt(u, this.clonePosition());
            c = { style: d, styleLocation: m };
          }
          var v = this.tryParseArgumentClose(r);
          if (v.err)
            return v;
          var b = rt(r, this.clonePosition());
          if (c && du(c?.style, "::", 0)) {
            var p = xg(c.style.slice(2));
            if (o === "number") {
              var h = this.parseNumberSkeletonFromString(p, c.styleLocation);
              return h.err ? h : {
                val: { type: Tt.number, value: n, location: b, style: h.val },
                err: null
              };
            } else {
              if (p.length === 0)
                return this.error(tt.EXPECT_DATE_TIME_SKELETON, b);
              var f = p;
              this.locale && (f = ag(p, this.locale));
              var d = {
                type: Ar.dateTime,
                pattern: f,
                location: c.styleLocation,
                parsedOptions: this.shouldParseSkeletons ? Qm(f) : {}
              }, x = o === "date" ? Tt.date : Tt.time;
              return {
                val: { type: x, value: n, location: b, style: d },
                err: null
              };
            }
          }
          return {
            val: {
              type: o === "number" ? Tt.number : o === "date" ? Tt.date : Tt.time,
              value: n,
              location: b,
              style: (s = c?.style) !== null && s !== void 0 ? s : null
            },
            err: null
          };
        }
        case "plural":
        case "selectordinal":
        case "select": {
          var g = this.clonePosition();
          if (this.bumpSpace(), !this.bumpIf(","))
            return this.error(tt.EXPECT_SELECT_ARGUMENT_OPTIONS, rt(g, ot({}, g)));
          this.bumpSpace();
          var _ = this.parseIdentifierIfPossible(), T = 0;
          if (o !== "select" && _.value === "offset") {
            if (!this.bumpIf(":"))
              return this.error(tt.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, rt(this.clonePosition(), this.clonePosition()));
            this.bumpSpace();
            var h = this.tryParseDecimalInteger(tt.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, tt.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
            if (h.err)
              return h;
            this.bumpSpace(), _ = this.parseIdentifierIfPossible(), T = h.val;
          }
          var A = this.tryParsePluralOrSelectOptions(e, o, t, _);
          if (A.err)
            return A;
          var v = this.tryParseArgumentClose(r);
          if (v.err)
            return v;
          var M = rt(r, this.clonePosition());
          return o === "select" ? {
            val: {
              type: Tt.select,
              value: n,
              options: pu(A.val),
              location: M
            },
            err: null
          } : {
            val: {
              type: Tt.plural,
              value: n,
              options: pu(A.val),
              offset: T,
              pluralType: o === "plural" ? "cardinal" : "ordinal",
              location: M
            },
            err: null
          };
        }
        default:
          return this.error(tt.INVALID_ARGUMENT_TYPE, rt(a, l));
      }
    }, i.prototype.tryParseArgumentClose = function(e) {
      return this.isEOF() || this.char() !== 125 ? this.error(tt.EXPECT_ARGUMENT_CLOSING_BRACE, rt(e, this.clonePosition())) : (this.bump(), { val: !0, err: null });
    }, i.prototype.parseSimpleArgStyleIfPossible = function() {
      for (var e = 0, t = this.clonePosition(); !this.isEOF(); ) {
        var n = this.char();
        switch (n) {
          case 39: {
            this.bump();
            var r = this.clonePosition();
            if (!this.bumpUntil("'"))
              return this.error(tt.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, rt(r, this.clonePosition()));
            this.bump();
            break;
          }
          case 123: {
            e += 1, this.bump();
            break;
          }
          case 125: {
            if (e > 0)
              e -= 1;
            else
              return {
                val: this.message.slice(t.offset, this.offset()),
                err: null
              };
            break;
          }
          default:
            this.bump();
            break;
        }
      }
      return {
        val: this.message.slice(t.offset, this.offset()),
        err: null
      };
    }, i.prototype.parseNumberSkeletonFromString = function(e, t) {
      var n = [];
      try {
        n = tg(e);
      } catch {
        return this.error(tt.INVALID_NUMBER_SKELETON, t);
      }
      return {
        val: {
          type: Ar.number,
          tokens: n,
          location: t,
          parsedOptions: this.shouldParseSkeletons ? sg(n) : {}
        },
        err: null
      };
    }, i.prototype.tryParsePluralOrSelectOptions = function(e, t, n, r) {
      for (var s, a = !1, o = [], l = /* @__PURE__ */ new Set(), c = r.value, u = r.location; ; ) {
        if (c.length === 0) {
          var h = this.clonePosition();
          if (t !== "select" && this.bumpIf("=")) {
            var d = this.tryParseDecimalInteger(tt.EXPECT_PLURAL_ARGUMENT_SELECTOR, tt.INVALID_PLURAL_ARGUMENT_SELECTOR);
            if (d.err)
              return d;
            u = rt(h, this.clonePosition()), c = this.message.slice(h.offset, this.offset());
          } else
            break;
        }
        if (l.has(c))
          return this.error(t === "select" ? tt.DUPLICATE_SELECT_ARGUMENT_SELECTOR : tt.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, u);
        c === "other" && (a = !0), this.bumpSpace();
        var m = this.clonePosition();
        if (!this.bumpIf("{"))
          return this.error(t === "select" ? tt.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : tt.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, rt(this.clonePosition(), this.clonePosition()));
        var v = this.parseMessage(e + 1, t, n);
        if (v.err)
          return v;
        var b = this.tryParseArgumentClose(m);
        if (b.err)
          return b;
        o.push([
          c,
          {
            value: v.val,
            location: rt(m, this.clonePosition())
          }
        ]), l.add(c), this.bumpSpace(), s = this.parseIdentifierIfPossible(), c = s.value, u = s.location;
      }
      return o.length === 0 ? this.error(t === "select" ? tt.EXPECT_SELECT_ARGUMENT_SELECTOR : tt.EXPECT_PLURAL_ARGUMENT_SELECTOR, rt(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !a ? this.error(tt.MISSING_OTHER_CLAUSE, rt(this.clonePosition(), this.clonePosition())) : { val: o, err: null };
    }, i.prototype.tryParseDecimalInteger = function(e, t) {
      var n = 1, r = this.clonePosition();
      this.bumpIf("+") || this.bumpIf("-") && (n = -1);
      for (var s = !1, a = 0; !this.isEOF(); ) {
        var o = this.char();
        if (o >= 48 && o <= 57)
          s = !0, a = a * 10 + (o - 48), this.bump();
        else
          break;
      }
      var l = rt(r, this.clonePosition());
      return s ? (a *= n, _g(a) ? { val: a, err: null } : this.error(t, l)) : this.error(e, l);
    }, i.prototype.offset = function() {
      return this.position.offset;
    }, i.prototype.isEOF = function() {
      return this.offset() === this.message.length;
    }, i.prototype.clonePosition = function() {
      return {
        offset: this.position.offset,
        line: this.position.line,
        column: this.position.column
      };
    }, i.prototype.char = function() {
      var e = this.position.offset;
      if (e >= this.message.length)
        throw Error("out of bound");
      var t = ed(this.message, e);
      if (t === void 0)
        throw Error("Offset ".concat(e, " is at invalid UTF-16 code unit boundary"));
      return t;
    }, i.prototype.error = function(e, t) {
      return {
        val: null,
        err: {
          kind: e,
          message: this.message,
          location: t
        }
      };
    }, i.prototype.bump = function() {
      if (!this.isEOF()) {
        var e = this.char();
        e === 10 ? (this.position.line += 1, this.position.column = 1, this.position.offset += 1) : (this.position.column += 1, this.position.offset += e < 65536 ? 1 : 2);
      }
    }, i.prototype.bumpIf = function(e) {
      if (du(this.message, e, this.offset())) {
        for (var t = 0; t < e.length; t++)
          this.bump();
        return !0;
      }
      return !1;
    }, i.prototype.bumpUntil = function(e) {
      var t = this.offset(), n = this.message.indexOf(e, t);
      return n >= 0 ? (this.bumpTo(n), !0) : (this.bumpTo(this.message.length), !1);
    }, i.prototype.bumpTo = function(e) {
      if (this.offset() > e)
        throw Error("targetOffset ".concat(e, " must be greater than or equal to the current offset ").concat(this.offset()));
      for (e = Math.min(e, this.message.length); ; ) {
        var t = this.offset();
        if (t === e)
          break;
        if (t > e)
          throw Error("targetOffset ".concat(e, " is at invalid UTF-16 code unit boundary"));
        if (this.bump(), this.isEOF())
          break;
      }
    }, i.prototype.bumpSpace = function() {
      for (; !this.isEOF() && nd(this.char()); )
        this.bump();
    }, i.prototype.peek = function() {
      if (this.isEOF())
        return null;
      var e = this.char(), t = this.offset(), n = this.message.charCodeAt(t + (e >= 65536 ? 2 : 1));
      return n ?? null;
    }, i;
  })()
);
function cl(i) {
  return i >= 97 && i <= 122 || i >= 65 && i <= 90;
}
function yg(i) {
  return cl(i) || i === 47;
}
function Sg(i) {
  return i === 45 || i === 46 || i >= 48 && i <= 57 || i === 95 || i >= 97 && i <= 122 || i >= 65 && i <= 90 || i == 183 || i >= 192 && i <= 214 || i >= 216 && i <= 246 || i >= 248 && i <= 893 || i >= 895 && i <= 8191 || i >= 8204 && i <= 8205 || i >= 8255 && i <= 8256 || i >= 8304 && i <= 8591 || i >= 11264 && i <= 12271 || i >= 12289 && i <= 55295 || i >= 63744 && i <= 64975 || i >= 65008 && i <= 65533 || i >= 65536 && i <= 983039;
}
function nd(i) {
  return i >= 9 && i <= 13 || i === 32 || i === 133 || i >= 8206 && i <= 8207 || i === 8232 || i === 8233;
}
function Mg(i) {
  return i >= 33 && i <= 35 || i === 36 || i >= 37 && i <= 39 || i === 40 || i === 41 || i === 42 || i === 43 || i === 44 || i === 45 || i >= 46 && i <= 47 || i >= 58 && i <= 59 || i >= 60 && i <= 62 || i >= 63 && i <= 64 || i === 91 || i === 92 || i === 93 || i === 94 || i === 96 || i === 123 || i === 124 || i === 125 || i === 126 || i === 161 || i >= 162 && i <= 165 || i === 166 || i === 167 || i === 169 || i === 171 || i === 172 || i === 174 || i === 176 || i === 177 || i === 182 || i === 187 || i === 191 || i === 215 || i === 247 || i >= 8208 && i <= 8213 || i >= 8214 && i <= 8215 || i === 8216 || i === 8217 || i === 8218 || i >= 8219 && i <= 8220 || i === 8221 || i === 8222 || i === 8223 || i >= 8224 && i <= 8231 || i >= 8240 && i <= 8248 || i === 8249 || i === 8250 || i >= 8251 && i <= 8254 || i >= 8257 && i <= 8259 || i === 8260 || i === 8261 || i === 8262 || i >= 8263 && i <= 8273 || i === 8274 || i === 8275 || i >= 8277 && i <= 8286 || i >= 8592 && i <= 8596 || i >= 8597 && i <= 8601 || i >= 8602 && i <= 8603 || i >= 8604 && i <= 8607 || i === 8608 || i >= 8609 && i <= 8610 || i === 8611 || i >= 8612 && i <= 8613 || i === 8614 || i >= 8615 && i <= 8621 || i === 8622 || i >= 8623 && i <= 8653 || i >= 8654 && i <= 8655 || i >= 8656 && i <= 8657 || i === 8658 || i === 8659 || i === 8660 || i >= 8661 && i <= 8691 || i >= 8692 && i <= 8959 || i >= 8960 && i <= 8967 || i === 8968 || i === 8969 || i === 8970 || i === 8971 || i >= 8972 && i <= 8991 || i >= 8992 && i <= 8993 || i >= 8994 && i <= 9e3 || i === 9001 || i === 9002 || i >= 9003 && i <= 9083 || i === 9084 || i >= 9085 && i <= 9114 || i >= 9115 && i <= 9139 || i >= 9140 && i <= 9179 || i >= 9180 && i <= 9185 || i >= 9186 && i <= 9254 || i >= 9255 && i <= 9279 || i >= 9280 && i <= 9290 || i >= 9291 && i <= 9311 || i >= 9472 && i <= 9654 || i === 9655 || i >= 9656 && i <= 9664 || i === 9665 || i >= 9666 && i <= 9719 || i >= 9720 && i <= 9727 || i >= 9728 && i <= 9838 || i === 9839 || i >= 9840 && i <= 10087 || i === 10088 || i === 10089 || i === 10090 || i === 10091 || i === 10092 || i === 10093 || i === 10094 || i === 10095 || i === 10096 || i === 10097 || i === 10098 || i === 10099 || i === 10100 || i === 10101 || i >= 10132 && i <= 10175 || i >= 10176 && i <= 10180 || i === 10181 || i === 10182 || i >= 10183 && i <= 10213 || i === 10214 || i === 10215 || i === 10216 || i === 10217 || i === 10218 || i === 10219 || i === 10220 || i === 10221 || i === 10222 || i === 10223 || i >= 10224 && i <= 10239 || i >= 10240 && i <= 10495 || i >= 10496 && i <= 10626 || i === 10627 || i === 10628 || i === 10629 || i === 10630 || i === 10631 || i === 10632 || i === 10633 || i === 10634 || i === 10635 || i === 10636 || i === 10637 || i === 10638 || i === 10639 || i === 10640 || i === 10641 || i === 10642 || i === 10643 || i === 10644 || i === 10645 || i === 10646 || i === 10647 || i === 10648 || i >= 10649 && i <= 10711 || i === 10712 || i === 10713 || i === 10714 || i === 10715 || i >= 10716 && i <= 10747 || i === 10748 || i === 10749 || i >= 10750 && i <= 11007 || i >= 11008 && i <= 11055 || i >= 11056 && i <= 11076 || i >= 11077 && i <= 11078 || i >= 11079 && i <= 11084 || i >= 11085 && i <= 11123 || i >= 11124 && i <= 11125 || i >= 11126 && i <= 11157 || i === 11158 || i >= 11159 && i <= 11263 || i >= 11776 && i <= 11777 || i === 11778 || i === 11779 || i === 11780 || i === 11781 || i >= 11782 && i <= 11784 || i === 11785 || i === 11786 || i === 11787 || i === 11788 || i === 11789 || i >= 11790 && i <= 11798 || i === 11799 || i >= 11800 && i <= 11801 || i === 11802 || i === 11803 || i === 11804 || i === 11805 || i >= 11806 && i <= 11807 || i === 11808 || i === 11809 || i === 11810 || i === 11811 || i === 11812 || i === 11813 || i === 11814 || i === 11815 || i === 11816 || i === 11817 || i >= 11818 && i <= 11822 || i === 11823 || i >= 11824 && i <= 11833 || i >= 11834 && i <= 11835 || i >= 11836 && i <= 11839 || i === 11840 || i === 11841 || i === 11842 || i >= 11843 && i <= 11855 || i >= 11856 && i <= 11857 || i === 11858 || i >= 11859 && i <= 11903 || i >= 12289 && i <= 12291 || i === 12296 || i === 12297 || i === 12298 || i === 12299 || i === 12300 || i === 12301 || i === 12302 || i === 12303 || i === 12304 || i === 12305 || i >= 12306 && i <= 12307 || i === 12308 || i === 12309 || i === 12310 || i === 12311 || i === 12312 || i === 12313 || i === 12314 || i === 12315 || i === 12316 || i === 12317 || i >= 12318 && i <= 12319 || i === 12320 || i === 12336 || i === 64830 || i === 64831 || i >= 65093 && i <= 65094;
}
function ul(i) {
  i.forEach(function(e) {
    if (delete e.location, jf(e) || qf(e))
      for (var t in e.options)
        delete e.options[t].location, ul(e.options[t].value);
    else Vf(e) && Zf(e.style) || (Wf(e) || Xf(e)) && sl(e.style) ? delete e.style.location : Yf(e) && ul(e.children);
  });
}
function Ag(i, e) {
  e === void 0 && (e = {}), e = ot({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, e);
  var t = new Eg(i, e).parse();
  if (t.err) {
    var n = SyntaxError(tt[t.err.kind]);
    throw n.location = t.err.location, n.originalMessage = t.err.message, n;
  }
  return e?.captureLocation || ul(t.val), t.val;
}
var Tr;
(function(i) {
  i.MISSING_VALUE = "MISSING_VALUE", i.INVALID_VALUE = "INVALID_VALUE", i.MISSING_INTL_API = "MISSING_INTL_API";
})(Tr || (Tr = {}));
var Ga = (
  /** @class */
  (function(i) {
    za(e, i);
    function e(t, n, r) {
      var s = i.call(this, t) || this;
      return s.code = n, s.originalMessage = r, s;
    }
    return e.prototype.toString = function() {
      return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
    }, e;
  })(Error)
), gu = (
  /** @class */
  (function(i) {
    za(e, i);
    function e(t, n, r, s) {
      return i.call(this, 'Invalid values for "'.concat(t, '": "').concat(n, '". Options are "').concat(Object.keys(r).join('", "'), '"'), Tr.INVALID_VALUE, s) || this;
    }
    return e;
  })(Ga)
), Tg = (
  /** @class */
  (function(i) {
    za(e, i);
    function e(t, n, r) {
      return i.call(this, 'Value for "'.concat(t, '" must be of type ').concat(n), Tr.INVALID_VALUE, r) || this;
    }
    return e;
  })(Ga)
), wg = (
  /** @class */
  (function(i) {
    za(e, i);
    function e(t, n) {
      return i.call(this, 'The intl string context variable "'.concat(t, '" was not provided to the string "').concat(n, '"'), Tr.MISSING_VALUE, n) || this;
    }
    return e;
  })(Ga)
), Zt;
(function(i) {
  i[i.literal = 0] = "literal", i[i.object = 1] = "object";
})(Zt || (Zt = {}));
function Dg(i) {
  return i.length < 2 ? i : i.reduce(function(e, t) {
    var n = e[e.length - 1];
    return !n || n.type !== Zt.literal || t.type !== Zt.literal ? e.push(t) : n.value += t.value, e;
  }, []);
}
function Rg(i) {
  return typeof i == "function";
}
function ga(i, e, t, n, r, s, a) {
  if (i.length === 1 && cu(i[0]))
    return [
      {
        type: Zt.literal,
        value: i[0].value
      }
    ];
  for (var o = [], l = 0, c = i; l < c.length; l++) {
    var u = c[l];
    if (cu(u)) {
      o.push({
        type: Zt.literal,
        value: u.value
      });
      continue;
    }
    if ($m(u)) {
      typeof s == "number" && o.push({
        type: Zt.literal,
        value: t.getNumberFormat(e).format(s)
      });
      continue;
    }
    var h = u.value;
    if (!(r && h in r))
      throw new wg(h, a);
    var d = r[h];
    if (Km(u)) {
      (!d || typeof d == "string" || typeof d == "number") && (d = typeof d == "string" || typeof d == "number" ? String(d) : ""), o.push({
        type: typeof d == "string" ? Zt.literal : Zt.object,
        value: d
      });
      continue;
    }
    if (Wf(u)) {
      var m = typeof u.style == "string" ? n.date[u.style] : sl(u.style) ? u.style.parsedOptions : void 0;
      o.push({
        type: Zt.literal,
        value: t.getDateTimeFormat(e, m).format(d)
      });
      continue;
    }
    if (Xf(u)) {
      var m = typeof u.style == "string" ? n.time[u.style] : sl(u.style) ? u.style.parsedOptions : n.time.medium;
      o.push({
        type: Zt.literal,
        value: t.getDateTimeFormat(e, m).format(d)
      });
      continue;
    }
    if (Vf(u)) {
      var m = typeof u.style == "string" ? n.number[u.style] : Zf(u.style) ? u.style.parsedOptions : void 0;
      m && m.scale && (d = d * (m.scale || 1)), o.push({
        type: Zt.literal,
        value: t.getNumberFormat(e, m).format(d)
      });
      continue;
    }
    if (Yf(u)) {
      var v = u.children, b = u.value, p = r[b];
      if (!Rg(p))
        throw new Tg(b, "function", a);
      var f = ga(v, e, t, n, r, s), x = p(f.map(function(T) {
        return T.value;
      }));
      Array.isArray(x) || (x = [x]), o.push.apply(o, x.map(function(T) {
        return {
          type: typeof T == "string" ? Zt.literal : Zt.object,
          value: T
        };
      }));
    }
    if (jf(u)) {
      var g = u.options[d] || u.options.other;
      if (!g)
        throw new gu(u.value, d, Object.keys(u.options), a);
      o.push.apply(o, ga(g.value, e, t, n, r));
      continue;
    }
    if (qf(u)) {
      var g = u.options["=".concat(d)];
      if (!g) {
        if (!Intl.PluralRules)
          throw new Ga(`Intl.PluralRules is not available in this environment.
Try polyfilling it using "@formatjs/intl-pluralrules"
`, Tr.MISSING_INTL_API, a);
        var _ = t.getPluralRules(e, { type: u.pluralType }).select(d - (u.offset || 0));
        g = u.options[_] || u.options.other;
      }
      if (!g)
        throw new gu(u.value, d, Object.keys(u.options), a);
      o.push.apply(o, ga(g.value, e, t, n, r, d - (u.offset || 0)));
      continue;
    }
  }
  return Dg(o);
}
function Cg(i, e) {
  return e ? ot(ot(ot({}, i || {}), e || {}), Object.keys(i).reduce(function(t, n) {
    return t[n] = ot(ot({}, i[n]), e[n] || {}), t;
  }, {})) : i;
}
function Pg(i, e) {
  return e ? Object.keys(i).reduce(function(t, n) {
    return t[n] = Cg(i[n], e[n]), t;
  }, ot({}, i)) : i;
}
function oo(i) {
  return {
    create: function() {
      return {
        get: function(e) {
          return i[e];
        },
        set: function(e, t) {
          i[e] = t;
        }
      };
    }
  };
}
function Lg(i) {
  return i === void 0 && (i = {
    number: {},
    dateTime: {},
    pluralRules: {}
  }), {
    getNumberFormat: ro(function() {
      for (var e, t = [], n = 0; n < arguments.length; n++)
        t[n] = arguments[n];
      return new ((e = Intl.NumberFormat).bind.apply(e, io([void 0], t, !1)))();
    }, {
      cache: oo(i.number),
      strategy: so.variadic
    }),
    getDateTimeFormat: ro(function() {
      for (var e, t = [], n = 0; n < arguments.length; n++)
        t[n] = arguments[n];
      return new ((e = Intl.DateTimeFormat).bind.apply(e, io([void 0], t, !1)))();
    }, {
      cache: oo(i.dateTime),
      strategy: so.variadic
    }),
    getPluralRules: ro(function() {
      for (var e, t = [], n = 0; n < arguments.length; n++)
        t[n] = arguments[n];
      return new ((e = Intl.PluralRules).bind.apply(e, io([void 0], t, !1)))();
    }, {
      cache: oo(i.pluralRules),
      strategy: so.variadic
    })
  };
}
var Ig = (
  /** @class */
  (function() {
    function i(e, t, n, r) {
      t === void 0 && (t = i.defaultLocale);
      var s = this;
      if (this.formatterCache = {
        number: {},
        dateTime: {},
        pluralRules: {}
      }, this.format = function(l) {
        var c = s.formatToParts(l);
        if (c.length === 1)
          return c[0].value;
        var u = c.reduce(function(h, d) {
          return !h.length || d.type !== Zt.literal || typeof h[h.length - 1] != "string" ? h.push(d.value) : h[h.length - 1] += d.value, h;
        }, []);
        return u.length <= 1 ? u[0] || "" : u;
      }, this.formatToParts = function(l) {
        return ga(s.ast, s.locales, s.formatters, s.formats, l, void 0, s.message);
      }, this.resolvedOptions = function() {
        var l;
        return {
          locale: ((l = s.resolvedLocale) === null || l === void 0 ? void 0 : l.toString()) || Intl.NumberFormat.supportedLocalesOf(s.locales)[0]
        };
      }, this.getAst = function() {
        return s.ast;
      }, this.locales = t, this.resolvedLocale = i.resolveLocale(t), typeof e == "string") {
        if (this.message = e, !i.__parse)
          throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
        var a = r || {};
        a.formatters;
        var o = Gm(a, ["formatters"]);
        this.ast = i.__parse(e, ot(ot({}, o), { locale: this.resolvedLocale }));
      } else
        this.ast = e;
      if (!Array.isArray(this.ast))
        throw new TypeError("A message must be provided as a String or AST.");
      this.formats = Pg(i.formats, n), this.formatters = r && r.formatters || Lg(this.formatterCache);
    }
    return Object.defineProperty(i, "defaultLocale", {
      get: function() {
        return i.memoizedDefaultLocale || (i.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale), i.memoizedDefaultLocale;
      },
      enumerable: !1,
      configurable: !0
    }), i.memoizedDefaultLocale = null, i.resolveLocale = function(e) {
      if (!(typeof Intl.Locale > "u")) {
        var t = Intl.NumberFormat.supportedLocalesOf(e);
        return t.length > 0 ? new Intl.Locale(t[0]) : new Intl.Locale(typeof e == "string" ? e : e[0]);
      }
    }, i.__parse = Ag, i.formats = {
      number: {
        integer: {
          maximumFractionDigits: 0
        },
        currency: {
          style: "currency"
        },
        percent: {
          style: "percent"
        }
      },
      date: {
        short: {
          month: "numeric",
          day: "numeric",
          year: "2-digit"
        },
        medium: {
          month: "short",
          day: "numeric",
          year: "numeric"
        },
        long: {
          month: "long",
          day: "numeric",
          year: "numeric"
        },
        full: {
          weekday: "long",
          month: "long",
          day: "numeric",
          year: "numeric"
        }
      },
      time: {
        short: {
          hour: "numeric",
          minute: "numeric"
        },
        medium: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric"
        },
        long: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric",
          timeZoneName: "short"
        },
        full: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric",
          timeZoneName: "short"
        }
      }
    }, i;
  })()
);
function Fg(i, e) {
  if (e == null)
    return;
  if (e in i)
    return i[e];
  const t = e.split(".");
  let n = i;
  for (let r = 0; r < t.length; r++)
    if (typeof n == "object") {
      if (r > 0) {
        const s = t.slice(r, t.length).join(".");
        if (s in n) {
          n = n[s];
          break;
        }
      }
      n = n[t[r]];
    } else
      n = void 0;
  return n;
}
const xi = {}, Ng = (i, e, t) => t && (e in xi || (xi[e] = {}), i in xi[e] || (xi[e][i] = t), t), id = (i, e) => {
  if (e == null)
    return;
  if (e in xi && i in xi[e])
    return xi[e][i];
  const t = Va(e);
  for (let n = 0; n < t.length; n++) {
    const r = t[n], s = Og(r, i);
    if (s)
      return Ng(i, e, s);
  }
};
let dc;
const ws = Ts({});
function Ug(i) {
  return dc[i] || null;
}
function rd(i) {
  return i in dc;
}
function Og(i, e) {
  if (!rd(i))
    return null;
  const t = Ug(i);
  return Fg(t, e);
}
function Bg(i) {
  if (i == null)
    return;
  const e = Va(i);
  for (let t = 0; t < e.length; t++) {
    const n = e[t];
    if (rd(n))
      return n;
  }
}
function kg(i, ...e) {
  delete xi[i], ws.update((t) => (t[i] = zm.all([t[i] || {}, ...e]), t));
}
Gr(
  [ws],
  ([i]) => Object.keys(i)
);
ws.subscribe((i) => dc = i);
const _a = {};
function Hg(i, e) {
  _a[i].delete(e), _a[i].size === 0 && delete _a[i];
}
function sd(i) {
  return _a[i];
}
function zg(i) {
  return Va(i).map((e) => {
    const t = sd(e);
    return [e, t ? [...t] : []];
  }).filter(([, e]) => e.length > 0);
}
function hl(i) {
  return i == null ? !1 : Va(i).some(
    (e) => {
      var t;
      return (t = sd(e)) == null ? void 0 : t.size;
    }
  );
}
function Gg(i, e) {
  return Promise.all(
    e.map((n) => (Hg(i, n), n().then((r) => r.default || r)))
  ).then((n) => kg(i, ...n));
}
const Qr = {};
function ad(i) {
  if (!hl(i))
    return i in Qr ? Qr[i] : Promise.resolve();
  const e = zg(i);
  return Qr[i] = Promise.all(
    e.map(
      ([t, n]) => Gg(t, n)
    )
  ).then(() => {
    if (hl(i))
      return ad(i);
    delete Qr[i];
  }), Qr[i];
}
const Vg = {
  number: {
    scientific: { notation: "scientific" },
    engineering: { notation: "engineering" },
    compactLong: { notation: "compact", compactDisplay: "long" },
    compactShort: { notation: "compact", compactDisplay: "short" }
  },
  date: {
    short: { month: "numeric", day: "numeric", year: "2-digit" },
    medium: { month: "short", day: "numeric", year: "numeric" },
    long: { month: "long", day: "numeric", year: "numeric" },
    full: { weekday: "long", month: "long", day: "numeric", year: "numeric" }
  },
  time: {
    short: { hour: "numeric", minute: "numeric" },
    medium: { hour: "numeric", minute: "numeric", second: "numeric" },
    long: {
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      timeZoneName: "short"
    },
    full: {
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      timeZoneName: "short"
    }
  }
}, Wg = {
  fallbackLocale: null,
  loadingDelay: 200,
  formats: Vg,
  warnOnMissingMessages: !0,
  handleMissingMessage: void 0,
  ignoreTag: !0
}, Xg = Wg;
function wr() {
  return Xg;
}
const lo = Ts(!1);
var jg = Object.defineProperty, qg = Object.defineProperties, Yg = Object.getOwnPropertyDescriptors, _u = Object.getOwnPropertySymbols, Zg = Object.prototype.hasOwnProperty, Kg = Object.prototype.propertyIsEnumerable, vu = (i, e, t) => e in i ? jg(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, $g = (i, e) => {
  for (var t in e || (e = {}))
    Zg.call(e, t) && vu(i, t, e[t]);
  if (_u)
    for (var t of _u(e))
      Kg.call(e, t) && vu(i, t, e[t]);
  return i;
}, Jg = (i, e) => qg(i, Yg(e));
let fl;
const wa = Ts(null);
function xu(i) {
  return i.split("-").map((e, t, n) => n.slice(0, t + 1).join("-")).reverse();
}
function Va(i, e = wr().fallbackLocale) {
  const t = xu(i);
  return e ? [.../* @__PURE__ */ new Set([...t, ...xu(e)])] : t;
}
function ji() {
  return fl ?? void 0;
}
wa.subscribe((i) => {
  fl = i ?? void 0, typeof window < "u" && i != null && document.documentElement.setAttribute("lang", i);
});
const Qg = (i) => {
  if (i && Bg(i) && hl(i)) {
    const { loadingDelay: e } = wr();
    let t;
    return typeof window < "u" && ji() != null && e ? t = window.setTimeout(
      () => lo.set(!0),
      e
    ) : lo.set(!0), ad(i).then(() => {
      wa.set(i);
    }).finally(() => {
      clearTimeout(t), lo.set(!1);
    });
  }
  return wa.set(i);
}, Vr = Jg($g({}, wa), {
  set: Qg
}), Wa = (i) => {
  const e = /* @__PURE__ */ Object.create(null);
  return (n) => {
    const r = JSON.stringify(n);
    return r in e ? e[r] : e[r] = i(n);
  };
};
var e_ = Object.defineProperty, Da = Object.getOwnPropertySymbols, od = Object.prototype.hasOwnProperty, ld = Object.prototype.propertyIsEnumerable, bu = (i, e, t) => e in i ? e_(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, pc = (i, e) => {
  for (var t in e || (e = {}))
    od.call(e, t) && bu(i, t, e[t]);
  if (Da)
    for (var t of Da(e))
      ld.call(e, t) && bu(i, t, e[t]);
  return i;
}, Wr = (i, e) => {
  var t = {};
  for (var n in i)
    od.call(i, n) && e.indexOf(n) < 0 && (t[n] = i[n]);
  if (i != null && Da)
    for (var n of Da(i))
      e.indexOf(n) < 0 && ld.call(i, n) && (t[n] = i[n]);
  return t;
};
const xs = (i, e) => {
  const { formats: t } = wr();
  if (i in t && e in t[i])
    return t[i][e];
  throw new Error(`[svelte-i18n] Unknown "${e}" ${i} format.`);
}, t_ = Wa(
  (i) => {
    var e = i, { locale: t, format: n } = e, r = Wr(e, ["locale", "format"]);
    if (t == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format numbers');
    return n && (r = xs("number", n)), new Intl.NumberFormat(t, r);
  }
), n_ = Wa(
  (i) => {
    var e = i, { locale: t, format: n } = e, r = Wr(e, ["locale", "format"]);
    if (t == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format dates');
    return n ? r = xs("date", n) : Object.keys(r).length === 0 && (r = xs("date", "short")), new Intl.DateTimeFormat(t, r);
  }
), i_ = Wa(
  (i) => {
    var e = i, { locale: t, format: n } = e, r = Wr(e, ["locale", "format"]);
    if (t == null)
      throw new Error(
        '[svelte-i18n] A "locale" must be set to format time values'
      );
    return n ? r = xs("time", n) : Object.keys(r).length === 0 && (r = xs("time", "short")), new Intl.DateTimeFormat(t, r);
  }
), r_ = (i = {}) => {
  var e = i, {
    locale: t = ji()
  } = e, n = Wr(e, [
    "locale"
  ]);
  return t_(pc({ locale: t }, n));
}, s_ = (i = {}) => {
  var e = i, {
    locale: t = ji()
  } = e, n = Wr(e, [
    "locale"
  ]);
  return n_(pc({ locale: t }, n));
}, a_ = (i = {}) => {
  var e = i, {
    locale: t = ji()
  } = e, n = Wr(e, [
    "locale"
  ]);
  return i_(pc({ locale: t }, n));
}, o_ = Wa(
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  (i, e = ji()) => new Ig(i, e, wr().formats, {
    ignoreTag: wr().ignoreTag
  })
), l_ = (i, e = {}) => {
  var t, n, r, s;
  let a = e;
  typeof i == "object" && (a = i, i = a.id);
  const {
    values: o,
    locale: l = ji(),
    default: c
  } = a;
  if (l == null)
    throw new Error(
      "[svelte-i18n] Cannot format a message without first setting the initial locale."
    );
  let u = id(i, l);
  if (!u)
    u = (s = (r = (n = (t = wr()).handleMissingMessage) == null ? void 0 : n.call(t, { locale: l, id: i, defaultValue: c })) != null ? r : c) != null ? s : i;
  else if (typeof u != "string")
    return console.warn(
      `[svelte-i18n] Message with id "${i}" must be of type "string", found: "${typeof u}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`
    ), u;
  if (!o)
    return u;
  let h = u;
  try {
    h = o_(u, l).format(o);
  } catch (d) {
    d instanceof Error && console.warn(
      `[svelte-i18n] Message "${i}" has syntax error:`,
      d.message
    );
  }
  return h;
}, c_ = (i, e) => a_(e).format(i), u_ = (i, e) => s_(e).format(i), h_ = (i, e) => r_(e).format(i), f_ = (i, e = ji()) => id(i, e);
Gr([Vr, ws], () => l_);
Gr([Vr], () => c_);
Gr([Vr], () => u_);
Gr([Vr], () => h_);
Gr([Vr, ws], () => f_);
const d_ = "__i18n__", p_ = [
  "label",
  "info",
  "placeholder",
  "description",
  "title",
  "value"
], m_ = typeof window < "u", g_ = [
  "elem_id",
  "elem_classes",
  "visible",
  "interactive",
  "server_fns",
  "server",
  "id",
  "target",
  "theme_mode",
  "version",
  "root",
  "autoscroll",
  "max_file_size",
  "formatter",
  "client",
  "load_component",
  "scale",
  "min_width",
  "theme",
  "padding",
  "loading_status",
  "label",
  "show_label",
  "validation_error",
  "show_progress",
  "api_prefix",
  "container",
  "attached_events",
  "register_component",
  "dispatcher"
];
function __(i) {
  return typeof i == "string" && i.includes(d_);
}
class v_ {
  load_component;
  #e = wt(Sn({}));
  get shared() {
    return P(this.#e);
  }
  set shared(e) {
    Te(this.#e, e, !0);
  }
  #n = wt(Sn({}));
  get props() {
    return P(this.#n);
  }
  set props(e) {
    Te(this.#n, e, !0);
  }
  #t = wt((e) => e);
  get i18n() {
    return P(this.#t);
  }
  set i18n(e) {
    Te(this.#t, e, !0);
  }
  translatable_props = {};
  dispatcher;
  last_update = null;
  shared_props = g_;
  register_component;
  constructor(e, t) {
    for (const n in e.shared_props)
      this.shared[n] = e.shared_props[n];
    for (const n in e.props)
      this.props[n] = e.props[n];
    if (t)
      for (const n in t)
        this.props[n] === void 0 && (this.props[n] = t[n]);
    this.i18n = this.props.i18n ?? ((n) => n);
    for (const n of p_)
      this.shared[n] = this._translate_and_store(
        "shared",
        n,
        // @ts-ignore
        e.shared_props[n]
      ), this.props[n] = this._translate_and_store(
        "props",
        n,
        // @ts-ignore
        e.props[n]
      );
    if (this.load_component = this.shared.load_component, !m_ || e.props?.__GRADIO_BROWSER_TEST__) {
      this.dispatcher = () => {
      };
      return;
    }
    this.register_component = this.shared.register_component || (() => {
    }), this.dispatcher = this.shared.dispatcher || (() => {
    }), this.register_component(
      e.shared_props.id,
      // @ts-ignore
      this.set_data.bind(this),
      this.get_data.bind(this)
    ), Lt(() => {
      for (const n in e.shared_props)
        this._is_i18n_managed(`shared.${n}`, e.shared_props[n]) || (this.shared[n] = e.shared_props[n]);
      for (const n in e.props)
        this._is_i18n_managed(`props.${n}`, e.props[n]) || (this.props[n] = e.props[n]);
      this.register_component(
        e.shared_props.id,
        // @ts-ignore
        this.set_data.bind(this),
        this.get_data.bind(this)
      ), Nt(() => {
        this.shared.id = e.shared_props.id;
      });
    }), Object.keys(this.translatable_props).length > 0 && Vr.subscribe(() => {
      for (const [n, r] of Object.entries(this.translatable_props)) {
        const [s, a] = n.split("."), o = this.i18n(r);
        s === "shared" ? this.shared[a] = o : this.props[a] = o;
      }
    });
  }
  // check if props are translatable
  _is_i18n_managed(e, t) {
    const n = this.translatable_props[e];
    return n ? t === n ? !0 : (delete this.translatable_props[e], !1) : !1;
  }
  _translate_and_store(e, t, n) {
    if (typeof n != "string") return n;
    const r = this.i18n(n);
    return r !== n && (this.translatable_props[`${e}.${t}`] = n), r;
  }
  dispatch(e, t) {
    this.dispatcher(this.shared.id, e, t);
  }
  async get_data() {
    return im(this.props);
  }
  update(e) {
    this.set_data(e);
  }
  set_data(e) {
    for (const t in e) {
      const n = e[t], r = __(n) ? this._translate_and_store(this.shared_props.includes(t) ? "shared" : "props", t, n) : n;
      if (this.shared_props.includes(t)) {
        const s = t;
        this.shared[s] = r;
        continue;
      }
      this.props[t] = r;
    }
  }
}
Qp();
var x_ = /* @__PURE__ */ If('<svg class="resize-handle svelte-1stq1b1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><line x1="1" y1="9" x2="9" y2="1" stroke="gray" stroke-width="0.5" class="svelte-1stq1b1"></line><line x1="5" y1="9" x2="9" y2="5" stroke="gray" stroke-width="0.5" class="svelte-1stq1b1"></line></svg>'), b_ = /* @__PURE__ */ Ct("<!> <!>", 1), E_ = /* @__PURE__ */ Ct('<div class="placeholder svelte-1stq1b1"></div>'), y_ = /* @__PURE__ */ Ct("<!> <!>", 1);
function S_(i, e) {
  zr(e, !1);
  let t = Ee(e, "height", 8, void 0), n = Ee(e, "min_height", 8, void 0), r = Ee(e, "max_height", 8, void 0), s = Ee(e, "width", 8, void 0), a = Ee(e, "elem_id", 8, ""), o = Ee(e, "elem_classes", 24, () => []), l = Ee(e, "variant", 8, "solid"), c = Ee(e, "border_mode", 8, "base"), u = Ee(e, "padding", 8, !0), h = Ee(e, "type", 8, "normal"), d = Ee(e, "test_id", 8, void 0), m = Ee(e, "explicit_call", 8, !1), v = Ee(e, "container", 8, !0), b = Ee(e, "visible", 8, !0), p = Ee(e, "allow_overflow", 8, !0), f = Ee(e, "overflow_behavior", 8, "auto"), x = Ee(e, "scale", 8, null), g = Ee(e, "min_width", 8, 0), _ = Ee(e, "flex", 12, !1), T = Ee(e, "resizable", 8, !1), A = Ee(e, "rtl", 8, !1), M = Ee(e, "fullscreen", 12, !1), C = Ee(e, "label", 8, void 0), y = Ni(M()), E = Ni(), R = h() === "fieldset" ? "fieldset" : "div", q = Ni(0), G = Ni(0), V = Ni(null);
  function B(ce) {
    M() && ce.key === "Escape" && M(!1);
  }
  const U = (ce) => {
    if (ce !== void 0) {
      if (typeof ce == "number")
        return ce + "px";
      if (typeof ce == "string")
        return ce;
    }
  }, Y = (ce) => {
    let ye = ce.clientY;
    const je = (Q) => {
      const re = Q.clientY - ye;
      ye = Q.clientY, tm(E, P(E).style.height = `${P(E).offsetHeight + re}px`);
    }, K = () => {
      window.removeEventListener("mousemove", je), window.removeEventListener("mouseup", K);
    };
    window.addEventListener("mousemove", je), window.addEventListener("mouseup", K);
  };
  Zc(
    () => (mn(M()), P(y), P(E)),
    () => {
      M() !== P(y) && (Te(y, M()), M() ? (Te(V, P(E).getBoundingClientRect()), Te(q, P(E).offsetHeight), Te(G, P(E).offsetWidth), window.addEventListener("keydown", B)) : (Te(V, null), window.removeEventListener("keydown", B)));
    }
  ), Zc(() => mn(b()), () => {
    b() || _(!1);
  }), em(), Cm();
  var z = mr(), ie = Kt(z);
  {
    var oe = (ce) => {
      var ye = y_(), je = Kt(ye);
      vm(je, () => R, !1, (re, ne) => {
        Ha(re, (Pe) => Te(E, Pe), () => P(E)), Rm(
          re,
          (Pe, Je) => ({
            "data-testid": d(),
            id: a(),
            class: `block ${Pe ?? ""}`,
            dir: A() ? "rtl" : "ltr",
            "aria-label": C(),
            style: "",
            [hs]: {
              hidden: b() === "hidden",
              padded: u(),
              flex: _(),
              border_focus: c() === "focus",
              border_contrast: c() === "contrast",
              "hide-container": !m() && !v(),
              fullscreen: M(),
              animating: M() && P(V) !== null,
              "auto-margin": x() === null
            },
            [pr]: Je
          }),
          [
            () => (mn(o()), Nt(() => o()?.join(" ") || "")),
            () => ({
              height: (mn(M()), mn(t()), Nt(() => M() ? void 0 : U(t()))),
              "min-height": (mn(M()), mn(n()), Nt(() => M() ? void 0 : U(n()))),
              "max-height": (mn(M()), mn(r()), Nt(() => M() ? void 0 : U(r()))),
              "--start-top": (P(V), Nt(() => P(V) ? `${P(V).top}px` : "0px")),
              "--start-left": (P(V), Nt(() => P(V) ? `${P(V).left}px` : "0px")),
              "--start-width": (P(V), Nt(() => P(V) ? `${P(V).width}px` : "0px")),
              "--start-height": (P(V), Nt(() => P(V) ? `${P(V).height}px` : "0px")),
              width: (mn(M()), mn(s()), Nt(() => M() ? void 0 : typeof s() == "number" ? `calc(min(${s()}px, 100%))` : U(s()))),
              "border-style": l(),
              overflow: p() ? f() : "hidden",
              "flex-grow": x(),
              "min-width": `calc(min(${g()}px, 100%))`
            })
          ],
          void 0,
          void 0,
          "svelte-1stq1b1"
        );
        var he = b_(), me = Kt(he);
        nl(me, e, "default", {});
        var we = st(me, 2);
        {
          var qe = (Pe) => {
            var Je = x_();
            Jo("mousedown", Je, Y), Ke(Pe, Je);
          };
          At(we, (Pe) => {
            T() && Pe(qe);
          });
        }
        Ke(ne, he);
      });
      var K = st(je, 2);
      {
        var Q = (re) => {
          var ne = E_();
          let he;
          Dt(() => he = Dn(ne, "", he, {
            height: P(q) + "px",
            width: P(G) + "px"
          })), Ke(re, ne);
        };
        At(K, (re) => {
          M() && re(Q);
        });
      }
      Ke(ce, ye);
    };
    At(ie, (ce) => {
      (b() === !0 || b() === "hidden") && ce(oe);
    });
  }
  Ke(i, z), Hr();
}
function mc() {
  return {
    async: !1,
    breaks: !1,
    extensions: null,
    gfm: !0,
    hooks: null,
    pedantic: !1,
    renderer: null,
    silent: !1,
    tokenizer: null,
    walkTokens: null
  };
}
let qi = mc();
function cd(i) {
  qi = i;
}
const ud = /[&<>"']/, M_ = new RegExp(ud.source, "g"), hd = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, A_ = new RegExp(hd.source, "g"), T_ = {
  "&": "&amp;",
  "<": "&lt;",
  ">": "&gt;",
  '"': "&quot;",
  "'": "&#39;"
}, Eu = (i) => T_[i];
function cn(i, e) {
  if (e) {
    if (ud.test(i))
      return i.replace(M_, Eu);
  } else if (hd.test(i))
    return i.replace(A_, Eu);
  return i;
}
const w_ = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
function D_(i) {
  return i.replace(w_, (e, t) => (t = t.toLowerCase(), t === "colon" ? ":" : t.charAt(0) === "#" ? t.charAt(1) === "x" ? String.fromCharCode(parseInt(t.substring(2), 16)) : String.fromCharCode(+t.substring(1)) : ""));
}
const R_ = /(^|[^\[])\^/g;
function vt(i, e) {
  let t = typeof i == "string" ? i : i.source;
  e = e || "";
  const n = {
    replace: (r, s) => {
      let a = typeof s == "string" ? s : s.source;
      return a = a.replace(R_, "$1"), t = t.replace(r, a), n;
    },
    getRegex: () => new RegExp(t, e)
  };
  return n;
}
function yu(i) {
  try {
    i = encodeURI(i).replace(/%25/g, "%");
  } catch {
    return null;
  }
  return i;
}
const ms = { exec: () => null };
function Su(i, e) {
  const t = i.replace(/\|/g, (s, a, o) => {
    let l = !1, c = a;
    for (; --c >= 0 && o[c] === "\\"; )
      l = !l;
    return l ? "|" : " |";
  }), n = t.split(/ \|/);
  let r = 0;
  if (n[0].trim() || n.shift(), n.length > 0 && !n[n.length - 1].trim() && n.pop(), e)
    if (n.length > e)
      n.splice(e);
    else
      for (; n.length < e; )
        n.push("");
  for (; r < n.length; r++)
    n[r] = n[r].trim().replace(/\\\|/g, "|");
  return n;
}
function Bs(i, e, t) {
  const n = i.length;
  if (n === 0)
    return "";
  let r = 0;
  for (; r < n && i.charAt(n - r - 1) === e; )
    r++;
  return i.slice(0, n - r);
}
function C_(i, e) {
  if (i.indexOf(e[1]) === -1)
    return -1;
  let t = 0;
  for (let n = 0; n < i.length; n++)
    if (i[n] === "\\")
      n++;
    else if (i[n] === e[0])
      t++;
    else if (i[n] === e[1] && (t--, t < 0))
      return n;
  return -1;
}
function Mu(i, e, t, n) {
  const r = e.href, s = e.title ? cn(e.title) : null, a = i[1].replace(/\\([\[\]])/g, "$1");
  if (i[0].charAt(0) !== "!") {
    n.state.inLink = !0;
    const o = {
      type: "link",
      raw: t,
      href: r,
      title: s,
      text: a,
      tokens: n.inlineTokens(a)
    };
    return n.state.inLink = !1, o;
  }
  return {
    type: "image",
    raw: t,
    href: r,
    title: s,
    text: cn(a)
  };
}
function P_(i, e) {
  const t = i.match(/^(\s+)(?:```)/);
  if (t === null)
    return e;
  const n = t[1];
  return e.split(`
`).map((r) => {
    const s = r.match(/^\s+/);
    if (s === null)
      return r;
    const [a] = s;
    return a.length >= n.length ? r.slice(n.length) : r;
  }).join(`
`);
}
class Ra {
  options;
  rules;
  // set by the lexer
  lexer;
  // set by the lexer
  constructor(e) {
    this.options = e || qi;
  }
  space(e) {
    const t = this.rules.block.newline.exec(e);
    if (t && t[0].length > 0)
      return {
        type: "space",
        raw: t[0]
      };
  }
  code(e) {
    const t = this.rules.block.code.exec(e);
    if (t) {
      const n = t[0].replace(/^ {1,4}/gm, "");
      return {
        type: "code",
        raw: t[0],
        codeBlockStyle: "indented",
        text: this.options.pedantic ? n : Bs(n, `
`)
      };
    }
  }
  fences(e) {
    const t = this.rules.block.fences.exec(e);
    if (t) {
      const n = t[0], r = P_(n, t[3] || "");
      return {
        type: "code",
        raw: n,
        lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
        text: r
      };
    }
  }
  heading(e) {
    const t = this.rules.block.heading.exec(e);
    if (t) {
      let n = t[2].trim();
      if (/#$/.test(n)) {
        const r = Bs(n, "#");
        (this.options.pedantic || !r || / $/.test(r)) && (n = r.trim());
      }
      return {
        type: "heading",
        raw: t[0],
        depth: t[1].length,
        text: n,
        tokens: this.lexer.inline(n)
      };
    }
  }
  hr(e) {
    const t = this.rules.block.hr.exec(e);
    if (t)
      return {
        type: "hr",
        raw: t[0]
      };
  }
  blockquote(e) {
    const t = this.rules.block.blockquote.exec(e);
    if (t) {
      let n = t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, `
    $1`);
      n = Bs(n.replace(/^ *>[ \t]?/gm, ""), `
`);
      const r = this.lexer.state.top;
      this.lexer.state.top = !0;
      const s = this.lexer.blockTokens(n);
      return this.lexer.state.top = r, {
        type: "blockquote",
        raw: t[0],
        tokens: s,
        text: n
      };
    }
  }
  list(e) {
    let t = this.rules.block.list.exec(e);
    if (t) {
      let n = t[1].trim();
      const r = n.length > 1, s = {
        type: "list",
        raw: "",
        ordered: r,
        start: r ? +n.slice(0, -1) : "",
        loose: !1,
        items: []
      };
      n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
      const a = new RegExp(`^( {0,3}${n})((?:[	 ][^\\n]*)?(?:\\n|$))`);
      let o = "", l = "", c = !1;
      for (; e; ) {
        let u = !1;
        if (!(t = a.exec(e)) || this.rules.block.hr.test(e))
          break;
        o = t[0], e = e.substring(o.length);
        let h = t[2].split(`
`, 1)[0].replace(/^\t+/, (f) => " ".repeat(3 * f.length)), d = e.split(`
`, 1)[0], m = 0;
        this.options.pedantic ? (m = 2, l = h.trimStart()) : (m = t[2].search(/[^ ]/), m = m > 4 ? 1 : m, l = h.slice(m), m += t[1].length);
        let v = !1;
        if (!h && /^ *$/.test(d) && (o += d + `
`, e = e.substring(d.length + 1), u = !0), !u) {
          const f = new RegExp(`^ {0,${Math.min(3, m - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ 	][^\\n]*)?(?:\\n|$))`), x = new RegExp(`^ {0,${Math.min(3, m - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), g = new RegExp(`^ {0,${Math.min(3, m - 1)}}(?:\`\`\`|~~~)`), _ = new RegExp(`^ {0,${Math.min(3, m - 1)}}#`);
          for (; e; ) {
            const T = e.split(`
`, 1)[0];
            if (d = T, this.options.pedantic && (d = d.replace(/^ {1,4}(?=( {4})*[^ ])/g, "  ")), g.test(d) || _.test(d) || f.test(d) || x.test(e))
              break;
            if (d.search(/[^ ]/) >= m || !d.trim())
              l += `
` + d.slice(m);
            else {
              if (v || h.search(/[^ ]/) >= 4 || g.test(h) || _.test(h) || x.test(h))
                break;
              l += `
` + d;
            }
            !v && !d.trim() && (v = !0), o += T + `
`, e = e.substring(T.length + 1), h = d.slice(m);
          }
        }
        s.loose || (c ? s.loose = !0 : /\n *\n *$/.test(o) && (c = !0));
        let b = null, p;
        this.options.gfm && (b = /^\[[ xX]\] /.exec(l), b && (p = b[0] !== "[ ] ", l = l.replace(/^\[[ xX]\] +/, ""))), s.items.push({
          type: "list_item",
          raw: o,
          task: !!b,
          checked: p,
          loose: !1,
          text: l,
          tokens: []
        }), s.raw += o;
      }
      s.items[s.items.length - 1].raw = o.trimEnd(), s.items[s.items.length - 1].text = l.trimEnd(), s.raw = s.raw.trimEnd();
      for (let u = 0; u < s.items.length; u++)
        if (this.lexer.state.top = !1, s.items[u].tokens = this.lexer.blockTokens(s.items[u].text, []), !s.loose) {
          const h = s.items[u].tokens.filter((m) => m.type === "space"), d = h.length > 0 && h.some((m) => /\n.*\n/.test(m.raw));
          s.loose = d;
        }
      if (s.loose)
        for (let u = 0; u < s.items.length; u++)
          s.items[u].loose = !0;
      return s;
    }
  }
  html(e) {
    const t = this.rules.block.html.exec(e);
    if (t)
      return {
        type: "html",
        block: !0,
        raw: t[0],
        pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
        text: t[0]
      };
  }
  def(e) {
    const t = this.rules.block.def.exec(e);
    if (t) {
      const n = t[1].toLowerCase().replace(/\s+/g, " "), r = t[2] ? t[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", s = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
      return {
        type: "def",
        tag: n,
        raw: t[0],
        href: r,
        title: s
      };
    }
  }
  table(e) {
    const t = this.rules.block.table.exec(e);
    if (!t || !/[:|]/.test(t[2]))
      return;
    const n = Su(t[1]), r = t[2].replace(/^\||\| *$/g, "").split("|"), s = t[3] && t[3].trim() ? t[3].replace(/\n[ \t]*$/, "").split(`
`) : [], a = {
      type: "table",
      raw: t[0],
      header: [],
      align: [],
      rows: []
    };
    if (n.length === r.length) {
      for (const o of r)
        /^ *-+: *$/.test(o) ? a.align.push("right") : /^ *:-+: *$/.test(o) ? a.align.push("center") : /^ *:-+ *$/.test(o) ? a.align.push("left") : a.align.push(null);
      for (const o of n)
        a.header.push({
          text: o,
          tokens: this.lexer.inline(o)
        });
      for (const o of s)
        a.rows.push(Su(o, a.header.length).map((l) => ({
          text: l,
          tokens: this.lexer.inline(l)
        })));
      return a;
    }
  }
  lheading(e) {
    const t = this.rules.block.lheading.exec(e);
    if (t)
      return {
        type: "heading",
        raw: t[0],
        depth: t[2].charAt(0) === "=" ? 1 : 2,
        text: t[1],
        tokens: this.lexer.inline(t[1])
      };
  }
  paragraph(e) {
    const t = this.rules.block.paragraph.exec(e);
    if (t) {
      const n = t[1].charAt(t[1].length - 1) === `
` ? t[1].slice(0, -1) : t[1];
      return {
        type: "paragraph",
        raw: t[0],
        text: n,
        tokens: this.lexer.inline(n)
      };
    }
  }
  text(e) {
    const t = this.rules.block.text.exec(e);
    if (t)
      return {
        type: "text",
        raw: t[0],
        text: t[0],
        tokens: this.lexer.inline(t[0])
      };
  }
  escape(e) {
    const t = this.rules.inline.escape.exec(e);
    if (t)
      return {
        type: "escape",
        raw: t[0],
        text: cn(t[1])
      };
  }
  tag(e) {
    const t = this.rules.inline.tag.exec(e);
    if (t)
      return !this.lexer.state.inLink && /^<a /i.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && /^<\/a>/i.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
        type: "html",
        raw: t[0],
        inLink: this.lexer.state.inLink,
        inRawBlock: this.lexer.state.inRawBlock,
        block: !1,
        text: t[0]
      };
  }
  link(e) {
    const t = this.rules.inline.link.exec(e);
    if (t) {
      const n = t[2].trim();
      if (!this.options.pedantic && /^</.test(n)) {
        if (!/>$/.test(n))
          return;
        const a = Bs(n.slice(0, -1), "\\");
        if ((n.length - a.length) % 2 === 0)
          return;
      } else {
        const a = C_(t[2], "()");
        if (a > -1) {
          const l = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + a;
          t[2] = t[2].substring(0, a), t[0] = t[0].substring(0, l).trim(), t[3] = "";
        }
      }
      let r = t[2], s = "";
      if (this.options.pedantic) {
        const a = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(r);
        a && (r = a[1], s = a[3]);
      } else
        s = t[3] ? t[3].slice(1, -1) : "";
      return r = r.trim(), /^</.test(r) && (this.options.pedantic && !/>$/.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), Mu(t, {
        href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
        title: s && s.replace(this.rules.inline.anyPunctuation, "$1")
      }, t[0], this.lexer);
    }
  }
  reflink(e, t) {
    let n;
    if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
      const r = (n[2] || n[1]).replace(/\s+/g, " "), s = t[r.toLowerCase()];
      if (!s) {
        const a = n[0].charAt(0);
        return {
          type: "text",
          raw: a,
          text: a
        };
      }
      return Mu(n, s, n[0], this.lexer);
    }
  }
  emStrong(e, t, n = "") {
    let r = this.rules.inline.emStrongLDelim.exec(e);
    if (!r || r[3] && n.match(/[\p{L}\p{N}]/u))
      return;
    if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
      const a = [...r[0]].length - 1;
      let o, l, c = a, u = 0;
      const h = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
      for (h.lastIndex = 0, t = t.slice(-1 * e.length + a); (r = h.exec(t)) != null; ) {
        if (o = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !o)
          continue;
        if (l = [...o].length, r[3] || r[4]) {
          c += l;
          continue;
        } else if ((r[5] || r[6]) && a % 3 && !((a + l) % 3)) {
          u += l;
          continue;
        }
        if (c -= l, c > 0)
          continue;
        l = Math.min(l, l + c + u);
        const d = [...r[0]][0].length, m = e.slice(0, a + r.index + d + l);
        if (Math.min(a, l) % 2) {
          const b = m.slice(1, -1);
          return {
            type: "em",
            raw: m,
            text: b,
            tokens: this.lexer.inlineTokens(b)
          };
        }
        const v = m.slice(2, -2);
        return {
          type: "strong",
          raw: m,
          text: v,
          tokens: this.lexer.inlineTokens(v)
        };
      }
    }
  }
  codespan(e) {
    const t = this.rules.inline.code.exec(e);
    if (t) {
      let n = t[2].replace(/\n/g, " ");
      const r = /[^ ]/.test(n), s = /^ /.test(n) && / $/.test(n);
      return r && s && (n = n.substring(1, n.length - 1)), n = cn(n, !0), {
        type: "codespan",
        raw: t[0],
        text: n
      };
    }
  }
  br(e) {
    const t = this.rules.inline.br.exec(e);
    if (t)
      return {
        type: "br",
        raw: t[0]
      };
  }
  del(e) {
    const t = this.rules.inline.del.exec(e);
    if (t)
      return {
        type: "del",
        raw: t[0],
        text: t[2],
        tokens: this.lexer.inlineTokens(t[2])
      };
  }
  autolink(e) {
    const t = this.rules.inline.autolink.exec(e);
    if (t) {
      let n, r;
      return t[2] === "@" ? (n = cn(t[1]), r = "mailto:" + n) : (n = cn(t[1]), r = n), {
        type: "link",
        raw: t[0],
        text: n,
        href: r,
        tokens: [
          {
            type: "text",
            raw: n,
            text: n
          }
        ]
      };
    }
  }
  url(e) {
    let t;
    if (t = this.rules.inline.url.exec(e)) {
      let n, r;
      if (t[2] === "@")
        n = cn(t[0]), r = "mailto:" + n;
      else {
        let s;
        do
          s = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
        while (s !== t[0]);
        n = cn(t[0]), t[1] === "www." ? r = "http://" + t[0] : r = t[0];
      }
      return {
        type: "link",
        raw: t[0],
        text: n,
        href: r,
        tokens: [
          {
            type: "text",
            raw: n,
            text: n
          }
        ]
      };
    }
  }
  inlineText(e) {
    const t = this.rules.inline.text.exec(e);
    if (t) {
      let n;
      return this.lexer.state.inRawBlock ? n = t[0] : n = cn(t[0]), {
        type: "text",
        raw: t[0],
        text: n
      };
    }
  }
}
const L_ = /^(?: *(?:\n|$))+/, I_ = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, F_ = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Ds = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, N_ = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, fd = /(?:[*+-]|\d{1,9}[.)])/, dd = vt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, fd).replace(/blockCode/g, / {4}/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex(), gc = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, U_ = /^[^\n]+/, _c = /(?!\s*\])(?:\\.|[^\[\]\\])+/, O_ = vt(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _c).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), B_ = vt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, fd).getRegex(), Xa = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", vc = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, k_ = vt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", vc).replace("tag", Xa).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), pd = vt(gc).replace("hr", Ds).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Xa).getRegex(), H_ = vt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", pd).getRegex(), xc = {
  blockquote: H_,
  code: I_,
  def: O_,
  fences: F_,
  heading: N_,
  hr: Ds,
  html: k_,
  lheading: dd,
  list: B_,
  newline: L_,
  paragraph: pd,
  table: ms,
  text: U_
}, Au = vt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", Ds).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Xa).getRegex(), z_ = {
  ...xc,
  table: Au,
  paragraph: vt(gc).replace("hr", Ds).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Au).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Xa).getRegex()
}, G_ = {
  ...xc,
  html: vt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", vc).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
  heading: /^(#{1,6})(.*)(?:\n+|$)/,
  fences: ms,
  // fences not supported
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
  paragraph: vt(gc).replace("hr", Ds).replace("heading", ` *#{1,6} *[^
]`).replace("lheading", dd).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
}, md = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, V_ = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, gd = /^( {2,}|\\)\n(?!\s*$)/, W_ = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, Rs = "\\p{P}\\p{S}", X_ = vt(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, Rs).getRegex(), j_ = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, q_ = vt(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, Rs).getRegex(), Y_ = vt("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, Rs).getRegex(), Z_ = vt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, Rs).getRegex(), K_ = vt(/\\([punct])/, "gu").replace(/punct/g, Rs).getRegex(), $_ = vt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), J_ = vt(vc).replace("(?:-->|$)", "-->").getRegex(), Q_ = vt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", J_).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Ca = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, e0 = vt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Ca).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), _d = vt(/^!?\[(label)\]\[(ref)\]/).replace("label", Ca).replace("ref", _c).getRegex(), vd = vt(/^!?\[(ref)\](?:\[\])?/).replace("ref", _c).getRegex(), t0 = vt("reflink|nolink(?!\\()", "g").replace("reflink", _d).replace("nolink", vd).getRegex(), bc = {
  _backpedal: ms,
  // only used for GFM url
  anyPunctuation: K_,
  autolink: $_,
  blockSkip: j_,
  br: gd,
  code: V_,
  del: ms,
  emStrongLDelim: q_,
  emStrongRDelimAst: Y_,
  emStrongRDelimUnd: Z_,
  escape: md,
  link: e0,
  nolink: vd,
  punctuation: X_,
  reflink: _d,
  reflinkSearch: t0,
  tag: Q_,
  text: W_,
  url: ms
}, n0 = {
  ...bc,
  link: vt(/^!?\[(label)\]\((.*?)\)/).replace("label", Ca).getRegex(),
  reflink: vt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Ca).getRegex()
}, dl = {
  ...bc,
  escape: vt(md).replace("])", "~|])").getRegex(),
  url: vt(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
  del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
  text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
}, i0 = {
  ...dl,
  br: vt(gd).replace("{2,}", "*").getRegex(),
  text: vt(dl.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
}, ks = {
  normal: xc,
  gfm: z_,
  pedantic: G_
}, es = {
  normal: bc,
  gfm: dl,
  breaks: i0,
  pedantic: n0
};
class Un {
  tokens;
  options;
  state;
  tokenizer;
  inlineQueue;
  constructor(e) {
    this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || qi, this.options.tokenizer = this.options.tokenizer || new Ra(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
      inLink: !1,
      inRawBlock: !1,
      top: !0
    };
    const t = {
      block: ks.normal,
      inline: es.normal
    };
    this.options.pedantic ? (t.block = ks.pedantic, t.inline = es.pedantic) : this.options.gfm && (t.block = ks.gfm, this.options.breaks ? t.inline = es.breaks : t.inline = es.gfm), this.tokenizer.rules = t;
  }
  /**
   * Expose Rules
   */
  static get rules() {
    return {
      block: ks,
      inline: es
    };
  }
  /**
   * Static Lex Method
   */
  static lex(e, t) {
    return new Un(t).lex(e);
  }
  /**
   * Static Lex Inline Method
   */
  static lexInline(e, t) {
    return new Un(t).inlineTokens(e);
  }
  /**
   * Preprocessing
   */
  lex(e) {
    e = e.replace(/\r\n|\r/g, `
`), this.blockTokens(e, this.tokens);
    for (let t = 0; t < this.inlineQueue.length; t++) {
      const n = this.inlineQueue[t];
      this.inlineTokens(n.src, n.tokens);
    }
    return this.inlineQueue = [], this.tokens;
  }
  blockTokens(e, t = []) {
    this.options.pedantic ? e = e.replace(/\t/g, "    ").replace(/^ +$/gm, "") : e = e.replace(/^( *)(\t+)/gm, (o, l, c) => l + "    ".repeat(c.length));
    let n, r, s, a;
    for (; e; )
      if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((o) => (n = o.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
        if (n = this.tokenizer.space(e)) {
          e = e.substring(n.raw.length), n.raw.length === 1 && t.length > 0 ? t[t.length - 1].raw += `
` : t.push(n);
          continue;
        }
        if (n = this.tokenizer.code(e)) {
          e = e.substring(n.raw.length), r = t[t.length - 1], r && (r.type === "paragraph" || r.type === "text") ? (r.raw += `
` + n.raw, r.text += `
` + n.text, this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : t.push(n);
          continue;
        }
        if (n = this.tokenizer.fences(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.heading(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.hr(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.blockquote(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.list(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.html(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.def(e)) {
          e = e.substring(n.raw.length), r = t[t.length - 1], r && (r.type === "paragraph" || r.type === "text") ? (r.raw += `
` + n.raw, r.text += `
` + n.raw, this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = {
            href: n.href,
            title: n.title
          });
          continue;
        }
        if (n = this.tokenizer.table(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.lheading(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (s = e, this.options.extensions && this.options.extensions.startBlock) {
          let o = 1 / 0;
          const l = e.slice(1);
          let c;
          this.options.extensions.startBlock.forEach((u) => {
            c = u.call({ lexer: this }, l), typeof c == "number" && c >= 0 && (o = Math.min(o, c));
          }), o < 1 / 0 && o >= 0 && (s = e.substring(0, o + 1));
        }
        if (this.state.top && (n = this.tokenizer.paragraph(s))) {
          r = t[t.length - 1], a && r.type === "paragraph" ? (r.raw += `
` + n.raw, r.text += `
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : t.push(n), a = s.length !== e.length, e = e.substring(n.raw.length);
          continue;
        }
        if (n = this.tokenizer.text(e)) {
          e = e.substring(n.raw.length), r = t[t.length - 1], r && r.type === "text" ? (r.raw += `
` + n.raw, r.text += `
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : t.push(n);
          continue;
        }
        if (e) {
          const o = "Infinite loop on byte: " + e.charCodeAt(0);
          if (this.options.silent) {
            console.error(o);
            break;
          } else
            throw new Error(o);
        }
      }
    return this.state.top = !0, t;
  }
  inline(e, t = []) {
    return this.inlineQueue.push({ src: e, tokens: t }), t;
  }
  /**
   * Lexing/Compiling
   */
  inlineTokens(e, t = []) {
    let n, r, s, a = e, o, l, c;
    if (this.tokens.links) {
      const u = Object.keys(this.tokens.links);
      if (u.length > 0)
        for (; (o = this.tokenizer.rules.inline.reflinkSearch.exec(a)) != null; )
          u.includes(o[0].slice(o[0].lastIndexOf("[") + 1, -1)) && (a = a.slice(0, o.index) + "[" + "a".repeat(o[0].length - 2) + "]" + a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
    }
    for (; (o = this.tokenizer.rules.inline.blockSkip.exec(a)) != null; )
      a = a.slice(0, o.index) + "[" + "a".repeat(o[0].length - 2) + "]" + a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
    for (; (o = this.tokenizer.rules.inline.anyPunctuation.exec(a)) != null; )
      a = a.slice(0, o.index) + "++" + a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
    for (; e; )
      if (l || (c = ""), l = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((u) => (n = u.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
        if (n = this.tokenizer.escape(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.tag(e)) {
          e = e.substring(n.raw.length), r = t[t.length - 1], r && n.type === "text" && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : t.push(n);
          continue;
        }
        if (n = this.tokenizer.link(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.reflink(e, this.tokens.links)) {
          e = e.substring(n.raw.length), r = t[t.length - 1], r && n.type === "text" && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : t.push(n);
          continue;
        }
        if (n = this.tokenizer.emStrong(e, a, c)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.codespan(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.br(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.del(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (n = this.tokenizer.autolink(e)) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (!this.state.inLink && (n = this.tokenizer.url(e))) {
          e = e.substring(n.raw.length), t.push(n);
          continue;
        }
        if (s = e, this.options.extensions && this.options.extensions.startInline) {
          let u = 1 / 0;
          const h = e.slice(1);
          let d;
          this.options.extensions.startInline.forEach((m) => {
            d = m.call({ lexer: this }, h), typeof d == "number" && d >= 0 && (u = Math.min(u, d));
          }), u < 1 / 0 && u >= 0 && (s = e.substring(0, u + 1));
        }
        if (n = this.tokenizer.inlineText(s)) {
          e = e.substring(n.raw.length), n.raw.slice(-1) !== "_" && (c = n.raw.slice(-1)), l = !0, r = t[t.length - 1], r && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : t.push(n);
          continue;
        }
        if (e) {
          const u = "Infinite loop on byte: " + e.charCodeAt(0);
          if (this.options.silent) {
            console.error(u);
            break;
          } else
            throw new Error(u);
        }
      }
    return t;
  }
}
class Pa {
  options;
  constructor(e) {
    this.options = e || qi;
  }
  code(e, t, n) {
    const r = (t || "").match(/^\S*/)?.[0];
    return e = e.replace(/\n$/, "") + `
`, r ? '<pre><code class="language-' + cn(r) + '">' + (n ? e : cn(e, !0)) + `</code></pre>
` : "<pre><code>" + (n ? e : cn(e, !0)) + `</code></pre>
`;
  }
  blockquote(e) {
    return `<blockquote>
${e}</blockquote>
`;
  }
  html(e, t) {
    return e;
  }
  heading(e, t, n) {
    return `<h${t}>${e}</h${t}>
`;
  }
  hr() {
    return `<hr>
`;
  }
  list(e, t, n) {
    const r = t ? "ol" : "ul", s = t && n !== 1 ? ' start="' + n + '"' : "";
    return "<" + r + s + `>
` + e + "</" + r + `>
`;
  }
  listitem(e, t, n) {
    return `<li>${e}</li>
`;
  }
  checkbox(e) {
    return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
  }
  paragraph(e) {
    return `<p>${e}</p>
`;
  }
  table(e, t) {
    return t && (t = `<tbody>${t}</tbody>`), `<table>
<thead>
` + e + `</thead>
` + t + `</table>
`;
  }
  tablerow(e) {
    return `<tr>
${e}</tr>
`;
  }
  tablecell(e, t) {
    const n = t.header ? "th" : "td";
    return (t.align ? `<${n} align="${t.align}">` : `<${n}>`) + e + `</${n}>
`;
  }
  /**
   * span level renderer
   */
  strong(e) {
    return `<strong>${e}</strong>`;
  }
  em(e) {
    return `<em>${e}</em>`;
  }
  codespan(e) {
    return `<code>${e}</code>`;
  }
  br() {
    return "<br>";
  }
  del(e) {
    return `<del>${e}</del>`;
  }
  link(e, t, n) {
    const r = yu(e);
    if (r === null)
      return n;
    e = r;
    let s = '<a href="' + e + '"';
    return t && (s += ' title="' + t + '"'), s += ">" + n + "</a>", s;
  }
  image(e, t, n) {
    const r = yu(e);
    if (r === null)
      return n;
    e = r;
    let s = `<img src="${e}" alt="${n}"`;
    return t && (s += ` title="${t}"`), s += ">", s;
  }
  text(e) {
    return e;
  }
}
class Ec {
  // no need for block level renderers
  strong(e) {
    return e;
  }
  em(e) {
    return e;
  }
  codespan(e) {
    return e;
  }
  del(e) {
    return e;
  }
  html(e) {
    return e;
  }
  text(e) {
    return e;
  }
  link(e, t, n) {
    return "" + n;
  }
  image(e, t, n) {
    return "" + n;
  }
  br() {
    return "";
  }
}
class On {
  options;
  renderer;
  textRenderer;
  constructor(e) {
    this.options = e || qi, this.options.renderer = this.options.renderer || new Pa(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new Ec();
  }
  /**
   * Static Parse Method
   */
  static parse(e, t) {
    return new On(t).parse(e);
  }
  /**
   * Static Parse Inline Method
   */
  static parseInline(e, t) {
    return new On(t).parseInline(e);
  }
  /**
   * Parse Loop
   */
  parse(e, t = !0) {
    let n = "";
    for (let r = 0; r < e.length; r++) {
      const s = e[r];
      if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[s.type]) {
        const a = s, o = this.options.extensions.renderers[a.type].call({ parser: this }, a);
        if (o !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(a.type)) {
          n += o || "";
          continue;
        }
      }
      switch (s.type) {
        case "space":
          continue;
        case "hr": {
          n += this.renderer.hr();
          continue;
        }
        case "heading": {
          const a = s;
          n += this.renderer.heading(this.parseInline(a.tokens), a.depth, D_(this.parseInline(a.tokens, this.textRenderer)));
          continue;
        }
        case "code": {
          const a = s;
          n += this.renderer.code(a.text, a.lang, !!a.escaped);
          continue;
        }
        case "table": {
          const a = s;
          let o = "", l = "";
          for (let u = 0; u < a.header.length; u++)
            l += this.renderer.tablecell(this.parseInline(a.header[u].tokens), { header: !0, align: a.align[u] });
          o += this.renderer.tablerow(l);
          let c = "";
          for (let u = 0; u < a.rows.length; u++) {
            const h = a.rows[u];
            l = "";
            for (let d = 0; d < h.length; d++)
              l += this.renderer.tablecell(this.parseInline(h[d].tokens), { header: !1, align: a.align[d] });
            c += this.renderer.tablerow(l);
          }
          n += this.renderer.table(o, c);
          continue;
        }
        case "blockquote": {
          const a = s, o = this.parse(a.tokens);
          n += this.renderer.blockquote(o);
          continue;
        }
        case "list": {
          const a = s, o = a.ordered, l = a.start, c = a.loose;
          let u = "";
          for (let h = 0; h < a.items.length; h++) {
            const d = a.items[h], m = d.checked, v = d.task;
            let b = "";
            if (d.task) {
              const p = this.renderer.checkbox(!!m);
              c ? d.tokens.length > 0 && d.tokens[0].type === "paragraph" ? (d.tokens[0].text = p + " " + d.tokens[0].text, d.tokens[0].tokens && d.tokens[0].tokens.length > 0 && d.tokens[0].tokens[0].type === "text" && (d.tokens[0].tokens[0].text = p + " " + d.tokens[0].tokens[0].text)) : d.tokens.unshift({
                type: "text",
                text: p + " "
              }) : b += p + " ";
            }
            b += this.parse(d.tokens, c), u += this.renderer.listitem(b, v, !!m);
          }
          n += this.renderer.list(u, o, l);
          continue;
        }
        case "html": {
          const a = s;
          n += this.renderer.html(a.text, a.block);
          continue;
        }
        case "paragraph": {
          const a = s;
          n += this.renderer.paragraph(this.parseInline(a.tokens));
          continue;
        }
        case "text": {
          let a = s, o = a.tokens ? this.parseInline(a.tokens) : a.text;
          for (; r + 1 < e.length && e[r + 1].type === "text"; )
            a = e[++r], o += `
` + (a.tokens ? this.parseInline(a.tokens) : a.text);
          n += t ? this.renderer.paragraph(o) : o;
          continue;
        }
        default: {
          const a = 'Token with "' + s.type + '" type was not found.';
          if (this.options.silent)
            return console.error(a), "";
          throw new Error(a);
        }
      }
    }
    return n;
  }
  /**
   * Parse Inline Tokens
   */
  parseInline(e, t) {
    t = t || this.renderer;
    let n = "";
    for (let r = 0; r < e.length; r++) {
      const s = e[r];
      if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[s.type]) {
        const a = this.options.extensions.renderers[s.type].call({ parser: this }, s);
        if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(s.type)) {
          n += a || "";
          continue;
        }
      }
      switch (s.type) {
        case "escape": {
          const a = s;
          n += t.text(a.text);
          break;
        }
        case "html": {
          const a = s;
          n += t.html(a.text);
          break;
        }
        case "link": {
          const a = s;
          n += t.link(a.href, a.title, this.parseInline(a.tokens, t));
          break;
        }
        case "image": {
          const a = s;
          n += t.image(a.href, a.title, a.text);
          break;
        }
        case "strong": {
          const a = s;
          n += t.strong(this.parseInline(a.tokens, t));
          break;
        }
        case "em": {
          const a = s;
          n += t.em(this.parseInline(a.tokens, t));
          break;
        }
        case "codespan": {
          const a = s;
          n += t.codespan(a.text);
          break;
        }
        case "br": {
          n += t.br();
          break;
        }
        case "del": {
          const a = s;
          n += t.del(this.parseInline(a.tokens, t));
          break;
        }
        case "text": {
          const a = s;
          n += t.text(a.text);
          break;
        }
        default: {
          const a = 'Token with "' + s.type + '" type was not found.';
          if (this.options.silent)
            return console.error(a), "";
          throw new Error(a);
        }
      }
    }
    return n;
  }
}
class va {
  options;
  constructor(e) {
    this.options = e || qi;
  }
  static passThroughHooks = /* @__PURE__ */ new Set([
    "preprocess",
    "postprocess",
    "processAllTokens"
  ]);
  /**
   * Process markdown before marked
   */
  preprocess(e) {
    return e;
  }
  /**
   * Process HTML after marked is finished
   */
  postprocess(e) {
    return e;
  }
  /**
   * Process all tokens before walk tokens
   */
  processAllTokens(e) {
    return e;
  }
}
class r0 {
  defaults = mc();
  options = this.setOptions;
  parse = this.#e(Un.lex, On.parse);
  parseInline = this.#e(Un.lexInline, On.parseInline);
  Parser = On;
  Renderer = Pa;
  TextRenderer = Ec;
  Lexer = Un;
  Tokenizer = Ra;
  Hooks = va;
  constructor(...e) {
    this.use(...e);
  }
  /**
   * Run callback for every token
   */
  walkTokens(e, t) {
    let n = [];
    for (const r of e)
      switch (n = n.concat(t.call(this, r)), r.type) {
        case "table": {
          const s = r;
          for (const a of s.header)
            n = n.concat(this.walkTokens(a.tokens, t));
          for (const a of s.rows)
            for (const o of a)
              n = n.concat(this.walkTokens(o.tokens, t));
          break;
        }
        case "list": {
          const s = r;
          n = n.concat(this.walkTokens(s.items, t));
          break;
        }
        default: {
          const s = r;
          this.defaults.extensions?.childTokens?.[s.type] ? this.defaults.extensions.childTokens[s.type].forEach((a) => {
            const o = s[a].flat(1 / 0);
            n = n.concat(this.walkTokens(o, t));
          }) : s.tokens && (n = n.concat(this.walkTokens(s.tokens, t)));
        }
      }
    return n;
  }
  use(...e) {
    const t = this.defaults.extensions || { renderers: {}, childTokens: {} };
    return e.forEach((n) => {
      const r = { ...n };
      if (r.async = this.defaults.async || r.async || !1, n.extensions && (n.extensions.forEach((s) => {
        if (!s.name)
          throw new Error("extension name required");
        if ("renderer" in s) {
          const a = t.renderers[s.name];
          a ? t.renderers[s.name] = function(...o) {
            let l = s.renderer.apply(this, o);
            return l === !1 && (l = a.apply(this, o)), l;
          } : t.renderers[s.name] = s.renderer;
        }
        if ("tokenizer" in s) {
          if (!s.level || s.level !== "block" && s.level !== "inline")
            throw new Error("extension level must be 'block' or 'inline'");
          const a = t[s.level];
          a ? a.unshift(s.tokenizer) : t[s.level] = [s.tokenizer], s.start && (s.level === "block" ? t.startBlock ? t.startBlock.push(s.start) : t.startBlock = [s.start] : s.level === "inline" && (t.startInline ? t.startInline.push(s.start) : t.startInline = [s.start]));
        }
        "childTokens" in s && s.childTokens && (t.childTokens[s.name] = s.childTokens);
      }), r.extensions = t), n.renderer) {
        const s = this.defaults.renderer || new Pa(this.defaults);
        for (const a in n.renderer) {
          if (!(a in s))
            throw new Error(`renderer '${a}' does not exist`);
          if (a === "options")
            continue;
          const o = a, l = n.renderer[o], c = s[o];
          s[o] = (...u) => {
            let h = l.apply(s, u);
            return h === !1 && (h = c.apply(s, u)), h || "";
          };
        }
        r.renderer = s;
      }
      if (n.tokenizer) {
        const s = this.defaults.tokenizer || new Ra(this.defaults);
        for (const a in n.tokenizer) {
          if (!(a in s))
            throw new Error(`tokenizer '${a}' does not exist`);
          if (["options", "rules", "lexer"].includes(a))
            continue;
          const o = a, l = n.tokenizer[o], c = s[o];
          s[o] = (...u) => {
            let h = l.apply(s, u);
            return h === !1 && (h = c.apply(s, u)), h;
          };
        }
        r.tokenizer = s;
      }
      if (n.hooks) {
        const s = this.defaults.hooks || new va();
        for (const a in n.hooks) {
          if (!(a in s))
            throw new Error(`hook '${a}' does not exist`);
          if (a === "options")
            continue;
          const o = a, l = n.hooks[o], c = s[o];
          va.passThroughHooks.has(a) ? s[o] = (u) => {
            if (this.defaults.async)
              return Promise.resolve(l.call(s, u)).then((d) => c.call(s, d));
            const h = l.call(s, u);
            return c.call(s, h);
          } : s[o] = (...u) => {
            let h = l.apply(s, u);
            return h === !1 && (h = c.apply(s, u)), h;
          };
        }
        r.hooks = s;
      }
      if (n.walkTokens) {
        const s = this.defaults.walkTokens, a = n.walkTokens;
        r.walkTokens = function(o) {
          let l = [];
          return l.push(a.call(this, o)), s && (l = l.concat(s.call(this, o))), l;
        };
      }
      this.defaults = { ...this.defaults, ...r };
    }), this;
  }
  setOptions(e) {
    return this.defaults = { ...this.defaults, ...e }, this;
  }
  lexer(e, t) {
    return Un.lex(e, t ?? this.defaults);
  }
  parser(e, t) {
    return On.parse(e, t ?? this.defaults);
  }
  #e(e, t) {
    return (n, r) => {
      const s = { ...r }, a = { ...this.defaults, ...s };
      this.defaults.async === !0 && s.async === !1 && (a.silent || console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."), a.async = !0);
      const o = this.#n(!!a.silent, !!a.async);
      if (typeof n > "u" || n === null)
        return o(new Error("marked(): input parameter is undefined or null"));
      if (typeof n != "string")
        return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
      if (a.hooks && (a.hooks.options = a), a.async)
        return Promise.resolve(a.hooks ? a.hooks.preprocess(n) : n).then((l) => e(l, a)).then((l) => a.hooks ? a.hooks.processAllTokens(l) : l).then((l) => a.walkTokens ? Promise.all(this.walkTokens(l, a.walkTokens)).then(() => l) : l).then((l) => t(l, a)).then((l) => a.hooks ? a.hooks.postprocess(l) : l).catch(o);
      try {
        a.hooks && (n = a.hooks.preprocess(n));
        let l = e(n, a);
        a.hooks && (l = a.hooks.processAllTokens(l)), a.walkTokens && this.walkTokens(l, a.walkTokens);
        let c = t(l, a);
        return a.hooks && (c = a.hooks.postprocess(c)), c;
      } catch (l) {
        return o(l);
      }
    };
  }
  #n(e, t) {
    return (n) => {
      if (n.message += `
Please report this to https://github.com/markedjs/marked.`, e) {
        const r = "<p>An error occurred:</p><pre>" + cn(n.message + "", !0) + "</pre>";
        return t ? Promise.resolve(r) : r;
      }
      if (t)
        return Promise.reject(n);
      throw n;
    };
  }
}
const Vi = new r0();
function _t(i, e) {
  return Vi.parse(i, e);
}
_t.options = _t.setOptions = function(i) {
  return Vi.setOptions(i), _t.defaults = Vi.defaults, cd(_t.defaults), _t;
};
_t.getDefaults = mc;
_t.defaults = qi;
_t.use = function(...i) {
  return Vi.use(...i), _t.defaults = Vi.defaults, cd(_t.defaults), _t;
};
_t.walkTokens = function(i, e) {
  return Vi.walkTokens(i, e);
};
_t.parseInline = Vi.parseInline;
_t.Parser = On;
_t.parser = On.parse;
_t.Renderer = Pa;
_t.TextRenderer = Ec;
_t.Lexer = Un;
_t.lexer = Un.lex;
_t.Tokenizer = Ra;
_t.Hooks = va;
_t.parse = _t;
_t.options;
_t.setOptions;
_t.use;
_t.walkTokens;
_t.parseInline;
On.parse;
Un.lex;
const s0 = /[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g, a0 = Object.hasOwnProperty;
class xd {
  /**
   * Create a new slug class.
   */
  constructor() {
    this.occurrences, this.reset();
  }
  /**
   * Generate a unique slug.
  *
  * Tracks previously generated slugs: repeated calls with the same value
  * will result in different slugs.
  * Use the `slug` function to get same slugs.
   *
   * @param  {string} value
   *   String of text to slugify
   * @param  {boolean} [maintainCase=false]
   *   Keep the current case, otherwise make all lowercase
   * @return {string}
   *   A unique slug string
   */
  slug(e, t) {
    const n = this;
    let r = o0(e, t === !0);
    const s = r;
    for (; a0.call(n.occurrences, r); )
      n.occurrences[s]++, r = s + "-" + n.occurrences[s];
    return n.occurrences[r] = 0, r;
  }
  /**
   * Reset - Forget all previous slugs
   *
   * @return void
   */
  reset() {
    this.occurrences = /* @__PURE__ */ Object.create(null);
  }
}
function o0(i, e) {
  return typeof i != "string" ? "" : (e || (i = i.toLowerCase()), i.replace(s0, "").replace(/ /g, "-"));
}
new xd();
var co = { exports: {} }, Tu;
function l0() {
  return Tu || (Tu = 1, (function(i) {
    var e = typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {};
    var t = (function(n) {
      var r = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, s = 0, a = {}, o = {
        /**
         * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
         * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
         * additional languages or plugins yourself.
         *
         * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
         *
         * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
         * empty Prism object into the global scope before loading the Prism script like this:
         *
         * ```js
         * window.Prism = window.Prism || {};
         * Prism.manual = true;
         * // add a new <script> to load Prism's script
         * ```
         *
         * @default false
         * @type {boolean}
         * @memberof Prism
         * @public
         */
        manual: n.Prism && n.Prism.manual,
        /**
         * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
         * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
         * own worker, you don't want it to do this.
         *
         * By setting this value to `true`, Prism will not add its own listeners to the worker.
         *
         * You obviously have to change this value before Prism executes. To do this, you can add an
         * empty Prism object into the global scope before loading the Prism script like this:
         *
         * ```js
         * window.Prism = window.Prism || {};
         * Prism.disableWorkerMessageHandler = true;
         * // Load Prism's script
         * ```
         *
         * @default false
         * @type {boolean}
         * @memberof Prism
         * @public
         */
        disableWorkerMessageHandler: n.Prism && n.Prism.disableWorkerMessageHandler,
        /**
         * A namespace for utility methods.
         *
         * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
         * change or disappear at any time.
         *
         * @namespace
         * @memberof Prism
         */
        util: {
          encode: function x(g) {
            return g instanceof l ? new l(g.type, x(g.content), g.alias) : Array.isArray(g) ? g.map(x) : g.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\u00a0/g, " ");
          },
          /**
           * Returns the name of the type of the given value.
           *
           * @param {any} o
           * @returns {string}
           * @example
           * type(null)      === 'Null'
           * type(undefined) === 'Undefined'
           * type(123)       === 'Number'
           * type('foo')     === 'String'
           * type(true)      === 'Boolean'
           * type([1, 2])    === 'Array'
           * type({})        === 'Object'
           * type(String)    === 'Function'
           * type(/abc+/)    === 'RegExp'
           */
          type: function(x) {
            return Object.prototype.toString.call(x).slice(8, -1);
          },
          /**
           * Returns a unique number for the given object. Later calls will still return the same number.
           *
           * @param {Object} obj
           * @returns {number}
           */
          objId: function(x) {
            return x.__id || Object.defineProperty(x, "__id", { value: ++s }), x.__id;
          },
          /**
           * Creates a deep clone of the given object.
           *
           * The main intended use of this function is to clone language definitions.
           *
           * @param {T} o
           * @param {Record<number, any>} [visited]
           * @returns {T}
           * @template T
           */
          clone: function x(g, _) {
            _ = _ || {};
            var T, A;
            switch (o.util.type(g)) {
              case "Object":
                if (A = o.util.objId(g), _[A])
                  return _[A];
                T = /** @type {Record<string, any>} */
                {}, _[A] = T;
                for (var M in g)
                  g.hasOwnProperty(M) && (T[M] = x(g[M], _));
                return (
                  /** @type {any} */
                  T
                );
              case "Array":
                return A = o.util.objId(g), _[A] ? _[A] : (T = [], _[A] = T, /** @type {Array} */
                /** @type {any} */
                g.forEach(function(C, y) {
                  T[y] = x(C, _);
                }), /** @type {any} */
                T);
              default:
                return g;
            }
          },
          /**
           * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
           *
           * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
           *
           * @param {Element} element
           * @returns {string}
           */
          getLanguage: function(x) {
            for (; x; ) {
              var g = r.exec(x.className);
              if (g)
                return g[1].toLowerCase();
              x = x.parentElement;
            }
            return "none";
          },
          /**
           * Sets the Prism `language-xxxx` class of the given element.
           *
           * @param {Element} element
           * @param {string} language
           * @returns {void}
           */
          setLanguage: function(x, g) {
            x.className = x.className.replace(RegExp(r, "gi"), ""), x.classList.add("language-" + g);
          },
          /**
           * Returns the script element that is currently executing.
           *
           * This does __not__ work for line script element.
           *
           * @returns {HTMLScriptElement | null}
           */
          currentScript: function() {
            if (typeof document > "u")
              return null;
            if (document.currentScript && document.currentScript.tagName === "SCRIPT")
              return (
                /** @type {any} */
                document.currentScript
              );
            try {
              throw new Error();
            } catch (T) {
              var x = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(T.stack) || [])[1];
              if (x) {
                var g = document.getElementsByTagName("script");
                for (var _ in g)
                  if (g[_].src == x)
                    return g[_];
              }
              return null;
            }
          },
          /**
           * Returns whether a given class is active for `element`.
           *
           * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
           * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
           * given class is just the given class with a `no-` prefix.
           *
           * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
           * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
           * ancestors have the given class or the negated version of it, then the default activation will be returned.
           *
           * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
           * version of it, the class is considered active.
           *
           * @param {Element} element
           * @param {string} className
           * @param {boolean} [defaultActivation=false]
           * @returns {boolean}
           */
          isActive: function(x, g, _) {
            for (var T = "no-" + g; x; ) {
              var A = x.classList;
              if (A.contains(g))
                return !0;
              if (A.contains(T))
                return !1;
              x = x.parentElement;
            }
            return !!_;
          }
        },
        /**
         * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
         *
         * @namespace
         * @memberof Prism
         * @public
         */
        languages: {
          /**
           * The grammar for plain, unformatted text.
           */
          plain: a,
          plaintext: a,
          text: a,
          txt: a,
          /**
           * Creates a deep copy of the language with the given id and appends the given tokens.
           *
           * If a token in `redef` also appears in the copied language, then the existing token in the copied language
           * will be overwritten at its original position.
           *
           * ## Best practices
           *
           * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
           * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
           * understand the language definition because, normally, the order of tokens matters in Prism grammars.
           *
           * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
           * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
           *
           * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
           * @param {Grammar} redef The new tokens to append.
           * @returns {Grammar} The new language created.
           * @public
           * @example
           * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
           *     // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
           *     // at its original position
           *     'comment': { ... },
           *     // CSS doesn't have a 'color' token, so this token will be appended
           *     'color': /\b(?:red|green|blue)\b/
           * });
           */
          extend: function(x, g) {
            var _ = o.util.clone(o.languages[x]);
            for (var T in g)
              _[T] = g[T];
            return _;
          },
          /**
           * Inserts tokens _before_ another token in a language definition or any other grammar.
           *
           * ## Usage
           *
           * This helper method makes it easy to modify existing languages. For example, the CSS language definition
           * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
           * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
           * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
           * this:
           *
           * ```js
           * Prism.languages.markup.style = {
           *     // token
           * };
           * ```
           *
           * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
           * before existing tokens. For the CSS example above, you would use it like this:
           *
           * ```js
           * Prism.languages.insertBefore('markup', 'cdata', {
           *     'style': {
           *         // token
           *     }
           * });
           * ```
           *
           * ## Special cases
           *
           * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
           * will be ignored.
           *
           * This behavior can be used to insert tokens after `before`:
           *
           * ```js
           * Prism.languages.insertBefore('markup', 'comment', {
           *     'comment': Prism.languages.markup.comment,
           *     // tokens after 'comment'
           * });
           * ```
           *
           * ## Limitations
           *
           * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
           * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
           * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
           * deleting properties which is necessary to insert at arbitrary positions.
           *
           * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
           * Instead, it will create a new object and replace all references to the target object with the new one. This
           * can be done without temporarily deleting properties, so the iteration order is well-defined.
           *
           * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
           * you hold the target object in a variable, then the value of the variable will not change.
           *
           * ```js
           * var oldMarkup = Prism.languages.markup;
           * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
           *
           * assert(oldMarkup !== Prism.languages.markup);
           * assert(newMarkup === Prism.languages.markup);
           * ```
           *
           * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
           * object to be modified.
           * @param {string} before The key to insert before.
           * @param {Grammar} insert An object containing the key-value pairs to be inserted.
           * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
           * object to be modified.
           *
           * Defaults to `Prism.languages`.
           * @returns {Grammar} The new grammar object.
           * @public
           */
          insertBefore: function(x, g, _, T) {
            T = T || /** @type {any} */
            o.languages;
            var A = T[x], M = {};
            for (var C in A)
              if (A.hasOwnProperty(C)) {
                if (C == g)
                  for (var y in _)
                    _.hasOwnProperty(y) && (M[y] = _[y]);
                _.hasOwnProperty(C) || (M[C] = A[C]);
              }
            var E = T[x];
            return T[x] = M, o.languages.DFS(o.languages, function(R, q) {
              q === E && R != x && (this[R] = M);
            }), M;
          },
          // Traverse a language definition with Depth First Search
          DFS: function x(g, _, T, A) {
            A = A || {};
            var M = o.util.objId;
            for (var C in g)
              if (g.hasOwnProperty(C)) {
                _.call(g, C, g[C], T || C);
                var y = g[C], E = o.util.type(y);
                E === "Object" && !A[M(y)] ? (A[M(y)] = !0, x(y, _, null, A)) : E === "Array" && !A[M(y)] && (A[M(y)] = !0, x(y, _, C, A));
              }
          }
        },
        plugins: {},
        /**
         * This is the most high-level function in Prism’s API.
         * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
         * each one of them.
         *
         * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
         *
         * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
         * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
         * @memberof Prism
         * @public
         */
        highlightAll: function(x, g) {
          o.highlightAllUnder(document, x, g);
        },
        /**
         * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
         * {@link Prism.highlightElement} on each one of them.
         *
         * The following hooks will be run:
         * 1. `before-highlightall`
         * 2. `before-all-elements-highlight`
         * 3. All hooks of {@link Prism.highlightElement} for each element.
         *
         * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
         * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
         * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
         * @memberof Prism
         * @public
         */
        highlightAllUnder: function(x, g, _) {
          var T = {
            callback: _,
            container: x,
            selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
          };
          o.hooks.run("before-highlightall", T), T.elements = Array.prototype.slice.apply(T.container.querySelectorAll(T.selector)), o.hooks.run("before-all-elements-highlight", T);
          for (var A = 0, M; M = T.elements[A++]; )
            o.highlightElement(M, g === !0, T.callback);
        },
        /**
         * Highlights the code inside a single element.
         *
         * The following hooks will be run:
         * 1. `before-sanity-check`
         * 2. `before-highlight`
         * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
         * 4. `before-insert`
         * 5. `after-highlight`
         * 6. `complete`
         *
         * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
         * the element's language.
         *
         * @param {Element} element The element containing the code.
         * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
         * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
         * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
         * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
         *
         * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
         * asynchronous highlighting to work. You can build your own bundle on the
         * [Download page](https://prismjs.com/download.html).
         * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
         * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
         * @memberof Prism
         * @public
         */
        highlightElement: function(x, g, _) {
          var T = o.util.getLanguage(x), A = o.languages[T];
          o.util.setLanguage(x, T);
          var M = x.parentElement;
          M && M.nodeName.toLowerCase() === "pre" && o.util.setLanguage(M, T);
          var C = x.textContent, y = {
            element: x,
            language: T,
            grammar: A,
            code: C
          };
          function E(q) {
            y.highlightedCode = q, o.hooks.run("before-insert", y), y.element.innerHTML = y.highlightedCode, o.hooks.run("after-highlight", y), o.hooks.run("complete", y), _ && _.call(y.element);
          }
          if (o.hooks.run("before-sanity-check", y), M = y.element.parentElement, M && M.nodeName.toLowerCase() === "pre" && !M.hasAttribute("tabindex") && M.setAttribute("tabindex", "0"), !y.code) {
            o.hooks.run("complete", y), _ && _.call(y.element);
            return;
          }
          if (o.hooks.run("before-highlight", y), !y.grammar) {
            E(o.util.encode(y.code));
            return;
          }
          if (g && n.Worker) {
            var R = new Worker(o.filename);
            R.onmessage = function(q) {
              E(q.data);
            }, R.postMessage(JSON.stringify({
              language: y.language,
              code: y.code,
              immediateClose: !0
            }));
          } else
            E(o.highlight(y.code, y.grammar, y.language));
        },
        /**
         * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
         * and the language definitions to use, and returns a string with the HTML produced.
         *
         * The following hooks will be run:
         * 1. `before-tokenize`
         * 2. `after-tokenize`
         * 3. `wrap`: On each {@link Token}.
         *
         * @param {string} text A string with the code to be highlighted.
         * @param {Grammar} grammar An object containing the tokens to use.
         *
         * Usually a language definition like `Prism.languages.markup`.
         * @param {string} language The name of the language definition passed to `grammar`.
         * @returns {string} The highlighted HTML.
         * @memberof Prism
         * @public
         * @example
         * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
         */
        highlight: function(x, g, _) {
          var T = {
            code: x,
            grammar: g,
            language: _
          };
          if (o.hooks.run("before-tokenize", T), !T.grammar)
            throw new Error('The language "' + T.language + '" has no grammar.');
          return T.tokens = o.tokenize(T.code, T.grammar), o.hooks.run("after-tokenize", T), l.stringify(o.util.encode(T.tokens), T.language);
        },
        /**
         * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
         * and the language definitions to use, and returns an array with the tokenized code.
         *
         * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
         *
         * This method could be useful in other contexts as well, as a very crude parser.
         *
         * @param {string} text A string with the code to be highlighted.
         * @param {Grammar} grammar An object containing the tokens to use.
         *
         * Usually a language definition like `Prism.languages.markup`.
         * @returns {TokenStream} An array of strings and tokens, a token stream.
         * @memberof Prism
         * @public
         * @example
         * let code = `var foo = 0;`;
         * let tokens = Prism.tokenize(code, Prism.languages.javascript);
         * tokens.forEach(token => {
         *     if (token instanceof Prism.Token && token.type === 'number') {
         *         console.log(`Found numeric literal: ${token.content}`);
         *     }
         * });
         */
        tokenize: function(x, g) {
          var _ = g.rest;
          if (_) {
            for (var T in _)
              g[T] = _[T];
            delete g.rest;
          }
          var A = new h();
          return d(A, A.head, x), u(x, A, g, A.head, 0), v(A);
        },
        /**
         * @namespace
         * @memberof Prism
         * @public
         */
        hooks: {
          all: {},
          /**
           * Adds the given callback to the list of callbacks for the given hook.
           *
           * The callback will be invoked when the hook it is registered for is run.
           * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
           *
           * One callback function can be registered to multiple hooks and the same hook multiple times.
           *
           * @param {string} name The name of the hook.
           * @param {HookCallback} callback The callback function which is given environment variables.
           * @public
           */
          add: function(x, g) {
            var _ = o.hooks.all;
            _[x] = _[x] || [], _[x].push(g);
          },
          /**
           * Runs a hook invoking all registered callbacks with the given environment variables.
           *
           * Callbacks will be invoked synchronously and in the order in which they were registered.
           *
           * @param {string} name The name of the hook.
           * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
           * @public
           */
          run: function(x, g) {
            var _ = o.hooks.all[x];
            if (!(!_ || !_.length))
              for (var T = 0, A; A = _[T++]; )
                A(g);
          }
        },
        Token: l
      };
      n.Prism = o;
      function l(x, g, _, T) {
        this.type = x, this.content = g, this.alias = _, this.length = (T || "").length | 0;
      }
      l.stringify = function x(g, _) {
        if (typeof g == "string")
          return g;
        if (Array.isArray(g)) {
          var T = "";
          return g.forEach(function(E) {
            T += x(E, _);
          }), T;
        }
        var A = {
          type: g.type,
          content: x(g.content, _),
          tag: "span",
          classes: ["token", g.type],
          attributes: {},
          language: _
        }, M = g.alias;
        M && (Array.isArray(M) ? Array.prototype.push.apply(A.classes, M) : A.classes.push(M)), o.hooks.run("wrap", A);
        var C = "";
        for (var y in A.attributes)
          C += " " + y + '="' + (A.attributes[y] || "").replace(/"/g, "&quot;") + '"';
        return "<" + A.tag + ' class="' + A.classes.join(" ") + '"' + C + ">" + A.content + "</" + A.tag + ">";
      };
      function c(x, g, _, T) {
        x.lastIndex = g;
        var A = x.exec(_);
        if (A && T && A[1]) {
          var M = A[1].length;
          A.index += M, A[0] = A[0].slice(M);
        }
        return A;
      }
      function u(x, g, _, T, A, M) {
        for (var C in _)
          if (!(!_.hasOwnProperty(C) || !_[C])) {
            var y = _[C];
            y = Array.isArray(y) ? y : [y];
            for (var E = 0; E < y.length; ++E) {
              if (M && M.cause == C + "," + E)
                return;
              var R = y[E], q = R.inside, G = !!R.lookbehind, V = !!R.greedy, B = R.alias;
              if (V && !R.pattern.global) {
                var U = R.pattern.toString().match(/[imsuy]*$/)[0];
                R.pattern = RegExp(R.pattern.source, U + "g");
              }
              for (var Y = R.pattern || R, z = T.next, ie = A; z !== g.tail && !(M && ie >= M.reach); ie += z.value.length, z = z.next) {
                var oe = z.value;
                if (g.length > x.length)
                  return;
                if (!(oe instanceof l)) {
                  var ce = 1, ye;
                  if (V) {
                    if (ye = c(Y, ie, x, G), !ye || ye.index >= x.length)
                      break;
                    var re = ye.index, je = ye.index + ye[0].length, K = ie;
                    for (K += z.value.length; re >= K; )
                      z = z.next, K += z.value.length;
                    if (K -= z.value.length, ie = K, z.value instanceof l)
                      continue;
                    for (var Q = z; Q !== g.tail && (K < je || typeof Q.value == "string"); Q = Q.next)
                      ce++, K += Q.value.length;
                    ce--, oe = x.slice(ie, K), ye.index -= ie;
                  } else if (ye = c(Y, 0, oe, G), !ye)
                    continue;
                  var re = ye.index, ne = ye[0], he = oe.slice(0, re), me = oe.slice(re + ne.length), we = ie + oe.length;
                  M && we > M.reach && (M.reach = we);
                  var qe = z.prev;
                  he && (qe = d(g, qe, he), ie += he.length), m(g, qe, ce);
                  var Pe = new l(C, q ? o.tokenize(ne, q) : ne, B, ne);
                  if (z = d(g, qe, Pe), me && d(g, z, me), ce > 1) {
                    var Je = {
                      cause: C + "," + E,
                      reach: we
                    };
                    u(x, g, _, z.prev, ie, Je), M && Je.reach > M.reach && (M.reach = Je.reach);
                  }
                }
              }
            }
          }
      }
      function h() {
        var x = { value: null, prev: null, next: null }, g = { value: null, prev: x, next: null };
        x.next = g, this.head = x, this.tail = g, this.length = 0;
      }
      function d(x, g, _) {
        var T = g.next, A = { value: _, prev: g, next: T };
        return g.next = A, T.prev = A, x.length++, A;
      }
      function m(x, g, _) {
        for (var T = g.next, A = 0; A < _ && T !== x.tail; A++)
          T = T.next;
        g.next = T, T.prev = g, x.length -= A;
      }
      function v(x) {
        for (var g = [], _ = x.head.next; _ !== x.tail; )
          g.push(_.value), _ = _.next;
        return g;
      }
      if (!n.document)
        return n.addEventListener && (o.disableWorkerMessageHandler || n.addEventListener("message", function(x) {
          var g = JSON.parse(x.data), _ = g.language, T = g.code, A = g.immediateClose;
          n.postMessage(o.highlight(T, o.languages[_], _)), A && n.close();
        }, !1)), o;
      var b = o.util.currentScript();
      b && (o.filename = b.src, b.hasAttribute("data-manual") && (o.manual = !0));
      function p() {
        o.manual || o.highlightAll();
      }
      if (!o.manual) {
        var f = document.readyState;
        f === "loading" || f === "interactive" && b && b.defer ? document.addEventListener("DOMContentLoaded", p) : window.requestAnimationFrame ? window.requestAnimationFrame(p) : window.setTimeout(p, 16);
      }
      return o;
    })(e);
    i.exports && (i.exports = t), typeof ou < "u" && (ou.Prism = t), t.languages.markup = {
      comment: {
        pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
        greedy: !0
      },
      prolog: {
        pattern: /<\?[\s\S]+?\?>/,
        greedy: !0
      },
      doctype: {
        // https://www.w3.org/TR/xml/#NT-doctypedecl
        pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
        greedy: !0,
        inside: {
          "internal-subset": {
            pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
            lookbehind: !0,
            greedy: !0,
            inside: null
            // see below
          },
          string: {
            pattern: /"[^"]*"|'[^']*'/,
            greedy: !0
          },
          punctuation: /^<!|>$|[[\]]/,
          "doctype-tag": /^DOCTYPE/i,
          name: /[^\s<>'"]+/
        }
      },
      cdata: {
        pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
        greedy: !0
      },
      tag: {
        pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
        greedy: !0,
        inside: {
          tag: {
            pattern: /^<\/?[^\s>\/]+/,
            inside: {
              punctuation: /^<\/?/,
              namespace: /^[^\s>\/:]+:/
            }
          },
          "special-attr": [],
          "attr-value": {
            pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
            inside: {
              punctuation: [
                {
                  pattern: /^=/,
                  alias: "attr-equals"
                },
                {
                  pattern: /^(\s*)["']|["']$/,
                  lookbehind: !0
                }
              ]
            }
          },
          punctuation: /\/?>/,
          "attr-name": {
            pattern: /[^\s>\/]+/,
            inside: {
              namespace: /^[^\s>\/:]+:/
            }
          }
        }
      },
      entity: [
        {
          pattern: /&[\da-z]{1,8};/i,
          alias: "named-entity"
        },
        /&#x?[\da-f]{1,8};/i
      ]
    }, t.languages.markup.tag.inside["attr-value"].inside.entity = t.languages.markup.entity, t.languages.markup.doctype.inside["internal-subset"].inside = t.languages.markup, t.hooks.add("wrap", function(n) {
      n.type === "entity" && (n.attributes.title = n.content.replace(/&amp;/, "&"));
    }), Object.defineProperty(t.languages.markup.tag, "addInlined", {
      /**
       * Adds an inlined language to markup.
       *
       * An example of an inlined language is CSS with `<style>` tags.
       *
       * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
       * case insensitive.
       * @param {string} lang The language key.
       * @example
       * addInlined('style', 'css');
       */
      value: function(r, s) {
        var a = {};
        a["language-" + s] = {
          pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
          lookbehind: !0,
          inside: t.languages[s]
        }, a.cdata = /^<!\[CDATA\[|\]\]>$/i;
        var o = {
          "included-cdata": {
            pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
            inside: a
          }
        };
        o["language-" + s] = {
          pattern: /[\s\S]+/,
          inside: t.languages[s]
        };
        var l = {};
        l[r] = {
          pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
            return r;
          }), "i"),
          lookbehind: !0,
          greedy: !0,
          inside: o
        }, t.languages.insertBefore("markup", "cdata", l);
      }
    }), Object.defineProperty(t.languages.markup.tag, "addAttribute", {
      /**
       * Adds an pattern to highlight languages embedded in HTML attributes.
       *
       * An example of an inlined language is CSS with `style` attributes.
       *
       * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
       * case insensitive.
       * @param {string} lang The language key.
       * @example
       * addAttribute('style', 'css');
       */
      value: function(n, r) {
        t.languages.markup.tag.inside["special-attr"].push({
          pattern: RegExp(
            /(^|["'\s])/.source + "(?:" + n + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
            "i"
          ),
          lookbehind: !0,
          inside: {
            "attr-name": /^[^\s=]+/,
            "attr-value": {
              pattern: /=[\s\S]+/,
              inside: {
                value: {
                  pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
                  lookbehind: !0,
                  alias: [r, "language-" + r],
                  inside: t.languages[r]
                },
                punctuation: [
                  {
                    pattern: /^=/,
                    alias: "attr-equals"
                  },
                  /"|'/
                ]
              }
            }
          }
        });
      }
    }), t.languages.html = t.languages.markup, t.languages.mathml = t.languages.markup, t.languages.svg = t.languages.markup, t.languages.xml = t.languages.extend("markup", {}), t.languages.ssml = t.languages.xml, t.languages.atom = t.languages.xml, t.languages.rss = t.languages.xml, (function(n) {
      var r = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
      n.languages.css = {
        comment: /\/\*[\s\S]*?\*\//,
        atrule: {
          pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + r.source + ")*?" + /(?:;|(?=\s*\{))/.source),
          inside: {
            rule: /^@[\w-]+/,
            "selector-function-argument": {
              pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
              lookbehind: !0,
              alias: "selector"
            },
            keyword: {
              pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
              lookbehind: !0
            }
            // See rest below
          }
        },
        url: {
          // https://drafts.csswg.org/css-values-3/#urls
          pattern: RegExp("\\burl\\((?:" + r.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
          greedy: !0,
          inside: {
            function: /^url/i,
            punctuation: /^\(|\)$/,
            string: {
              pattern: RegExp("^" + r.source + "$"),
              alias: "url"
            }
          }
        },
        selector: {
          pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + r.source + ")*(?=\\s*\\{)"),
          lookbehind: !0
        },
        string: {
          pattern: r,
          greedy: !0
        },
        property: {
          pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
          lookbehind: !0
        },
        important: /!important\b/i,
        function: {
          pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
          lookbehind: !0
        },
        punctuation: /[(){};:,]/
      }, n.languages.css.atrule.inside.rest = n.languages.css;
      var s = n.languages.markup;
      s && (s.tag.addInlined("style", "css"), s.tag.addAttribute("style", "css"));
    })(t), t.languages.clike = {
      comment: [
        {
          pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
          lookbehind: !0,
          greedy: !0
        },
        {
          pattern: /(^|[^\\:])\/\/.*/,
          lookbehind: !0,
          greedy: !0
        }
      ],
      string: {
        pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
        greedy: !0
      },
      "class-name": {
        pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
        lookbehind: !0,
        inside: {
          punctuation: /[.\\]/
        }
      },
      keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
      boolean: /\b(?:false|true)\b/,
      function: /\b\w+(?=\()/,
      number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
      operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
      punctuation: /[{}[\];(),.:]/
    }, t.languages.javascript = t.languages.extend("clike", {
      "class-name": [
        t.languages.clike["class-name"],
        {
          pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
          lookbehind: !0
        }
      ],
      keyword: [
        {
          pattern: /((?:^|\})\s*)catch\b/,
          lookbehind: !0
        },
        {
          pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
          lookbehind: !0
        }
      ],
      // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
      function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
      number: {
        pattern: RegExp(
          /(^|[^\w$])/.source + "(?:" + // constant
          (/NaN|Infinity/.source + "|" + // binary integer
          /0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
          /0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
          /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
          /\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
          /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
        ),
        lookbehind: !0
      },
      operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
    }), t.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, t.languages.insertBefore("javascript", "keyword", {
      regex: {
        pattern: RegExp(
          // lookbehind
          // eslint-disable-next-line regexp/no-dupe-characters-character-class
          /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
          // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
          // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
          // with the only syntax, so we have to define 2 different regex patterns.
          /\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
          /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
          /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
        ),
        lookbehind: !0,
        greedy: !0,
        inside: {
          "regex-source": {
            pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
            lookbehind: !0,
            alias: "language-regex",
            inside: t.languages.regex
          },
          "regex-delimiter": /^\/|\/$/,
          "regex-flags": /^[a-z]+$/
        }
      },
      // This must be declared before keyword because we use "function" inside the look-forward
      "function-variable": {
        pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
        alias: "function"
      },
      parameter: [
        {
          pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
          lookbehind: !0,
          inside: t.languages.javascript
        },
        {
          pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
          lookbehind: !0,
          inside: t.languages.javascript
        },
        {
          pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
          lookbehind: !0,
          inside: t.languages.javascript
        },
        {
          pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
          lookbehind: !0,
          inside: t.languages.javascript
        }
      ],
      constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
    }), t.languages.insertBefore("javascript", "string", {
      hashbang: {
        pattern: /^#!.*/,
        greedy: !0,
        alias: "comment"
      },
      "template-string": {
        pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
        greedy: !0,
        inside: {
          "template-punctuation": {
            pattern: /^`|`$/,
            alias: "string"
          },
          interpolation: {
            pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
            lookbehind: !0,
            inside: {
              "interpolation-punctuation": {
                pattern: /^\$\{|\}$/,
                alias: "punctuation"
              },
              rest: t.languages.javascript
            }
          },
          string: /[\s\S]+/
        }
      },
      "string-property": {
        pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
        lookbehind: !0,
        greedy: !0,
        alias: "property"
      }
    }), t.languages.insertBefore("javascript", "operator", {
      "literal-property": {
        pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
        lookbehind: !0,
        alias: "property"
      }
    }), t.languages.markup && (t.languages.markup.tag.addInlined("script", "javascript"), t.languages.markup.tag.addAttribute(
      /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
      "javascript"
    )), t.languages.js = t.languages.javascript, (function() {
      if (typeof t > "u" || typeof document > "u")
        return;
      Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
      var n = "Loading…", r = function(b, p) {
        return "✖ Error " + b + " while fetching file: " + p;
      }, s = "✖ Error: File does not exist or is empty", a = {
        js: "javascript",
        py: "python",
        rb: "ruby",
        ps1: "powershell",
        psm1: "powershell",
        sh: "bash",
        bat: "batch",
        h: "c",
        tex: "latex"
      }, o = "data-src-status", l = "loading", c = "loaded", u = "failed", h = "pre[data-src]:not([" + o + '="' + c + '"]):not([' + o + '="' + l + '"])';
      function d(b, p, f) {
        var x = new XMLHttpRequest();
        x.open("GET", b, !0), x.onreadystatechange = function() {
          x.readyState == 4 && (x.status < 400 && x.responseText ? p(x.responseText) : x.status >= 400 ? f(r(x.status, x.statusText)) : f(s));
        }, x.send(null);
      }
      function m(b) {
        var p = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(b || "");
        if (p) {
          var f = Number(p[1]), x = p[2], g = p[3];
          return x ? g ? [f, Number(g)] : [f, void 0] : [f, f];
        }
      }
      t.hooks.add("before-highlightall", function(b) {
        b.selector += ", " + h;
      }), t.hooks.add("before-sanity-check", function(b) {
        var p = (
          /** @type {HTMLPreElement} */
          b.element
        );
        if (p.matches(h)) {
          b.code = "", p.setAttribute(o, l);
          var f = p.appendChild(document.createElement("CODE"));
          f.textContent = n;
          var x = p.getAttribute("data-src"), g = b.language;
          if (g === "none") {
            var _ = (/\.(\w+)$/.exec(x) || [, "none"])[1];
            g = a[_] || _;
          }
          t.util.setLanguage(f, g), t.util.setLanguage(p, g);
          var T = t.plugins.autoloader;
          T && T.loadLanguages(g), d(
            x,
            function(A) {
              p.setAttribute(o, c);
              var M = m(p.getAttribute("data-range"));
              if (M) {
                var C = A.split(/\r\n?|\n/g), y = M[0], E = M[1] == null ? C.length : M[1];
                y < 0 && (y += C.length), y = Math.max(0, Math.min(y - 1, C.length)), E < 0 && (E += C.length), E = Math.max(0, Math.min(E, C.length)), A = C.slice(y, E).join(`
`), p.hasAttribute("data-start") || p.setAttribute("data-start", String(y + 1));
              }
              f.textContent = A, t.highlightElement(f);
            },
            function(A) {
              p.setAttribute(o, u), f.textContent = A;
            }
          );
        }
      }), t.plugins.fileHighlight = {
        /**
         * Executes the File Highlight plugin for all matching `pre` elements under the given container.
         *
         * Note: Elements which are already loaded or currently loading will not be touched by this method.
         *
         * @param {ParentNode} [container=document]
         */
        highlight: function(p) {
          for (var f = (p || document).querySelectorAll(h), x = 0, g; g = f[x++]; )
            t.highlightElement(g);
        }
      };
      var v = !1;
      t.fileHighlight = function() {
        v || (console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."), v = !0), t.plugins.fileHighlight.highlight.apply(this, arguments);
      };
    })();
  })(co)), co.exports;
}
l0();
var wu = {}, Du;
function c0() {
  return Du || (Du = 1, Prism.languages.python = {
    comment: {
      pattern: /(^|[^\\])#.*/,
      lookbehind: !0,
      greedy: !0
    },
    "string-interpolation": {
      pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
      greedy: !0,
      inside: {
        interpolation: {
          // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
          pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
          lookbehind: !0,
          inside: {
            "format-spec": {
              pattern: /(:)[^:(){}]+(?=\}$)/,
              lookbehind: !0
            },
            "conversion-option": {
              pattern: /![sra](?=[:}]$)/,
              alias: "punctuation"
            },
            rest: null
          }
        },
        string: /[\s\S]+/
      }
    },
    "triple-quoted-string": {
      pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
      greedy: !0,
      alias: "string"
    },
    string: {
      pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
      greedy: !0
    },
    function: {
      pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
      lookbehind: !0
    },
    "class-name": {
      pattern: /(\bclass\s+)\w+/i,
      lookbehind: !0
    },
    decorator: {
      pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
      lookbehind: !0,
      alias: ["annotation", "punctuation"],
      inside: {
        punctuation: /\./
      }
    },
    keyword: /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
    builtin: /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
    boolean: /\b(?:False|None|True)\b/,
    number: /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
    operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
    punctuation: /[{}[\];(),.:]/
  }, Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest = Prism.languages.python, Prism.languages.py = Prism.languages.python), wu;
}
c0();
(function(i) {
  var e = /\\(?:[^a-z()[\]]|[a-z*]+)/i, t = {
    "equation-command": {
      pattern: e,
      alias: "regex"
    }
  };
  i.languages.latex = {
    comment: /%.*/,
    // the verbatim environment prints whitespace to the document
    cdata: {
      pattern: /(\\begin\{((?:lstlisting|verbatim)\*?)\})[\s\S]*?(?=\\end\{\2\})/,
      lookbehind: !0
    },
    /*
     * equations can be between $$ $$ or $ $ or \( \) or \[ \]
     * (all are multiline)
     */
    equation: [
      {
        pattern: /\$\$(?:\\[\s\S]|[^\\$])+\$\$|\$(?:\\[\s\S]|[^\\$])+\$|\\\([\s\S]*?\\\)|\\\[[\s\S]*?\\\]/,
        inside: t,
        alias: "string"
      },
      {
        pattern: /(\\begin\{((?:align|eqnarray|equation|gather|math|multline)\*?)\})[\s\S]*?(?=\\end\{\2\})/,
        lookbehind: !0,
        inside: t,
        alias: "string"
      }
    ],
    /*
     * arguments which are keywords or references are highlighted
     * as keywords
     */
    keyword: {
      pattern: /(\\(?:begin|cite|documentclass|end|label|ref|usepackage)(?:\[[^\]]+\])?\{)[^}]+(?=\})/,
      lookbehind: !0
    },
    url: {
      pattern: /(\\url\{)[^}]+(?=\})/,
      lookbehind: !0
    },
    /*
     * section or chapter headlines are highlighted as bold so that
     * they stand out more
     */
    headline: {
      pattern: /(\\(?:chapter|frametitle|paragraph|part|section|subparagraph|subsection|subsubparagraph|subsubsection|subsubsubparagraph)\*?(?:\[[^\]]+\])?\{)[^}]+(?=\})/,
      lookbehind: !0,
      alias: "class-name"
    },
    function: {
      pattern: e,
      alias: "selector"
    },
    punctuation: /[[\]{}&]/
  }, i.languages.tex = i.languages.latex, i.languages.context = i.languages.latex;
})(Prism);
(function(i) {
  var e = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b", t = {
    pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
    lookbehind: !0,
    alias: "punctuation",
    // this looks reasonably well in all themes
    inside: null
    // see below
  }, n = {
    bash: t,
    environment: {
      pattern: RegExp("\\$" + e),
      alias: "constant"
    },
    variable: [
      // [0]: Arithmetic Environment
      {
        pattern: /\$?\(\([\s\S]+?\)\)/,
        greedy: !0,
        inside: {
          // If there is a $ sign at the beginning highlight $(( and )) as variable
          variable: [
            {
              pattern: /(^\$\(\([\s\S]+)\)\)/,
              lookbehind: !0
            },
            /^\$\(\(/
          ],
          number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
          // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
          operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
          // If there is no $ sign at the beginning highlight (( and )) as punctuation
          punctuation: /\(\(?|\)\)?|,|;/
        }
      },
      // [1]: Command Substitution
      {
        pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
        greedy: !0,
        inside: {
          variable: /^\$\(|^`|\)$|`$/
        }
      },
      // [2]: Brace expansion
      {
        pattern: /\$\{[^}]+\}/,
        greedy: !0,
        inside: {
          operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
          punctuation: /[\[\]]/,
          environment: {
            pattern: RegExp("(\\{)" + e),
            lookbehind: !0,
            alias: "constant"
          }
        }
      },
      /\$(?:\w+|[#?*!@$])/
    ],
    // Escape sequences from echo and printf's manuals, and escaped quotes.
    entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
  };
  i.languages.bash = {
    shebang: {
      pattern: /^#!\s*\/.*/,
      alias: "important"
    },
    comment: {
      pattern: /(^|[^"{\\$])#.*/,
      lookbehind: !0
    },
    "function-name": [
      // a) function foo {
      // b) foo() {
      // c) function foo() {
      // but not “foo {”
      {
        // a) and c)
        pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
        lookbehind: !0,
        alias: "function"
      },
      {
        // b)
        pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
        alias: "function"
      }
    ],
    // Highlight variable names as variables in for and select beginnings.
    "for-or-select": {
      pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
      alias: "variable",
      lookbehind: !0
    },
    // Highlight variable names as variables in the left-hand part
    // of assignments (“=” and “+=”).
    "assign-left": {
      pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
      inside: {
        environment: {
          pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + e),
          lookbehind: !0,
          alias: "constant"
        }
      },
      alias: "variable",
      lookbehind: !0
    },
    // Highlight parameter names as variables
    parameter: {
      pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
      alias: "variable",
      lookbehind: !0
    },
    string: [
      // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
      {
        pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
        lookbehind: !0,
        greedy: !0,
        inside: n
      },
      // Here-document with quotes around the tag
      // → No expansion (so no “inside”).
      {
        pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
        lookbehind: !0,
        greedy: !0,
        inside: {
          bash: t
        }
      },
      // “Normal” string
      {
        // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
        pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
        lookbehind: !0,
        greedy: !0,
        inside: n
      },
      {
        // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
        pattern: /(^|[^$\\])'[^']*'/,
        lookbehind: !0,
        greedy: !0
      },
      {
        // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
        pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
        greedy: !0,
        inside: {
          entity: n.entity
        }
      }
    ],
    environment: {
      pattern: RegExp("\\$?" + e),
      alias: "constant"
    },
    variable: n.variable,
    function: {
      pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
      lookbehind: !0
    },
    keyword: {
      pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
      lookbehind: !0
    },
    // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
    builtin: {
      pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
      lookbehind: !0,
      // Alias added to make those easier to distinguish from strings.
      alias: "class-name"
    },
    boolean: {
      pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
      lookbehind: !0
    },
    "file-descriptor": {
      pattern: /\B&\d\b/,
      alias: "important"
    },
    operator: {
      // Lots of redirections here, but not just that.
      pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
      inside: {
        "file-descriptor": {
          pattern: /^\d/,
          alias: "important"
        }
      }
    },
    punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
    number: {
      pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
      lookbehind: !0
    }
  }, t.inside = i.languages.bash;
  for (var r = [
    "comment",
    "function-name",
    "for-or-select",
    "assign-left",
    "parameter",
    "string",
    "environment",
    "function",
    "keyword",
    "builtin",
    "boolean",
    "file-descriptor",
    "operator",
    "punctuation",
    "number"
  ], s = n.variable[1].inside, a = 0; a < r.length; a++)
    s[r[a]] = i.languages.bash[r[a]];
  i.languages.sh = i.languages.bash, i.languages.shell = i.languages.bash;
})(Prism);
Prism.languages.c = Prism.languages.extend("clike", {
  comment: {
    pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
    greedy: !0
  },
  string: {
    // https://en.cppreference.com/w/c/language/string_literal
    pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
    greedy: !0
  },
  "class-name": {
    pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
    lookbehind: !0
  },
  keyword: /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
  function: /\b[a-z_]\w*(?=\s*\()/i,
  number: /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
  operator: />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
});
Prism.languages.insertBefore("c", "string", {
  char: {
    // https://en.cppreference.com/w/c/language/character_constant
    pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
    greedy: !0
  }
});
Prism.languages.insertBefore("c", "string", {
  macro: {
    // allow for multiline macro definitions
    // spaces after the # character compile fine with gcc
    pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
    lookbehind: !0,
    greedy: !0,
    alias: "property",
    inside: {
      string: [
        {
          // highlight the path of the include statement as a string
          pattern: /^(#\s*include\s*)<[^>]+>/,
          lookbehind: !0
        },
        Prism.languages.c.string
      ],
      char: Prism.languages.c.char,
      comment: Prism.languages.c.comment,
      "macro-name": [
        {
          pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
          lookbehind: !0
        },
        {
          pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
          lookbehind: !0,
          alias: "function"
        }
      ],
      // highlight macro directives as keywords
      directive: {
        pattern: /^(#\s*)[a-z]+/,
        lookbehind: !0,
        alias: "keyword"
      },
      "directive-hash": /^#/,
      punctuation: /##|\\(?=[\r\n])/,
      expression: {
        pattern: /\S[\s\S]*/,
        inside: Prism.languages.c
      }
    }
  }
});
Prism.languages.insertBefore("c", "function", {
  // highlight predefined macros as constants
  constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
});
delete Prism.languages.c.boolean;
var Ru = {}, Cu;
function u0() {
  return Cu || (Cu = 1, (function(i) {
    var e = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/, t = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function() {
      return e.source;
    });
    i.languages.cpp = i.languages.extend("c", {
      "class-name": [
        {
          pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g, function() {
            return e.source;
          })),
          lookbehind: !0
        },
        // This is intended to capture the class name of method implementations like:
        //   void foo::bar() const {}
        // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
        // it starts with an uppercase letter. This approximation should give decent results.
        /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
        // This will capture the class name before destructors like:
        //   Foo::~Foo() {}
        /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
        // This also intends to capture the class name of method implementations but here the class has template
        // parameters, so it can't be a namespace (until C++ adds generic namespaces).
        /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
      ],
      keyword: e,
      number: {
        pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
        greedy: !0
      },
      operator: />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
      boolean: /\b(?:false|true)\b/
    }), i.languages.insertBefore("cpp", "string", {
      module: {
        // https://en.cppreference.com/w/cpp/language/modules
        pattern: RegExp(
          /(\b(?:import|module)\s+)/.source + "(?:" + // header-name
          /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + "|" + // module name or partition or both
          /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function() {
            return t;
          }) + ")"
        ),
        lookbehind: !0,
        greedy: !0,
        inside: {
          string: /^[<"][\s\S]+/,
          operator: /:/,
          punctuation: /\./
        }
      },
      "raw-string": {
        pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
        alias: "string",
        greedy: !0
      }
    }), i.languages.insertBefore("cpp", "keyword", {
      "generic-function": {
        pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
        inside: {
          function: /^\w+/,
          generic: {
            pattern: /<[\s\S]+/,
            alias: "class-name",
            inside: i.languages.cpp
          }
        }
      }
    }), i.languages.insertBefore("cpp", "operator", {
      "double-colon": {
        pattern: /::/,
        alias: "punctuation"
      }
    }), i.languages.insertBefore("cpp", "class-name", {
      // the base clause is an optional list of parent classes
      // https://en.cppreference.com/w/cpp/language/class
      "base-clause": {
        pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
        lookbehind: !0,
        greedy: !0,
        inside: i.languages.extend("cpp", {})
      }
    }), i.languages.insertBefore("inside", "double-colon", {
      // All untokenized words that are not namespaces should be class names
      "class-name": /\b[a-z_]\w*\b(?!\s*::)/i
    }, i.languages.cpp["base-clause"]);
  })(Prism)), Ru;
}
u0();
Prism.languages.json = {
  property: {
    pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
    lookbehind: !0,
    greedy: !0
  },
  string: {
    pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
    lookbehind: !0,
    greedy: !0
  },
  comment: {
    pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
    greedy: !0
  },
  number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
  punctuation: /[{}[\],]/,
  operator: /:/,
  boolean: /\b(?:false|true)\b/,
  null: {
    pattern: /\bnull\b/,
    alias: "keyword"
  }
};
Prism.languages.webmanifest = Prism.languages.json;
Prism.languages.sql = {
  comment: {
    pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
    lookbehind: !0
  },
  variable: [
    {
      pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
      greedy: !0
    },
    /@[\w.$]+/
  ],
  string: {
    pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
    greedy: !0,
    lookbehind: !0
  },
  identifier: {
    pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
    greedy: !0,
    lookbehind: !0,
    inside: {
      punctuation: /^`|`$/
    }
  },
  function: /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
  // Should we highlight user defined functions too?
  keyword: /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
  boolean: /\b(?:FALSE|NULL|TRUE)\b/i,
  number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
  operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
  punctuation: /[;[\]()`,.]/
};
var Pu = {}, Lu;
function h0() {
  return Lu || (Lu = 1, (function(i) {
    var e = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/, t = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source, n = {
      pattern: RegExp(/(^|[^\w.])/.source + t + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
      lookbehind: !0,
      inside: {
        namespace: {
          pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
          inside: {
            punctuation: /\./
          }
        },
        punctuation: /\./
      }
    };
    i.languages.java = i.languages.extend("clike", {
      string: {
        pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
        lookbehind: !0,
        greedy: !0
      },
      "class-name": [
        n,
        {
          // variables, parameters, and constructor references
          // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
          pattern: RegExp(/(^|[^\w.])/.source + t + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
          lookbehind: !0,
          inside: n.inside
        },
        {
          // class names based on keyword
          // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
          pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + t + /[A-Z]\w*\b/.source),
          lookbehind: !0,
          inside: n.inside
        }
      ],
      keyword: e,
      function: [
        i.languages.clike.function,
        {
          pattern: /(::\s*)[a-z_]\w*/,
          lookbehind: !0
        }
      ],
      number: /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
      operator: {
        pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
        lookbehind: !0
      },
      constant: /\b[A-Z][A-Z_\d]+\b/
    }), i.languages.insertBefore("java", "string", {
      "triple-quoted-string": {
        // http://openjdk.java.net/jeps/355#Description
        pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
        greedy: !0,
        alias: "string"
      },
      char: {
        pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
        greedy: !0
      }
    }), i.languages.insertBefore("java", "class-name", {
      annotation: {
        pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
        lookbehind: !0,
        alias: "punctuation"
      },
      generics: {
        pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
        inside: {
          "class-name": n,
          keyword: e,
          punctuation: /[<>(),.:]/,
          operator: /[?&|]/
        }
      },
      import: [
        {
          pattern: RegExp(/(\bimport\s+)/.source + t + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
          lookbehind: !0,
          inside: {
            namespace: n.inside.namespace,
            punctuation: /\./,
            operator: /\*/,
            "class-name": /\w+/
          }
        },
        {
          pattern: RegExp(/(\bimport\s+static\s+)/.source + t + /(?:\w+|\*)(?=\s*;)/.source),
          lookbehind: !0,
          alias: "static",
          inside: {
            namespace: n.inside.namespace,
            static: /\b\w+$/,
            punctuation: /\./,
            operator: /\*/,
            "class-name": /\w+/
          }
        }
      ],
      namespace: {
        pattern: RegExp(
          /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g, function() {
            return e.source;
          })
        ),
        lookbehind: !0,
        inside: {
          punctuation: /\./
        }
      }
    });
  })(Prism)), Pu;
}
h0();
Prism.languages.go = Prism.languages.extend("clike", {
  string: {
    pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
    lookbehind: !0,
    greedy: !0
  },
  keyword: /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
  boolean: /\b(?:_|false|iota|nil|true)\b/,
  number: [
    // binary and octal integers
    /\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
    // hexadecimal integers and floats
    /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
    // decimal integers and floats
    /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
  ],
  operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
  builtin: /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
});
Prism.languages.insertBefore("go", "string", {
  char: {
    pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
    greedy: !0
  }
});
delete Prism.languages.go["class-name"];
var Iu = {}, Fu;
function f0() {
  return Fu || (Fu = 1, (function(i) {
    for (var e = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source, t = 0; t < 2; t++)
      e = e.replace(/<self>/g, function() {
        return e;
      });
    e = e.replace(/<self>/g, function() {
      return /[^\s\S]/.source;
    }), i.languages.rust = {
      comment: [
        {
          pattern: RegExp(/(^|[^\\])/.source + e),
          lookbehind: !0,
          greedy: !0
        },
        {
          pattern: /(^|[^\\:])\/\/.*/,
          lookbehind: !0,
          greedy: !0
        }
      ],
      string: {
        pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
        greedy: !0
      },
      char: {
        pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
        greedy: !0
      },
      attribute: {
        pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
        greedy: !0,
        alias: "attr-name",
        inside: {
          string: null
          // see below
        }
      },
      // Closure params should not be confused with bitwise OR |
      "closure-params": {
        pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
        lookbehind: !0,
        greedy: !0,
        inside: {
          "closure-punctuation": {
            pattern: /^\||\|$/,
            alias: "punctuation"
          },
          rest: null
          // see below
        }
      },
      "lifetime-annotation": {
        pattern: /'\w+/,
        alias: "symbol"
      },
      "fragment-specifier": {
        pattern: /(\$\w+:)[a-z]+/,
        lookbehind: !0,
        alias: "punctuation"
      },
      variable: /\$\w+/,
      "function-definition": {
        pattern: /(\bfn\s+)\w+/,
        lookbehind: !0,
        alias: "function"
      },
      "type-definition": {
        pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
        lookbehind: !0,
        alias: "class-name"
      },
      "module-declaration": [
        {
          pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
          lookbehind: !0,
          alias: "namespace"
        },
        {
          pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
          lookbehind: !0,
          alias: "namespace",
          inside: {
            punctuation: /::/
          }
        }
      ],
      keyword: [
        // https://github.com/rust-lang/reference/blob/master/src/keywords.md
        /\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
        // primitives and str
        // https://doc.rust-lang.org/stable/rust-by-example/primitives.html
        /\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/
      ],
      // functions can technically start with an upper-case letter, but this will introduce a lot of false positives
      // and Rust's naming conventions recommend snake_case anyway.
      // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
      function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
      macro: {
        pattern: /\b\w+!/,
        alias: "property"
      },
      constant: /\b[A-Z_][A-Z_\d]+\b/,
      "class-name": /\b[A-Z]\w*\b/,
      namespace: {
        pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
        inside: {
          punctuation: /::/
        }
      },
      // Hex, oct, bin, dec numbers with visual separators and type suffix
      number: /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
      boolean: /\b(?:false|true)\b/,
      punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
      operator: /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
    }, i.languages.rust["closure-params"].inside.rest = i.languages.rust, i.languages.rust.attribute.inside.string = i.languages.rust.string;
  })(Prism)), Iu;
}
f0();
var Nu = {}, Uu;
function d0() {
  return Uu || (Uu = 1, (function(i) {
    var e = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/, t = [
      {
        pattern: /\b(?:false|true)\b/i,
        alias: "boolean"
      },
      {
        pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
        greedy: !0,
        lookbehind: !0
      },
      {
        pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
        greedy: !0,
        lookbehind: !0
      },
      /\b(?:null)\b/i,
      /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/
    ], n = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i, r = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/, s = /[{}\[\](),:;]/;
    i.languages.php = {
      delimiter: {
        pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
        alias: "important"
      },
      comment: e,
      variable: /\$+(?:\w+\b|(?=\{))/,
      package: {
        pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
        lookbehind: !0,
        inside: {
          punctuation: /\\/
        }
      },
      "class-name-definition": {
        pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
        lookbehind: !0,
        alias: "class-name"
      },
      "function-definition": {
        pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
        lookbehind: !0,
        alias: "function"
      },
      keyword: [
        {
          pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,
          alias: "type-casting",
          greedy: !0,
          lookbehind: !0
        },
        {
          pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,
          alias: "type-hint",
          greedy: !0,
          lookbehind: !0
        },
        {
          pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
          alias: "return-type",
          greedy: !0,
          lookbehind: !0
        },
        {
          pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
          alias: "type-declaration",
          greedy: !0
        },
        {
          pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
          alias: "type-declaration",
          greedy: !0,
          lookbehind: !0
        },
        {
          pattern: /\b(?:parent|self|static)(?=\s*::)/i,
          alias: "static-context",
          greedy: !0
        },
        {
          // yield from
          pattern: /(\byield\s+)from\b/i,
          lookbehind: !0
        },
        // `class` is always a keyword unlike other keywords
        /\bclass\b/i,
        {
          // https://www.php.net/manual/en/reserved.keywords.php
          //
          // keywords cannot be preceded by "->"
          // the complex lookbehind means `(?<!(?:->|::)\s*)`
          pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
          lookbehind: !0
        }
      ],
      "argument-name": {
        pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
        lookbehind: !0
      },
      "class-name": [
        {
          pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
          greedy: !0,
          lookbehind: !0
        },
        {
          pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
          greedy: !0,
          lookbehind: !0
        },
        {
          pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
          greedy: !0
        },
        {
          pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
          alias: "class-name-fully-qualified",
          greedy: !0,
          lookbehind: !0,
          inside: {
            punctuation: /\\/
          }
        },
        {
          pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
          alias: "class-name-fully-qualified",
          greedy: !0,
          inside: {
            punctuation: /\\/
          }
        },
        {
          pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
          alias: "class-name-fully-qualified",
          greedy: !0,
          lookbehind: !0,
          inside: {
            punctuation: /\\/
          }
        },
        {
          pattern: /\b[a-z_]\w*(?=\s*\$)/i,
          alias: "type-declaration",
          greedy: !0
        },
        {
          pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
          alias: ["class-name-fully-qualified", "type-declaration"],
          greedy: !0,
          inside: {
            punctuation: /\\/
          }
        },
        {
          pattern: /\b[a-z_]\w*(?=\s*::)/i,
          alias: "static-context",
          greedy: !0
        },
        {
          pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
          alias: ["class-name-fully-qualified", "static-context"],
          greedy: !0,
          inside: {
            punctuation: /\\/
          }
        },
        {
          pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
          alias: "type-hint",
          greedy: !0,
          lookbehind: !0
        },
        {
          pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
          alias: ["class-name-fully-qualified", "type-hint"],
          greedy: !0,
          lookbehind: !0,
          inside: {
            punctuation: /\\/
          }
        },
        {
          pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
          alias: "return-type",
          greedy: !0,
          lookbehind: !0
        },
        {
          pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
          alias: ["class-name-fully-qualified", "return-type"],
          greedy: !0,
          lookbehind: !0,
          inside: {
            punctuation: /\\/
          }
        }
      ],
      constant: t,
      function: {
        pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
        lookbehind: !0,
        inside: {
          punctuation: /\\/
        }
      },
      property: {
        pattern: /(->\s*)\w+/,
        lookbehind: !0
      },
      number: n,
      operator: r,
      punctuation: s
    };
    var a = {
      pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
      lookbehind: !0,
      inside: i.languages.php
    }, o = [
      {
        pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
        alias: "nowdoc-string",
        greedy: !0,
        inside: {
          delimiter: {
            pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
            alias: "symbol",
            inside: {
              punctuation: /^<<<'?|[';]$/
            }
          }
        }
      },
      {
        pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
        alias: "heredoc-string",
        greedy: !0,
        inside: {
          delimiter: {
            pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
            alias: "symbol",
            inside: {
              punctuation: /^<<<"?|[";]$/
            }
          },
          interpolation: a
        }
      },
      {
        pattern: /`(?:\\[\s\S]|[^\\`])*`/,
        alias: "backtick-quoted-string",
        greedy: !0
      },
      {
        pattern: /'(?:\\[\s\S]|[^\\'])*'/,
        alias: "single-quoted-string",
        greedy: !0
      },
      {
        pattern: /"(?:\\[\s\S]|[^\\"])*"/,
        alias: "double-quoted-string",
        greedy: !0,
        inside: {
          interpolation: a
        }
      }
    ];
    i.languages.insertBefore("php", "variable", {
      string: o,
      attribute: {
        pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
        greedy: !0,
        inside: {
          "attribute-content": {
            pattern: /^(#\[)[\s\S]+(?=\]$)/,
            lookbehind: !0,
            // inside can appear subset of php
            inside: {
              comment: e,
              string: o,
              "attribute-class-name": [
                {
                  pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
                  alias: "class-name",
                  greedy: !0,
                  lookbehind: !0
                },
                {
                  pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
                  alias: [
                    "class-name",
                    "class-name-fully-qualified"
                  ],
                  greedy: !0,
                  lookbehind: !0,
                  inside: {
                    punctuation: /\\/
                  }
                }
              ],
              constant: t,
              number: n,
              operator: r,
              punctuation: s
            }
          },
          delimiter: {
            pattern: /^#\[|\]$/,
            alias: "punctuation"
          }
        }
      }
    }), i.hooks.add("before-tokenize", function(l) {
      if (/<\?/.test(l.code)) {
        var c = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;
        i.languages["markup-templating"].buildPlaceholders(l, "php", c);
      }
    }), i.hooks.add("after-tokenize", function(l) {
      i.languages["markup-templating"].tokenizePlaceholders(l, "php");
    });
  })(Prism)), Nu;
}
d0();
(function(i) {
  var e = /[*&][^\s[\]{},]+/, t = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/, n = "(?:" + t.source + "(?:[ 	]+" + e.source + ")?|" + e.source + "(?:[ 	]+" + t.source + ")?)", r = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g, function() {
    return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
  }), s = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
  function a(o, l) {
    l = (l || "").replace(/m/g, "") + "m";
    var c = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, function() {
      return n;
    }).replace(/<<value>>/g, function() {
      return o;
    });
    return RegExp(c, l);
  }
  i.languages.yaml = {
    scalar: {
      pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g, function() {
        return n;
      })),
      lookbehind: !0,
      alias: "string"
    },
    comment: /#.*/,
    key: {
      pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, function() {
        return n;
      }).replace(/<<key>>/g, function() {
        return "(?:" + r + "|" + s + ")";
      })),
      lookbehind: !0,
      greedy: !0,
      alias: "atrule"
    },
    directive: {
      pattern: /(^[ \t]*)%.+/m,
      lookbehind: !0,
      alias: "important"
    },
    datetime: {
      pattern: a(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),
      lookbehind: !0,
      alias: "number"
    },
    boolean: {
      pattern: a(/false|true/.source, "i"),
      lookbehind: !0,
      alias: "important"
    },
    null: {
      pattern: a(/null|~/.source, "i"),
      lookbehind: !0,
      alias: "important"
    },
    string: {
      pattern: a(s),
      lookbehind: !0,
      greedy: !0
    },
    number: {
      pattern: a(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, "i"),
      lookbehind: !0
    },
    tag: t,
    important: e,
    punctuation: /---|[:[\]{}\-,|>?]|\.\.\./
  }, i.languages.yml = i.languages.yaml;
})(Prism);
(function(i) {
  function e(t, n) {
    return "___" + t.toUpperCase() + n + "___";
  }
  Object.defineProperties(i.languages["markup-templating"] = {}, {
    buildPlaceholders: {
      /**
       * Tokenize all inline templating expressions matching `placeholderPattern`.
       *
       * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
       * `true` will be replaced.
       *
       * @param {object} env The environment of the `before-tokenize` hook.
       * @param {string} language The language id.
       * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
       * @param {(match: string) => boolean} [replaceFilter]
       */
      value: function(t, n, r, s) {
        if (t.language === n) {
          var a = t.tokenStack = [];
          t.code = t.code.replace(r, function(o) {
            if (typeof s == "function" && !s(o))
              return o;
            for (var l = a.length, c; t.code.indexOf(c = e(n, l)) !== -1; )
              ++l;
            return a[l] = o, c;
          }), t.grammar = i.languages.markup;
        }
      }
    },
    tokenizePlaceholders: {
      /**
       * Replace placeholders with proper tokens after tokenizing.
       *
       * @param {object} env The environment of the `after-tokenize` hook.
       * @param {string} language The language id.
       */
      value: function(t, n) {
        if (t.language !== n || !t.tokenStack)
          return;
        t.grammar = i.languages[n];
        var r = 0, s = Object.keys(t.tokenStack);
        function a(o) {
          for (var l = 0; l < o.length && !(r >= s.length); l++) {
            var c = o[l];
            if (typeof c == "string" || c.content && typeof c.content == "string") {
              var u = s[r], h = t.tokenStack[u], d = typeof c == "string" ? c : c.content, m = e(n, u), v = d.indexOf(m);
              if (v > -1) {
                ++r;
                var b = d.substring(0, v), p = new i.Token(n, i.tokenize(h, t.grammar), "language-" + n, h), f = d.substring(v + m.length), x = [];
                b && x.push.apply(x, a([b])), x.push(p), f && x.push.apply(x, a([f])), typeof c == "string" ? o.splice.apply(o, [l, 1].concat(x)) : c.content = x;
              }
            } else c.content && a(c.content);
          }
          return o;
        }
        a(t.tokens);
      }
    }
  });
})(Prism);
new xd();
const p0 = (i) => {
  const e = {};
  for (let t = 0, n = i.length; t < n; t++) {
    const r = i[t];
    for (const s in r)
      e[s] ? e[s] = e[s].concat(r[s]) : e[s] = r[s];
  }
  return e;
}, m0 = [
  "abbr",
  "accept",
  "accept-charset",
  "accesskey",
  "action",
  "align",
  "alink",
  "allow",
  "allowfullscreen",
  "alt",
  "anchor",
  "archive",
  "as",
  "async",
  "autocapitalize",
  "autocomplete",
  "autocorrect",
  "autofocus",
  "autopictureinpicture",
  "autoplay",
  "axis",
  "background",
  "behavior",
  "bgcolor",
  "border",
  "bordercolor",
  "capture",
  "cellpadding",
  "cellspacing",
  "challenge",
  "char",
  "charoff",
  "charset",
  "checked",
  "cite",
  "class",
  "classid",
  "clear",
  "code",
  "codebase",
  "codetype",
  "color",
  "cols",
  "colspan",
  "compact",
  "content",
  "contenteditable",
  "controls",
  "controlslist",
  "conversiondestination",
  "coords",
  "crossorigin",
  "csp",
  "data",
  "datetime",
  "declare",
  "decoding",
  "default",
  "defer",
  "dir",
  "direction",
  "dirname",
  "disabled",
  "disablepictureinpicture",
  "disableremoteplayback",
  "disallowdocumentaccess",
  "download",
  "draggable",
  "elementtiming",
  "enctype",
  "end",
  "enterkeyhint",
  "event",
  "exportparts",
  "face",
  "for",
  "form",
  "formaction",
  "formenctype",
  "formmethod",
  "formnovalidate",
  "formtarget",
  "frame",
  "frameborder",
  "headers",
  "height",
  "hidden",
  "high",
  "href",
  "hreflang",
  "hreftranslate",
  "hspace",
  "http-equiv",
  "id",
  "imagesizes",
  "imagesrcset",
  "importance",
  "impressiondata",
  "impressionexpiry",
  "incremental",
  "inert",
  "inputmode",
  "integrity",
  "invisible",
  "ismap",
  "keytype",
  "kind",
  "label",
  "lang",
  "language",
  "latencyhint",
  "leftmargin",
  "link",
  "list",
  "loading",
  "longdesc",
  "loop",
  "low",
  "lowsrc",
  "manifest",
  "marginheight",
  "marginwidth",
  "max",
  "maxlength",
  "mayscript",
  "media",
  "method",
  "min",
  "minlength",
  "multiple",
  "muted",
  "name",
  "nohref",
  "nomodule",
  "nonce",
  "noresize",
  "noshade",
  "novalidate",
  "nowrap",
  "object",
  "open",
  "optimum",
  "part",
  "pattern",
  "ping",
  "placeholder",
  "playsinline",
  "policy",
  "poster",
  "preload",
  "pseudo",
  "readonly",
  "referrerpolicy",
  "rel",
  "reportingorigin",
  "required",
  "resources",
  "rev",
  "reversed",
  "role",
  "rows",
  "rowspan",
  "rules",
  "sandbox",
  "scheme",
  "scope",
  "scopes",
  "scrollamount",
  "scrolldelay",
  "scrolling",
  "select",
  "selected",
  "shadowroot",
  "shadowrootdelegatesfocus",
  "shape",
  "size",
  "sizes",
  "slot",
  "span",
  "spellcheck",
  "src",
  "srclang",
  "srcset",
  "standby",
  "start",
  "step",
  "style",
  "summary",
  "tabindex",
  "target",
  "text",
  "title",
  "topmargin",
  "translate",
  "truespeed",
  "trusttoken",
  "type",
  "usemap",
  "valign",
  "value",
  "valuetype",
  "version",
  "virtualkeyboardpolicy",
  "vlink",
  "vspace",
  "webkitdirectory",
  "width",
  "wrap"
], g0 = [
  "accent-height",
  "accumulate",
  "additive",
  "alignment-baseline",
  "ascent",
  "attributename",
  "attributetype",
  "azimuth",
  "basefrequency",
  "baseline-shift",
  "begin",
  "bias",
  "by",
  "class",
  "clip",
  "clippathunits",
  "clip-path",
  "clip-rule",
  "color",
  "color-interpolation",
  "color-interpolation-filters",
  "color-profile",
  "color-rendering",
  "cx",
  "cy",
  "d",
  "dx",
  "dy",
  "diffuseconstant",
  "direction",
  "display",
  "divisor",
  "dominant-baseline",
  "dur",
  "edgemode",
  "elevation",
  "end",
  "fill",
  "fill-opacity",
  "fill-rule",
  "filter",
  "filterunits",
  "flood-color",
  "flood-opacity",
  "font-family",
  "font-size",
  "font-size-adjust",
  "font-stretch",
  "font-style",
  "font-variant",
  "font-weight",
  "fx",
  "fy",
  "g1",
  "g2",
  "glyph-name",
  "glyphref",
  "gradientunits",
  "gradienttransform",
  "height",
  "href",
  "id",
  "image-rendering",
  "in",
  "in2",
  "k",
  "k1",
  "k2",
  "k3",
  "k4",
  "kerning",
  "keypoints",
  "keysplines",
  "keytimes",
  "lang",
  "lengthadjust",
  "letter-spacing",
  "kernelmatrix",
  "kernelunitlength",
  "lighting-color",
  "local",
  "marker-end",
  "marker-mid",
  "marker-start",
  "markerheight",
  "markerunits",
  "markerwidth",
  "maskcontentunits",
  "maskunits",
  "max",
  "mask",
  "media",
  "method",
  "mode",
  "min",
  "name",
  "numoctaves",
  "offset",
  "operator",
  "opacity",
  "order",
  "orient",
  "orientation",
  "origin",
  "overflow",
  "paint-order",
  "path",
  "pathlength",
  "patterncontentunits",
  "patterntransform",
  "patternunits",
  "points",
  "preservealpha",
  "preserveaspectratio",
  "primitiveunits",
  "r",
  "rx",
  "ry",
  "radius",
  "refx",
  "refy",
  "repeatcount",
  "repeatdur",
  "restart",
  "result",
  "rotate",
  "scale",
  "seed",
  "shape-rendering",
  "specularconstant",
  "specularexponent",
  "spreadmethod",
  "startoffset",
  "stddeviation",
  "stitchtiles",
  "stop-color",
  "stop-opacity",
  "stroke-dasharray",
  "stroke-dashoffset",
  "stroke-linecap",
  "stroke-linejoin",
  "stroke-miterlimit",
  "stroke-opacity",
  "stroke",
  "stroke-width",
  "style",
  "surfacescale",
  "systemlanguage",
  "tabindex",
  "targetx",
  "targety",
  "transform",
  "transform-origin",
  "text-anchor",
  "text-decoration",
  "text-rendering",
  "textlength",
  "type",
  "u1",
  "u2",
  "unicode",
  "values",
  "viewbox",
  "visibility",
  "version",
  "vert-adv-y",
  "vert-origin-x",
  "vert-origin-y",
  "width",
  "word-spacing",
  "wrap",
  "writing-mode",
  "xchannelselector",
  "ychannelselector",
  "x",
  "x1",
  "x2",
  "xmlns",
  "y",
  "y1",
  "y2",
  "z",
  "zoomandpan"
], _0 = [
  "accent",
  "accentunder",
  "align",
  "bevelled",
  "close",
  "columnsalign",
  "columnlines",
  "columnspan",
  "denomalign",
  "depth",
  "dir",
  "display",
  "displaystyle",
  "encoding",
  "fence",
  "frame",
  "height",
  "href",
  "id",
  "largeop",
  "length",
  "linethickness",
  "lspace",
  "lquote",
  "mathbackground",
  "mathcolor",
  "mathsize",
  "mathvariant",
  "maxsize",
  "minsize",
  "movablelimits",
  "notation",
  "numalign",
  "open",
  "rowalign",
  "rowlines",
  "rowspacing",
  "rowspan",
  "rspace",
  "rquote",
  "scriptlevel",
  "scriptminsize",
  "scriptsizemultiplier",
  "selection",
  "separator",
  "separators",
  "stretchy",
  "subscriptshift",
  "supscriptshift",
  "symmetric",
  "voffset",
  "width",
  "xmlns"
];
p0([
  Object.fromEntries(m0.map((i) => [i, ["*"]])),
  Object.fromEntries(g0.map((i) => [i, ["svg:*"]])),
  Object.fromEntries(_0.map((i) => [i, ["math:*"]]))
]);
var v0 = /* @__PURE__ */ Ct('<span class="svelte-vvirtv"> </span>'), x0 = /* @__PURE__ */ Ct("<button><!> <div><!> <!></div></button>");
function Ou(i, e) {
  let t = Ee(e, "label", 3, ""), n = Ee(e, "show_label", 3, !1), r = Ee(e, "pending", 3, !1), s = Ee(e, "size", 3, "small"), a = Ee(e, "padded", 3, !0), o = Ee(e, "highlight", 3, !1), l = Ee(e, "disabled", 3, !1), c = Ee(e, "hasPopup", 3, !1), u = Ee(e, "color", 3, "var(--block-label-text-color)"), h = Ee(e, "transparent", 3, !1), d = Ee(e, "background", 3, "var(--block-background-fill)"), m = Ee(e, "border", 3, "transparent"), v = Mt(() => o() ? "var(--color-accent)" : u());
  var b = x0();
  let p, f;
  var x = pt(b);
  {
    var g = (y) => {
      var E = v0(), R = pt(E);
      Dt(() => Yt(R, t())), Ke(y, E);
    };
    At(x, (y) => {
      n() && y(g);
    });
  }
  var _ = st(x, 2);
  let T;
  var A = pt(_);
  mm(A, () => e.Icon, (y, E) => {
    E(y, {});
  });
  var M = st(A, 2);
  {
    var C = (y) => {
      var E = mr(), R = Kt(E);
      pm(R, () => e.children), Ke(y, E);
    };
    At(M, (y) => {
      e.children && y(C);
    });
  }
  Dt(() => {
    p = ri(b, 1, "icon-button svelte-vvirtv", null, p, {
      pending: r(),
      padded: a(),
      highlight: o(),
      transparent: h()
    }), b.disabled = l(), In(b, "aria-label", t()), In(b, "aria-haspopup", c()), In(b, "title", t()), f = Dn(b, "", f, {
      "--border-color": m(),
      color: !l() && P(v) ? P(v) : "var(--block-label-text-color)",
      "--bg-color": l() ? "auto" : d()
    }), T = ri(_, 1, "svelte-vvirtv", null, T, {
      "x-small": s() === "x-small",
      small: s() === "small",
      large: s() === "large",
      medium: s() === "medium"
    });
  }), ei("click", b, function(...y) {
    e.onclick?.apply(this, y);
  }), Ke(i, b);
}
kr(["click"]);
var b0 = /* @__PURE__ */ If('<svg width="100%" height="100%" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" stroke="currentColor" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;"><g transform="matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"><path d="M18,6L6.087,17.913" style="fill:none;fill-rule:nonzero;stroke-width:2px;"></path></g><path d="M4.364,4.364L19.636,19.636" style="fill:none;fill-rule:nonzero;stroke-width:2px;"></path></svg>');
function Bu(i) {
  var e = b0();
  Ke(i, e);
}
kr(["click"]);
function uo(i) {
  let e = ["", "k", "M", "G", "T", "P", "E", "Z"], t = 0;
  for (; i > 1e3 && t < e.length - 1; )
    i /= 1e3, t++;
  let n = e[t];
  return (Number.isInteger(i) ? i : i.toFixed(1)) + n;
}
function ku(i) {
  return Object.prototype.toString.call(i) === "[object Date]";
}
function pl(i, e, t, n) {
  if (typeof t == "number" || ku(t)) {
    const r = n - t, s = (t - e) / (i.dt || 1 / 60), a = i.opts.stiffness * r, o = i.opts.damping * s, l = (a - o) * i.inv_mass, c = (s + l) * i.dt;
    return Math.abs(c) < i.opts.precision && Math.abs(r) < i.opts.precision ? n : (i.settled = !1, ku(t) ? new Date(t.getTime() + c) : t + c);
  } else {
    if (Array.isArray(t))
      return t.map(
        (r, s) => (
          // @ts-ignore
          pl(i, e[s], t[s], n[s])
        )
      );
    if (typeof t == "object") {
      const r = {};
      for (const s in t)
        r[s] = pl(i, e[s], t[s], n[s]);
      return r;
    } else
      throw new Error(`Cannot spring ${typeof t} values`);
  }
}
function Hu(i, e = {}) {
  const t = Ts(i), { stiffness: n = 0.15, damping: r = 0.8, precision: s = 0.01 } = e;
  let a, o, l, c = (
    /** @type {T} */
    i
  ), u = (
    /** @type {T | undefined} */
    i
  ), h = 1, d = 0, m = !1;
  function v(p, f = {}) {
    u = p;
    const x = l = {};
    return i == null || f.hard || b.stiffness >= 1 && b.damping >= 1 ? (m = !0, a = Mn.now(), c = p, t.set(i = u), Promise.resolve()) : (f.soft && (d = 1 / ((f.soft === !0 ? 0.5 : +f.soft) * 60), h = 0), o || (a = Mn.now(), m = !1, o = _m((g) => {
      if (m)
        return m = !1, o = null, !1;
      h = Math.min(h + d, 1);
      const _ = Math.min(g - a, 1e3 / 30), T = {
        inv_mass: h,
        opts: b,
        settled: !0,
        dt: _ * 60 / 1e3
      }, A = pl(T, c, i, u);
      return a = g, c = /** @type {T} */
      i, t.set(i = /** @type {T} */
      A), T.settled && (o = null), !T.settled;
    })), new Promise((g) => {
      o.promise.then(() => {
        x === l && g();
      });
    }));
  }
  const b = {
    set: v,
    update: (p, f) => v(p(
      /** @type {T} */
      u,
      /** @type {T} */
      i
    ), f),
    subscribe: t.subscribe,
    stiffness: n,
    damping: r,
    precision: s
  };
  return b;
}
var E0 = /* @__PURE__ */ Ct('<div><svg viewBox="-1200 -1200 3000 3000" fill="none" xmlns="http://www.w3.org/2000/svg" class="svelte-m6d381"><g><path d="M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z" fill="#FF7C00" fill-opacity="0.4" class="svelte-m6d381"></path><path d="M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z" fill="#FF7C00" class="svelte-m6d381"></path><path d="M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z" fill="#FF7C00" fill-opacity="0.4" class="svelte-m6d381"></path><path d="M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z" fill="#FF7C00" class="svelte-m6d381"></path></g><g><path d="M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z" fill="#FF7C00" fill-opacity="0.4" class="svelte-m6d381"></path><path d="M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z" fill="#FF7C00" class="svelte-m6d381"></path><path d="M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z" fill="#FF7C00" fill-opacity="0.4" class="svelte-m6d381"></path><path d="M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z" fill="#FF7C00" class="svelte-m6d381"></path></g></svg></div>');
function y0(i, e) {
  zr(e, !0);
  const t = () => Kc(l, "$top", r), n = () => Kc(c, "$bottom", r), [r, s] = am();
  var a = this && this.__awaiter || function(g, _, T, A) {
    function M(C) {
      return C instanceof T ? C : new T(function(y) {
        y(C);
      });
    }
    return new (T || (T = Promise))(function(C, y) {
      function E(G) {
        try {
          q(A.next(G));
        } catch (V) {
          y(V);
        }
      }
      function R(G) {
        try {
          q(A.throw(G));
        } catch (V) {
          y(V);
        }
      }
      function q(G) {
        G.done ? C(G.value) : M(G.value).then(E, R);
      }
      q((A = A.apply(g, _ || [])).next());
    });
  };
  let o = Ee(e, "margin", 3, !0);
  const l = Hu([0, 0]), c = Hu([0, 0]);
  let u = wt(!1);
  function h() {
    return a(this, void 0, void 0, function* () {
      yield Promise.all([l.set([125, 140]), c.set([-125, -140])]), yield Promise.all([l.set([-125, 140]), c.set([125, -140])]), yield Promise.all([l.set([-125, 0]), c.set([125, -0])]), yield Promise.all([l.set([125, 0]), c.set([-125, 0])]);
    });
  }
  function d() {
    return a(this, void 0, void 0, function* () {
      yield h(), P(u) || d();
    });
  }
  function m() {
    return a(this, void 0, void 0, function* () {
      yield Promise.all([l.set([125, 0]), c.set([-125, 0])]), d();
    });
  }
  Lt(() => (m(), () => {
    Te(u, !0);
  }));
  var v = E0();
  let b;
  var p = pt(v), f = pt(p), x = st(f);
  Dt(() => {
    b = ri(v, 1, "svelte-m6d381", null, b, { margin: o() }), Dn(f, `transform: translate(${t()[0] ?? ""}px, ${t()[1] ?? ""}px);`), Dn(x, `transform: translate(${n()[0] ?? ""}px, ${n()[1] ?? ""}px);`);
  }), Ke(i, v), Hr(), s();
}
var S0 = function(i, e, t, n) {
  function r(s) {
    return s instanceof t ? s : new t(function(a) {
      a(s);
    });
  }
  return new (t || (t = Promise))(function(s, a) {
    function o(u) {
      try {
        c(n.next(u));
      } catch (h) {
        a(h);
      }
    }
    function l(u) {
      try {
        c(n.throw(u));
      } catch (h) {
        a(h);
      }
    }
    function c(u) {
      u.done ? s(u.value) : r(u.value).then(o, l);
    }
    c((n = n.apply(i, e || [])).next());
  });
};
let Hs = [], ho = !1;
const M0 = typeof window < "u", bd = M0 ? window.requestAnimationFrame : (i) => {
};
function A0(i) {
  return S0(this, arguments, void 0, function* (e, t = !0) {
    if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && t !== !0)) {
      if (Hs.push(e), !ho) ho = !0;
      else return;
      yield Tf(), bd(() => {
        let n = [0, 0];
        for (let r = 0; r < Hs.length; r++) {
          const a = Hs[r].getBoundingClientRect();
          (r === 0 || a.top + window.scrollY <= n[0]) && (n[0] = a.top + window.scrollY, n[1] = r);
        }
        window.scrollTo({ top: n[0] - 20, behavior: "smooth" }), ho = !1, Hs = [];
      });
    }
  });
}
var T0 = /* @__PURE__ */ Ct('<div class="validation-error svelte-124hqw6"> <button class="svelte-124hqw6"><!></button></div>'), w0 = /* @__PURE__ */ Ct('<div class="eta-bar svelte-124hqw6"></div>'), D0 = /* @__PURE__ */ Ct("<!> ", 1), R0 = /* @__PURE__ */ Ct("<!> <!> <!> <!>", 1), C0 = /* @__PURE__ */ Ct('<div class="progress-level svelte-124hqw6"><div class="progress-level-inner svelte-124hqw6"><!></div> <div class="progress-bar-wrap svelte-124hqw6"><div class="progress-bar svelte-124hqw6"></div></div></div>'), P0 = /* @__PURE__ */ Ct('<p class="loading svelte-124hqw6"> </p> <!>', 1), L0 = /* @__PURE__ */ Ct("<!> <div><!> <!></div> <!> <!>", 1), I0 = /* @__PURE__ */ Ct('<div class="clear-status svelte-124hqw6"><!></div> <span class="error svelte-124hqw6"> </span> <!>', 1), F0 = /* @__PURE__ */ Ct('<div data-testid="status-tracker"><!> <!></div>');
function N0(i, e) {
  zr(e, !0);
  let t = Ee(e, "eta", 7, null), n = Ee(e, "scroll_to_output", 3, !1), r = Ee(e, "timer", 3, !0), s = Ee(e, "show_progress", 3, "full"), a = Ee(e, "message", 3, null), o = Ee(e, "progress", 3, null), l = Ee(e, "variant", 3, "default"), c = Ee(e, "loading_text", 3, "Loading..."), u = Ee(e, "absolute", 3, !0), h = Ee(e, "translucent", 3, !1), d = Ee(e, "border", 3, !1), m = Ee(e, "validation_error", 7, null), v = Ee(e, "show_validation_error", 3, !0), b = Ee(e, "type", 3, null), p, f = !1, x = wt(0), g = wt(null), _ = wt(null), T = wt(!1), A = wt(null);
  const M = Mt(() => b() === "input" || !e.status || e.status === "complete" || s() === "hidden" || e.status == "streaming" || !!(v() && m()));
  let C = wt(0);
  const y = Mt(() => P(_) === null || P(_) <= 0 || !P(C) ? 0 : Math.min(P(C) / P(_), 1)), E = Mt(() => P(C).toFixed(1));
  let R = Mt(() => o() == null);
  function q() {
    bd(() => {
      Te(C, (performance.now() - P(x)) / 1e3), f && q();
    });
  }
  let G = Mt(() => {
    let Q = null;
    o() != null ? Q = o().map((he) => {
      if (he.index != null && he.length != null)
        return he.index / he.length;
      if (he.progress != null)
        return he.progress;
    }) : Q = null;
    let re, ne = "";
    return Q ? (re = Q[Q.length - 1], re === 0 ? ne = "0" : ne = "150ms") : re = void 0, {
      progress_level: Q,
      last_progress_level: re,
      progress_bar_transition: ne
    };
  });
  function V() {
    f || (Te(g, Te(A, null), !0), Te(x, performance.now(), !0), f = !0, q());
  }
  function B() {
    Te(g, Te(A, null), !0), f && (f = !1);
  }
  Lt(() => {
    e.status === "pending" ? V() : Nt(() => {
      B();
    });
  }), Lt(() => {
    p && n() && (e.status === "pending" || e.status === "complete") && A0(p, e.autoscroll);
  }), Lt(() => {
    t() === null && t(P(g)), t() != null && P(g) !== t() && (Te(_, (performance.now() - P(x)) / 1e3 + t()), Te(A, P(_).toFixed(1), !0), Te(g, t(), !0));
  });
  function U() {
    Te(T, !1);
  }
  Lt(() => {
    Nt(() => {
      U();
    }), e.status === "error" && a() && Te(T, !0);
  });
  var Y = F0();
  let z, ie;
  var oe = pt(Y);
  {
    var ce = (Q) => {
      var re = T0(), ne = pt(re), he = st(ne), me = pt(he);
      {
        let we = Mt(() => e.i18n ? e.i18n("common.clear") : "Clear");
        Ou(me, {
          get Icon() {
            return Bu;
          },
          get label() {
            return P(we);
          },
          disabled: !1,
          size: "x-small",
          background: "var(--background-fill-primary)",
          color: "var(--error-background-text)",
          border: "var(--border-color-primary)",
          onclick: () => m(null)
        });
      }
      Dt(() => Yt(ne, `${m() ?? ""} `)), Ke(Q, re);
    };
    At(oe, (Q) => {
      m() && v() && Q(ce);
    });
  }
  var ye = st(oe, 2);
  {
    var je = (Q) => {
      var re = L0(), ne = Kt(re);
      {
        var he = (S) => {
          var k = w0();
          let J;
          Dt(() => J = Dn(k, "", J, {
            transform: `translateX(${(P(y) || 0) * 100 - 100}%)`
          })), Ke(S, k);
        };
        At(ne, (S) => {
          l() === "default" && P(R) && s() === "full" && S(he);
        });
      }
      var me = st(ne, 2);
      let we;
      var qe = pt(me);
      {
        var Pe = (S) => {
          var k = mr(), J = Kt(k);
          tl(J, 17, o, $c, (te, $) => {
            var be = mr(), fe = Kt(be);
            {
              var ge = (He) => {
                var se = D0(), _e = Kt(se);
                {
                  var Re = (Be) => {
                    var Oe = Xn();
                    Dt((et, I) => Yt(Oe, `${et ?? ""}/${I ?? ""}`), [
                      () => uo(P($).index || 0),
                      () => uo(P($).length)
                    ]), Ke(Be, Oe);
                  }, Ce = (Be) => {
                    var Oe = Xn();
                    Dt((et) => Yt(Oe, et), [() => uo(P($).index || 0)]), Ke(Be, Oe);
                  };
                  At(_e, (Be) => {
                    P($).length != null ? Be(Re) : Be(Ce, -1);
                  });
                }
                var pe = st(_e);
                Dt(() => Yt(pe, ` ${P($).unit ?? ""} |  `)), Ke(He, se);
              };
              At(fe, (He) => {
                P($).index != null && He(ge);
              });
            }
            Ke(te, be);
          }), Ke(S, k);
        }, Je = (S) => {
          var k = Xn();
          Dt(() => Yt(k, `queue: ${e.queue_position + 1}/${e.queue_size ?? ""} |`)), Ke(S, k);
        }, F = (S) => {
          var k = Xn("processing |");
          Ke(S, k);
        };
        At(qe, (S) => {
          o() ? S(Pe) : e.queue_position !== null && e.queue_size !== void 0 && e.queue_position >= 0 ? S(Je, 1) : e.queue_position === 0 && S(F, 2);
        });
      }
      var Gt = st(qe, 2);
      {
        var $e = (S) => {
          var k = Xn();
          Dt(() => Yt(k, `${P(E) ?? ""}${t() ? `/${P(A)}` : ""}s`)), Ke(S, k);
        };
        At(Gt, (S) => {
          r() && S($e);
        });
      }
      var Ze = st(me, 2);
      {
        var Le = (S) => {
          var k = C0(), J = pt(k), te = pt(J);
          {
            var $ = (He) => {
              var se = mr(), _e = Kt(se);
              tl(_e, 17, o, $c, (Re, Ce, pe) => {
                var Be = mr(), Oe = Kt(Be);
                {
                  var et = (I) => {
                    var ue = R0(), Z = Kt(ue);
                    {
                      var ee = (ke) => {
                        var it = Xn(" /");
                        Ke(ke, it);
                      };
                      At(Z, (ke) => {
                        pe !== 0 && ke(ee);
                      });
                    }
                    var H = st(Z, 2);
                    {
                      var X = (ke) => {
                        var it = Xn();
                        Dt(() => Yt(it, P(Ce).desc)), Ke(ke, it);
                      };
                      At(H, (ke) => {
                        P(Ce).desc != null && ke(X);
                      });
                    }
                    var ae = st(H, 2);
                    {
                      var xe = (ke) => {
                        var it = Xn("-");
                        Ke(ke, it);
                      };
                      At(ae, (ke) => {
                        P(Ce).desc != null && P(G).progress_level && P(G).progress_level[pe] != null && ke(xe);
                      });
                    }
                    var Ne = st(ae, 2);
                    {
                      var Fe = (ke) => {
                        var it = Xn();
                        Dt((Et) => Yt(it, `${Et ?? ""}%`), [
                          () => (100 * (P(G).progress_level[pe] || 0)).toFixed(1)
                        ]), Ke(ke, it);
                      };
                      At(Ne, (ke) => {
                        P(G).progress_level != null && ke(Fe);
                      });
                    }
                    Ke(I, ue);
                  };
                  At(Oe, (I) => {
                    (P(Ce).desc != null || P(G).progress_level && P(G).progress_level[pe] != null) && I(et);
                  });
                }
                Ke(Re, Be);
              }), Ke(He, se);
            };
            At(te, (He) => {
              o() != null && He($);
            });
          }
          var be = st(J, 2), fe = pt(be);
          let ge;
          Dt(() => ge = Dn(fe, "", ge, {
            width: `${P(G).last_progress_level * 100}%`,
            transition: P(G).progress_bar_transition
          })), Ke(S, k);
        }, ht = (S) => {
          {
            let k = Mt(() => l() === "default");
            y0(S, {
              get margin() {
                return P(k);
              }
            });
          }
        };
        At(Ze, (S) => {
          P(G).last_progress_level != null ? S(Le) : s() === "full" && S(ht, 1);
        });
      }
      var Ie = st(Ze, 2);
      {
        var D = (S) => {
          var k = P0(), J = Kt(k), te = pt(J), $ = st(J, 2);
          nl($, e, "additional-loading-text", {}), Dt(() => Yt(te, c())), Ke(S, k);
        };
        At(Ie, (S) => {
          r() || S(D);
        });
      }
      Dt(() => we = ri(me, 1, "progress-text svelte-124hqw6", null, we, {
        "meta-text-center": l() === "center",
        "meta-text": l() === "default"
      })), Ke(Q, re);
    }, K = (Q) => {
      var re = I0(), ne = Kt(re), he = pt(ne);
      {
        let Pe = Mt(() => e.i18n("common.clear"));
        Ou(he, {
          get Icon() {
            return Bu;
          },
          get label() {
            return P(Pe);
          },
          disabled: !1,
          $$events: {
            click: () => {
              e.on_clear_status?.();
            }
          }
        });
      }
      var me = st(ne, 2), we = pt(me), qe = st(me, 2);
      nl(qe, e, "error", {}), Dt((Pe) => Yt(we, Pe), [() => e.i18n("common.error")]), Ke(Q, re);
    };
    At(ye, (Q) => {
      e.status === "pending" ? Q(je) : e.status === "error" && Q(K, 1);
    });
  }
  Ha(Y, (Q) => p = Q, () => p), Dt(() => {
    z = ri(Y, 1, `wrap ${l() ?? ""} ${s() ?? ""}`, "svelte-124hqw6", z, {
      "no-click": m() && v(),
      hide: P(M),
      translucent: l() === "center" && (e.status === "pending" || e.status === "error") || h() || s() === "minimal" || m(),
      generating: e.status === "generating" && s() === "full",
      border: d()
    }), ie = Dn(Y, "", ie, {
      position: u() ? "absolute" : "static",
      padding: u() ? "0" : "var(--size-8) 0"
    });
  }), Ke(i, Y), Hr();
}
kr(["touchstart", "touchmove", "touchend", "click", "keydown"]);
const yc = "170", xr = { ROTATE: 0, DOLLY: 1, PAN: 2 }, gr = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, U0 = 0, zu = 1, O0 = 2, Ed = 1, B0 = 2, Jn = 3, si = 0, sn = 1, Fn = 2, Mi = 0, br = 1, Gu = 2, Vu = 3, Wu = 4, k0 = 5, Oi = 100, H0 = 101, z0 = 102, G0 = 103, V0 = 104, W0 = 200, X0 = 201, j0 = 202, q0 = 203, ml = 204, gl = 205, Y0 = 206, Z0 = 207, K0 = 208, $0 = 209, J0 = 210, Q0 = 211, ev = 212, tv = 213, nv = 214, _l = 0, vl = 1, xl = 2, Dr = 3, bl = 4, El = 5, yl = 6, Sl = 7, yd = 0, iv = 1, rv = 2, Ai = 0, sv = 1, av = 2, ov = 3, lv = 4, cv = 5, uv = 6, hv = 7, Xu = "attached", fv = "detached", Sd = 300, Rr = 301, Cr = 302, Ml = 303, Al = 304, ja = 306, Pr = 1e3, bi = 1001, La = 1002, Jt = 1003, Md = 1004, fs = 1005, un = 1006, xa = 1007, ti = 1008, ai = 1009, Ad = 1010, Td = 1011, bs = 1012, Sc = 1013, Wi = 1014, wn = 1015, Cs = 1016, Mc = 1017, Ac = 1018, Lr = 1020, wd = 35902, Dd = 1021, Rd = 1022, _n = 1023, Cd = 1024, Pd = 1025, Er = 1026, Ir = 1027, Tc = 1028, wc = 1029, Ld = 1030, Dc = 1031, Rc = 1033, ba = 33776, Ea = 33777, ya = 33778, Sa = 33779, Tl = 35840, wl = 35841, Dl = 35842, Rl = 35843, Cl = 36196, Pl = 37492, Ll = 37496, Il = 37808, Fl = 37809, Nl = 37810, Ul = 37811, Ol = 37812, Bl = 37813, kl = 37814, Hl = 37815, zl = 37816, Gl = 37817, Vl = 37818, Wl = 37819, Xl = 37820, jl = 37821, Ma = 36492, ql = 36494, Yl = 36495, Id = 36283, Zl = 36284, Kl = 36285, $l = 36286, Es = 2300, ys = 2301, fo = 2302, ju = 2400, qu = 2401, Yu = 2402, dv = 2500, pv = 0, Fd = 1, Jl = 2, mv = 3200, gv = 3201, Nd = 0, _v = 1, vi = "", Ut = "srgb", en = "srgb-linear", qa = "linear", mt = "srgb", Qi = 7680, Zu = 519, vv = 512, xv = 513, bv = 514, Ud = 515, Ev = 516, yv = 517, Sv = 518, Mv = 519, Ql = 35044, Ku = "300 es", ni = 2e3, Ia = 2001;
class Yi {
  addEventListener(e, t) {
    this._listeners === void 0 && (this._listeners = {});
    const n = this._listeners;
    n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t);
  }
  hasEventListener(e, t) {
    if (this._listeners === void 0) return !1;
    const n = this._listeners;
    return n[e] !== void 0 && n[e].indexOf(t) !== -1;
  }
  removeEventListener(e, t) {
    if (this._listeners === void 0) return;
    const r = this._listeners[e];
    if (r !== void 0) {
      const s = r.indexOf(t);
      s !== -1 && r.splice(s, 1);
    }
  }
  dispatchEvent(e) {
    if (this._listeners === void 0) return;
    const n = this._listeners[e.type];
    if (n !== void 0) {
      e.target = this;
      const r = n.slice(0);
      for (let s = 0, a = r.length; s < a; s++)
        r[s].call(this, e);
      e.target = null;
    }
  }
}
const Wt = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
let $u = 1234567;
const gs = Math.PI / 180, Fr = 180 / Math.PI;
function Rn() {
  const i = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0;
  return (Wt[i & 255] + Wt[i >> 8 & 255] + Wt[i >> 16 & 255] + Wt[i >> 24 & 255] + "-" + Wt[e & 255] + Wt[e >> 8 & 255] + "-" + Wt[e >> 16 & 15 | 64] + Wt[e >> 24 & 255] + "-" + Wt[t & 63 | 128] + Wt[t >> 8 & 255] + "-" + Wt[t >> 16 & 255] + Wt[t >> 24 & 255] + Wt[n & 255] + Wt[n >> 8 & 255] + Wt[n >> 16 & 255] + Wt[n >> 24 & 255]).toLowerCase();
}
function Vt(i, e, t) {
  return Math.max(e, Math.min(t, i));
}
function Cc(i, e) {
  return (i % e + e) % e;
}
function Av(i, e, t, n, r) {
  return n + (i - e) * (r - n) / (t - e);
}
function Tv(i, e, t) {
  return i !== e ? (t - i) / (e - i) : 0;
}
function _s(i, e, t) {
  return (1 - t) * i + t * e;
}
function wv(i, e, t, n) {
  return _s(i, e, 1 - Math.exp(-t * n));
}
function Dv(i, e = 1) {
  return e - Math.abs(Cc(i, e * 2) - e);
}
function Rv(i, e, t) {
  return i <= e ? 0 : i >= t ? 1 : (i = (i - e) / (t - e), i * i * (3 - 2 * i));
}
function Cv(i, e, t) {
  return i <= e ? 0 : i >= t ? 1 : (i = (i - e) / (t - e), i * i * i * (i * (i * 6 - 15) + 10));
}
function Pv(i, e) {
  return i + Math.floor(Math.random() * (e - i + 1));
}
function Lv(i, e) {
  return i + Math.random() * (e - i);
}
function Iv(i) {
  return i * (0.5 - Math.random());
}
function Fv(i) {
  i !== void 0 && ($u = i);
  let e = $u += 1831565813;
  return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
}
function Nv(i) {
  return i * gs;
}
function Uv(i) {
  return i * Fr;
}
function Ov(i) {
  return (i & i - 1) === 0 && i !== 0;
}
function Bv(i) {
  return Math.pow(2, Math.ceil(Math.log(i) / Math.LN2));
}
function kv(i) {
  return Math.pow(2, Math.floor(Math.log(i) / Math.LN2));
}
function Hv(i, e, t, n, r) {
  const s = Math.cos, a = Math.sin, o = s(t / 2), l = a(t / 2), c = s((e + n) / 2), u = a((e + n) / 2), h = s((e - n) / 2), d = a((e - n) / 2), m = s((n - e) / 2), v = a((n - e) / 2);
  switch (r) {
    case "XYX":
      i.set(o * u, l * h, l * d, o * c);
      break;
    case "YZY":
      i.set(l * d, o * u, l * h, o * c);
      break;
    case "ZXZ":
      i.set(l * h, l * d, o * u, o * c);
      break;
    case "XZX":
      i.set(o * u, l * v, l * m, o * c);
      break;
    case "YXY":
      i.set(l * m, o * u, l * v, o * c);
      break;
    case "ZYZ":
      i.set(l * v, l * m, o * u, o * c);
      break;
    default:
      console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + r);
  }
}
function An(i, e) {
  switch (e.constructor) {
    case Float32Array:
      return i;
    case Uint32Array:
      return i / 4294967295;
    case Uint16Array:
      return i / 65535;
    case Uint8Array:
      return i / 255;
    case Int32Array:
      return Math.max(i / 2147483647, -1);
    case Int16Array:
      return Math.max(i / 32767, -1);
    case Int8Array:
      return Math.max(i / 127, -1);
    default:
      throw new Error("Invalid component type.");
  }
}
function ft(i, e) {
  switch (e.constructor) {
    case Float32Array:
      return i;
    case Uint32Array:
      return Math.round(i * 4294967295);
    case Uint16Array:
      return Math.round(i * 65535);
    case Uint8Array:
      return Math.round(i * 255);
    case Int32Array:
      return Math.round(i * 2147483647);
    case Int16Array:
      return Math.round(i * 32767);
    case Int8Array:
      return Math.round(i * 127);
    default:
      throw new Error("Invalid component type.");
  }
}
const Od = {
  DEG2RAD: gs,
  RAD2DEG: Fr,
  generateUUID: Rn,
  clamp: Vt,
  euclideanModulo: Cc,
  mapLinear: Av,
  inverseLerp: Tv,
  lerp: _s,
  damp: wv,
  pingpong: Dv,
  smoothstep: Rv,
  smootherstep: Cv,
  randInt: Pv,
  randFloat: Lv,
  randFloatSpread: Iv,
  seededRandom: Fv,
  degToRad: Nv,
  radToDeg: Uv,
  isPowerOfTwo: Ov,
  ceilPowerOfTwo: Bv,
  floorPowerOfTwo: kv,
  setQuaternionFromProperEuler: Hv,
  normalize: ft,
  denormalize: An
};
class ze {
  constructor(e = 0, t = 0) {
    ze.prototype.isVector2 = !0, this.x = e, this.y = t;
  }
  get width() {
    return this.x;
  }
  set width(e) {
    this.x = e;
  }
  get height() {
    return this.y;
  }
  set height(e) {
    this.y = e;
  }
  set(e, t) {
    return this.x = e, this.y = t, this;
  }
  setScalar(e) {
    return this.x = e, this.y = e, this;
  }
  setX(e) {
    return this.x = e, this;
  }
  setY(e) {
    return this.y = e, this;
  }
  setComponent(e, t) {
    switch (e) {
      case 0:
        this.x = t;
        break;
      case 1:
        this.y = t;
        break;
      default:
        throw new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this;
  }
  divide(e) {
    return this.x /= e.x, this.y /= e.y, this;
  }
  divideScalar(e) {
    return this.multiplyScalar(1 / e);
  }
  applyMatrix3(e) {
    const t = this.x, n = this.y, r = e.elements;
    return this.x = r[0] * t + r[3] * n + r[6], this.y = r[1] * t + r[4] * n + r[7], this;
  }
  min(e) {
    return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this;
  }
  max(e) {
    return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this;
  }
  clamp(e, t) {
    return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this;
  }
  clampLength(e, t) {
    const n = this.length();
    return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this;
  }
  dot(e) {
    return this.x * e.x + this.y * e.y;
  }
  cross(e) {
    return this.x * e.y - this.y * e.x;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  angle() {
    return Math.atan2(-this.y, -this.x) + Math.PI;
  }
  angleTo(e) {
    const t = Math.sqrt(this.lengthSq() * e.lengthSq());
    if (t === 0) return Math.PI / 2;
    const n = this.dot(e) / t;
    return Math.acos(Vt(n, -1, 1));
  }
  distanceTo(e) {
    return Math.sqrt(this.distanceToSquared(e));
  }
  distanceToSquared(e) {
    const t = this.x - e.x, n = this.y - e.y;
    return t * t + n * n;
  }
  manhattanDistanceTo(e) {
    return Math.abs(this.x - e.x) + Math.abs(this.y - e.y);
  }
  setLength(e) {
    return this.normalize().multiplyScalar(e);
  }
  lerp(e, t) {
    return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this;
  }
  lerpVectors(e, t, n) {
    return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this;
  }
  equals(e) {
    return e.x === this.x && e.y === this.y;
  }
  fromArray(e, t = 0) {
    return this.x = e[t], this.y = e[t + 1], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.x, e[t + 1] = this.y, e;
  }
  fromBufferAttribute(e, t) {
    return this.x = e.getX(t), this.y = e.getY(t), this;
  }
  rotateAround(e, t) {
    const n = Math.cos(t), r = Math.sin(t), s = this.x - e.x, a = this.y - e.y;
    return this.x = s * n - a * r + e.x, this.y = s * r + a * n + e.y, this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y;
  }
}
class We {
  constructor(e, t, n, r, s, a, o, l, c) {
    We.prototype.isMatrix3 = !0, this.elements = [
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ], e !== void 0 && this.set(e, t, n, r, s, a, o, l, c);
  }
  set(e, t, n, r, s, a, o, l, c) {
    const u = this.elements;
    return u[0] = e, u[1] = r, u[2] = o, u[3] = t, u[4] = s, u[5] = l, u[6] = n, u[7] = a, u[8] = c, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ), this;
  }
  copy(e) {
    const t = this.elements, n = e.elements;
    return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this;
  }
  extractBasis(e, t, n) {
    return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this;
  }
  setFromMatrix4(e) {
    const t = e.elements;
    return this.set(
      t[0],
      t[4],
      t[8],
      t[1],
      t[5],
      t[9],
      t[2],
      t[6],
      t[10]
    ), this;
  }
  multiply(e) {
    return this.multiplyMatrices(this, e);
  }
  premultiply(e) {
    return this.multiplyMatrices(e, this);
  }
  multiplyMatrices(e, t) {
    const n = e.elements, r = t.elements, s = this.elements, a = n[0], o = n[3], l = n[6], c = n[1], u = n[4], h = n[7], d = n[2], m = n[5], v = n[8], b = r[0], p = r[3], f = r[6], x = r[1], g = r[4], _ = r[7], T = r[2], A = r[5], M = r[8];
    return s[0] = a * b + o * x + l * T, s[3] = a * p + o * g + l * A, s[6] = a * f + o * _ + l * M, s[1] = c * b + u * x + h * T, s[4] = c * p + u * g + h * A, s[7] = c * f + u * _ + h * M, s[2] = d * b + m * x + v * T, s[5] = d * p + m * g + v * A, s[8] = d * f + m * _ + v * M, this;
  }
  multiplyScalar(e) {
    const t = this.elements;
    return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, this;
  }
  determinant() {
    const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], a = e[4], o = e[5], l = e[6], c = e[7], u = e[8];
    return t * a * u - t * o * c - n * s * u + n * o * l + r * s * c - r * a * l;
  }
  invert() {
    const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], a = e[4], o = e[5], l = e[6], c = e[7], u = e[8], h = u * a - o * c, d = o * l - u * s, m = c * s - a * l, v = t * h + n * d + r * m;
    if (v === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
    const b = 1 / v;
    return e[0] = h * b, e[1] = (r * c - u * n) * b, e[2] = (o * n - r * a) * b, e[3] = d * b, e[4] = (u * t - r * l) * b, e[5] = (r * s - o * t) * b, e[6] = m * b, e[7] = (n * l - c * t) * b, e[8] = (a * t - n * s) * b, this;
  }
  transpose() {
    let e;
    const t = this.elements;
    return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this;
  }
  getNormalMatrix(e) {
    return this.setFromMatrix4(e).invert().transpose();
  }
  transposeIntoArray(e) {
    const t = this.elements;
    return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this;
  }
  setUvTransform(e, t, n, r, s, a, o) {
    const l = Math.cos(s), c = Math.sin(s);
    return this.set(
      n * l,
      n * c,
      -n * (l * a + c * o) + a + e,
      -r * c,
      r * l,
      -r * (-c * a + l * o) + o + t,
      0,
      0,
      1
    ), this;
  }
  //
  scale(e, t) {
    return this.premultiply(po.makeScale(e, t)), this;
  }
  rotate(e) {
    return this.premultiply(po.makeRotation(-e)), this;
  }
  translate(e, t) {
    return this.premultiply(po.makeTranslation(e, t)), this;
  }
  // for 2D Transforms
  makeTranslation(e, t) {
    return e.isVector2 ? this.set(
      1,
      0,
      e.x,
      0,
      1,
      e.y,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      e,
      0,
      1,
      t,
      0,
      0,
      1
    ), this;
  }
  makeRotation(e) {
    const t = Math.cos(e), n = Math.sin(e);
    return this.set(
      t,
      -n,
      0,
      n,
      t,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(e, t) {
    return this.set(
      e,
      0,
      0,
      0,
      t,
      0,
      0,
      0,
      1
    ), this;
  }
  //
  equals(e) {
    const t = this.elements, n = e.elements;
    for (let r = 0; r < 9; r++)
      if (t[r] !== n[r]) return !1;
    return !0;
  }
  fromArray(e, t = 0) {
    for (let n = 0; n < 9; n++)
      this.elements[n] = e[n + t];
    return this;
  }
  toArray(e = [], t = 0) {
    const n = this.elements;
    return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e;
  }
  clone() {
    return new this.constructor().fromArray(this.elements);
  }
}
const po = /* @__PURE__ */ new We();
function Bd(i) {
  for (let e = i.length - 1; e >= 0; --e)
    if (i[e] >= 65535) return !0;
  return !1;
}
function Ss(i) {
  return document.createElementNS("http://www.w3.org/1999/xhtml", i);
}
function zv() {
  const i = Ss("canvas");
  return i.style.display = "block", i;
}
const Ju = {};
function ds(i) {
  i in Ju || (Ju[i] = !0, console.warn(i));
}
function Gv(i, e, t) {
  return new Promise(function(n, r) {
    function s() {
      switch (i.clientWaitSync(e, i.SYNC_FLUSH_COMMANDS_BIT, 0)) {
        case i.WAIT_FAILED:
          r();
          break;
        case i.TIMEOUT_EXPIRED:
          setTimeout(s, t);
          break;
        default:
          n();
      }
    }
    setTimeout(s, t);
  });
}
function Vv(i) {
  const e = i.elements;
  e[2] = 0.5 * e[2] + 0.5 * e[3], e[6] = 0.5 * e[6] + 0.5 * e[7], e[10] = 0.5 * e[10] + 0.5 * e[11], e[14] = 0.5 * e[14] + 0.5 * e[15];
}
function Wv(i) {
  const e = i.elements;
  e[11] === -1 ? (e[10] = -e[10] - 1, e[14] = -e[14]) : (e[10] = -e[10], e[14] = -e[14] + 1);
}
const nt = {
  enabled: !0,
  workingColorSpace: en,
  /**
   * Implementations of supported color spaces.
   *
   * Required:
   *	- primaries: chromaticity coordinates [ rx ry gx gy bx by ]
   *	- whitePoint: reference white [ x y ]
   *	- transfer: transfer function (pre-defined)
   *	- toXYZ: Matrix3 RGB to XYZ transform
   *	- fromXYZ: Matrix3 XYZ to RGB transform
   *	- luminanceCoefficients: RGB luminance coefficients
   *
   * Optional:
   *  - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }
   *  - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
   *
   * Reference:
   * - https://www.russellcottrell.com/photo/matrixCalculator.htm
   */
  spaces: {},
  convert: function(i, e, t) {
    return this.enabled === !1 || e === t || !e || !t || (this.spaces[e].transfer === mt && (i.r = ii(i.r), i.g = ii(i.g), i.b = ii(i.b)), this.spaces[e].primaries !== this.spaces[t].primaries && (i.applyMatrix3(this.spaces[e].toXYZ), i.applyMatrix3(this.spaces[t].fromXYZ)), this.spaces[t].transfer === mt && (i.r = yr(i.r), i.g = yr(i.g), i.b = yr(i.b))), i;
  },
  fromWorkingColorSpace: function(i, e) {
    return this.convert(i, this.workingColorSpace, e);
  },
  toWorkingColorSpace: function(i, e) {
    return this.convert(i, e, this.workingColorSpace);
  },
  getPrimaries: function(i) {
    return this.spaces[i].primaries;
  },
  getTransfer: function(i) {
    return i === vi ? qa : this.spaces[i].transfer;
  },
  getLuminanceCoefficients: function(i, e = this.workingColorSpace) {
    return i.fromArray(this.spaces[e].luminanceCoefficients);
  },
  define: function(i) {
    Object.assign(this.spaces, i);
  },
  // Internal APIs
  _getMatrix: function(i, e, t) {
    return i.copy(this.spaces[e].toXYZ).multiply(this.spaces[t].fromXYZ);
  },
  _getDrawingBufferColorSpace: function(i) {
    return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace;
  },
  _getUnpackColorSpace: function(i = this.workingColorSpace) {
    return this.spaces[i].workingColorSpaceConfig.unpackColorSpace;
  }
};
function ii(i) {
  return i < 0.04045 ? i * 0.0773993808 : Math.pow(i * 0.9478672986 + 0.0521327014, 2.4);
}
function yr(i) {
  return i < 31308e-7 ? i * 12.92 : 1.055 * Math.pow(i, 0.41666) - 0.055;
}
const Qu = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], eh = [0.2126, 0.7152, 0.0722], th = [0.3127, 0.329], nh = /* @__PURE__ */ new We().set(
  0.4123908,
  0.3575843,
  0.1804808,
  0.212639,
  0.7151687,
  0.0721923,
  0.0193308,
  0.1191948,
  0.9505322
), ih = /* @__PURE__ */ new We().set(
  3.2409699,
  -1.5373832,
  -0.4986108,
  -0.9692436,
  1.8759675,
  0.0415551,
  0.0556301,
  -0.203977,
  1.0569715
);
nt.define({
  [en]: {
    primaries: Qu,
    whitePoint: th,
    transfer: qa,
    toXYZ: nh,
    fromXYZ: ih,
    luminanceCoefficients: eh,
    workingColorSpaceConfig: { unpackColorSpace: Ut },
    outputColorSpaceConfig: { drawingBufferColorSpace: Ut }
  },
  [Ut]: {
    primaries: Qu,
    whitePoint: th,
    transfer: mt,
    toXYZ: nh,
    fromXYZ: ih,
    luminanceCoefficients: eh,
    outputColorSpaceConfig: { drawingBufferColorSpace: Ut }
  }
});
let er;
class Xv {
  static getDataURL(e) {
    if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u")
      return e.src;
    let t;
    if (e instanceof HTMLCanvasElement)
      t = e;
    else {
      er === void 0 && (er = Ss("canvas")), er.width = e.width, er.height = e.height;
      const n = er.getContext("2d");
      e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), t = er;
    }
    return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", 0.6)) : t.toDataURL("image/png");
  }
  static sRGBToLinear(e) {
    if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) {
      const t = Ss("canvas");
      t.width = e.width, t.height = e.height;
      const n = t.getContext("2d");
      n.drawImage(e, 0, 0, e.width, e.height);
      const r = n.getImageData(0, 0, e.width, e.height), s = r.data;
      for (let a = 0; a < s.length; a++)
        s[a] = ii(s[a] / 255) * 255;
      return n.putImageData(r, 0, 0), t;
    } else if (e.data) {
      const t = e.data.slice(0);
      for (let n = 0; n < t.length; n++)
        t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[n] = Math.floor(ii(t[n] / 255) * 255) : t[n] = ii(t[n]);
      return {
        data: t,
        width: e.width,
        height: e.height
      };
    } else
      return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e;
  }
}
let jv = 0;
class kd {
  constructor(e = null) {
    this.isSource = !0, Object.defineProperty(this, "id", { value: jv++ }), this.uuid = Rn(), this.data = e, this.dataReady = !0, this.version = 0;
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    if (!t && e.images[this.uuid] !== void 0)
      return e.images[this.uuid];
    const n = {
      uuid: this.uuid,
      url: ""
    }, r = this.data;
    if (r !== null) {
      let s;
      if (Array.isArray(r)) {
        s = [];
        for (let a = 0, o = r.length; a < o; a++)
          r[a].isDataTexture ? s.push(mo(r[a].image)) : s.push(mo(r[a]));
      } else
        s = mo(r);
      n.url = s;
    }
    return t || (e.images[this.uuid] = n), n;
  }
}
function mo(i) {
  return typeof HTMLImageElement < "u" && i instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && i instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && i instanceof ImageBitmap ? Xv.getDataURL(i) : i.data ? {
    data: Array.from(i.data),
    width: i.width,
    height: i.height,
    type: i.data.constructor.name
  } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
}
let qv = 0;
class zt extends Yi {
  constructor(e = zt.DEFAULT_IMAGE, t = zt.DEFAULT_MAPPING, n = bi, r = bi, s = un, a = ti, o = _n, l = ai, c = zt.DEFAULT_ANISOTROPY, u = vi) {
    super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: qv++ }), this.uuid = Rn(), this.name = "", this.source = new kd(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = r, this.magFilter = s, this.minFilter = a, this.anisotropy = c, this.format = o, this.internalFormat = null, this.type = l, this.offset = new ze(0, 0), this.repeat = new ze(1, 1), this.center = new ze(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new We(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = u, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0;
  }
  get image() {
    return this.source.data;
  }
  set image(e = null) {
    this.source.data = e;
  }
  updateMatrix() {
    this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.name = e.name, this.source = e.source, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.channel = e.channel, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.colorSpace = e.colorSpace, this.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this;
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    if (!t && e.textures[this.uuid] !== void 0)
      return e.textures[this.uuid];
    const n = {
      metadata: {
        version: 4.6,
        type: "Texture",
        generator: "Texture.toJSON"
      },
      uuid: this.uuid,
      name: this.name,
      image: this.source.toJSON(e).uuid,
      mapping: this.mapping,
      channel: this.channel,
      repeat: [this.repeat.x, this.repeat.y],
      offset: [this.offset.x, this.offset.y],
      center: [this.center.x, this.center.y],
      rotation: this.rotation,
      wrap: [this.wrapS, this.wrapT],
      format: this.format,
      internalFormat: this.internalFormat,
      type: this.type,
      colorSpace: this.colorSpace,
      minFilter: this.minFilter,
      magFilter: this.magFilter,
      anisotropy: this.anisotropy,
      flipY: this.flipY,
      generateMipmaps: this.generateMipmaps,
      premultiplyAlpha: this.premultiplyAlpha,
      unpackAlignment: this.unpackAlignment
    };
    return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  transformUv(e) {
    if (this.mapping !== Sd) return e;
    if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)
      switch (this.wrapS) {
        case Pr:
          e.x = e.x - Math.floor(e.x);
          break;
        case bi:
          e.x = e.x < 0 ? 0 : 1;
          break;
        case La:
          Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x);
          break;
      }
    if (e.y < 0 || e.y > 1)
      switch (this.wrapT) {
        case Pr:
          e.y = e.y - Math.floor(e.y);
          break;
        case bi:
          e.y = e.y < 0 ? 0 : 1;
          break;
        case La:
          Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y);
          break;
      }
    return this.flipY && (e.y = 1 - e.y), e;
  }
  set needsUpdate(e) {
    e === !0 && (this.version++, this.source.needsUpdate = !0);
  }
  set needsPMREMUpdate(e) {
    e === !0 && this.pmremVersion++;
  }
}
zt.DEFAULT_IMAGE = null;
zt.DEFAULT_MAPPING = Sd;
zt.DEFAULT_ANISOTROPY = 1;
class lt {
  constructor(e = 0, t = 0, n = 0, r = 1) {
    lt.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = n, this.w = r;
  }
  get width() {
    return this.z;
  }
  set width(e) {
    this.z = e;
  }
  get height() {
    return this.w;
  }
  set height(e) {
    this.w = e;
  }
  set(e, t, n, r) {
    return this.x = e, this.y = t, this.z = n, this.w = r, this;
  }
  setScalar(e) {
    return this.x = e, this.y = e, this.z = e, this.w = e, this;
  }
  setX(e) {
    return this.x = e, this;
  }
  setY(e) {
    return this.y = e, this;
  }
  setZ(e) {
    return this.z = e, this;
  }
  setW(e) {
    return this.w = e, this;
  }
  setComponent(e, t) {
    switch (e) {
      case 0:
        this.x = t;
        break;
      case 1:
        this.y = t;
        break;
      case 2:
        this.z = t;
        break;
      case 3:
        this.w = t;
        break;
      default:
        throw new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      case 3:
        return this.w;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z, this.w);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this.z += e, this.w += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this;
  }
  applyMatrix4(e) {
    const t = this.x, n = this.y, r = this.z, s = this.w, a = e.elements;
    return this.x = a[0] * t + a[4] * n + a[8] * r + a[12] * s, this.y = a[1] * t + a[5] * n + a[9] * r + a[13] * s, this.z = a[2] * t + a[6] * n + a[10] * r + a[14] * s, this.w = a[3] * t + a[7] * n + a[11] * r + a[15] * s, this;
  }
  divide(e) {
    return this.x /= e.x, this.y /= e.y, this.z /= e.z, this.w /= e.w, this;
  }
  divideScalar(e) {
    return this.multiplyScalar(1 / e);
  }
  setAxisAngleFromQuaternion(e) {
    this.w = 2 * Math.acos(e.w);
    const t = Math.sqrt(1 - e.w * e.w);
    return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this;
  }
  setAxisAngleFromRotationMatrix(e) {
    let t, n, r, s;
    const l = e.elements, c = l[0], u = l[4], h = l[8], d = l[1], m = l[5], v = l[9], b = l[2], p = l[6], f = l[10];
    if (Math.abs(u - d) < 0.01 && Math.abs(h - b) < 0.01 && Math.abs(v - p) < 0.01) {
      if (Math.abs(u + d) < 0.1 && Math.abs(h + b) < 0.1 && Math.abs(v + p) < 0.1 && Math.abs(c + m + f - 3) < 0.1)
        return this.set(1, 0, 0, 0), this;
      t = Math.PI;
      const g = (c + 1) / 2, _ = (m + 1) / 2, T = (f + 1) / 2, A = (u + d) / 4, M = (h + b) / 4, C = (v + p) / 4;
      return g > _ && g > T ? g < 0.01 ? (n = 0, r = 0.707106781, s = 0.707106781) : (n = Math.sqrt(g), r = A / n, s = M / n) : _ > T ? _ < 0.01 ? (n = 0.707106781, r = 0, s = 0.707106781) : (r = Math.sqrt(_), n = A / r, s = C / r) : T < 0.01 ? (n = 0.707106781, r = 0.707106781, s = 0) : (s = Math.sqrt(T), n = M / s, r = C / s), this.set(n, r, s, t), this;
    }
    let x = Math.sqrt((p - v) * (p - v) + (h - b) * (h - b) + (d - u) * (d - u));
    return Math.abs(x) < 1e-3 && (x = 1), this.x = (p - v) / x, this.y = (h - b) / x, this.z = (d - u) / x, this.w = Math.acos((c + m + f - 1) / 2), this;
  }
  setFromMatrixPosition(e) {
    const t = e.elements;
    return this.x = t[12], this.y = t[13], this.z = t[14], this.w = t[15], this;
  }
  min(e) {
    return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), this;
  }
  max(e) {
    return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.w), this;
  }
  clamp(e, t) {
    return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this;
  }
  clampLength(e, t) {
    const n = this.length();
    return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this.w = Math.floor(this.w), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this.w = Math.ceil(this.w), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this.w = Math.round(this.w), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this.w = Math.trunc(this.w), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this;
  }
  dot(e) {
    return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  setLength(e) {
    return this.normalize().multiplyScalar(e);
  }
  lerp(e, t) {
    return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this;
  }
  lerpVectors(e, t, n) {
    return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this;
  }
  equals(e) {
    return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w;
  }
  fromArray(e, t = 0) {
    return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e;
  }
  fromBufferAttribute(e, t) {
    return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z, yield this.w;
  }
}
class Yv extends Yi {
  constructor(e = 1, t = 1, n = {}) {
    super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = 1, this.scissor = new lt(0, 0, e, t), this.scissorTest = !1, this.viewport = new lt(0, 0, e, t);
    const r = { width: e, height: t, depth: 1 };
    n = Object.assign({
      generateMipmaps: !1,
      internalFormat: null,
      minFilter: un,
      depthBuffer: !0,
      stencilBuffer: !1,
      resolveDepthBuffer: !0,
      resolveStencilBuffer: !0,
      depthTexture: null,
      samples: 0,
      count: 1
    }, n);
    const s = new zt(r, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.colorSpace);
    s.flipY = !1, s.generateMipmaps = n.generateMipmaps, s.internalFormat = n.internalFormat, this.textures = [];
    const a = n.count;
    for (let o = 0; o < a; o++)
      this.textures[o] = s.clone(), this.textures[o].isRenderTargetTexture = !0;
    this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.resolveDepthBuffer = n.resolveDepthBuffer, this.resolveStencilBuffer = n.resolveStencilBuffer, this.depthTexture = n.depthTexture, this.samples = n.samples;
  }
  get texture() {
    return this.textures[0];
  }
  set texture(e) {
    this.textures[0] = e;
  }
  setSize(e, t, n = 1) {
    if (this.width !== e || this.height !== t || this.depth !== n) {
      this.width = e, this.height = t, this.depth = n;
      for (let r = 0, s = this.textures.length; r < s; r++)
        this.textures[r].image.width = e, this.textures[r].image.height = t, this.textures[r].image.depth = n;
      this.dispose();
    }
    this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    this.width = e.width, this.height = e.height, this.depth = e.depth, this.scissor.copy(e.scissor), this.scissorTest = e.scissorTest, this.viewport.copy(e.viewport), this.textures.length = 0;
    for (let n = 0, r = e.textures.length; n < r; n++)
      this.textures[n] = e.textures[n].clone(), this.textures[n].isRenderTargetTexture = !0;
    const t = Object.assign({}, e.texture.image);
    return this.texture.source = new kd(t), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.resolveDepthBuffer = e.resolveDepthBuffer, this.resolveStencilBuffer = e.resolveStencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
class Xi extends Yv {
  constructor(e = 1, t = 1, n = {}) {
    super(e, t, n), this.isWebGLRenderTarget = !0;
  }
}
class Hd extends zt {
  constructor(e = null, t = 1, n = 1, r = 1) {
    super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: n, depth: r }, this.magFilter = Jt, this.minFilter = Jt, this.wrapR = bi, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set();
  }
  addLayerUpdate(e) {
    this.layerUpdates.add(e);
  }
  clearLayerUpdates() {
    this.layerUpdates.clear();
  }
}
class Zv extends zt {
  constructor(e = null, t = 1, n = 1, r = 1) {
    super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: n, depth: r }, this.magFilter = Jt, this.minFilter = Jt, this.wrapR = bi, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class kn {
  constructor(e = 0, t = 0, n = 0, r = 1) {
    this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = r;
  }
  static slerpFlat(e, t, n, r, s, a, o) {
    let l = n[r + 0], c = n[r + 1], u = n[r + 2], h = n[r + 3];
    const d = s[a + 0], m = s[a + 1], v = s[a + 2], b = s[a + 3];
    if (o === 0) {
      e[t + 0] = l, e[t + 1] = c, e[t + 2] = u, e[t + 3] = h;
      return;
    }
    if (o === 1) {
      e[t + 0] = d, e[t + 1] = m, e[t + 2] = v, e[t + 3] = b;
      return;
    }
    if (h !== b || l !== d || c !== m || u !== v) {
      let p = 1 - o;
      const f = l * d + c * m + u * v + h * b, x = f >= 0 ? 1 : -1, g = 1 - f * f;
      if (g > Number.EPSILON) {
        const T = Math.sqrt(g), A = Math.atan2(T, f * x);
        p = Math.sin(p * A) / T, o = Math.sin(o * A) / T;
      }
      const _ = o * x;
      if (l = l * p + d * _, c = c * p + m * _, u = u * p + v * _, h = h * p + b * _, p === 1 - o) {
        const T = 1 / Math.sqrt(l * l + c * c + u * u + h * h);
        l *= T, c *= T, u *= T, h *= T;
      }
    }
    e[t] = l, e[t + 1] = c, e[t + 2] = u, e[t + 3] = h;
  }
  static multiplyQuaternionsFlat(e, t, n, r, s, a) {
    const o = n[r], l = n[r + 1], c = n[r + 2], u = n[r + 3], h = s[a], d = s[a + 1], m = s[a + 2], v = s[a + 3];
    return e[t] = o * v + u * h + l * m - c * d, e[t + 1] = l * v + u * d + c * h - o * m, e[t + 2] = c * v + u * m + o * d - l * h, e[t + 3] = u * v - o * h - l * d - c * m, e;
  }
  get x() {
    return this._x;
  }
  set x(e) {
    this._x = e, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(e) {
    this._y = e, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(e) {
    this._z = e, this._onChangeCallback();
  }
  get w() {
    return this._w;
  }
  set w(e) {
    this._w = e, this._onChangeCallback();
  }
  set(e, t, n, r) {
    return this._x = e, this._y = t, this._z = n, this._w = r, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._w);
  }
  copy(e) {
    return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this;
  }
  setFromEuler(e, t = !0) {
    const n = e._x, r = e._y, s = e._z, a = e._order, o = Math.cos, l = Math.sin, c = o(n / 2), u = o(r / 2), h = o(s / 2), d = l(n / 2), m = l(r / 2), v = l(s / 2);
    switch (a) {
      case "XYZ":
        this._x = d * u * h + c * m * v, this._y = c * m * h - d * u * v, this._z = c * u * v + d * m * h, this._w = c * u * h - d * m * v;
        break;
      case "YXZ":
        this._x = d * u * h + c * m * v, this._y = c * m * h - d * u * v, this._z = c * u * v - d * m * h, this._w = c * u * h + d * m * v;
        break;
      case "ZXY":
        this._x = d * u * h - c * m * v, this._y = c * m * h + d * u * v, this._z = c * u * v + d * m * h, this._w = c * u * h - d * m * v;
        break;
      case "ZYX":
        this._x = d * u * h - c * m * v, this._y = c * m * h + d * u * v, this._z = c * u * v - d * m * h, this._w = c * u * h + d * m * v;
        break;
      case "YZX":
        this._x = d * u * h + c * m * v, this._y = c * m * h + d * u * v, this._z = c * u * v - d * m * h, this._w = c * u * h - d * m * v;
        break;
      case "XZY":
        this._x = d * u * h - c * m * v, this._y = c * m * h - d * u * v, this._z = c * u * v + d * m * h, this._w = c * u * h + d * m * v;
        break;
      default:
        console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a);
    }
    return t === !0 && this._onChangeCallback(), this;
  }
  setFromAxisAngle(e, t) {
    const n = t / 2, r = Math.sin(n);
    return this._x = e.x * r, this._y = e.y * r, this._z = e.z * r, this._w = Math.cos(n), this._onChangeCallback(), this;
  }
  setFromRotationMatrix(e) {
    const t = e.elements, n = t[0], r = t[4], s = t[8], a = t[1], o = t[5], l = t[9], c = t[2], u = t[6], h = t[10], d = n + o + h;
    if (d > 0) {
      const m = 0.5 / Math.sqrt(d + 1);
      this._w = 0.25 / m, this._x = (u - l) * m, this._y = (s - c) * m, this._z = (a - r) * m;
    } else if (n > o && n > h) {
      const m = 2 * Math.sqrt(1 + n - o - h);
      this._w = (u - l) / m, this._x = 0.25 * m, this._y = (r + a) / m, this._z = (s + c) / m;
    } else if (o > h) {
      const m = 2 * Math.sqrt(1 + o - n - h);
      this._w = (s - c) / m, this._x = (r + a) / m, this._y = 0.25 * m, this._z = (l + u) / m;
    } else {
      const m = 2 * Math.sqrt(1 + h - n - o);
      this._w = (a - r) / m, this._x = (s + c) / m, this._y = (l + u) / m, this._z = 0.25 * m;
    }
    return this._onChangeCallback(), this;
  }
  setFromUnitVectors(e, t) {
    let n = e.dot(t) + 1;
    return n < Number.EPSILON ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize();
  }
  angleTo(e) {
    return 2 * Math.acos(Math.abs(Vt(this.dot(e), -1, 1)));
  }
  rotateTowards(e, t) {
    const n = this.angleTo(e);
    if (n === 0) return this;
    const r = Math.min(1, t / n);
    return this.slerp(e, r), this;
  }
  identity() {
    return this.set(0, 0, 0, 1);
  }
  invert() {
    return this.conjugate();
  }
  conjugate() {
    return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
  }
  dot(e) {
    return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;
  }
  lengthSq() {
    return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
  }
  length() {
    return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
  }
  normalize() {
    let e = this.length();
    return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this;
  }
  multiply(e) {
    return this.multiplyQuaternions(this, e);
  }
  premultiply(e) {
    return this.multiplyQuaternions(e, this);
  }
  multiplyQuaternions(e, t) {
    const n = e._x, r = e._y, s = e._z, a = e._w, o = t._x, l = t._y, c = t._z, u = t._w;
    return this._x = n * u + a * o + r * c - s * l, this._y = r * u + a * l + s * o - n * c, this._z = s * u + a * c + n * l - r * o, this._w = a * u - n * o - r * l - s * c, this._onChangeCallback(), this;
  }
  slerp(e, t) {
    if (t === 0) return this;
    if (t === 1) return this.copy(e);
    const n = this._x, r = this._y, s = this._z, a = this._w;
    let o = a * e._w + n * e._x + r * e._y + s * e._z;
    if (o < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, o = -o) : this.copy(e), o >= 1)
      return this._w = a, this._x = n, this._y = r, this._z = s, this;
    const l = 1 - o * o;
    if (l <= Number.EPSILON) {
      const m = 1 - t;
      return this._w = m * a + t * this._w, this._x = m * n + t * this._x, this._y = m * r + t * this._y, this._z = m * s + t * this._z, this.normalize(), this;
    }
    const c = Math.sqrt(l), u = Math.atan2(c, o), h = Math.sin((1 - t) * u) / c, d = Math.sin(t * u) / c;
    return this._w = a * h + this._w * d, this._x = n * h + this._x * d, this._y = r * h + this._y * d, this._z = s * h + this._z * d, this._onChangeCallback(), this;
  }
  slerpQuaternions(e, t, n) {
    return this.copy(e).slerp(t, n);
  }
  random() {
    const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), r = Math.sqrt(1 - n), s = Math.sqrt(n);
    return this.set(
      r * Math.sin(e),
      r * Math.cos(e),
      s * Math.sin(t),
      s * Math.cos(t)
    );
  }
  equals(e) {
    return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;
  }
  fromArray(e, t = 0) {
    return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e;
  }
  fromBufferAttribute(e, t) {
    return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this._onChangeCallback(), this;
  }
  toJSON() {
    return this.toArray();
  }
  _onChange(e) {
    return this._onChangeCallback = e, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._w;
  }
}
class L {
  constructor(e = 0, t = 0, n = 0) {
    L.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = n;
  }
  set(e, t, n) {
    return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this;
  }
  setScalar(e) {
    return this.x = e, this.y = e, this.z = e, this;
  }
  setX(e) {
    return this.x = e, this;
  }
  setY(e) {
    return this.y = e, this;
  }
  setZ(e) {
    return this.z = e, this;
  }
  setComponent(e, t) {
    switch (e) {
      case 0:
        this.x = t;
        break;
      case 1:
        this.y = t;
        break;
      case 2:
        this.z = t;
        break;
      default:
        throw new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this.z = e.z, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this.z += e.z, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this.z += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this.z -= e.z, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this.z -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this.z *= e.z, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this.z *= e, this;
  }
  multiplyVectors(e, t) {
    return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this;
  }
  applyEuler(e) {
    return this.applyQuaternion(rh.setFromEuler(e));
  }
  applyAxisAngle(e, t) {
    return this.applyQuaternion(rh.setFromAxisAngle(e, t));
  }
  applyMatrix3(e) {
    const t = this.x, n = this.y, r = this.z, s = e.elements;
    return this.x = s[0] * t + s[3] * n + s[6] * r, this.y = s[1] * t + s[4] * n + s[7] * r, this.z = s[2] * t + s[5] * n + s[8] * r, this;
  }
  applyNormalMatrix(e) {
    return this.applyMatrix3(e).normalize();
  }
  applyMatrix4(e) {
    const t = this.x, n = this.y, r = this.z, s = e.elements, a = 1 / (s[3] * t + s[7] * n + s[11] * r + s[15]);
    return this.x = (s[0] * t + s[4] * n + s[8] * r + s[12]) * a, this.y = (s[1] * t + s[5] * n + s[9] * r + s[13]) * a, this.z = (s[2] * t + s[6] * n + s[10] * r + s[14]) * a, this;
  }
  applyQuaternion(e) {
    const t = this.x, n = this.y, r = this.z, s = e.x, a = e.y, o = e.z, l = e.w, c = 2 * (a * r - o * n), u = 2 * (o * t - s * r), h = 2 * (s * n - a * t);
    return this.x = t + l * c + a * h - o * u, this.y = n + l * u + o * c - s * h, this.z = r + l * h + s * u - a * c, this;
  }
  project(e) {
    return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);
  }
  unproject(e) {
    return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);
  }
  transformDirection(e) {
    const t = this.x, n = this.y, r = this.z, s = e.elements;
    return this.x = s[0] * t + s[4] * n + s[8] * r, this.y = s[1] * t + s[5] * n + s[9] * r, this.z = s[2] * t + s[6] * n + s[10] * r, this.normalize();
  }
  divide(e) {
    return this.x /= e.x, this.y /= e.y, this.z /= e.z, this;
  }
  divideScalar(e) {
    return this.multiplyScalar(1 / e);
  }
  min(e) {
    return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this;
  }
  max(e) {
    return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this;
  }
  clamp(e, t) {
    return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this;
  }
  clampLength(e, t) {
    const n = this.length();
    return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
  }
  dot(e) {
    return this.x * e.x + this.y * e.y + this.z * e.z;
  }
  // TODO lengthSquared?
  lengthSq() {
    return this.x * this.x + this.y * this.y + this.z * this.z;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  setLength(e) {
    return this.normalize().multiplyScalar(e);
  }
  lerp(e, t) {
    return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this;
  }
  lerpVectors(e, t, n) {
    return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this;
  }
  cross(e) {
    return this.crossVectors(this, e);
  }
  crossVectors(e, t) {
    const n = e.x, r = e.y, s = e.z, a = t.x, o = t.y, l = t.z;
    return this.x = r * l - s * o, this.y = s * a - n * l, this.z = n * o - r * a, this;
  }
  projectOnVector(e) {
    const t = e.lengthSq();
    if (t === 0) return this.set(0, 0, 0);
    const n = e.dot(this) / t;
    return this.copy(e).multiplyScalar(n);
  }
  projectOnPlane(e) {
    return go.copy(this).projectOnVector(e), this.sub(go);
  }
  reflect(e) {
    return this.sub(go.copy(e).multiplyScalar(2 * this.dot(e)));
  }
  angleTo(e) {
    const t = Math.sqrt(this.lengthSq() * e.lengthSq());
    if (t === 0) return Math.PI / 2;
    const n = this.dot(e) / t;
    return Math.acos(Vt(n, -1, 1));
  }
  distanceTo(e) {
    return Math.sqrt(this.distanceToSquared(e));
  }
  distanceToSquared(e) {
    const t = this.x - e.x, n = this.y - e.y, r = this.z - e.z;
    return t * t + n * n + r * r;
  }
  manhattanDistanceTo(e) {
    return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z);
  }
  setFromSpherical(e) {
    return this.setFromSphericalCoords(e.radius, e.phi, e.theta);
  }
  setFromSphericalCoords(e, t, n) {
    const r = Math.sin(t) * e;
    return this.x = r * Math.sin(n), this.y = Math.cos(t) * e, this.z = r * Math.cos(n), this;
  }
  setFromCylindrical(e) {
    return this.setFromCylindricalCoords(e.radius, e.theta, e.y);
  }
  setFromCylindricalCoords(e, t, n) {
    return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this;
  }
  setFromMatrixPosition(e) {
    const t = e.elements;
    return this.x = t[12], this.y = t[13], this.z = t[14], this;
  }
  setFromMatrixScale(e) {
    const t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), r = this.setFromMatrixColumn(e, 2).length();
    return this.x = t, this.y = n, this.z = r, this;
  }
  setFromMatrixColumn(e, t) {
    return this.fromArray(e.elements, t * 4);
  }
  setFromMatrix3Column(e, t) {
    return this.fromArray(e.elements, t * 3);
  }
  setFromEuler(e) {
    return this.x = e._x, this.y = e._y, this.z = e._z, this;
  }
  setFromColor(e) {
    return this.x = e.r, this.y = e.g, this.z = e.b, this;
  }
  equals(e) {
    return e.x === this.x && e.y === this.y && e.z === this.z;
  }
  fromArray(e, t = 0) {
    return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e;
  }
  fromBufferAttribute(e, t) {
    return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
  }
  randomDirection() {
    const e = Math.random() * Math.PI * 2, t = Math.random() * 2 - 1, n = Math.sqrt(1 - t * t);
    return this.x = n * Math.cos(e), this.y = t, this.z = n * Math.sin(e), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z;
  }
}
const go = /* @__PURE__ */ new L(), rh = /* @__PURE__ */ new kn();
class vn {
  constructor(e = new L(1 / 0, 1 / 0, 1 / 0), t = new L(-1 / 0, -1 / 0, -1 / 0)) {
    this.isBox3 = !0, this.min = e, this.max = t;
  }
  set(e, t) {
    return this.min.copy(e), this.max.copy(t), this;
  }
  setFromArray(e) {
    this.makeEmpty();
    for (let t = 0, n = e.length; t < n; t += 3)
      this.expandByPoint(bn.fromArray(e, t));
    return this;
  }
  setFromBufferAttribute(e) {
    this.makeEmpty();
    for (let t = 0, n = e.count; t < n; t++)
      this.expandByPoint(bn.fromBufferAttribute(e, t));
    return this;
  }
  setFromPoints(e) {
    this.makeEmpty();
    for (let t = 0, n = e.length; t < n; t++)
      this.expandByPoint(e[t]);
    return this;
  }
  setFromCenterAndSize(e, t) {
    const n = bn.copy(t).multiplyScalar(0.5);
    return this.min.copy(e).sub(n), this.max.copy(e).add(n), this;
  }
  setFromObject(e, t = !1) {
    return this.makeEmpty(), this.expandByObject(e, t);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.min.copy(e.min), this.max.copy(e.max), this;
  }
  makeEmpty() {
    return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this;
  }
  isEmpty() {
    return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
  }
  getCenter(e) {
    return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5);
  }
  getSize(e) {
    return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min);
  }
  expandByPoint(e) {
    return this.min.min(e), this.max.max(e), this;
  }
  expandByVector(e) {
    return this.min.sub(e), this.max.add(e), this;
  }
  expandByScalar(e) {
    return this.min.addScalar(-e), this.max.addScalar(e), this;
  }
  expandByObject(e, t = !1) {
    e.updateWorldMatrix(!1, !1);
    const n = e.geometry;
    if (n !== void 0) {
      const s = n.getAttribute("position");
      if (t === !0 && s !== void 0 && e.isInstancedMesh !== !0)
        for (let a = 0, o = s.count; a < o; a++)
          e.isMesh === !0 ? e.getVertexPosition(a, bn) : bn.fromBufferAttribute(s, a), bn.applyMatrix4(e.matrixWorld), this.expandByPoint(bn);
      else
        e.boundingBox !== void 0 ? (e.boundingBox === null && e.computeBoundingBox(), zs.copy(e.boundingBox)) : (n.boundingBox === null && n.computeBoundingBox(), zs.copy(n.boundingBox)), zs.applyMatrix4(e.matrixWorld), this.union(zs);
    }
    const r = e.children;
    for (let s = 0, a = r.length; s < a; s++)
      this.expandByObject(r[s], t);
    return this;
  }
  containsPoint(e) {
    return e.x >= this.min.x && e.x <= this.max.x && e.y >= this.min.y && e.y <= this.max.y && e.z >= this.min.z && e.z <= this.max.z;
  }
  containsBox(e) {
    return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z;
  }
  getParameter(e, t) {
    return t.set(
      (e.x - this.min.x) / (this.max.x - this.min.x),
      (e.y - this.min.y) / (this.max.y - this.min.y),
      (e.z - this.min.z) / (this.max.z - this.min.z)
    );
  }
  intersectsBox(e) {
    return e.max.x >= this.min.x && e.min.x <= this.max.x && e.max.y >= this.min.y && e.min.y <= this.max.y && e.max.z >= this.min.z && e.min.z <= this.max.z;
  }
  intersectsSphere(e) {
    return this.clampPoint(e.center, bn), bn.distanceToSquared(e.center) <= e.radius * e.radius;
  }
  intersectsPlane(e) {
    let t, n;
    return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant;
  }
  intersectsTriangle(e) {
    if (this.isEmpty())
      return !1;
    this.getCenter(ts), Gs.subVectors(this.max, ts), tr.subVectors(e.a, ts), nr.subVectors(e.b, ts), ir.subVectors(e.c, ts), ui.subVectors(nr, tr), hi.subVectors(ir, nr), wi.subVectors(tr, ir);
    let t = [
      0,
      -ui.z,
      ui.y,
      0,
      -hi.z,
      hi.y,
      0,
      -wi.z,
      wi.y,
      ui.z,
      0,
      -ui.x,
      hi.z,
      0,
      -hi.x,
      wi.z,
      0,
      -wi.x,
      -ui.y,
      ui.x,
      0,
      -hi.y,
      hi.x,
      0,
      -wi.y,
      wi.x,
      0
    ];
    return !_o(t, tr, nr, ir, Gs) || (t = [1, 0, 0, 0, 1, 0, 0, 0, 1], !_o(t, tr, nr, ir, Gs)) ? !1 : (Vs.crossVectors(ui, hi), t = [Vs.x, Vs.y, Vs.z], _o(t, tr, nr, ir, Gs));
  }
  clampPoint(e, t) {
    return t.copy(e).clamp(this.min, this.max);
  }
  distanceToPoint(e) {
    return this.clampPoint(e, bn).distanceTo(e);
  }
  getBoundingSphere(e) {
    return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(bn).length() * 0.5), e;
  }
  intersect(e) {
    return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this;
  }
  union(e) {
    return this.min.min(e.min), this.max.max(e.max), this;
  }
  applyMatrix4(e) {
    return this.isEmpty() ? this : (jn[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), jn[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), jn[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), jn[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), jn[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), jn[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), jn[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), jn[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(jn), this);
  }
  translate(e) {
    return this.min.add(e), this.max.add(e), this;
  }
  equals(e) {
    return e.min.equals(this.min) && e.max.equals(this.max);
  }
}
const jn = [
  /* @__PURE__ */ new L(),
  /* @__PURE__ */ new L(),
  /* @__PURE__ */ new L(),
  /* @__PURE__ */ new L(),
  /* @__PURE__ */ new L(),
  /* @__PURE__ */ new L(),
  /* @__PURE__ */ new L(),
  /* @__PURE__ */ new L()
], bn = /* @__PURE__ */ new L(), zs = /* @__PURE__ */ new vn(), tr = /* @__PURE__ */ new L(), nr = /* @__PURE__ */ new L(), ir = /* @__PURE__ */ new L(), ui = /* @__PURE__ */ new L(), hi = /* @__PURE__ */ new L(), wi = /* @__PURE__ */ new L(), ts = /* @__PURE__ */ new L(), Gs = /* @__PURE__ */ new L(), Vs = /* @__PURE__ */ new L(), Di = /* @__PURE__ */ new L();
function _o(i, e, t, n, r) {
  for (let s = 0, a = i.length - 3; s <= a; s += 3) {
    Di.fromArray(i, s);
    const o = r.x * Math.abs(Di.x) + r.y * Math.abs(Di.y) + r.z * Math.abs(Di.z), l = e.dot(Di), c = t.dot(Di), u = n.dot(Di);
    if (Math.max(-Math.max(l, c, u), Math.min(l, c, u)) > o)
      return !1;
  }
  return !0;
}
const Kv = /* @__PURE__ */ new vn(), ns = /* @__PURE__ */ new L(), vo = /* @__PURE__ */ new L();
class zn {
  constructor(e = new L(), t = -1) {
    this.isSphere = !0, this.center = e, this.radius = t;
  }
  set(e, t) {
    return this.center.copy(e), this.radius = t, this;
  }
  setFromPoints(e, t) {
    const n = this.center;
    t !== void 0 ? n.copy(t) : Kv.setFromPoints(e).getCenter(n);
    let r = 0;
    for (let s = 0, a = e.length; s < a; s++)
      r = Math.max(r, n.distanceToSquared(e[s]));
    return this.radius = Math.sqrt(r), this;
  }
  copy(e) {
    return this.center.copy(e.center), this.radius = e.radius, this;
  }
  isEmpty() {
    return this.radius < 0;
  }
  makeEmpty() {
    return this.center.set(0, 0, 0), this.radius = -1, this;
  }
  containsPoint(e) {
    return e.distanceToSquared(this.center) <= this.radius * this.radius;
  }
  distanceToPoint(e) {
    return e.distanceTo(this.center) - this.radius;
  }
  intersectsSphere(e) {
    const t = this.radius + e.radius;
    return e.center.distanceToSquared(this.center) <= t * t;
  }
  intersectsBox(e) {
    return e.intersectsSphere(this);
  }
  intersectsPlane(e) {
    return Math.abs(e.distanceToPoint(this.center)) <= this.radius;
  }
  clampPoint(e, t) {
    const n = this.center.distanceToSquared(e);
    return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t;
  }
  getBoundingBox(e) {
    return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e);
  }
  applyMatrix4(e) {
    return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this;
  }
  translate(e) {
    return this.center.add(e), this;
  }
  expandByPoint(e) {
    if (this.isEmpty())
      return this.center.copy(e), this.radius = 0, this;
    ns.subVectors(e, this.center);
    const t = ns.lengthSq();
    if (t > this.radius * this.radius) {
      const n = Math.sqrt(t), r = (n - this.radius) * 0.5;
      this.center.addScaledVector(ns, r / n), this.radius += r;
    }
    return this;
  }
  union(e) {
    return e.isEmpty() ? this : this.isEmpty() ? (this.copy(e), this) : (this.center.equals(e.center) === !0 ? this.radius = Math.max(this.radius, e.radius) : (vo.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(ns.copy(e.center).add(vo)), this.expandByPoint(ns.copy(e.center).sub(vo))), this);
  }
  equals(e) {
    return e.center.equals(this.center) && e.radius === this.radius;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const qn = /* @__PURE__ */ new L(), xo = /* @__PURE__ */ new L(), Ws = /* @__PURE__ */ new L(), fi = /* @__PURE__ */ new L(), bo = /* @__PURE__ */ new L(), Xs = /* @__PURE__ */ new L(), Eo = /* @__PURE__ */ new L();
class Ps {
  constructor(e = new L(), t = new L(0, 0, -1)) {
    this.origin = e, this.direction = t;
  }
  set(e, t) {
    return this.origin.copy(e), this.direction.copy(t), this;
  }
  copy(e) {
    return this.origin.copy(e.origin), this.direction.copy(e.direction), this;
  }
  at(e, t) {
    return t.copy(this.origin).addScaledVector(this.direction, e);
  }
  lookAt(e) {
    return this.direction.copy(e).sub(this.origin).normalize(), this;
  }
  recast(e) {
    return this.origin.copy(this.at(e, qn)), this;
  }
  closestPointToPoint(e, t) {
    t.subVectors(e, this.origin);
    const n = t.dot(this.direction);
    return n < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, n);
  }
  distanceToPoint(e) {
    return Math.sqrt(this.distanceSqToPoint(e));
  }
  distanceSqToPoint(e) {
    const t = qn.subVectors(e, this.origin).dot(this.direction);
    return t < 0 ? this.origin.distanceToSquared(e) : (qn.copy(this.origin).addScaledVector(this.direction, t), qn.distanceToSquared(e));
  }
  distanceSqToSegment(e, t, n, r) {
    xo.copy(e).add(t).multiplyScalar(0.5), Ws.copy(t).sub(e).normalize(), fi.copy(this.origin).sub(xo);
    const s = e.distanceTo(t) * 0.5, a = -this.direction.dot(Ws), o = fi.dot(this.direction), l = -fi.dot(Ws), c = fi.lengthSq(), u = Math.abs(1 - a * a);
    let h, d, m, v;
    if (u > 0)
      if (h = a * l - o, d = a * o - l, v = s * u, h >= 0)
        if (d >= -v)
          if (d <= v) {
            const b = 1 / u;
            h *= b, d *= b, m = h * (h + a * d + 2 * o) + d * (a * h + d + 2 * l) + c;
          } else
            d = s, h = Math.max(0, -(a * d + o)), m = -h * h + d * (d + 2 * l) + c;
        else
          d = -s, h = Math.max(0, -(a * d + o)), m = -h * h + d * (d + 2 * l) + c;
      else
        d <= -v ? (h = Math.max(0, -(-a * s + o)), d = h > 0 ? -s : Math.min(Math.max(-s, -l), s), m = -h * h + d * (d + 2 * l) + c) : d <= v ? (h = 0, d = Math.min(Math.max(-s, -l), s), m = d * (d + 2 * l) + c) : (h = Math.max(0, -(a * s + o)), d = h > 0 ? s : Math.min(Math.max(-s, -l), s), m = -h * h + d * (d + 2 * l) + c);
    else
      d = a > 0 ? -s : s, h = Math.max(0, -(a * d + o)), m = -h * h + d * (d + 2 * l) + c;
    return n && n.copy(this.origin).addScaledVector(this.direction, h), r && r.copy(xo).addScaledVector(Ws, d), m;
  }
  intersectSphere(e, t) {
    qn.subVectors(e.center, this.origin);
    const n = qn.dot(this.direction), r = qn.dot(qn) - n * n, s = e.radius * e.radius;
    if (r > s) return null;
    const a = Math.sqrt(s - r), o = n - a, l = n + a;
    return l < 0 ? null : o < 0 ? this.at(l, t) : this.at(o, t);
  }
  intersectsSphere(e) {
    return this.distanceSqToPoint(e.center) <= e.radius * e.radius;
  }
  distanceToPlane(e) {
    const t = e.normal.dot(this.direction);
    if (t === 0)
      return e.distanceToPoint(this.origin) === 0 ? 0 : null;
    const n = -(this.origin.dot(e.normal) + e.constant) / t;
    return n >= 0 ? n : null;
  }
  intersectPlane(e, t) {
    const n = this.distanceToPlane(e);
    return n === null ? null : this.at(n, t);
  }
  intersectsPlane(e) {
    const t = e.distanceToPoint(this.origin);
    return t === 0 || e.normal.dot(this.direction) * t < 0;
  }
  intersectBox(e, t) {
    let n, r, s, a, o, l;
    const c = 1 / this.direction.x, u = 1 / this.direction.y, h = 1 / this.direction.z, d = this.origin;
    return c >= 0 ? (n = (e.min.x - d.x) * c, r = (e.max.x - d.x) * c) : (n = (e.max.x - d.x) * c, r = (e.min.x - d.x) * c), u >= 0 ? (s = (e.min.y - d.y) * u, a = (e.max.y - d.y) * u) : (s = (e.max.y - d.y) * u, a = (e.min.y - d.y) * u), n > a || s > r || ((s > n || isNaN(n)) && (n = s), (a < r || isNaN(r)) && (r = a), h >= 0 ? (o = (e.min.z - d.z) * h, l = (e.max.z - d.z) * h) : (o = (e.max.z - d.z) * h, l = (e.min.z - d.z) * h), n > l || o > r) || ((o > n || n !== n) && (n = o), (l < r || r !== r) && (r = l), r < 0) ? null : this.at(n >= 0 ? n : r, t);
  }
  intersectsBox(e) {
    return this.intersectBox(e, qn) !== null;
  }
  intersectTriangle(e, t, n, r, s) {
    bo.subVectors(t, e), Xs.subVectors(n, e), Eo.crossVectors(bo, Xs);
    let a = this.direction.dot(Eo), o;
    if (a > 0) {
      if (r) return null;
      o = 1;
    } else if (a < 0)
      o = -1, a = -a;
    else
      return null;
    fi.subVectors(this.origin, e);
    const l = o * this.direction.dot(Xs.crossVectors(fi, Xs));
    if (l < 0)
      return null;
    const c = o * this.direction.dot(bo.cross(fi));
    if (c < 0 || l + c > a)
      return null;
    const u = -o * fi.dot(Eo);
    return u < 0 ? null : this.at(u / a, s);
  }
  applyMatrix4(e) {
    return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this;
  }
  equals(e) {
    return e.origin.equals(this.origin) && e.direction.equals(this.direction);
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Xe {
  constructor(e, t, n, r, s, a, o, l, c, u, h, d, m, v, b, p) {
    Xe.prototype.isMatrix4 = !0, this.elements = [
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ], e !== void 0 && this.set(e, t, n, r, s, a, o, l, c, u, h, d, m, v, b, p);
  }
  set(e, t, n, r, s, a, o, l, c, u, h, d, m, v, b, p) {
    const f = this.elements;
    return f[0] = e, f[4] = t, f[8] = n, f[12] = r, f[1] = s, f[5] = a, f[9] = o, f[13] = l, f[2] = c, f[6] = u, f[10] = h, f[14] = d, f[3] = m, f[7] = v, f[11] = b, f[15] = p, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  clone() {
    return new Xe().fromArray(this.elements);
  }
  copy(e) {
    const t = this.elements, n = e.elements;
    return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this;
  }
  copyPosition(e) {
    const t = this.elements, n = e.elements;
    return t[12] = n[12], t[13] = n[13], t[14] = n[14], this;
  }
  setFromMatrix3(e) {
    const t = e.elements;
    return this.set(
      t[0],
      t[3],
      t[6],
      0,
      t[1],
      t[4],
      t[7],
      0,
      t[2],
      t[5],
      t[8],
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractBasis(e, t, n) {
    return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this;
  }
  makeBasis(e, t, n) {
    return this.set(
      e.x,
      t.x,
      n.x,
      0,
      e.y,
      t.y,
      n.y,
      0,
      e.z,
      t.z,
      n.z,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractRotation(e) {
    const t = this.elements, n = e.elements, r = 1 / rr.setFromMatrixColumn(e, 0).length(), s = 1 / rr.setFromMatrixColumn(e, 1).length(), a = 1 / rr.setFromMatrixColumn(e, 2).length();
    return t[0] = n[0] * r, t[1] = n[1] * r, t[2] = n[2] * r, t[3] = 0, t[4] = n[4] * s, t[5] = n[5] * s, t[6] = n[6] * s, t[7] = 0, t[8] = n[8] * a, t[9] = n[9] * a, t[10] = n[10] * a, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
  }
  makeRotationFromEuler(e) {
    const t = this.elements, n = e.x, r = e.y, s = e.z, a = Math.cos(n), o = Math.sin(n), l = Math.cos(r), c = Math.sin(r), u = Math.cos(s), h = Math.sin(s);
    if (e.order === "XYZ") {
      const d = a * u, m = a * h, v = o * u, b = o * h;
      t[0] = l * u, t[4] = -l * h, t[8] = c, t[1] = m + v * c, t[5] = d - b * c, t[9] = -o * l, t[2] = b - d * c, t[6] = v + m * c, t[10] = a * l;
    } else if (e.order === "YXZ") {
      const d = l * u, m = l * h, v = c * u, b = c * h;
      t[0] = d + b * o, t[4] = v * o - m, t[8] = a * c, t[1] = a * h, t[5] = a * u, t[9] = -o, t[2] = m * o - v, t[6] = b + d * o, t[10] = a * l;
    } else if (e.order === "ZXY") {
      const d = l * u, m = l * h, v = c * u, b = c * h;
      t[0] = d - b * o, t[4] = -a * h, t[8] = v + m * o, t[1] = m + v * o, t[5] = a * u, t[9] = b - d * o, t[2] = -a * c, t[6] = o, t[10] = a * l;
    } else if (e.order === "ZYX") {
      const d = a * u, m = a * h, v = o * u, b = o * h;
      t[0] = l * u, t[4] = v * c - m, t[8] = d * c + b, t[1] = l * h, t[5] = b * c + d, t[9] = m * c - v, t[2] = -c, t[6] = o * l, t[10] = a * l;
    } else if (e.order === "YZX") {
      const d = a * l, m = a * c, v = o * l, b = o * c;
      t[0] = l * u, t[4] = b - d * h, t[8] = v * h + m, t[1] = h, t[5] = a * u, t[9] = -o * u, t[2] = -c * u, t[6] = m * h + v, t[10] = d - b * h;
    } else if (e.order === "XZY") {
      const d = a * l, m = a * c, v = o * l, b = o * c;
      t[0] = l * u, t[4] = -h, t[8] = c * u, t[1] = d * h + b, t[5] = a * u, t[9] = m * h - v, t[2] = v * h - m, t[6] = o * u, t[10] = b * h + d;
    }
    return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
  }
  makeRotationFromQuaternion(e) {
    return this.compose($v, e, Jv);
  }
  lookAt(e, t, n) {
    const r = this.elements;
    return on.subVectors(e, t), on.lengthSq() === 0 && (on.z = 1), on.normalize(), di.crossVectors(n, on), di.lengthSq() === 0 && (Math.abs(n.z) === 1 ? on.x += 1e-4 : on.z += 1e-4, on.normalize(), di.crossVectors(n, on)), di.normalize(), js.crossVectors(on, di), r[0] = di.x, r[4] = js.x, r[8] = on.x, r[1] = di.y, r[5] = js.y, r[9] = on.y, r[2] = di.z, r[6] = js.z, r[10] = on.z, this;
  }
  multiply(e) {
    return this.multiplyMatrices(this, e);
  }
  premultiply(e) {
    return this.multiplyMatrices(e, this);
  }
  multiplyMatrices(e, t) {
    const n = e.elements, r = t.elements, s = this.elements, a = n[0], o = n[4], l = n[8], c = n[12], u = n[1], h = n[5], d = n[9], m = n[13], v = n[2], b = n[6], p = n[10], f = n[14], x = n[3], g = n[7], _ = n[11], T = n[15], A = r[0], M = r[4], C = r[8], y = r[12], E = r[1], R = r[5], q = r[9], G = r[13], V = r[2], B = r[6], U = r[10], Y = r[14], z = r[3], ie = r[7], oe = r[11], ce = r[15];
    return s[0] = a * A + o * E + l * V + c * z, s[4] = a * M + o * R + l * B + c * ie, s[8] = a * C + o * q + l * U + c * oe, s[12] = a * y + o * G + l * Y + c * ce, s[1] = u * A + h * E + d * V + m * z, s[5] = u * M + h * R + d * B + m * ie, s[9] = u * C + h * q + d * U + m * oe, s[13] = u * y + h * G + d * Y + m * ce, s[2] = v * A + b * E + p * V + f * z, s[6] = v * M + b * R + p * B + f * ie, s[10] = v * C + b * q + p * U + f * oe, s[14] = v * y + b * G + p * Y + f * ce, s[3] = x * A + g * E + _ * V + T * z, s[7] = x * M + g * R + _ * B + T * ie, s[11] = x * C + g * q + _ * U + T * oe, s[15] = x * y + g * G + _ * Y + T * ce, this;
  }
  multiplyScalar(e) {
    const t = this.elements;
    return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this;
  }
  determinant() {
    const e = this.elements, t = e[0], n = e[4], r = e[8], s = e[12], a = e[1], o = e[5], l = e[9], c = e[13], u = e[2], h = e[6], d = e[10], m = e[14], v = e[3], b = e[7], p = e[11], f = e[15];
    return v * (+s * l * h - r * c * h - s * o * d + n * c * d + r * o * m - n * l * m) + b * (+t * l * m - t * c * d + s * a * d - r * a * m + r * c * u - s * l * u) + p * (+t * c * h - t * o * m - s * a * h + n * a * m + s * o * u - n * c * u) + f * (-r * o * u - t * l * h + t * o * d + r * a * h - n * a * d + n * l * u);
  }
  transpose() {
    const e = this.elements;
    let t;
    return t = e[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this;
  }
  setPosition(e, t, n) {
    const r = this.elements;
    return e.isVector3 ? (r[12] = e.x, r[13] = e.y, r[14] = e.z) : (r[12] = e, r[13] = t, r[14] = n), this;
  }
  invert() {
    const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], a = e[4], o = e[5], l = e[6], c = e[7], u = e[8], h = e[9], d = e[10], m = e[11], v = e[12], b = e[13], p = e[14], f = e[15], x = h * p * c - b * d * c + b * l * m - o * p * m - h * l * f + o * d * f, g = v * d * c - u * p * c - v * l * m + a * p * m + u * l * f - a * d * f, _ = u * b * c - v * h * c + v * o * m - a * b * m - u * o * f + a * h * f, T = v * h * l - u * b * l - v * o * d + a * b * d + u * o * p - a * h * p, A = t * x + n * g + r * _ + s * T;
    if (A === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    const M = 1 / A;
    return e[0] = x * M, e[1] = (b * d * s - h * p * s - b * r * m + n * p * m + h * r * f - n * d * f) * M, e[2] = (o * p * s - b * l * s + b * r * c - n * p * c - o * r * f + n * l * f) * M, e[3] = (h * l * s - o * d * s - h * r * c + n * d * c + o * r * m - n * l * m) * M, e[4] = g * M, e[5] = (u * p * s - v * d * s + v * r * m - t * p * m - u * r * f + t * d * f) * M, e[6] = (v * l * s - a * p * s - v * r * c + t * p * c + a * r * f - t * l * f) * M, e[7] = (a * d * s - u * l * s + u * r * c - t * d * c - a * r * m + t * l * m) * M, e[8] = _ * M, e[9] = (v * h * s - u * b * s - v * n * m + t * b * m + u * n * f - t * h * f) * M, e[10] = (a * b * s - v * o * s + v * n * c - t * b * c - a * n * f + t * o * f) * M, e[11] = (u * o * s - a * h * s - u * n * c + t * h * c + a * n * m - t * o * m) * M, e[12] = T * M, e[13] = (u * b * r - v * h * r + v * n * d - t * b * d - u * n * p + t * h * p) * M, e[14] = (v * o * r - a * b * r - v * n * l + t * b * l + a * n * p - t * o * p) * M, e[15] = (a * h * r - u * o * r + u * n * l - t * h * l - a * n * d + t * o * d) * M, this;
  }
  scale(e) {
    const t = this.elements, n = e.x, r = e.y, s = e.z;
    return t[0] *= n, t[4] *= r, t[8] *= s, t[1] *= n, t[5] *= r, t[9] *= s, t[2] *= n, t[6] *= r, t[10] *= s, t[3] *= n, t[7] *= r, t[11] *= s, this;
  }
  getMaxScaleOnAxis() {
    const e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], r = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];
    return Math.sqrt(Math.max(t, n, r));
  }
  makeTranslation(e, t, n) {
    return e.isVector3 ? this.set(
      1,
      0,
      0,
      e.x,
      0,
      1,
      0,
      e.y,
      0,
      0,
      1,
      e.z,
      0,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      0,
      e,
      0,
      1,
      0,
      t,
      0,
      0,
      1,
      n,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationX(e) {
    const t = Math.cos(e), n = Math.sin(e);
    return this.set(
      1,
      0,
      0,
      0,
      0,
      t,
      -n,
      0,
      0,
      n,
      t,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationY(e) {
    const t = Math.cos(e), n = Math.sin(e);
    return this.set(
      t,
      0,
      n,
      0,
      0,
      1,
      0,
      0,
      -n,
      0,
      t,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationZ(e) {
    const t = Math.cos(e), n = Math.sin(e);
    return this.set(
      t,
      -n,
      0,
      0,
      n,
      t,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationAxis(e, t) {
    const n = Math.cos(t), r = Math.sin(t), s = 1 - n, a = e.x, o = e.y, l = e.z, c = s * a, u = s * o;
    return this.set(
      c * a + n,
      c * o - r * l,
      c * l + r * o,
      0,
      c * o + r * l,
      u * o + n,
      u * l - r * a,
      0,
      c * l - r * o,
      u * l + r * a,
      s * l * l + n,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(e, t, n) {
    return this.set(
      e,
      0,
      0,
      0,
      0,
      t,
      0,
      0,
      0,
      0,
      n,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeShear(e, t, n, r, s, a) {
    return this.set(
      1,
      n,
      s,
      0,
      e,
      1,
      a,
      0,
      t,
      r,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  compose(e, t, n) {
    const r = this.elements, s = t._x, a = t._y, o = t._z, l = t._w, c = s + s, u = a + a, h = o + o, d = s * c, m = s * u, v = s * h, b = a * u, p = a * h, f = o * h, x = l * c, g = l * u, _ = l * h, T = n.x, A = n.y, M = n.z;
    return r[0] = (1 - (b + f)) * T, r[1] = (m + _) * T, r[2] = (v - g) * T, r[3] = 0, r[4] = (m - _) * A, r[5] = (1 - (d + f)) * A, r[6] = (p + x) * A, r[7] = 0, r[8] = (v + g) * M, r[9] = (p - x) * M, r[10] = (1 - (d + b)) * M, r[11] = 0, r[12] = e.x, r[13] = e.y, r[14] = e.z, r[15] = 1, this;
  }
  decompose(e, t, n) {
    const r = this.elements;
    let s = rr.set(r[0], r[1], r[2]).length();
    const a = rr.set(r[4], r[5], r[6]).length(), o = rr.set(r[8], r[9], r[10]).length();
    this.determinant() < 0 && (s = -s), e.x = r[12], e.y = r[13], e.z = r[14], En.copy(this);
    const c = 1 / s, u = 1 / a, h = 1 / o;
    return En.elements[0] *= c, En.elements[1] *= c, En.elements[2] *= c, En.elements[4] *= u, En.elements[5] *= u, En.elements[6] *= u, En.elements[8] *= h, En.elements[9] *= h, En.elements[10] *= h, t.setFromRotationMatrix(En), n.x = s, n.y = a, n.z = o, this;
  }
  makePerspective(e, t, n, r, s, a, o = ni) {
    const l = this.elements, c = 2 * s / (t - e), u = 2 * s / (n - r), h = (t + e) / (t - e), d = (n + r) / (n - r);
    let m, v;
    if (o === ni)
      m = -(a + s) / (a - s), v = -2 * a * s / (a - s);
    else if (o === Ia)
      m = -a / (a - s), v = -a * s / (a - s);
    else
      throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o);
    return l[0] = c, l[4] = 0, l[8] = h, l[12] = 0, l[1] = 0, l[5] = u, l[9] = d, l[13] = 0, l[2] = 0, l[6] = 0, l[10] = m, l[14] = v, l[3] = 0, l[7] = 0, l[11] = -1, l[15] = 0, this;
  }
  makeOrthographic(e, t, n, r, s, a, o = ni) {
    const l = this.elements, c = 1 / (t - e), u = 1 / (n - r), h = 1 / (a - s), d = (t + e) * c, m = (n + r) * u;
    let v, b;
    if (o === ni)
      v = (a + s) * h, b = -2 * h;
    else if (o === Ia)
      v = s * h, b = -1 * h;
    else
      throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o);
    return l[0] = 2 * c, l[4] = 0, l[8] = 0, l[12] = -d, l[1] = 0, l[5] = 2 * u, l[9] = 0, l[13] = -m, l[2] = 0, l[6] = 0, l[10] = b, l[14] = -v, l[3] = 0, l[7] = 0, l[11] = 0, l[15] = 1, this;
  }
  equals(e) {
    const t = this.elements, n = e.elements;
    for (let r = 0; r < 16; r++)
      if (t[r] !== n[r]) return !1;
    return !0;
  }
  fromArray(e, t = 0) {
    for (let n = 0; n < 16; n++)
      this.elements[n] = e[n + t];
    return this;
  }
  toArray(e = [], t = 0) {
    const n = this.elements;
    return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e;
  }
}
const rr = /* @__PURE__ */ new L(), En = /* @__PURE__ */ new Xe(), $v = /* @__PURE__ */ new L(0, 0, 0), Jv = /* @__PURE__ */ new L(1, 1, 1), di = /* @__PURE__ */ new L(), js = /* @__PURE__ */ new L(), on = /* @__PURE__ */ new L(), sh = /* @__PURE__ */ new Xe(), ah = /* @__PURE__ */ new kn();
class Hn {
  constructor(e = 0, t = 0, n = 0, r = Hn.DEFAULT_ORDER) {
    this.isEuler = !0, this._x = e, this._y = t, this._z = n, this._order = r;
  }
  get x() {
    return this._x;
  }
  set x(e) {
    this._x = e, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(e) {
    this._y = e, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(e) {
    this._z = e, this._onChangeCallback();
  }
  get order() {
    return this._order;
  }
  set order(e) {
    this._order = e, this._onChangeCallback();
  }
  set(e, t, n, r = this._order) {
    return this._x = e, this._y = t, this._z = n, this._order = r, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._order);
  }
  copy(e) {
    return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this;
  }
  setFromRotationMatrix(e, t = this._order, n = !0) {
    const r = e.elements, s = r[0], a = r[4], o = r[8], l = r[1], c = r[5], u = r[9], h = r[2], d = r[6], m = r[10];
    switch (t) {
      case "XYZ":
        this._y = Math.asin(Vt(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-u, m), this._z = Math.atan2(-a, s)) : (this._x = Math.atan2(d, c), this._z = 0);
        break;
      case "YXZ":
        this._x = Math.asin(-Vt(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._y = Math.atan2(o, m), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-h, s), this._z = 0);
        break;
      case "ZXY":
        this._x = Math.asin(Vt(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._y = Math.atan2(-h, m), this._z = Math.atan2(-a, c)) : (this._y = 0, this._z = Math.atan2(l, s));
        break;
      case "ZYX":
        this._y = Math.asin(-Vt(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._x = Math.atan2(d, m), this._z = Math.atan2(l, s)) : (this._x = 0, this._z = Math.atan2(-a, c));
        break;
      case "YZX":
        this._z = Math.asin(Vt(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(-u, c), this._y = Math.atan2(-h, s)) : (this._x = 0, this._y = Math.atan2(o, m));
        break;
      case "XZY":
        this._z = Math.asin(-Vt(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(o, s)) : (this._x = Math.atan2(-u, m), this._y = 0);
        break;
      default:
        console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t);
    }
    return this._order = t, n === !0 && this._onChangeCallback(), this;
  }
  setFromQuaternion(e, t, n) {
    return sh.makeRotationFromQuaternion(e), this.setFromRotationMatrix(sh, t, n);
  }
  setFromVector3(e, t = this._order) {
    return this.set(e.x, e.y, e.z, t);
  }
  reorder(e) {
    return ah.setFromEuler(this), this.setFromQuaternion(ah, e);
  }
  equals(e) {
    return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order;
  }
  fromArray(e) {
    return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e;
  }
  _onChange(e) {
    return this._onChangeCallback = e, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._order;
  }
}
Hn.DEFAULT_ORDER = "XYZ";
class zd {
  constructor() {
    this.mask = 1;
  }
  set(e) {
    this.mask = (1 << e | 0) >>> 0;
  }
  enable(e) {
    this.mask |= 1 << e | 0;
  }
  enableAll() {
    this.mask = -1;
  }
  toggle(e) {
    this.mask ^= 1 << e | 0;
  }
  disable(e) {
    this.mask &= ~(1 << e | 0);
  }
  disableAll() {
    this.mask = 0;
  }
  test(e) {
    return (this.mask & e.mask) !== 0;
  }
  isEnabled(e) {
    return (this.mask & (1 << e | 0)) !== 0;
  }
}
let Qv = 0;
const oh = /* @__PURE__ */ new L(), sr = /* @__PURE__ */ new kn(), Yn = /* @__PURE__ */ new Xe(), qs = /* @__PURE__ */ new L(), is = /* @__PURE__ */ new L(), ex = /* @__PURE__ */ new L(), tx = /* @__PURE__ */ new kn(), lh = /* @__PURE__ */ new L(1, 0, 0), ch = /* @__PURE__ */ new L(0, 1, 0), uh = /* @__PURE__ */ new L(0, 0, 1), hh = { type: "added" }, nx = { type: "removed" }, ar = { type: "childadded", child: null }, yo = { type: "childremoved", child: null };
class Rt extends Yi {
  constructor() {
    super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: Qv++ }), this.uuid = Rn(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = Rt.DEFAULT_UP.clone();
    const e = new L(), t = new Hn(), n = new kn(), r = new L(1, 1, 1);
    function s() {
      n.setFromEuler(t, !1);
    }
    function a() {
      t.setFromQuaternion(n, void 0, !1);
    }
    t._onChange(s), n._onChange(a), Object.defineProperties(this, {
      position: {
        configurable: !0,
        enumerable: !0,
        value: e
      },
      rotation: {
        configurable: !0,
        enumerable: !0,
        value: t
      },
      quaternion: {
        configurable: !0,
        enumerable: !0,
        value: n
      },
      scale: {
        configurable: !0,
        enumerable: !0,
        value: r
      },
      modelViewMatrix: {
        value: new Xe()
      },
      normalMatrix: {
        value: new We()
      }
    }), this.matrix = new Xe(), this.matrixWorld = new Xe(), this.matrixAutoUpdate = Rt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = Rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new zd(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
  }
  onBeforeShadow() {
  }
  onAfterShadow() {
  }
  onBeforeRender() {
  }
  onAfterRender() {
  }
  applyMatrix4(e) {
    this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale);
  }
  applyQuaternion(e) {
    return this.quaternion.premultiply(e), this;
  }
  setRotationFromAxisAngle(e, t) {
    this.quaternion.setFromAxisAngle(e, t);
  }
  setRotationFromEuler(e) {
    this.quaternion.setFromEuler(e, !0);
  }
  setRotationFromMatrix(e) {
    this.quaternion.setFromRotationMatrix(e);
  }
  setRotationFromQuaternion(e) {
    this.quaternion.copy(e);
  }
  rotateOnAxis(e, t) {
    return sr.setFromAxisAngle(e, t), this.quaternion.multiply(sr), this;
  }
  rotateOnWorldAxis(e, t) {
    return sr.setFromAxisAngle(e, t), this.quaternion.premultiply(sr), this;
  }
  rotateX(e) {
    return this.rotateOnAxis(lh, e);
  }
  rotateY(e) {
    return this.rotateOnAxis(ch, e);
  }
  rotateZ(e) {
    return this.rotateOnAxis(uh, e);
  }
  translateOnAxis(e, t) {
    return oh.copy(e).applyQuaternion(this.quaternion), this.position.add(oh.multiplyScalar(t)), this;
  }
  translateX(e) {
    return this.translateOnAxis(lh, e);
  }
  translateY(e) {
    return this.translateOnAxis(ch, e);
  }
  translateZ(e) {
    return this.translateOnAxis(uh, e);
  }
  localToWorld(e) {
    return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld);
  }
  worldToLocal(e) {
    return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Yn.copy(this.matrixWorld).invert());
  }
  lookAt(e, t, n) {
    e.isVector3 ? qs.copy(e) : qs.set(e, t, n);
    const r = this.parent;
    this.updateWorldMatrix(!0, !1), is.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Yn.lookAt(is, qs, this.up) : Yn.lookAt(qs, is, this.up), this.quaternion.setFromRotationMatrix(Yn), r && (Yn.extractRotation(r.matrixWorld), sr.setFromRotationMatrix(Yn), this.quaternion.premultiply(sr.invert()));
  }
  add(e) {
    if (arguments.length > 1) {
      for (let t = 0; t < arguments.length; t++)
        this.add(arguments[t]);
      return this;
    }
    return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.removeFromParent(), e.parent = this, this.children.push(e), e.dispatchEvent(hh), ar.child = e, this.dispatchEvent(ar), ar.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e), this);
  }
  remove(e) {
    if (arguments.length > 1) {
      for (let n = 0; n < arguments.length; n++)
        this.remove(arguments[n]);
      return this;
    }
    const t = this.children.indexOf(e);
    return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(nx), yo.child = e, this.dispatchEvent(yo), yo.child = null), this;
  }
  removeFromParent() {
    const e = this.parent;
    return e !== null && e.remove(this), this;
  }
  clear() {
    return this.remove(...this.children);
  }
  attach(e) {
    return this.updateWorldMatrix(!0, !1), Yn.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Yn.multiply(e.parent.matrixWorld)), e.applyMatrix4(Yn), e.removeFromParent(), e.parent = this, this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(hh), ar.child = e, this.dispatchEvent(ar), ar.child = null, this;
  }
  getObjectById(e) {
    return this.getObjectByProperty("id", e);
  }
  getObjectByName(e) {
    return this.getObjectByProperty("name", e);
  }
  getObjectByProperty(e, t) {
    if (this[e] === t) return this;
    for (let n = 0, r = this.children.length; n < r; n++) {
      const a = this.children[n].getObjectByProperty(e, t);
      if (a !== void 0)
        return a;
    }
  }
  getObjectsByProperty(e, t, n = []) {
    this[e] === t && n.push(this);
    const r = this.children;
    for (let s = 0, a = r.length; s < a; s++)
      r[s].getObjectsByProperty(e, t, n);
    return n;
  }
  getWorldPosition(e) {
    return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld);
  }
  getWorldQuaternion(e) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(is, e, ex), e;
  }
  getWorldScale(e) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(is, tx, e), e;
  }
  getWorldDirection(e) {
    this.updateWorldMatrix(!0, !1);
    const t = this.matrixWorld.elements;
    return e.set(t[8], t[9], t[10]).normalize();
  }
  raycast() {
  }
  traverse(e) {
    e(this);
    const t = this.children;
    for (let n = 0, r = t.length; n < r; n++)
      t[n].traverse(e);
  }
  traverseVisible(e) {
    if (this.visible === !1) return;
    e(this);
    const t = this.children;
    for (let n = 0, r = t.length; n < r; n++)
      t[n].traverseVisible(e);
  }
  traverseAncestors(e) {
    const t = this.parent;
    t !== null && (e(t), t.traverseAncestors(e));
  }
  updateMatrix() {
    this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;
  }
  updateMatrixWorld(e) {
    this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, e = !0);
    const t = this.children;
    for (let n = 0, r = t.length; n < r; n++)
      t[n].updateMatrixWorld(e);
  }
  updateWorldMatrix(e, t) {
    const n = this.parent;
    if (e === !0 && n !== null && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), t === !0) {
      const r = this.children;
      for (let s = 0, a = r.length; s < a; s++)
        r[s].updateWorldMatrix(!1, !0);
    }
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string", n = {};
    t && (e = {
      geometries: {},
      materials: {},
      textures: {},
      images: {},
      shapes: {},
      skeletons: {},
      animations: {},
      nodes: {}
    }, n.metadata = {
      version: 4.6,
      type: "Object",
      generator: "Object3D.toJSON"
    });
    const r = {};
    r.uuid = this.uuid, r.type = this.type, this.name !== "" && (r.name = this.name), this.castShadow === !0 && (r.castShadow = !0), this.receiveShadow === !0 && (r.receiveShadow = !0), this.visible === !1 && (r.visible = !1), this.frustumCulled === !1 && (r.frustumCulled = !1), this.renderOrder !== 0 && (r.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (r.userData = this.userData), r.layers = this.layers.mask, r.matrix = this.matrix.toArray(), r.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1), this.isInstancedMesh && (r.type = "InstancedMesh", r.count = this.count, r.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (r.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (r.type = "BatchedMesh", r.perObjectFrustumCulled = this.perObjectFrustumCulled, r.sortObjects = this.sortObjects, r.drawRanges = this._drawRanges, r.reservedRanges = this._reservedRanges, r.visibility = this._visibility, r.active = this._active, r.bounds = this._bounds.map((o) => ({
      boxInitialized: o.boxInitialized,
      boxMin: o.box.min.toArray(),
      boxMax: o.box.max.toArray(),
      sphereInitialized: o.sphereInitialized,
      sphereRadius: o.sphere.radius,
      sphereCenter: o.sphere.center.toArray()
    })), r.maxInstanceCount = this._maxInstanceCount, r.maxVertexCount = this._maxVertexCount, r.maxIndexCount = this._maxIndexCount, r.geometryInitialized = this._geometryInitialized, r.geometryCount = this._geometryCount, r.matricesTexture = this._matricesTexture.toJSON(e), this._colorsTexture !== null && (r.colorsTexture = this._colorsTexture.toJSON(e)), this.boundingSphere !== null && (r.boundingSphere = {
      center: r.boundingSphere.center.toArray(),
      radius: r.boundingSphere.radius
    }), this.boundingBox !== null && (r.boundingBox = {
      min: r.boundingBox.min.toArray(),
      max: r.boundingBox.max.toArray()
    }));
    function s(o, l) {
      return o[l.uuid] === void 0 && (o[l.uuid] = l.toJSON(e)), l.uuid;
    }
    if (this.isScene)
      this.background && (this.background.isColor ? r.background = this.background.toJSON() : this.background.isTexture && (r.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (r.environment = this.environment.toJSON(e).uuid);
    else if (this.isMesh || this.isLine || this.isPoints) {
      r.geometry = s(e.geometries, this.geometry);
      const o = this.geometry.parameters;
      if (o !== void 0 && o.shapes !== void 0) {
        const l = o.shapes;
        if (Array.isArray(l))
          for (let c = 0, u = l.length; c < u; c++) {
            const h = l[c];
            s(e.shapes, h);
          }
        else
          s(e.shapes, l);
      }
    }
    if (this.isSkinnedMesh && (r.bindMode = this.bindMode, r.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (s(e.skeletons, this.skeleton), r.skeleton = this.skeleton.uuid)), this.material !== void 0)
      if (Array.isArray(this.material)) {
        const o = [];
        for (let l = 0, c = this.material.length; l < c; l++)
          o.push(s(e.materials, this.material[l]));
        r.material = o;
      } else
        r.material = s(e.materials, this.material);
    if (this.children.length > 0) {
      r.children = [];
      for (let o = 0; o < this.children.length; o++)
        r.children.push(this.children[o].toJSON(e).object);
    }
    if (this.animations.length > 0) {
      r.animations = [];
      for (let o = 0; o < this.animations.length; o++) {
        const l = this.animations[o];
        r.animations.push(s(e.animations, l));
      }
    }
    if (t) {
      const o = a(e.geometries), l = a(e.materials), c = a(e.textures), u = a(e.images), h = a(e.shapes), d = a(e.skeletons), m = a(e.animations), v = a(e.nodes);
      o.length > 0 && (n.geometries = o), l.length > 0 && (n.materials = l), c.length > 0 && (n.textures = c), u.length > 0 && (n.images = u), h.length > 0 && (n.shapes = h), d.length > 0 && (n.skeletons = d), m.length > 0 && (n.animations = m), v.length > 0 && (n.nodes = v);
    }
    return n.object = r, n;
    function a(o) {
      const l = [];
      for (const c in o) {
        const u = o[c];
        delete u.metadata, l.push(u);
      }
      return l;
    }
  }
  clone(e) {
    return new this.constructor().copy(this, e);
  }
  copy(e, t = !0) {
    if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.animations = e.animations.slice(), this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0)
      for (let n = 0; n < e.children.length; n++) {
        const r = e.children[n];
        this.add(r.clone());
      }
    return this;
  }
}
Rt.DEFAULT_UP = /* @__PURE__ */ new L(0, 1, 0);
Rt.DEFAULT_MATRIX_AUTO_UPDATE = !0;
Rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
const yn = /* @__PURE__ */ new L(), Zn = /* @__PURE__ */ new L(), So = /* @__PURE__ */ new L(), Kn = /* @__PURE__ */ new L(), or = /* @__PURE__ */ new L(), lr = /* @__PURE__ */ new L(), fh = /* @__PURE__ */ new L(), Mo = /* @__PURE__ */ new L(), Ao = /* @__PURE__ */ new L(), To = /* @__PURE__ */ new L(), wo = /* @__PURE__ */ new lt(), Do = /* @__PURE__ */ new lt(), Ro = /* @__PURE__ */ new lt();
class Tn {
  constructor(e = new L(), t = new L(), n = new L()) {
    this.a = e, this.b = t, this.c = n;
  }
  static getNormal(e, t, n, r) {
    r.subVectors(n, t), yn.subVectors(e, t), r.cross(yn);
    const s = r.lengthSq();
    return s > 0 ? r.multiplyScalar(1 / Math.sqrt(s)) : r.set(0, 0, 0);
  }
  // static/instance method to calculate barycentric coordinates
  // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
  static getBarycoord(e, t, n, r, s) {
    yn.subVectors(r, t), Zn.subVectors(n, t), So.subVectors(e, t);
    const a = yn.dot(yn), o = yn.dot(Zn), l = yn.dot(So), c = Zn.dot(Zn), u = Zn.dot(So), h = a * c - o * o;
    if (h === 0)
      return s.set(0, 0, 0), null;
    const d = 1 / h, m = (c * l - o * u) * d, v = (a * u - o * l) * d;
    return s.set(1 - m - v, v, m);
  }
  static containsPoint(e, t, n, r) {
    return this.getBarycoord(e, t, n, r, Kn) === null ? !1 : Kn.x >= 0 && Kn.y >= 0 && Kn.x + Kn.y <= 1;
  }
  static getInterpolation(e, t, n, r, s, a, o, l) {
    return this.getBarycoord(e, t, n, r, Kn) === null ? (l.x = 0, l.y = 0, "z" in l && (l.z = 0), "w" in l && (l.w = 0), null) : (l.setScalar(0), l.addScaledVector(s, Kn.x), l.addScaledVector(a, Kn.y), l.addScaledVector(o, Kn.z), l);
  }
  static getInterpolatedAttribute(e, t, n, r, s, a) {
    return wo.setScalar(0), Do.setScalar(0), Ro.setScalar(0), wo.fromBufferAttribute(e, t), Do.fromBufferAttribute(e, n), Ro.fromBufferAttribute(e, r), a.setScalar(0), a.addScaledVector(wo, s.x), a.addScaledVector(Do, s.y), a.addScaledVector(Ro, s.z), a;
  }
  static isFrontFacing(e, t, n, r) {
    return yn.subVectors(n, t), Zn.subVectors(e, t), yn.cross(Zn).dot(r) < 0;
  }
  set(e, t, n) {
    return this.a.copy(e), this.b.copy(t), this.c.copy(n), this;
  }
  setFromPointsAndIndices(e, t, n, r) {
    return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[r]), this;
  }
  setFromAttributeAndIndices(e, t, n, r) {
    return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, r), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this;
  }
  getArea() {
    return yn.subVectors(this.c, this.b), Zn.subVectors(this.a, this.b), yn.cross(Zn).length() * 0.5;
  }
  getMidpoint(e) {
    return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
  }
  getNormal(e) {
    return Tn.getNormal(this.a, this.b, this.c, e);
  }
  getPlane(e) {
    return e.setFromCoplanarPoints(this.a, this.b, this.c);
  }
  getBarycoord(e, t) {
    return Tn.getBarycoord(e, this.a, this.b, this.c, t);
  }
  getInterpolation(e, t, n, r, s) {
    return Tn.getInterpolation(e, this.a, this.b, this.c, t, n, r, s);
  }
  containsPoint(e) {
    return Tn.containsPoint(e, this.a, this.b, this.c);
  }
  isFrontFacing(e) {
    return Tn.isFrontFacing(this.a, this.b, this.c, e);
  }
  intersectsBox(e) {
    return e.intersectsTriangle(this);
  }
  closestPointToPoint(e, t) {
    const n = this.a, r = this.b, s = this.c;
    let a, o;
    or.subVectors(r, n), lr.subVectors(s, n), Mo.subVectors(e, n);
    const l = or.dot(Mo), c = lr.dot(Mo);
    if (l <= 0 && c <= 0)
      return t.copy(n);
    Ao.subVectors(e, r);
    const u = or.dot(Ao), h = lr.dot(Ao);
    if (u >= 0 && h <= u)
      return t.copy(r);
    const d = l * h - u * c;
    if (d <= 0 && l >= 0 && u <= 0)
      return a = l / (l - u), t.copy(n).addScaledVector(or, a);
    To.subVectors(e, s);
    const m = or.dot(To), v = lr.dot(To);
    if (v >= 0 && m <= v)
      return t.copy(s);
    const b = m * c - l * v;
    if (b <= 0 && c >= 0 && v <= 0)
      return o = c / (c - v), t.copy(n).addScaledVector(lr, o);
    const p = u * v - m * h;
    if (p <= 0 && h - u >= 0 && m - v >= 0)
      return fh.subVectors(s, r), o = (h - u) / (h - u + (m - v)), t.copy(r).addScaledVector(fh, o);
    const f = 1 / (p + b + d);
    return a = b * f, o = d * f, t.copy(n).addScaledVector(or, a).addScaledVector(lr, o);
  }
  equals(e) {
    return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c);
  }
}
const Gd = {
  aliceblue: 15792383,
  antiquewhite: 16444375,
  aqua: 65535,
  aquamarine: 8388564,
  azure: 15794175,
  beige: 16119260,
  bisque: 16770244,
  black: 0,
  blanchedalmond: 16772045,
  blue: 255,
  blueviolet: 9055202,
  brown: 10824234,
  burlywood: 14596231,
  cadetblue: 6266528,
  chartreuse: 8388352,
  chocolate: 13789470,
  coral: 16744272,
  cornflowerblue: 6591981,
  cornsilk: 16775388,
  crimson: 14423100,
  cyan: 65535,
  darkblue: 139,
  darkcyan: 35723,
  darkgoldenrod: 12092939,
  darkgray: 11119017,
  darkgreen: 25600,
  darkgrey: 11119017,
  darkkhaki: 12433259,
  darkmagenta: 9109643,
  darkolivegreen: 5597999,
  darkorange: 16747520,
  darkorchid: 10040012,
  darkred: 9109504,
  darksalmon: 15308410,
  darkseagreen: 9419919,
  darkslateblue: 4734347,
  darkslategray: 3100495,
  darkslategrey: 3100495,
  darkturquoise: 52945,
  darkviolet: 9699539,
  deeppink: 16716947,
  deepskyblue: 49151,
  dimgray: 6908265,
  dimgrey: 6908265,
  dodgerblue: 2003199,
  firebrick: 11674146,
  floralwhite: 16775920,
  forestgreen: 2263842,
  fuchsia: 16711935,
  gainsboro: 14474460,
  ghostwhite: 16316671,
  gold: 16766720,
  goldenrod: 14329120,
  gray: 8421504,
  green: 32768,
  greenyellow: 11403055,
  grey: 8421504,
  honeydew: 15794160,
  hotpink: 16738740,
  indianred: 13458524,
  indigo: 4915330,
  ivory: 16777200,
  khaki: 15787660,
  lavender: 15132410,
  lavenderblush: 16773365,
  lawngreen: 8190976,
  lemonchiffon: 16775885,
  lightblue: 11393254,
  lightcoral: 15761536,
  lightcyan: 14745599,
  lightgoldenrodyellow: 16448210,
  lightgray: 13882323,
  lightgreen: 9498256,
  lightgrey: 13882323,
  lightpink: 16758465,
  lightsalmon: 16752762,
  lightseagreen: 2142890,
  lightskyblue: 8900346,
  lightslategray: 7833753,
  lightslategrey: 7833753,
  lightsteelblue: 11584734,
  lightyellow: 16777184,
  lime: 65280,
  limegreen: 3329330,
  linen: 16445670,
  magenta: 16711935,
  maroon: 8388608,
  mediumaquamarine: 6737322,
  mediumblue: 205,
  mediumorchid: 12211667,
  mediumpurple: 9662683,
  mediumseagreen: 3978097,
  mediumslateblue: 8087790,
  mediumspringgreen: 64154,
  mediumturquoise: 4772300,
  mediumvioletred: 13047173,
  midnightblue: 1644912,
  mintcream: 16121850,
  mistyrose: 16770273,
  moccasin: 16770229,
  navajowhite: 16768685,
  navy: 128,
  oldlace: 16643558,
  olive: 8421376,
  olivedrab: 7048739,
  orange: 16753920,
  orangered: 16729344,
  orchid: 14315734,
  palegoldenrod: 15657130,
  palegreen: 10025880,
  paleturquoise: 11529966,
  palevioletred: 14381203,
  papayawhip: 16773077,
  peachpuff: 16767673,
  peru: 13468991,
  pink: 16761035,
  plum: 14524637,
  powderblue: 11591910,
  purple: 8388736,
  rebeccapurple: 6697881,
  red: 16711680,
  rosybrown: 12357519,
  royalblue: 4286945,
  saddlebrown: 9127187,
  salmon: 16416882,
  sandybrown: 16032864,
  seagreen: 3050327,
  seashell: 16774638,
  sienna: 10506797,
  silver: 12632256,
  skyblue: 8900331,
  slateblue: 6970061,
  slategray: 7372944,
  slategrey: 7372944,
  snow: 16775930,
  springgreen: 65407,
  steelblue: 4620980,
  tan: 13808780,
  teal: 32896,
  thistle: 14204888,
  tomato: 16737095,
  turquoise: 4251856,
  violet: 15631086,
  wheat: 16113331,
  white: 16777215,
  whitesmoke: 16119285,
  yellow: 16776960,
  yellowgreen: 10145074
}, pi = { h: 0, s: 0, l: 0 }, Ys = { h: 0, s: 0, l: 0 };
function Co(i, e, t) {
  return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? i + (e - i) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? i + (e - i) * 6 * (2 / 3 - t) : i;
}
class Ue {
  constructor(e, t, n) {
    return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(e, t, n);
  }
  set(e, t, n) {
    if (t === void 0 && n === void 0) {
      const r = e;
      r && r.isColor ? this.copy(r) : typeof r == "number" ? this.setHex(r) : typeof r == "string" && this.setStyle(r);
    } else
      this.setRGB(e, t, n);
    return this;
  }
  setScalar(e) {
    return this.r = e, this.g = e, this.b = e, this;
  }
  setHex(e, t = Ut) {
    return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, nt.toWorkingColorSpace(this, t), this;
  }
  setRGB(e, t, n, r = nt.workingColorSpace) {
    return this.r = e, this.g = t, this.b = n, nt.toWorkingColorSpace(this, r), this;
  }
  setHSL(e, t, n, r = nt.workingColorSpace) {
    if (e = Cc(e, 1), t = Vt(t, 0, 1), n = Vt(n, 0, 1), t === 0)
      this.r = this.g = this.b = n;
    else {
      const s = n <= 0.5 ? n * (1 + t) : n + t - n * t, a = 2 * n - s;
      this.r = Co(a, s, e + 1 / 3), this.g = Co(a, s, e), this.b = Co(a, s, e - 1 / 3);
    }
    return nt.toWorkingColorSpace(this, r), this;
  }
  setStyle(e, t = Ut) {
    function n(s) {
      s !== void 0 && parseFloat(s) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored.");
    }
    let r;
    if (r = /^(\w+)\(([^\)]*)\)/.exec(e)) {
      let s;
      const a = r[1], o = r[2];
      switch (a) {
        case "rgb":
        case "rgba":
          if (s = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
            return n(s[4]), this.setRGB(
              Math.min(255, parseInt(s[1], 10)) / 255,
              Math.min(255, parseInt(s[2], 10)) / 255,
              Math.min(255, parseInt(s[3], 10)) / 255,
              t
            );
          if (s = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
            return n(s[4]), this.setRGB(
              Math.min(100, parseInt(s[1], 10)) / 100,
              Math.min(100, parseInt(s[2], 10)) / 100,
              Math.min(100, parseInt(s[3], 10)) / 100,
              t
            );
          break;
        case "hsl":
        case "hsla":
          if (s = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
            return n(s[4]), this.setHSL(
              parseFloat(s[1]) / 360,
              parseFloat(s[2]) / 100,
              parseFloat(s[3]) / 100,
              t
            );
          break;
        default:
          console.warn("THREE.Color: Unknown color model " + e);
      }
    } else if (r = /^\#([A-Fa-f\d]+)$/.exec(e)) {
      const s = r[1], a = s.length;
      if (a === 3)
        return this.setRGB(
          parseInt(s.charAt(0), 16) / 15,
          parseInt(s.charAt(1), 16) / 15,
          parseInt(s.charAt(2), 16) / 15,
          t
        );
      if (a === 6)
        return this.setHex(parseInt(s, 16), t);
      console.warn("THREE.Color: Invalid hex color " + e);
    } else if (e && e.length > 0)
      return this.setColorName(e, t);
    return this;
  }
  setColorName(e, t = Ut) {
    const n = Gd[e.toLowerCase()];
    return n !== void 0 ? this.setHex(n, t) : console.warn("THREE.Color: Unknown color " + e), this;
  }
  clone() {
    return new this.constructor(this.r, this.g, this.b);
  }
  copy(e) {
    return this.r = e.r, this.g = e.g, this.b = e.b, this;
  }
  copySRGBToLinear(e) {
    return this.r = ii(e.r), this.g = ii(e.g), this.b = ii(e.b), this;
  }
  copyLinearToSRGB(e) {
    return this.r = yr(e.r), this.g = yr(e.g), this.b = yr(e.b), this;
  }
  convertSRGBToLinear() {
    return this.copySRGBToLinear(this), this;
  }
  convertLinearToSRGB() {
    return this.copyLinearToSRGB(this), this;
  }
  getHex(e = Ut) {
    return nt.fromWorkingColorSpace(Xt.copy(this), e), Math.round(Vt(Xt.r * 255, 0, 255)) * 65536 + Math.round(Vt(Xt.g * 255, 0, 255)) * 256 + Math.round(Vt(Xt.b * 255, 0, 255));
  }
  getHexString(e = Ut) {
    return ("000000" + this.getHex(e).toString(16)).slice(-6);
  }
  getHSL(e, t = nt.workingColorSpace) {
    nt.fromWorkingColorSpace(Xt.copy(this), t);
    const n = Xt.r, r = Xt.g, s = Xt.b, a = Math.max(n, r, s), o = Math.min(n, r, s);
    let l, c;
    const u = (o + a) / 2;
    if (o === a)
      l = 0, c = 0;
    else {
      const h = a - o;
      switch (c = u <= 0.5 ? h / (a + o) : h / (2 - a - o), a) {
        case n:
          l = (r - s) / h + (r < s ? 6 : 0);
          break;
        case r:
          l = (s - n) / h + 2;
          break;
        case s:
          l = (n - r) / h + 4;
          break;
      }
      l /= 6;
    }
    return e.h = l, e.s = c, e.l = u, e;
  }
  getRGB(e, t = nt.workingColorSpace) {
    return nt.fromWorkingColorSpace(Xt.copy(this), t), e.r = Xt.r, e.g = Xt.g, e.b = Xt.b, e;
  }
  getStyle(e = Ut) {
    nt.fromWorkingColorSpace(Xt.copy(this), e);
    const t = Xt.r, n = Xt.g, r = Xt.b;
    return e !== Ut ? `color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})` : `rgb(${Math.round(t * 255)},${Math.round(n * 255)},${Math.round(r * 255)})`;
  }
  offsetHSL(e, t, n) {
    return this.getHSL(pi), this.setHSL(pi.h + e, pi.s + t, pi.l + n);
  }
  add(e) {
    return this.r += e.r, this.g += e.g, this.b += e.b, this;
  }
  addColors(e, t) {
    return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this;
  }
  addScalar(e) {
    return this.r += e, this.g += e, this.b += e, this;
  }
  sub(e) {
    return this.r = Math.max(0, this.r - e.r), this.g = Math.max(0, this.g - e.g), this.b = Math.max(0, this.b - e.b), this;
  }
  multiply(e) {
    return this.r *= e.r, this.g *= e.g, this.b *= e.b, this;
  }
  multiplyScalar(e) {
    return this.r *= e, this.g *= e, this.b *= e, this;
  }
  lerp(e, t) {
    return this.r += (e.r - this.r) * t, this.g += (e.g - this.g) * t, this.b += (e.b - this.b) * t, this;
  }
  lerpColors(e, t, n) {
    return this.r = e.r + (t.r - e.r) * n, this.g = e.g + (t.g - e.g) * n, this.b = e.b + (t.b - e.b) * n, this;
  }
  lerpHSL(e, t) {
    this.getHSL(pi), e.getHSL(Ys);
    const n = _s(pi.h, Ys.h, t), r = _s(pi.s, Ys.s, t), s = _s(pi.l, Ys.l, t);
    return this.setHSL(n, r, s), this;
  }
  setFromVector3(e) {
    return this.r = e.x, this.g = e.y, this.b = e.z, this;
  }
  applyMatrix3(e) {
    const t = this.r, n = this.g, r = this.b, s = e.elements;
    return this.r = s[0] * t + s[3] * n + s[6] * r, this.g = s[1] * t + s[4] * n + s[7] * r, this.b = s[2] * t + s[5] * n + s[8] * r, this;
  }
  equals(e) {
    return e.r === this.r && e.g === this.g && e.b === this.b;
  }
  fromArray(e, t = 0) {
    return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e;
  }
  fromBufferAttribute(e, t) {
    return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), this;
  }
  toJSON() {
    return this.getHex();
  }
  *[Symbol.iterator]() {
    yield this.r, yield this.g, yield this.b;
  }
}
const Xt = /* @__PURE__ */ new Ue();
Ue.NAMES = Gd;
let ix = 0;
class Bn extends Yi {
  static get type() {
    return "Material";
  }
  get type() {
    return this.constructor.type;
  }
  set type(e) {
  }
  constructor() {
    super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: ix++ }), this.uuid = Rn(), this.name = "", this.blending = br, this.side = si, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = ml, this.blendDst = gl, this.blendEquation = Oi, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new Ue(0, 0, 0), this.blendAlpha = 0, this.depthFunc = Dr, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = Zu, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = Qi, this.stencilZFail = Qi, this.stencilZPass = Qi, this.stencilWrite = !1, this.clippingPlanes = null, this.clipIntersection = !1, this.clipShadows = !1, this.shadowSide = null, this.colorWrite = !0, this.precision = null, this.polygonOffset = !1, this.polygonOffsetFactor = 0, this.polygonOffsetUnits = 0, this.dithering = !1, this.alphaToCoverage = !1, this.premultipliedAlpha = !1, this.forceSinglePass = !1, this.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0;
  }
  get alphaTest() {
    return this._alphaTest;
  }
  set alphaTest(e) {
    this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e;
  }
  // onBeforeRender and onBeforeCompile only supported in WebGLRenderer
  onBeforeRender() {
  }
  onBeforeCompile() {
  }
  customProgramCacheKey() {
    return this.onBeforeCompile.toString();
  }
  setValues(e) {
    if (e !== void 0)
      for (const t in e) {
        const n = e[t];
        if (n === void 0) {
          console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);
          continue;
        }
        const r = this[t];
        if (r === void 0) {
          console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);
          continue;
        }
        r && r.isColor ? r.set(n) : r && r.isVector3 && n && n.isVector3 ? r.copy(n) : this[t] = n;
      }
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    t && (e = {
      textures: {},
      images: {}
    });
    const n = {
      metadata: {
        version: 4.6,
        type: "Material",
        generator: "Material.toJSON"
      }
    };
    n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.color && this.color.isColor && (n.color = this.color.getHex()), this.roughness !== void 0 && (n.roughness = this.roughness), this.metalness !== void 0 && (n.metalness = this.metalness), this.sheen !== void 0 && (n.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (n.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (n.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (n.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (n.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (n.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (n.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (n.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (n.shininess = this.shininess), this.clearcoat !== void 0 && (n.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (n.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (n.clearcoatMap = this.clearcoatMap.toJSON(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.dispersion !== void 0 && (n.dispersion = this.dispersion), this.iridescence !== void 0 && (n.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (n.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (n.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (n.iridescenceMap = this.iridescenceMap.toJSON(e).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (n.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid), this.anisotropy !== void 0 && (n.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (n.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (n.anisotropyMap = this.anisotropyMap.toJSON(e).uuid), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), this.envMapRotation !== void 0 && (n.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (n.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (n.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (n.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (n.gradientMap = this.gradientMap.toJSON(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (n.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (n.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (n.size = this.size), this.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== br && (n.blending = this.blending), this.side !== si && (n.side = this.side), this.vertexColors === !0 && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.transparent === !0 && (n.transparent = !0), this.blendSrc !== ml && (n.blendSrc = this.blendSrc), this.blendDst !== gl && (n.blendDst = this.blendDst), this.blendEquation !== Oi && (n.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (n.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (n.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (n.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (n.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (n.blendAlpha = this.blendAlpha), this.depthFunc !== Dr && (n.depthFunc = this.depthFunc), this.depthTest === !1 && (n.depthTest = this.depthTest), this.depthWrite === !1 && (n.depthWrite = this.depthWrite), this.colorWrite === !1 && (n.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (n.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== Zu && (n.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (n.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (n.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== Qi && (n.stencilFail = this.stencilFail), this.stencilZFail !== Qi && (n.stencilZFail = this.stencilZFail), this.stencilZPass !== Qi && (n.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (n.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (n.linewidth = this.linewidth), this.dashSize !== void 0 && (n.dashSize = this.dashSize), this.gapSize !== void 0 && (n.gapSize = this.gapSize), this.scale !== void 0 && (n.scale = this.scale), this.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaHash === !0 && (n.alphaHash = !0), this.alphaToCoverage === !0 && (n.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = !0), this.forceSinglePass === !0 && (n.forceSinglePass = !0), this.wireframe === !0 && (n.wireframe = !0), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = !0), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), this.fog === !1 && (n.fog = !1), Object.keys(this.userData).length > 0 && (n.userData = this.userData);
    function r(s) {
      const a = [];
      for (const o in s) {
        const l = s[o];
        delete l.metadata, a.push(l);
      }
      return a;
    }
    if (t) {
      const s = r(e.textures), a = r(e.images);
      s.length > 0 && (n.textures = s), a.length > 0 && (n.images = a);
    }
    return n;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    this.name = e.name, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.blendColor.copy(e.blendColor), this.blendAlpha = e.blendAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite;
    const t = e.clippingPlanes;
    let n = null;
    if (t !== null) {
      const r = t.length;
      n = new Array(r);
      for (let s = 0; s !== r; ++s)
        n[s] = t[s].clone();
    }
    return this.clippingPlanes = n, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaHash = e.alphaHash, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.forceSinglePass = e.forceSinglePass, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
  onBuild() {
    console.warn("Material: onBuild() has been removed.");
  }
}
class ki extends Bn {
  static get type() {
    return "MeshBasicMaterial";
  }
  constructor(e) {
    super(), this.isMeshBasicMaterial = !0, this.color = new Ue(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new Hn(), this.combine = yd, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.fog = e.fog, this;
  }
}
const Pt = /* @__PURE__ */ new L(), Zs = /* @__PURE__ */ new ze();
class Qt {
  constructor(e, t, n = !1) {
    if (Array.isArray(e))
      throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
    this.isBufferAttribute = !0, this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = n, this.usage = Ql, this.updateRanges = [], this.gpuType = wn, this.version = 0;
  }
  onUploadCallback() {
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
  setUsage(e) {
    return this.usage = e, this;
  }
  addUpdateRange(e, t) {
    this.updateRanges.push({ start: e, count: t });
  }
  clearUpdateRanges() {
    this.updateRanges.length = 0;
  }
  copy(e) {
    return this.name = e.name, this.array = new e.array.constructor(e.array), this.itemSize = e.itemSize, this.count = e.count, this.normalized = e.normalized, this.usage = e.usage, this.gpuType = e.gpuType, this;
  }
  copyAt(e, t, n) {
    e *= this.itemSize, n *= t.itemSize;
    for (let r = 0, s = this.itemSize; r < s; r++)
      this.array[e + r] = t.array[n + r];
    return this;
  }
  copyArray(e) {
    return this.array.set(e), this;
  }
  applyMatrix3(e) {
    if (this.itemSize === 2)
      for (let t = 0, n = this.count; t < n; t++)
        Zs.fromBufferAttribute(this, t), Zs.applyMatrix3(e), this.setXY(t, Zs.x, Zs.y);
    else if (this.itemSize === 3)
      for (let t = 0, n = this.count; t < n; t++)
        Pt.fromBufferAttribute(this, t), Pt.applyMatrix3(e), this.setXYZ(t, Pt.x, Pt.y, Pt.z);
    return this;
  }
  applyMatrix4(e) {
    for (let t = 0, n = this.count; t < n; t++)
      Pt.fromBufferAttribute(this, t), Pt.applyMatrix4(e), this.setXYZ(t, Pt.x, Pt.y, Pt.z);
    return this;
  }
  applyNormalMatrix(e) {
    for (let t = 0, n = this.count; t < n; t++)
      Pt.fromBufferAttribute(this, t), Pt.applyNormalMatrix(e), this.setXYZ(t, Pt.x, Pt.y, Pt.z);
    return this;
  }
  transformDirection(e) {
    for (let t = 0, n = this.count; t < n; t++)
      Pt.fromBufferAttribute(this, t), Pt.transformDirection(e), this.setXYZ(t, Pt.x, Pt.y, Pt.z);
    return this;
  }
  set(e, t = 0) {
    return this.array.set(e, t), this;
  }
  getComponent(e, t) {
    let n = this.array[e * this.itemSize + t];
    return this.normalized && (n = An(n, this.array)), n;
  }
  setComponent(e, t, n) {
    return this.normalized && (n = ft(n, this.array)), this.array[e * this.itemSize + t] = n, this;
  }
  getX(e) {
    let t = this.array[e * this.itemSize];
    return this.normalized && (t = An(t, this.array)), t;
  }
  setX(e, t) {
    return this.normalized && (t = ft(t, this.array)), this.array[e * this.itemSize] = t, this;
  }
  getY(e) {
    let t = this.array[e * this.itemSize + 1];
    return this.normalized && (t = An(t, this.array)), t;
  }
  setY(e, t) {
    return this.normalized && (t = ft(t, this.array)), this.array[e * this.itemSize + 1] = t, this;
  }
  getZ(e) {
    let t = this.array[e * this.itemSize + 2];
    return this.normalized && (t = An(t, this.array)), t;
  }
  setZ(e, t) {
    return this.normalized && (t = ft(t, this.array)), this.array[e * this.itemSize + 2] = t, this;
  }
  getW(e) {
    let t = this.array[e * this.itemSize + 3];
    return this.normalized && (t = An(t, this.array)), t;
  }
  setW(e, t) {
    return this.normalized && (t = ft(t, this.array)), this.array[e * this.itemSize + 3] = t, this;
  }
  setXY(e, t, n) {
    return e *= this.itemSize, this.normalized && (t = ft(t, this.array), n = ft(n, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this;
  }
  setXYZ(e, t, n, r) {
    return e *= this.itemSize, this.normalized && (t = ft(t, this.array), n = ft(n, this.array), r = ft(r, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this;
  }
  setXYZW(e, t, n, r, s) {
    return e *= this.itemSize, this.normalized && (t = ft(t, this.array), n = ft(n, this.array), r = ft(r, this.array), s = ft(s, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this.array[e + 3] = s, this;
  }
  onUpload(e) {
    return this.onUploadCallback = e, this;
  }
  clone() {
    return new this.constructor(this.array, this.itemSize).copy(this);
  }
  toJSON() {
    const e = {
      itemSize: this.itemSize,
      type: this.array.constructor.name,
      array: Array.from(this.array),
      normalized: this.normalized
    };
    return this.name !== "" && (e.name = this.name), this.usage !== Ql && (e.usage = this.usage), e;
  }
}
class Vd extends Qt {
  constructor(e, t, n) {
    super(new Uint16Array(e), t, n);
  }
}
class Wd extends Qt {
  constructor(e, t, n) {
    super(new Uint32Array(e), t, n);
  }
}
class Ot extends Qt {
  constructor(e, t, n) {
    super(new Float32Array(e), t, n);
  }
}
let rx = 0;
const pn = /* @__PURE__ */ new Xe(), Po = /* @__PURE__ */ new Rt(), cr = /* @__PURE__ */ new L(), ln = /* @__PURE__ */ new vn(), rs = /* @__PURE__ */ new vn(), Ht = /* @__PURE__ */ new L();
class fn extends Yi {
  constructor() {
    super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: rx++ }), this.uuid = Rn(), this.name = "", this.type = "BufferGeometry", this.index = null, this.indirect = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { start: 0, count: 1 / 0 }, this.userData = {};
  }
  getIndex() {
    return this.index;
  }
  setIndex(e) {
    return Array.isArray(e) ? this.index = new (Bd(e) ? Wd : Vd)(e, 1) : this.index = e, this;
  }
  setIndirect(e) {
    return this.indirect = e, this;
  }
  getIndirect() {
    return this.indirect;
  }
  getAttribute(e) {
    return this.attributes[e];
  }
  setAttribute(e, t) {
    return this.attributes[e] = t, this;
  }
  deleteAttribute(e) {
    return delete this.attributes[e], this;
  }
  hasAttribute(e) {
    return this.attributes[e] !== void 0;
  }
  addGroup(e, t, n = 0) {
    this.groups.push({
      start: e,
      count: t,
      materialIndex: n
    });
  }
  clearGroups() {
    this.groups = [];
  }
  setDrawRange(e, t) {
    this.drawRange.start = e, this.drawRange.count = t;
  }
  applyMatrix4(e) {
    const t = this.attributes.position;
    t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0);
    const n = this.attributes.normal;
    if (n !== void 0) {
      const s = new We().getNormalMatrix(e);
      n.applyNormalMatrix(s), n.needsUpdate = !0;
    }
    const r = this.attributes.tangent;
    return r !== void 0 && (r.transformDirection(e), r.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;
  }
  applyQuaternion(e) {
    return pn.makeRotationFromQuaternion(e), this.applyMatrix4(pn), this;
  }
  rotateX(e) {
    return pn.makeRotationX(e), this.applyMatrix4(pn), this;
  }
  rotateY(e) {
    return pn.makeRotationY(e), this.applyMatrix4(pn), this;
  }
  rotateZ(e) {
    return pn.makeRotationZ(e), this.applyMatrix4(pn), this;
  }
  translate(e, t, n) {
    return pn.makeTranslation(e, t, n), this.applyMatrix4(pn), this;
  }
  scale(e, t, n) {
    return pn.makeScale(e, t, n), this.applyMatrix4(pn), this;
  }
  lookAt(e) {
    return Po.lookAt(e), Po.updateMatrix(), this.applyMatrix4(Po.matrix), this;
  }
  center() {
    return this.computeBoundingBox(), this.boundingBox.getCenter(cr).negate(), this.translate(cr.x, cr.y, cr.z), this;
  }
  setFromPoints(e) {
    const t = this.getAttribute("position");
    if (t === void 0) {
      const n = [];
      for (let r = 0, s = e.length; r < s; r++) {
        const a = e[r];
        n.push(a.x, a.y, a.z || 0);
      }
      this.setAttribute("position", new Ot(n, 3));
    } else {
      for (let n = 0, r = t.count; n < r; n++) {
        const s = e[n];
        t.setXYZ(n, s.x, s.y, s.z || 0);
      }
      e.length > t.count && console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."), t.needsUpdate = !0;
    }
    return this;
  }
  computeBoundingBox() {
    this.boundingBox === null && (this.boundingBox = new vn());
    const e = this.attributes.position, t = this.morphAttributes.position;
    if (e && e.isGLBufferAttribute) {
      console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set(
        new L(-1 / 0, -1 / 0, -1 / 0),
        new L(1 / 0, 1 / 0, 1 / 0)
      );
      return;
    }
    if (e !== void 0) {
      if (this.boundingBox.setFromBufferAttribute(e), t)
        for (let n = 0, r = t.length; n < r; n++) {
          const s = t[n];
          ln.setFromBufferAttribute(s), this.morphTargetsRelative ? (Ht.addVectors(this.boundingBox.min, ln.min), this.boundingBox.expandByPoint(Ht), Ht.addVectors(this.boundingBox.max, ln.max), this.boundingBox.expandByPoint(Ht)) : (this.boundingBox.expandByPoint(ln.min), this.boundingBox.expandByPoint(ln.max));
        }
    } else
      this.boundingBox.makeEmpty();
    (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);
  }
  computeBoundingSphere() {
    this.boundingSphere === null && (this.boundingSphere = new zn());
    const e = this.attributes.position, t = this.morphAttributes.position;
    if (e && e.isGLBufferAttribute) {
      console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new L(), 1 / 0);
      return;
    }
    if (e) {
      const n = this.boundingSphere.center;
      if (ln.setFromBufferAttribute(e), t)
        for (let s = 0, a = t.length; s < a; s++) {
          const o = t[s];
          rs.setFromBufferAttribute(o), this.morphTargetsRelative ? (Ht.addVectors(ln.min, rs.min), ln.expandByPoint(Ht), Ht.addVectors(ln.max, rs.max), ln.expandByPoint(Ht)) : (ln.expandByPoint(rs.min), ln.expandByPoint(rs.max));
        }
      ln.getCenter(n);
      let r = 0;
      for (let s = 0, a = e.count; s < a; s++)
        Ht.fromBufferAttribute(e, s), r = Math.max(r, n.distanceToSquared(Ht));
      if (t)
        for (let s = 0, a = t.length; s < a; s++) {
          const o = t[s], l = this.morphTargetsRelative;
          for (let c = 0, u = o.count; c < u; c++)
            Ht.fromBufferAttribute(o, c), l && (cr.fromBufferAttribute(e, c), Ht.add(cr)), r = Math.max(r, n.distanceToSquared(Ht));
        }
      this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
    }
  }
  computeTangents() {
    const e = this.index, t = this.attributes;
    if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) {
      console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");
      return;
    }
    const n = t.position, r = t.normal, s = t.uv;
    this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new Qt(new Float32Array(4 * n.count), 4));
    const a = this.getAttribute("tangent"), o = [], l = [];
    for (let C = 0; C < n.count; C++)
      o[C] = new L(), l[C] = new L();
    const c = new L(), u = new L(), h = new L(), d = new ze(), m = new ze(), v = new ze(), b = new L(), p = new L();
    function f(C, y, E) {
      c.fromBufferAttribute(n, C), u.fromBufferAttribute(n, y), h.fromBufferAttribute(n, E), d.fromBufferAttribute(s, C), m.fromBufferAttribute(s, y), v.fromBufferAttribute(s, E), u.sub(c), h.sub(c), m.sub(d), v.sub(d);
      const R = 1 / (m.x * v.y - v.x * m.y);
      isFinite(R) && (b.copy(u).multiplyScalar(v.y).addScaledVector(h, -m.y).multiplyScalar(R), p.copy(h).multiplyScalar(m.x).addScaledVector(u, -v.x).multiplyScalar(R), o[C].add(b), o[y].add(b), o[E].add(b), l[C].add(p), l[y].add(p), l[E].add(p));
    }
    let x = this.groups;
    x.length === 0 && (x = [{
      start: 0,
      count: e.count
    }]);
    for (let C = 0, y = x.length; C < y; ++C) {
      const E = x[C], R = E.start, q = E.count;
      for (let G = R, V = R + q; G < V; G += 3)
        f(
          e.getX(G + 0),
          e.getX(G + 1),
          e.getX(G + 2)
        );
    }
    const g = new L(), _ = new L(), T = new L(), A = new L();
    function M(C) {
      T.fromBufferAttribute(r, C), A.copy(T);
      const y = o[C];
      g.copy(y), g.sub(T.multiplyScalar(T.dot(y))).normalize(), _.crossVectors(A, y);
      const R = _.dot(l[C]) < 0 ? -1 : 1;
      a.setXYZW(C, g.x, g.y, g.z, R);
    }
    for (let C = 0, y = x.length; C < y; ++C) {
      const E = x[C], R = E.start, q = E.count;
      for (let G = R, V = R + q; G < V; G += 3)
        M(e.getX(G + 0)), M(e.getX(G + 1)), M(e.getX(G + 2));
    }
  }
  computeVertexNormals() {
    const e = this.index, t = this.getAttribute("position");
    if (t !== void 0) {
      let n = this.getAttribute("normal");
      if (n === void 0)
        n = new Qt(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n);
      else
        for (let d = 0, m = n.count; d < m; d++)
          n.setXYZ(d, 0, 0, 0);
      const r = new L(), s = new L(), a = new L(), o = new L(), l = new L(), c = new L(), u = new L(), h = new L();
      if (e)
        for (let d = 0, m = e.count; d < m; d += 3) {
          const v = e.getX(d + 0), b = e.getX(d + 1), p = e.getX(d + 2);
          r.fromBufferAttribute(t, v), s.fromBufferAttribute(t, b), a.fromBufferAttribute(t, p), u.subVectors(a, s), h.subVectors(r, s), u.cross(h), o.fromBufferAttribute(n, v), l.fromBufferAttribute(n, b), c.fromBufferAttribute(n, p), o.add(u), l.add(u), c.add(u), n.setXYZ(v, o.x, o.y, o.z), n.setXYZ(b, l.x, l.y, l.z), n.setXYZ(p, c.x, c.y, c.z);
        }
      else
        for (let d = 0, m = t.count; d < m; d += 3)
          r.fromBufferAttribute(t, d + 0), s.fromBufferAttribute(t, d + 1), a.fromBufferAttribute(t, d + 2), u.subVectors(a, s), h.subVectors(r, s), u.cross(h), n.setXYZ(d + 0, u.x, u.y, u.z), n.setXYZ(d + 1, u.x, u.y, u.z), n.setXYZ(d + 2, u.x, u.y, u.z);
      this.normalizeNormals(), n.needsUpdate = !0;
    }
  }
  normalizeNormals() {
    const e = this.attributes.normal;
    for (let t = 0, n = e.count; t < n; t++)
      Ht.fromBufferAttribute(e, t), Ht.normalize(), e.setXYZ(t, Ht.x, Ht.y, Ht.z);
  }
  toNonIndexed() {
    function e(o, l) {
      const c = o.array, u = o.itemSize, h = o.normalized, d = new c.constructor(l.length * u);
      let m = 0, v = 0;
      for (let b = 0, p = l.length; b < p; b++) {
        o.isInterleavedBufferAttribute ? m = l[b] * o.data.stride + o.offset : m = l[b] * u;
        for (let f = 0; f < u; f++)
          d[v++] = c[m++];
      }
      return new Qt(d, u, h);
    }
    if (this.index === null)
      return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;
    const t = new fn(), n = this.index.array, r = this.attributes;
    for (const o in r) {
      const l = r[o], c = e(l, n);
      t.setAttribute(o, c);
    }
    const s = this.morphAttributes;
    for (const o in s) {
      const l = [], c = s[o];
      for (let u = 0, h = c.length; u < h; u++) {
        const d = c[u], m = e(d, n);
        l.push(m);
      }
      t.morphAttributes[o] = l;
    }
    t.morphTargetsRelative = this.morphTargetsRelative;
    const a = this.groups;
    for (let o = 0, l = a.length; o < l; o++) {
      const c = a[o];
      t.addGroup(c.start, c.count, c.materialIndex);
    }
    return t;
  }
  toJSON() {
    const e = {
      metadata: {
        version: 4.6,
        type: "BufferGeometry",
        generator: "BufferGeometry.toJSON"
      }
    };
    if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) {
      const l = this.parameters;
      for (const c in l)
        l[c] !== void 0 && (e[c] = l[c]);
      return e;
    }
    e.data = { attributes: {} };
    const t = this.index;
    t !== null && (e.data.index = {
      type: t.array.constructor.name,
      array: Array.prototype.slice.call(t.array)
    });
    const n = this.attributes;
    for (const l in n) {
      const c = n[l];
      e.data.attributes[l] = c.toJSON(e.data);
    }
    const r = {};
    let s = !1;
    for (const l in this.morphAttributes) {
      const c = this.morphAttributes[l], u = [];
      for (let h = 0, d = c.length; h < d; h++) {
        const m = c[h];
        u.push(m.toJSON(e.data));
      }
      u.length > 0 && (r[l] = u, s = !0);
    }
    s && (e.data.morphAttributes = r, e.data.morphTargetsRelative = this.morphTargetsRelative);
    const a = this.groups;
    a.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(a)));
    const o = this.boundingSphere;
    return o !== null && (e.data.boundingSphere = {
      center: o.center.toArray(),
      radius: o.radius
    }), e;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null;
    const t = {};
    this.name = e.name;
    const n = e.index;
    n !== null && this.setIndex(n.clone(t));
    const r = e.attributes;
    for (const c in r) {
      const u = r[c];
      this.setAttribute(c, u.clone(t));
    }
    const s = e.morphAttributes;
    for (const c in s) {
      const u = [], h = s[c];
      for (let d = 0, m = h.length; d < m; d++)
        u.push(h[d].clone(t));
      this.morphAttributes[c] = u;
    }
    this.morphTargetsRelative = e.morphTargetsRelative;
    const a = e.groups;
    for (let c = 0, u = a.length; c < u; c++) {
      const h = a[c];
      this.addGroup(h.start, h.count, h.materialIndex);
    }
    const o = e.boundingBox;
    o !== null && (this.boundingBox = o.clone());
    const l = e.boundingSphere;
    return l !== null && (this.boundingSphere = l.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
const dh = /* @__PURE__ */ new Xe(), Ri = /* @__PURE__ */ new Ps(), Ks = /* @__PURE__ */ new zn(), ph = /* @__PURE__ */ new L(), $s = /* @__PURE__ */ new L(), Js = /* @__PURE__ */ new L(), Qs = /* @__PURE__ */ new L(), Lo = /* @__PURE__ */ new L(), ea = /* @__PURE__ */ new L(), mh = /* @__PURE__ */ new L(), ta = /* @__PURE__ */ new L();
class hn extends Rt {
  constructor(e = new fn(), t = new ki()) {
    super(), this.isMesh = !0, this.type = "Mesh", this.geometry = e, this.material = t, this.updateMorphTargets();
  }
  copy(e, t) {
    return super.copy(e, t), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;
  }
  updateMorphTargets() {
    const t = this.geometry.morphAttributes, n = Object.keys(t);
    if (n.length > 0) {
      const r = t[n[0]];
      if (r !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let s = 0, a = r.length; s < a; s++) {
          const o = r[s].name || String(s);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = s;
        }
      }
    }
  }
  getVertexPosition(e, t) {
    const n = this.geometry, r = n.attributes.position, s = n.morphAttributes.position, a = n.morphTargetsRelative;
    t.fromBufferAttribute(r, e);
    const o = this.morphTargetInfluences;
    if (s && o) {
      ea.set(0, 0, 0);
      for (let l = 0, c = s.length; l < c; l++) {
        const u = o[l], h = s[l];
        u !== 0 && (Lo.fromBufferAttribute(h, e), a ? ea.addScaledVector(Lo, u) : ea.addScaledVector(Lo.sub(t), u));
      }
      t.add(ea);
    }
    return t;
  }
  raycast(e, t) {
    const n = this.geometry, r = this.material, s = this.matrixWorld;
    r !== void 0 && (n.boundingSphere === null && n.computeBoundingSphere(), Ks.copy(n.boundingSphere), Ks.applyMatrix4(s), Ri.copy(e.ray).recast(e.near), !(Ks.containsPoint(Ri.origin) === !1 && (Ri.intersectSphere(Ks, ph) === null || Ri.origin.distanceToSquared(ph) > (e.far - e.near) ** 2)) && (dh.copy(s).invert(), Ri.copy(e.ray).applyMatrix4(dh), !(n.boundingBox !== null && Ri.intersectsBox(n.boundingBox) === !1) && this._computeIntersections(e, t, Ri)));
  }
  _computeIntersections(e, t, n) {
    let r;
    const s = this.geometry, a = this.material, o = s.index, l = s.attributes.position, c = s.attributes.uv, u = s.attributes.uv1, h = s.attributes.normal, d = s.groups, m = s.drawRange;
    if (o !== null)
      if (Array.isArray(a))
        for (let v = 0, b = d.length; v < b; v++) {
          const p = d[v], f = a[p.materialIndex], x = Math.max(p.start, m.start), g = Math.min(o.count, Math.min(p.start + p.count, m.start + m.count));
          for (let _ = x, T = g; _ < T; _ += 3) {
            const A = o.getX(_), M = o.getX(_ + 1), C = o.getX(_ + 2);
            r = na(this, f, e, n, c, u, h, A, M, C), r && (r.faceIndex = Math.floor(_ / 3), r.face.materialIndex = p.materialIndex, t.push(r));
          }
        }
      else {
        const v = Math.max(0, m.start), b = Math.min(o.count, m.start + m.count);
        for (let p = v, f = b; p < f; p += 3) {
          const x = o.getX(p), g = o.getX(p + 1), _ = o.getX(p + 2);
          r = na(this, a, e, n, c, u, h, x, g, _), r && (r.faceIndex = Math.floor(p / 3), t.push(r));
        }
      }
    else if (l !== void 0)
      if (Array.isArray(a))
        for (let v = 0, b = d.length; v < b; v++) {
          const p = d[v], f = a[p.materialIndex], x = Math.max(p.start, m.start), g = Math.min(l.count, Math.min(p.start + p.count, m.start + m.count));
          for (let _ = x, T = g; _ < T; _ += 3) {
            const A = _, M = _ + 1, C = _ + 2;
            r = na(this, f, e, n, c, u, h, A, M, C), r && (r.faceIndex = Math.floor(_ / 3), r.face.materialIndex = p.materialIndex, t.push(r));
          }
        }
      else {
        const v = Math.max(0, m.start), b = Math.min(l.count, m.start + m.count);
        for (let p = v, f = b; p < f; p += 3) {
          const x = p, g = p + 1, _ = p + 2;
          r = na(this, a, e, n, c, u, h, x, g, _), r && (r.faceIndex = Math.floor(p / 3), t.push(r));
        }
      }
  }
}
function sx(i, e, t, n, r, s, a, o) {
  let l;
  if (e.side === sn ? l = n.intersectTriangle(a, s, r, !0, o) : l = n.intersectTriangle(r, s, a, e.side === si, o), l === null) return null;
  ta.copy(o), ta.applyMatrix4(i.matrixWorld);
  const c = t.ray.origin.distanceTo(ta);
  return c < t.near || c > t.far ? null : {
    distance: c,
    point: ta.clone(),
    object: i
  };
}
function na(i, e, t, n, r, s, a, o, l, c) {
  i.getVertexPosition(o, $s), i.getVertexPosition(l, Js), i.getVertexPosition(c, Qs);
  const u = sx(i, e, t, n, $s, Js, Qs, mh);
  if (u) {
    const h = new L();
    Tn.getBarycoord(mh, $s, Js, Qs, h), r && (u.uv = Tn.getInterpolatedAttribute(r, o, l, c, h, new ze())), s && (u.uv1 = Tn.getInterpolatedAttribute(s, o, l, c, h, new ze())), a && (u.normal = Tn.getInterpolatedAttribute(a, o, l, c, h, new L()), u.normal.dot(n.direction) > 0 && u.normal.multiplyScalar(-1));
    const d = {
      a: o,
      b: l,
      c,
      normal: new L(),
      materialIndex: 0
    };
    Tn.getNormal($s, Js, Qs, d.normal), u.face = d, u.barycoord = h;
  }
  return u;
}
class Ls extends fn {
  constructor(e = 1, t = 1, n = 1, r = 1, s = 1, a = 1) {
    super(), this.type = "BoxGeometry", this.parameters = {
      width: e,
      height: t,
      depth: n,
      widthSegments: r,
      heightSegments: s,
      depthSegments: a
    };
    const o = this;
    r = Math.floor(r), s = Math.floor(s), a = Math.floor(a);
    const l = [], c = [], u = [], h = [];
    let d = 0, m = 0;
    v("z", "y", "x", -1, -1, n, t, e, a, s, 0), v("z", "y", "x", 1, -1, n, t, -e, a, s, 1), v("x", "z", "y", 1, 1, e, n, t, r, a, 2), v("x", "z", "y", 1, -1, e, n, -t, r, a, 3), v("x", "y", "z", 1, -1, e, t, n, r, s, 4), v("x", "y", "z", -1, -1, e, t, -n, r, s, 5), this.setIndex(l), this.setAttribute("position", new Ot(c, 3)), this.setAttribute("normal", new Ot(u, 3)), this.setAttribute("uv", new Ot(h, 2));
    function v(b, p, f, x, g, _, T, A, M, C, y) {
      const E = _ / M, R = T / C, q = _ / 2, G = T / 2, V = A / 2, B = M + 1, U = C + 1;
      let Y = 0, z = 0;
      const ie = new L();
      for (let oe = 0; oe < U; oe++) {
        const ce = oe * R - G;
        for (let ye = 0; ye < B; ye++) {
          const je = ye * E - q;
          ie[b] = je * x, ie[p] = ce * g, ie[f] = V, c.push(ie.x, ie.y, ie.z), ie[b] = 0, ie[p] = 0, ie[f] = A > 0 ? 1 : -1, u.push(ie.x, ie.y, ie.z), h.push(ye / M), h.push(1 - oe / C), Y += 1;
        }
      }
      for (let oe = 0; oe < C; oe++)
        for (let ce = 0; ce < M; ce++) {
          const ye = d + ce + B * oe, je = d + ce + B * (oe + 1), K = d + (ce + 1) + B * (oe + 1), Q = d + (ce + 1) + B * oe;
          l.push(ye, je, Q), l.push(je, K, Q), z += 6;
        }
      o.addGroup(m, z, y), m += z, d += Y;
    }
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new Ls(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments);
  }
}
function Nr(i) {
  const e = {};
  for (const t in i) {
    e[t] = {};
    for (const n in i[t]) {
      const r = i[t][n];
      r && (r.isColor || r.isMatrix3 || r.isMatrix4 || r.isVector2 || r.isVector3 || r.isVector4 || r.isTexture || r.isQuaternion) ? r.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), e[t][n] = null) : e[t][n] = r.clone() : Array.isArray(r) ? e[t][n] = r.slice() : e[t][n] = r;
    }
  }
  return e;
}
function qt(i) {
  const e = {};
  for (let t = 0; t < i.length; t++) {
    const n = Nr(i[t]);
    for (const r in n)
      e[r] = n[r];
  }
  return e;
}
function ax(i) {
  const e = [];
  for (let t = 0; t < i.length; t++)
    e.push(i[t].clone());
  return e;
}
function Xd(i) {
  const e = i.getRenderTarget();
  return e === null ? i.outputColorSpace : e.isXRRenderTarget === !0 ? e.texture.colorSpace : nt.workingColorSpace;
}
const ox = { clone: Nr, merge: qt };
var lx = `void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`, cx = `void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;
class Ti extends Bn {
  static get type() {
    return "ShaderMaterial";
  }
  constructor(e) {
    super(), this.isShaderMaterial = !0, this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = lx, this.fragmentShader = cx, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.forceSinglePass = !0, this.extensions = {
      clipCullDistance: !1,
      // set to use vertex shader clipping
      multiDraw: !1
      // set to use vertex shader multi_draw / enable gl_DrawID
    }, this.defaultAttributeValues = {
      color: [1, 1, 1],
      uv: [0, 0],
      uv1: [0, 0]
    }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, e !== void 0 && this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.fragmentShader = e.fragmentShader, this.vertexShader = e.vertexShader, this.uniforms = Nr(e.uniforms), this.uniformsGroups = ax(e.uniformsGroups), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.fog = e.fog, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    t.glslVersion = this.glslVersion, t.uniforms = {};
    for (const r in this.uniforms) {
      const a = this.uniforms[r].value;
      a && a.isTexture ? t.uniforms[r] = {
        type: "t",
        value: a.toJSON(e).uuid
      } : a && a.isColor ? t.uniforms[r] = {
        type: "c",
        value: a.getHex()
      } : a && a.isVector2 ? t.uniforms[r] = {
        type: "v2",
        value: a.toArray()
      } : a && a.isVector3 ? t.uniforms[r] = {
        type: "v3",
        value: a.toArray()
      } : a && a.isVector4 ? t.uniforms[r] = {
        type: "v4",
        value: a.toArray()
      } : a && a.isMatrix3 ? t.uniforms[r] = {
        type: "m3",
        value: a.toArray()
      } : a && a.isMatrix4 ? t.uniforms[r] = {
        type: "m4",
        value: a.toArray()
      } : t.uniforms[r] = {
        value: a
      };
    }
    Object.keys(this.defines).length > 0 && (t.defines = this.defines), t.vertexShader = this.vertexShader, t.fragmentShader = this.fragmentShader, t.lights = this.lights, t.clipping = this.clipping;
    const n = {};
    for (const r in this.extensions)
      this.extensions[r] === !0 && (n[r] = !0);
    return Object.keys(n).length > 0 && (t.extensions = n), t;
  }
}
class jd extends Rt {
  constructor() {
    super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new Xe(), this.projectionMatrix = new Xe(), this.projectionMatrixInverse = new Xe(), this.coordinateSystem = ni;
  }
  copy(e, t) {
    return super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this.coordinateSystem = e.coordinateSystem, this;
  }
  getWorldDirection(e) {
    return super.getWorldDirection(e).negate();
  }
  updateMatrixWorld(e) {
    super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  updateWorldMatrix(e, t) {
    super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const mi = /* @__PURE__ */ new L(), gh = /* @__PURE__ */ new ze(), _h = /* @__PURE__ */ new ze();
class $t extends jd {
  constructor(e = 50, t = 1, n = 0.1, r = 2e3) {
    super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = r, this.focus = 10, this.aspect = t, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix();
  }
  copy(e, t) {
    return super.copy(e, t), this.fov = e.fov, this.zoom = e.zoom, this.near = e.near, this.far = e.far, this.focus = e.focus, this.aspect = e.aspect, this.view = e.view === null ? null : Object.assign({}, e.view), this.filmGauge = e.filmGauge, this.filmOffset = e.filmOffset, this;
  }
  /**
   * Sets the FOV by focal length in respect to the current .filmGauge.
   *
   * The default film gauge is 35, so that the focal length can be specified for
   * a 35mm (full frame) camera.
   *
   * Values for focal length and film gauge must have the same unit.
   */
  setFocalLength(e) {
    const t = 0.5 * this.getFilmHeight() / e;
    this.fov = Fr * 2 * Math.atan(t), this.updateProjectionMatrix();
  }
  /**
   * Calculates the focal length from the current .fov and .filmGauge.
   */
  getFocalLength() {
    const e = Math.tan(gs * 0.5 * this.fov);
    return 0.5 * this.getFilmHeight() / e;
  }
  getEffectiveFOV() {
    return Fr * 2 * Math.atan(
      Math.tan(gs * 0.5 * this.fov) / this.zoom
    );
  }
  getFilmWidth() {
    return this.filmGauge * Math.min(this.aspect, 1);
  }
  getFilmHeight() {
    return this.filmGauge / Math.max(this.aspect, 1);
  }
  /**
   * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction.
   * Sets minTarget and maxTarget to the coordinates of the lower-left and upper-right corners of the view rectangle.
   */
  getViewBounds(e, t, n) {
    mi.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), t.set(mi.x, mi.y).multiplyScalar(-e / mi.z), mi.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), n.set(mi.x, mi.y).multiplyScalar(-e / mi.z);
  }
  /**
   * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction.
   * Copies the result into the target Vector2, where x is width and y is height.
   */
  getViewSize(e, t) {
    return this.getViewBounds(e, gh, _h), t.subVectors(_h, gh);
  }
  /**
   * Sets an offset in a larger frustum. This is useful for multi-window or
   * multi-monitor/multi-machine setups.
   *
   * For example, if you have 3x2 monitors and each monitor is 1920x1080 and
   * the monitors are in grid like this
   *
   *   +---+---+---+
   *   | A | B | C |
   *   +---+---+---+
   *   | D | E | F |
   *   +---+---+---+
   *
   * then for each monitor you would call it like this
   *
   *   const w = 1920;
   *   const h = 1080;
   *   const fullWidth = w * 3;
   *   const fullHeight = h * 2;
   *
   *   --A--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
   *   --B--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
   *   --C--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
   *   --D--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
   *   --E--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
   *   --F--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
   *
   *   Note there is no reason monitors have to be the same size or in a grid.
   */
  setViewOffset(e, t, n, r, s, a) {
    this.aspect = e / t, this.view === null && (this.view = {
      enabled: !0,
      fullWidth: 1,
      fullHeight: 1,
      offsetX: 0,
      offsetY: 0,
      width: 1,
      height: 1
    }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = r, this.view.width = s, this.view.height = a, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const e = this.near;
    let t = e * Math.tan(gs * 0.5 * this.fov) / this.zoom, n = 2 * t, r = this.aspect * n, s = -0.5 * r;
    const a = this.view;
    if (this.view !== null && this.view.enabled) {
      const l = a.fullWidth, c = a.fullHeight;
      s += a.offsetX * r / l, t -= a.offsetY * n / c, r *= a.width / l, n *= a.height / c;
    }
    const o = this.filmOffset;
    o !== 0 && (s += e * o / this.getFilmWidth()), this.projectionMatrix.makePerspective(s, s + r, t, t - n, e, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return t.object.fov = this.fov, t.object.zoom = this.zoom, t.object.near = this.near, t.object.far = this.far, t.object.focus = this.focus, t.object.aspect = this.aspect, this.view !== null && (t.object.view = Object.assign({}, this.view)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t;
  }
}
const ur = -90, hr = 1;
class ux extends Rt {
  constructor(e, t, n) {
    super(), this.type = "CubeCamera", this.renderTarget = n, this.coordinateSystem = null, this.activeMipmapLevel = 0;
    const r = new $t(ur, hr, e, t);
    r.layers = this.layers, this.add(r);
    const s = new $t(ur, hr, e, t);
    s.layers = this.layers, this.add(s);
    const a = new $t(ur, hr, e, t);
    a.layers = this.layers, this.add(a);
    const o = new $t(ur, hr, e, t);
    o.layers = this.layers, this.add(o);
    const l = new $t(ur, hr, e, t);
    l.layers = this.layers, this.add(l);
    const c = new $t(ur, hr, e, t);
    c.layers = this.layers, this.add(c);
  }
  updateCoordinateSystem() {
    const e = this.coordinateSystem, t = this.children.concat(), [n, r, s, a, o, l] = t;
    for (const c of t) this.remove(c);
    if (e === ni)
      n.up.set(0, 1, 0), n.lookAt(1, 0, 0), r.up.set(0, 1, 0), r.lookAt(-1, 0, 0), s.up.set(0, 0, -1), s.lookAt(0, 1, 0), a.up.set(0, 0, 1), a.lookAt(0, -1, 0), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), l.up.set(0, 1, 0), l.lookAt(0, 0, -1);
    else if (e === Ia)
      n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), r.up.set(0, -1, 0), r.lookAt(1, 0, 0), s.up.set(0, 0, 1), s.lookAt(0, 1, 0), a.up.set(0, 0, -1), a.lookAt(0, -1, 0), o.up.set(0, -1, 0), o.lookAt(0, 0, 1), l.up.set(0, -1, 0), l.lookAt(0, 0, -1);
    else
      throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e);
    for (const c of t)
      this.add(c), c.updateMatrixWorld();
  }
  update(e, t) {
    this.parent === null && this.updateMatrixWorld();
    const { renderTarget: n, activeMipmapLevel: r } = this;
    this.coordinateSystem !== e.coordinateSystem && (this.coordinateSystem = e.coordinateSystem, this.updateCoordinateSystem());
    const [s, a, o, l, c, u] = this.children, h = e.getRenderTarget(), d = e.getActiveCubeFace(), m = e.getActiveMipmapLevel(), v = e.xr.enabled;
    e.xr.enabled = !1;
    const b = n.texture.generateMipmaps;
    n.texture.generateMipmaps = !1, e.setRenderTarget(n, 0, r), e.render(t, s), e.setRenderTarget(n, 1, r), e.render(t, a), e.setRenderTarget(n, 2, r), e.render(t, o), e.setRenderTarget(n, 3, r), e.render(t, l), e.setRenderTarget(n, 4, r), e.render(t, c), n.texture.generateMipmaps = b, e.setRenderTarget(n, 5, r), e.render(t, u), e.setRenderTarget(h, d, m), e.xr.enabled = v, n.texture.needsPMREMUpdate = !0;
  }
}
class qd extends zt {
  constructor(e, t, n, r, s, a, o, l, c, u) {
    e = e !== void 0 ? e : [], t = t !== void 0 ? t : Rr, super(e, t, n, r, s, a, o, l, c, u), this.isCubeTexture = !0, this.flipY = !1;
  }
  get images() {
    return this.image;
  }
  set images(e) {
    this.image = e;
  }
}
class hx extends Xi {
  constructor(e = 1, t = {}) {
    super(e, e, t), this.isWebGLCubeRenderTarget = !0;
    const n = { width: e, height: e, depth: 1 }, r = [n, n, n, n, n, n];
    this.texture = new qd(r, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1, this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : un;
  }
  fromEquirectangularTexture(e, t) {
    this.texture.type = t.type, this.texture.colorSpace = t.colorSpace, this.texture.generateMipmaps = t.generateMipmaps, this.texture.minFilter = t.minFilter, this.texture.magFilter = t.magFilter;
    const n = {
      uniforms: {
        tEquirect: { value: null }
      },
      vertexShader: (
        /* glsl */
        `

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`
      ),
      fragmentShader: (
        /* glsl */
        `

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`
      )
    }, r = new Ls(5, 5, 5), s = new Ti({
      name: "CubemapFromEquirect",
      uniforms: Nr(n.uniforms),
      vertexShader: n.vertexShader,
      fragmentShader: n.fragmentShader,
      side: sn,
      blending: Mi
    });
    s.uniforms.tEquirect.value = t;
    const a = new hn(r, s), o = t.minFilter;
    return t.minFilter === ti && (t.minFilter = un), new ux(1, 10, this).update(e, a), t.minFilter = o, a.geometry.dispose(), a.material.dispose(), this;
  }
  clear(e, t, n, r) {
    const s = e.getRenderTarget();
    for (let a = 0; a < 6; a++)
      e.setRenderTarget(this, a), e.clear(t, n, r);
    e.setRenderTarget(s);
  }
}
const Io = /* @__PURE__ */ new L(), fx = /* @__PURE__ */ new L(), dx = /* @__PURE__ */ new We();
class _i {
  constructor(e = new L(1, 0, 0), t = 0) {
    this.isPlane = !0, this.normal = e, this.constant = t;
  }
  set(e, t) {
    return this.normal.copy(e), this.constant = t, this;
  }
  setComponents(e, t, n, r) {
    return this.normal.set(e, t, n), this.constant = r, this;
  }
  setFromNormalAndCoplanarPoint(e, t) {
    return this.normal.copy(e), this.constant = -t.dot(this.normal), this;
  }
  setFromCoplanarPoints(e, t, n) {
    const r = Io.subVectors(n, t).cross(fx.subVectors(e, t)).normalize();
    return this.setFromNormalAndCoplanarPoint(r, e), this;
  }
  copy(e) {
    return this.normal.copy(e.normal), this.constant = e.constant, this;
  }
  normalize() {
    const e = 1 / this.normal.length();
    return this.normal.multiplyScalar(e), this.constant *= e, this;
  }
  negate() {
    return this.constant *= -1, this.normal.negate(), this;
  }
  distanceToPoint(e) {
    return this.normal.dot(e) + this.constant;
  }
  distanceToSphere(e) {
    return this.distanceToPoint(e.center) - e.radius;
  }
  projectPoint(e, t) {
    return t.copy(e).addScaledVector(this.normal, -this.distanceToPoint(e));
  }
  intersectLine(e, t) {
    const n = e.delta(Io), r = this.normal.dot(n);
    if (r === 0)
      return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null;
    const s = -(e.start.dot(this.normal) + this.constant) / r;
    return s < 0 || s > 1 ? null : t.copy(e.start).addScaledVector(n, s);
  }
  intersectsLine(e) {
    const t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end);
    return t < 0 && n > 0 || n < 0 && t > 0;
  }
  intersectsBox(e) {
    return e.intersectsPlane(this);
  }
  intersectsSphere(e) {
    return e.intersectsPlane(this);
  }
  coplanarPoint(e) {
    return e.copy(this.normal).multiplyScalar(-this.constant);
  }
  applyMatrix4(e, t) {
    const n = t || dx.getNormalMatrix(e), r = this.coplanarPoint(Io).applyMatrix4(e), s = this.normal.applyMatrix3(n).normalize();
    return this.constant = -r.dot(s), this;
  }
  translate(e) {
    return this.constant -= e.dot(this.normal), this;
  }
  equals(e) {
    return e.normal.equals(this.normal) && e.constant === this.constant;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const Ci = /* @__PURE__ */ new zn(), ia = /* @__PURE__ */ new L();
class Pc {
  constructor(e = new _i(), t = new _i(), n = new _i(), r = new _i(), s = new _i(), a = new _i()) {
    this.planes = [e, t, n, r, s, a];
  }
  set(e, t, n, r, s, a) {
    const o = this.planes;
    return o[0].copy(e), o[1].copy(t), o[2].copy(n), o[3].copy(r), o[4].copy(s), o[5].copy(a), this;
  }
  copy(e) {
    const t = this.planes;
    for (let n = 0; n < 6; n++)
      t[n].copy(e.planes[n]);
    return this;
  }
  setFromProjectionMatrix(e, t = ni) {
    const n = this.planes, r = e.elements, s = r[0], a = r[1], o = r[2], l = r[3], c = r[4], u = r[5], h = r[6], d = r[7], m = r[8], v = r[9], b = r[10], p = r[11], f = r[12], x = r[13], g = r[14], _ = r[15];
    if (n[0].setComponents(l - s, d - c, p - m, _ - f).normalize(), n[1].setComponents(l + s, d + c, p + m, _ + f).normalize(), n[2].setComponents(l + a, d + u, p + v, _ + x).normalize(), n[3].setComponents(l - a, d - u, p - v, _ - x).normalize(), n[4].setComponents(l - o, d - h, p - b, _ - g).normalize(), t === ni)
      n[5].setComponents(l + o, d + h, p + b, _ + g).normalize();
    else if (t === Ia)
      n[5].setComponents(o, h, b, g).normalize();
    else
      throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t);
    return this;
  }
  intersectsObject(e) {
    if (e.boundingSphere !== void 0)
      e.boundingSphere === null && e.computeBoundingSphere(), Ci.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);
    else {
      const t = e.geometry;
      t.boundingSphere === null && t.computeBoundingSphere(), Ci.copy(t.boundingSphere).applyMatrix4(e.matrixWorld);
    }
    return this.intersectsSphere(Ci);
  }
  intersectsSprite(e) {
    return Ci.center.set(0, 0, 0), Ci.radius = 0.7071067811865476, Ci.applyMatrix4(e.matrixWorld), this.intersectsSphere(Ci);
  }
  intersectsSphere(e) {
    const t = this.planes, n = e.center, r = -e.radius;
    for (let s = 0; s < 6; s++)
      if (t[s].distanceToPoint(n) < r)
        return !1;
    return !0;
  }
  intersectsBox(e) {
    const t = this.planes;
    for (let n = 0; n < 6; n++) {
      const r = t[n];
      if (ia.x = r.normal.x > 0 ? e.max.x : e.min.x, ia.y = r.normal.y > 0 ? e.max.y : e.min.y, ia.z = r.normal.z > 0 ? e.max.z : e.min.z, r.distanceToPoint(ia) < 0)
        return !1;
    }
    return !0;
  }
  containsPoint(e) {
    const t = this.planes;
    for (let n = 0; n < 6; n++)
      if (t[n].distanceToPoint(e) < 0)
        return !1;
    return !0;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
function Yd() {
  let i = null, e = !1, t = null, n = null;
  function r(s, a) {
    t(s, a), n = i.requestAnimationFrame(r);
  }
  return {
    start: function() {
      e !== !0 && t !== null && (n = i.requestAnimationFrame(r), e = !0);
    },
    stop: function() {
      i.cancelAnimationFrame(n), e = !1;
    },
    setAnimationLoop: function(s) {
      t = s;
    },
    setContext: function(s) {
      i = s;
    }
  };
}
function px(i) {
  const e = /* @__PURE__ */ new WeakMap();
  function t(o, l) {
    const c = o.array, u = o.usage, h = c.byteLength, d = i.createBuffer();
    i.bindBuffer(l, d), i.bufferData(l, c, u), o.onUploadCallback();
    let m;
    if (c instanceof Float32Array)
      m = i.FLOAT;
    else if (c instanceof Uint16Array)
      o.isFloat16BufferAttribute ? m = i.HALF_FLOAT : m = i.UNSIGNED_SHORT;
    else if (c instanceof Int16Array)
      m = i.SHORT;
    else if (c instanceof Uint32Array)
      m = i.UNSIGNED_INT;
    else if (c instanceof Int32Array)
      m = i.INT;
    else if (c instanceof Int8Array)
      m = i.BYTE;
    else if (c instanceof Uint8Array)
      m = i.UNSIGNED_BYTE;
    else if (c instanceof Uint8ClampedArray)
      m = i.UNSIGNED_BYTE;
    else
      throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + c);
    return {
      buffer: d,
      type: m,
      bytesPerElement: c.BYTES_PER_ELEMENT,
      version: o.version,
      size: h
    };
  }
  function n(o, l, c) {
    const u = l.array, h = l.updateRanges;
    if (i.bindBuffer(c, o), h.length === 0)
      i.bufferSubData(c, 0, u);
    else {
      h.sort((m, v) => m.start - v.start);
      let d = 0;
      for (let m = 1; m < h.length; m++) {
        const v = h[d], b = h[m];
        b.start <= v.start + v.count + 1 ? v.count = Math.max(
          v.count,
          b.start + b.count - v.start
        ) : (++d, h[d] = b);
      }
      h.length = d + 1;
      for (let m = 0, v = h.length; m < v; m++) {
        const b = h[m];
        i.bufferSubData(
          c,
          b.start * u.BYTES_PER_ELEMENT,
          u,
          b.start,
          b.count
        );
      }
      l.clearUpdateRanges();
    }
    l.onUploadCallback();
  }
  function r(o) {
    return o.isInterleavedBufferAttribute && (o = o.data), e.get(o);
  }
  function s(o) {
    o.isInterleavedBufferAttribute && (o = o.data);
    const l = e.get(o);
    l && (i.deleteBuffer(l.buffer), e.delete(o));
  }
  function a(o, l) {
    if (o.isInterleavedBufferAttribute && (o = o.data), o.isGLBufferAttribute) {
      const u = e.get(o);
      (!u || u.version < o.version) && e.set(o, {
        buffer: o.buffer,
        type: o.type,
        bytesPerElement: o.elementSize,
        version: o.version
      });
      return;
    }
    const c = e.get(o);
    if (c === void 0)
      e.set(o, t(o, l));
    else if (c.version < o.version) {
      if (c.size !== o.array.byteLength)
        throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");
      n(c.buffer, o, l), c.version = o.version;
    }
  }
  return {
    get: r,
    remove: s,
    update: a
  };
}
class Ya extends fn {
  constructor(e = 1, t = 1, n = 1, r = 1) {
    super(), this.type = "PlaneGeometry", this.parameters = {
      width: e,
      height: t,
      widthSegments: n,
      heightSegments: r
    };
    const s = e / 2, a = t / 2, o = Math.floor(n), l = Math.floor(r), c = o + 1, u = l + 1, h = e / o, d = t / l, m = [], v = [], b = [], p = [];
    for (let f = 0; f < u; f++) {
      const x = f * d - a;
      for (let g = 0; g < c; g++) {
        const _ = g * h - s;
        v.push(_, -x, 0), b.push(0, 0, 1), p.push(g / o), p.push(1 - f / l);
      }
    }
    for (let f = 0; f < l; f++)
      for (let x = 0; x < o; x++) {
        const g = x + c * f, _ = x + c * (f + 1), T = x + 1 + c * (f + 1), A = x + 1 + c * f;
        m.push(g, _, A), m.push(_, T, A);
      }
    this.setIndex(m), this.setAttribute("position", new Ot(v, 3)), this.setAttribute("normal", new Ot(b, 3)), this.setAttribute("uv", new Ot(p, 2));
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new Ya(e.width, e.height, e.widthSegments, e.heightSegments);
  }
}
var mx = `#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`, gx = `#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`, _x = `#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`, vx = `#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, xx = `#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`, bx = `#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`, Ex = `#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`, yx = `#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`, Sx = `#ifdef USE_BATCHING
	#if ! defined( GL_ANGLE_multi_draw )
	#define gl_DrawID _gl_DrawID
	uniform int _gl_DrawID;
	#endif
	uniform highp sampler2D batchingTexture;
	uniform highp usampler2D batchingIdTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
	float getIndirectIndex( const in int i ) {
		int size = textureSize( batchingIdTexture, 0 ).x;
		int x = i % size;
		int y = i / size;
		return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
	}
#endif
#ifdef USE_BATCHING_COLOR
	uniform sampler2D batchingColorTexture;
	vec3 getBatchingColor( const in float i ) {
		int size = textureSize( batchingColorTexture, 0 ).x;
		int j = int( i );
		int x = j % size;
		int y = j / size;
		return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
	}
#endif`, Mx = `#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`, Ax = `vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`, Tx = `vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`, wx = `float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`, Dx = `#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`, Rx = `#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`, Cx = `#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`, Px = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`, Lx = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`, Ix = `#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`, Fx = `#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`, Nx = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`, Ux = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`, Ox = `#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
	vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
	vColor.xyz *= batchingColor.xyz;
#endif`, Bx = `#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`, kx = `#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`, Hx = `vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`, zx = `#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`, Gx = `#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`, Vx = `#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`, Wx = `#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`, Xx = "gl_FragColor = linearToOutputTexel( gl_FragColor );", jx = `vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`, qx = `#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`, Yx = `#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`, Zx = `#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`, Kx = `#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`, $x = `#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`, Jx = `#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`, Qx = `#ifdef USE_FOG
	varying float vFogDepth;
#endif`, eb = `#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`, tb = `#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`, nb = `#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`, ib = `#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`, rb = `LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`, sb = `varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`, ab = `uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`, ob = `#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`, lb = `ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`, cb = `varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`, ub = `BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`, hb = `varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`, fb = `PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
	material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`, db = `struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	float dispersion;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`, pb = `
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`, mb = `#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`, gb = `#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`, _b = `#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`, vb = `#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, xb = `#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, bb = `#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`, Eb = `#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`, yb = `#ifdef USE_MAP
	uniform sampler2D map;
#endif`, Sb = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`, Mb = `#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, Ab = `float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`, Tb = `#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`, wb = `#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`, Db = `#if defined( USE_MORPHCOLORS )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`, Rb = `#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
	}
#endif`, Cb = `#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	#endif
	uniform sampler2DArray morphTargetsTexture;
	uniform ivec2 morphTargetsTextureSize;
	vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
		int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
		int y = texelIndex / morphTargetsTextureSize.x;
		int x = texelIndex - y * morphTargetsTextureSize.x;
		ivec3 morphUV = ivec3( x, y, morphTargetIndex );
		return texelFetch( morphTargetsTexture, morphUV, 0 );
	}
#endif`, Pb = `#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
	}
#endif`, Lb = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`, Ib = `#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`, Fb = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, Nb = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, Ub = `#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`, Ob = `#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`, Bb = `#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`, kb = `#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`, Hb = `#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`, zb = `#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`, Gb = `#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, Vb = `vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
	if( v <= 0.0 )
		return vec4( 0., 0., 0., 0. );
	if( v >= 1.0 )
		return vec4( 1., 1., 1., 1. );
	float vuf;
	float af = modf( v * PackFactors.a, vuf );
	float bf = modf( vuf * ShiftRight8, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
	if( v <= 0.0 )
		return vec3( 0., 0., 0. );
	if( v >= 1.0 )
		return vec3( 1., 1., 1. );
	float vuf;
	float bf = modf( v * PackFactors.b, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
	if( v <= 0.0 )
		return vec2( 0., 0. );
	if( v >= 1.0 )
		return vec2( 1., 1. );
	float vuf;
	float gf = modf( v * 256., vuf );
	return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
	return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
	return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`, Wb = `#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`, Xb = `vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`, jb = `#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`, qb = `#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`, Yb = `float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`, Zb = `#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`, Kb = `#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
#endif`, $b = `#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`, Jb = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`, Qb = `float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`, eE = `#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`, tE = `#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`, nE = `#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`, iE = `#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`, rE = `float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`, sE = `#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`, aE = `#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`, oE = `#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	const float StartCompression = 0.8 - 0.04;
	const float Desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min( color.r, min( color.g, color.b ) );
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max( color.r, max( color.g, color.b ) );
	if ( peak < StartCompression ) return color;
	float d = 1. - StartCompression;
	float newPeak = 1. - d * d / ( peak + d - StartCompression );
	color *= newPeak / peak;
	float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
	return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`, lE = `#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`, cE = `#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec4 transmittedLight;
		vec3 transmittance;
		#ifdef USE_DISPERSION
			float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
			vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
			for ( int i = 0; i < 3; i ++ ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;
		
				vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;
		
				vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
				transmittedLight[ i ] = transmissionSample[ i ];
				transmittedLight.a += transmissionSample.a;
				transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
			}
			transmittedLight.a /= 3.0;
		
		#else
		
			vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
			vec3 refractedRayExit = position + transmissionRay;
			vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
			vec2 refractionCoords = ndcPos.xy / ndcPos.w;
			refractionCoords += 1.0;
			refractionCoords /= 2.0;
			transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
			transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		
		#endif
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`, uE = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`, hE = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`, fE = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`, dE = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`;
const pE = `varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`, mE = `uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, gE = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, _E = `#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, vE = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, xE = `uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, bE = `#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`, EE = `#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#elif DEPTH_PACKING == 3202
		gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
	#elif DEPTH_PACKING == 3203
		gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
	#endif
}`, yE = `#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`, SE = `#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`, ME = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`, AE = `uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, TE = `uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`, wE = `uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`, DE = `#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`, RE = `uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, CE = `#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, PE = `#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, LE = `#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`, IE = `#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, FE = `#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`, NE = `#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`, UE = `#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, OE = `#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, BE = `#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`, kE = `#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
	uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, HE = `#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, zE = `#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, GE = `uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`, VE = `uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`, WE = `#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, XE = `uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`, jE = `uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix[ 3 ];
	vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`, qE = `uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`, Ye = {
  alphahash_fragment: mx,
  alphahash_pars_fragment: gx,
  alphamap_fragment: _x,
  alphamap_pars_fragment: vx,
  alphatest_fragment: xx,
  alphatest_pars_fragment: bx,
  aomap_fragment: Ex,
  aomap_pars_fragment: yx,
  batching_pars_vertex: Sx,
  batching_vertex: Mx,
  begin_vertex: Ax,
  beginnormal_vertex: Tx,
  bsdfs: wx,
  iridescence_fragment: Dx,
  bumpmap_pars_fragment: Rx,
  clipping_planes_fragment: Cx,
  clipping_planes_pars_fragment: Px,
  clipping_planes_pars_vertex: Lx,
  clipping_planes_vertex: Ix,
  color_fragment: Fx,
  color_pars_fragment: Nx,
  color_pars_vertex: Ux,
  color_vertex: Ox,
  common: Bx,
  cube_uv_reflection_fragment: kx,
  defaultnormal_vertex: Hx,
  displacementmap_pars_vertex: zx,
  displacementmap_vertex: Gx,
  emissivemap_fragment: Vx,
  emissivemap_pars_fragment: Wx,
  colorspace_fragment: Xx,
  colorspace_pars_fragment: jx,
  envmap_fragment: qx,
  envmap_common_pars_fragment: Yx,
  envmap_pars_fragment: Zx,
  envmap_pars_vertex: Kx,
  envmap_physical_pars_fragment: ob,
  envmap_vertex: $x,
  fog_vertex: Jx,
  fog_pars_vertex: Qx,
  fog_fragment: eb,
  fog_pars_fragment: tb,
  gradientmap_pars_fragment: nb,
  lightmap_pars_fragment: ib,
  lights_lambert_fragment: rb,
  lights_lambert_pars_fragment: sb,
  lights_pars_begin: ab,
  lights_toon_fragment: lb,
  lights_toon_pars_fragment: cb,
  lights_phong_fragment: ub,
  lights_phong_pars_fragment: hb,
  lights_physical_fragment: fb,
  lights_physical_pars_fragment: db,
  lights_fragment_begin: pb,
  lights_fragment_maps: mb,
  lights_fragment_end: gb,
  logdepthbuf_fragment: _b,
  logdepthbuf_pars_fragment: vb,
  logdepthbuf_pars_vertex: xb,
  logdepthbuf_vertex: bb,
  map_fragment: Eb,
  map_pars_fragment: yb,
  map_particle_fragment: Sb,
  map_particle_pars_fragment: Mb,
  metalnessmap_fragment: Ab,
  metalnessmap_pars_fragment: Tb,
  morphinstance_vertex: wb,
  morphcolor_vertex: Db,
  morphnormal_vertex: Rb,
  morphtarget_pars_vertex: Cb,
  morphtarget_vertex: Pb,
  normal_fragment_begin: Lb,
  normal_fragment_maps: Ib,
  normal_pars_fragment: Fb,
  normal_pars_vertex: Nb,
  normal_vertex: Ub,
  normalmap_pars_fragment: Ob,
  clearcoat_normal_fragment_begin: Bb,
  clearcoat_normal_fragment_maps: kb,
  clearcoat_pars_fragment: Hb,
  iridescence_pars_fragment: zb,
  opaque_fragment: Gb,
  packing: Vb,
  premultiplied_alpha_fragment: Wb,
  project_vertex: Xb,
  dithering_fragment: jb,
  dithering_pars_fragment: qb,
  roughnessmap_fragment: Yb,
  roughnessmap_pars_fragment: Zb,
  shadowmap_pars_fragment: Kb,
  shadowmap_pars_vertex: $b,
  shadowmap_vertex: Jb,
  shadowmask_pars_fragment: Qb,
  skinbase_vertex: eE,
  skinning_pars_vertex: tE,
  skinning_vertex: nE,
  skinnormal_vertex: iE,
  specularmap_fragment: rE,
  specularmap_pars_fragment: sE,
  tonemapping_fragment: aE,
  tonemapping_pars_fragment: oE,
  transmission_fragment: lE,
  transmission_pars_fragment: cE,
  uv_pars_fragment: uE,
  uv_pars_vertex: hE,
  uv_vertex: fE,
  worldpos_vertex: dE,
  background_vert: pE,
  background_frag: mE,
  backgroundCube_vert: gE,
  backgroundCube_frag: _E,
  cube_vert: vE,
  cube_frag: xE,
  depth_vert: bE,
  depth_frag: EE,
  distanceRGBA_vert: yE,
  distanceRGBA_frag: SE,
  equirect_vert: ME,
  equirect_frag: AE,
  linedashed_vert: TE,
  linedashed_frag: wE,
  meshbasic_vert: DE,
  meshbasic_frag: RE,
  meshlambert_vert: CE,
  meshlambert_frag: PE,
  meshmatcap_vert: LE,
  meshmatcap_frag: IE,
  meshnormal_vert: FE,
  meshnormal_frag: NE,
  meshphong_vert: UE,
  meshphong_frag: OE,
  meshphysical_vert: BE,
  meshphysical_frag: kE,
  meshtoon_vert: HE,
  meshtoon_frag: zE,
  points_vert: GE,
  points_frag: VE,
  shadow_vert: WE,
  shadow_frag: XE,
  sprite_vert: jE,
  sprite_frag: qE
}, de = {
  common: {
    diffuse: { value: /* @__PURE__ */ new Ue(16777215) },
    opacity: { value: 1 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new We() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new We() },
    alphaTest: { value: 0 }
  },
  specularmap: {
    specularMap: { value: null },
    specularMapTransform: { value: /* @__PURE__ */ new We() }
  },
  envmap: {
    envMap: { value: null },
    envMapRotation: { value: /* @__PURE__ */ new We() },
    flipEnvMap: { value: -1 },
    reflectivity: { value: 1 },
    // basic, lambert, phong
    ior: { value: 1.5 },
    // physical
    refractionRatio: { value: 0.98 }
    // basic, lambert, phong
  },
  aomap: {
    aoMap: { value: null },
    aoMapIntensity: { value: 1 },
    aoMapTransform: { value: /* @__PURE__ */ new We() }
  },
  lightmap: {
    lightMap: { value: null },
    lightMapIntensity: { value: 1 },
    lightMapTransform: { value: /* @__PURE__ */ new We() }
  },
  bumpmap: {
    bumpMap: { value: null },
    bumpMapTransform: { value: /* @__PURE__ */ new We() },
    bumpScale: { value: 1 }
  },
  normalmap: {
    normalMap: { value: null },
    normalMapTransform: { value: /* @__PURE__ */ new We() },
    normalScale: { value: /* @__PURE__ */ new ze(1, 1) }
  },
  displacementmap: {
    displacementMap: { value: null },
    displacementMapTransform: { value: /* @__PURE__ */ new We() },
    displacementScale: { value: 1 },
    displacementBias: { value: 0 }
  },
  emissivemap: {
    emissiveMap: { value: null },
    emissiveMapTransform: { value: /* @__PURE__ */ new We() }
  },
  metalnessmap: {
    metalnessMap: { value: null },
    metalnessMapTransform: { value: /* @__PURE__ */ new We() }
  },
  roughnessmap: {
    roughnessMap: { value: null },
    roughnessMapTransform: { value: /* @__PURE__ */ new We() }
  },
  gradientmap: {
    gradientMap: { value: null }
  },
  fog: {
    fogDensity: { value: 25e-5 },
    fogNear: { value: 1 },
    fogFar: { value: 2e3 },
    fogColor: { value: /* @__PURE__ */ new Ue(16777215) }
  },
  lights: {
    ambientLightColor: { value: [] },
    lightProbe: { value: [] },
    directionalLights: { value: [], properties: {
      direction: {},
      color: {}
    } },
    directionalLightShadows: { value: [], properties: {
      shadowIntensity: 1,
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {}
    } },
    directionalShadowMap: { value: [] },
    directionalShadowMatrix: { value: [] },
    spotLights: { value: [], properties: {
      color: {},
      position: {},
      direction: {},
      distance: {},
      coneCos: {},
      penumbraCos: {},
      decay: {}
    } },
    spotLightShadows: { value: [], properties: {
      shadowIntensity: 1,
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {}
    } },
    spotLightMap: { value: [] },
    spotShadowMap: { value: [] },
    spotLightMatrix: { value: [] },
    pointLights: { value: [], properties: {
      color: {},
      position: {},
      decay: {},
      distance: {}
    } },
    pointLightShadows: { value: [], properties: {
      shadowIntensity: 1,
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {},
      shadowCameraNear: {},
      shadowCameraFar: {}
    } },
    pointShadowMap: { value: [] },
    pointShadowMatrix: { value: [] },
    hemisphereLights: { value: [], properties: {
      direction: {},
      skyColor: {},
      groundColor: {}
    } },
    // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
    rectAreaLights: { value: [], properties: {
      color: {},
      position: {},
      width: {},
      height: {}
    } },
    ltc_1: { value: null },
    ltc_2: { value: null }
  },
  points: {
    diffuse: { value: /* @__PURE__ */ new Ue(16777215) },
    opacity: { value: 1 },
    size: { value: 1 },
    scale: { value: 1 },
    map: { value: null },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new We() },
    alphaTest: { value: 0 },
    uvTransform: { value: /* @__PURE__ */ new We() }
  },
  sprite: {
    diffuse: { value: /* @__PURE__ */ new Ue(16777215) },
    opacity: { value: 1 },
    center: { value: /* @__PURE__ */ new ze(0.5, 0.5) },
    rotation: { value: 0 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new We() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new We() },
    alphaTest: { value: 0 }
  }
}, Ln = {
  basic: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.specularmap,
      de.envmap,
      de.aomap,
      de.lightmap,
      de.fog
    ]),
    vertexShader: Ye.meshbasic_vert,
    fragmentShader: Ye.meshbasic_frag
  },
  lambert: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.specularmap,
      de.envmap,
      de.aomap,
      de.lightmap,
      de.emissivemap,
      de.bumpmap,
      de.normalmap,
      de.displacementmap,
      de.fog,
      de.lights,
      {
        emissive: { value: /* @__PURE__ */ new Ue(0) }
      }
    ]),
    vertexShader: Ye.meshlambert_vert,
    fragmentShader: Ye.meshlambert_frag
  },
  phong: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.specularmap,
      de.envmap,
      de.aomap,
      de.lightmap,
      de.emissivemap,
      de.bumpmap,
      de.normalmap,
      de.displacementmap,
      de.fog,
      de.lights,
      {
        emissive: { value: /* @__PURE__ */ new Ue(0) },
        specular: { value: /* @__PURE__ */ new Ue(1118481) },
        shininess: { value: 30 }
      }
    ]),
    vertexShader: Ye.meshphong_vert,
    fragmentShader: Ye.meshphong_frag
  },
  standard: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.envmap,
      de.aomap,
      de.lightmap,
      de.emissivemap,
      de.bumpmap,
      de.normalmap,
      de.displacementmap,
      de.roughnessmap,
      de.metalnessmap,
      de.fog,
      de.lights,
      {
        emissive: { value: /* @__PURE__ */ new Ue(0) },
        roughness: { value: 1 },
        metalness: { value: 0 },
        envMapIntensity: { value: 1 }
      }
    ]),
    vertexShader: Ye.meshphysical_vert,
    fragmentShader: Ye.meshphysical_frag
  },
  toon: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.aomap,
      de.lightmap,
      de.emissivemap,
      de.bumpmap,
      de.normalmap,
      de.displacementmap,
      de.gradientmap,
      de.fog,
      de.lights,
      {
        emissive: { value: /* @__PURE__ */ new Ue(0) }
      }
    ]),
    vertexShader: Ye.meshtoon_vert,
    fragmentShader: Ye.meshtoon_frag
  },
  matcap: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.bumpmap,
      de.normalmap,
      de.displacementmap,
      de.fog,
      {
        matcap: { value: null }
      }
    ]),
    vertexShader: Ye.meshmatcap_vert,
    fragmentShader: Ye.meshmatcap_frag
  },
  points: {
    uniforms: /* @__PURE__ */ qt([
      de.points,
      de.fog
    ]),
    vertexShader: Ye.points_vert,
    fragmentShader: Ye.points_frag
  },
  dashed: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.fog,
      {
        scale: { value: 1 },
        dashSize: { value: 1 },
        totalSize: { value: 2 }
      }
    ]),
    vertexShader: Ye.linedashed_vert,
    fragmentShader: Ye.linedashed_frag
  },
  depth: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.displacementmap
    ]),
    vertexShader: Ye.depth_vert,
    fragmentShader: Ye.depth_frag
  },
  normal: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.bumpmap,
      de.normalmap,
      de.displacementmap,
      {
        opacity: { value: 1 }
      }
    ]),
    vertexShader: Ye.meshnormal_vert,
    fragmentShader: Ye.meshnormal_frag
  },
  sprite: {
    uniforms: /* @__PURE__ */ qt([
      de.sprite,
      de.fog
    ]),
    vertexShader: Ye.sprite_vert,
    fragmentShader: Ye.sprite_frag
  },
  background: {
    uniforms: {
      uvTransform: { value: /* @__PURE__ */ new We() },
      t2D: { value: null },
      backgroundIntensity: { value: 1 }
    },
    vertexShader: Ye.background_vert,
    fragmentShader: Ye.background_frag
  },
  backgroundCube: {
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 },
      backgroundBlurriness: { value: 0 },
      backgroundIntensity: { value: 1 },
      backgroundRotation: { value: /* @__PURE__ */ new We() }
    },
    vertexShader: Ye.backgroundCube_vert,
    fragmentShader: Ye.backgroundCube_frag
  },
  cube: {
    uniforms: {
      tCube: { value: null },
      tFlip: { value: -1 },
      opacity: { value: 1 }
    },
    vertexShader: Ye.cube_vert,
    fragmentShader: Ye.cube_frag
  },
  equirect: {
    uniforms: {
      tEquirect: { value: null }
    },
    vertexShader: Ye.equirect_vert,
    fragmentShader: Ye.equirect_frag
  },
  distanceRGBA: {
    uniforms: /* @__PURE__ */ qt([
      de.common,
      de.displacementmap,
      {
        referencePosition: { value: /* @__PURE__ */ new L() },
        nearDistance: { value: 1 },
        farDistance: { value: 1e3 }
      }
    ]),
    vertexShader: Ye.distanceRGBA_vert,
    fragmentShader: Ye.distanceRGBA_frag
  },
  shadow: {
    uniforms: /* @__PURE__ */ qt([
      de.lights,
      de.fog,
      {
        color: { value: /* @__PURE__ */ new Ue(0) },
        opacity: { value: 1 }
      }
    ]),
    vertexShader: Ye.shadow_vert,
    fragmentShader: Ye.shadow_frag
  }
};
Ln.physical = {
  uniforms: /* @__PURE__ */ qt([
    Ln.standard.uniforms,
    {
      clearcoat: { value: 0 },
      clearcoatMap: { value: null },
      clearcoatMapTransform: { value: /* @__PURE__ */ new We() },
      clearcoatNormalMap: { value: null },
      clearcoatNormalMapTransform: { value: /* @__PURE__ */ new We() },
      clearcoatNormalScale: { value: /* @__PURE__ */ new ze(1, 1) },
      clearcoatRoughness: { value: 0 },
      clearcoatRoughnessMap: { value: null },
      clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new We() },
      dispersion: { value: 0 },
      iridescence: { value: 0 },
      iridescenceMap: { value: null },
      iridescenceMapTransform: { value: /* @__PURE__ */ new We() },
      iridescenceIOR: { value: 1.3 },
      iridescenceThicknessMinimum: { value: 100 },
      iridescenceThicknessMaximum: { value: 400 },
      iridescenceThicknessMap: { value: null },
      iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new We() },
      sheen: { value: 0 },
      sheenColor: { value: /* @__PURE__ */ new Ue(0) },
      sheenColorMap: { value: null },
      sheenColorMapTransform: { value: /* @__PURE__ */ new We() },
      sheenRoughness: { value: 1 },
      sheenRoughnessMap: { value: null },
      sheenRoughnessMapTransform: { value: /* @__PURE__ */ new We() },
      transmission: { value: 0 },
      transmissionMap: { value: null },
      transmissionMapTransform: { value: /* @__PURE__ */ new We() },
      transmissionSamplerSize: { value: /* @__PURE__ */ new ze() },
      transmissionSamplerMap: { value: null },
      thickness: { value: 0 },
      thicknessMap: { value: null },
      thicknessMapTransform: { value: /* @__PURE__ */ new We() },
      attenuationDistance: { value: 0 },
      attenuationColor: { value: /* @__PURE__ */ new Ue(0) },
      specularColor: { value: /* @__PURE__ */ new Ue(1, 1, 1) },
      specularColorMap: { value: null },
      specularColorMapTransform: { value: /* @__PURE__ */ new We() },
      specularIntensity: { value: 1 },
      specularIntensityMap: { value: null },
      specularIntensityMapTransform: { value: /* @__PURE__ */ new We() },
      anisotropyVector: { value: /* @__PURE__ */ new ze() },
      anisotropyMap: { value: null },
      anisotropyMapTransform: { value: /* @__PURE__ */ new We() }
    }
  ]),
  vertexShader: Ye.meshphysical_vert,
  fragmentShader: Ye.meshphysical_frag
};
const ra = { r: 0, b: 0, g: 0 }, Pi = /* @__PURE__ */ new Hn(), YE = /* @__PURE__ */ new Xe();
function ZE(i, e, t, n, r, s, a) {
  const o = new Ue(0);
  let l = s === !0 ? 0 : 1, c, u, h = null, d = 0, m = null;
  function v(x) {
    let g = x.isScene === !0 ? x.background : null;
    return g && g.isTexture && (g = (x.backgroundBlurriness > 0 ? t : e).get(g)), g;
  }
  function b(x) {
    let g = !1;
    const _ = v(x);
    _ === null ? f(o, l) : _ && _.isColor && (f(_, 1), g = !0);
    const T = i.xr.getEnvironmentBlendMode();
    T === "additive" ? n.buffers.color.setClear(0, 0, 0, 1, a) : T === "alpha-blend" && n.buffers.color.setClear(0, 0, 0, 0, a), (i.autoClear || g) && (n.buffers.depth.setTest(!0), n.buffers.depth.setMask(!0), n.buffers.color.setMask(!0), i.clear(i.autoClearColor, i.autoClearDepth, i.autoClearStencil));
  }
  function p(x, g) {
    const _ = v(g);
    _ && (_.isCubeTexture || _.mapping === ja) ? (u === void 0 && (u = new hn(
      new Ls(1, 1, 1),
      new Ti({
        name: "BackgroundCubeMaterial",
        uniforms: Nr(Ln.backgroundCube.uniforms),
        vertexShader: Ln.backgroundCube.vertexShader,
        fragmentShader: Ln.backgroundCube.fragmentShader,
        side: sn,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), u.geometry.deleteAttribute("normal"), u.geometry.deleteAttribute("uv"), u.onBeforeRender = function(T, A, M) {
      this.matrixWorld.copyPosition(M.matrixWorld);
    }, Object.defineProperty(u.material, "envMap", {
      get: function() {
        return this.uniforms.envMap.value;
      }
    }), r.update(u)), Pi.copy(g.backgroundRotation), Pi.x *= -1, Pi.y *= -1, Pi.z *= -1, _.isCubeTexture && _.isRenderTargetTexture === !1 && (Pi.y *= -1, Pi.z *= -1), u.material.uniforms.envMap.value = _, u.material.uniforms.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, u.material.uniforms.backgroundBlurriness.value = g.backgroundBlurriness, u.material.uniforms.backgroundIntensity.value = g.backgroundIntensity, u.material.uniforms.backgroundRotation.value.setFromMatrix4(YE.makeRotationFromEuler(Pi)), u.material.toneMapped = nt.getTransfer(_.colorSpace) !== mt, (h !== _ || d !== _.version || m !== i.toneMapping) && (u.material.needsUpdate = !0, h = _, d = _.version, m = i.toneMapping), u.layers.enableAll(), x.unshift(u, u.geometry, u.material, 0, 0, null)) : _ && _.isTexture && (c === void 0 && (c = new hn(
      new Ya(2, 2),
      new Ti({
        name: "BackgroundMaterial",
        uniforms: Nr(Ln.background.uniforms),
        vertexShader: Ln.background.vertexShader,
        fragmentShader: Ln.background.fragmentShader,
        side: si,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), c.geometry.deleteAttribute("normal"), Object.defineProperty(c.material, "map", {
      get: function() {
        return this.uniforms.t2D.value;
      }
    }), r.update(c)), c.material.uniforms.t2D.value = _, c.material.uniforms.backgroundIntensity.value = g.backgroundIntensity, c.material.toneMapped = nt.getTransfer(_.colorSpace) !== mt, _.matrixAutoUpdate === !0 && _.updateMatrix(), c.material.uniforms.uvTransform.value.copy(_.matrix), (h !== _ || d !== _.version || m !== i.toneMapping) && (c.material.needsUpdate = !0, h = _, d = _.version, m = i.toneMapping), c.layers.enableAll(), x.unshift(c, c.geometry, c.material, 0, 0, null));
  }
  function f(x, g) {
    x.getRGB(ra, Xd(i)), n.buffers.color.setClear(ra.r, ra.g, ra.b, g, a);
  }
  return {
    getClearColor: function() {
      return o;
    },
    setClearColor: function(x, g = 1) {
      o.set(x), l = g, f(o, l);
    },
    getClearAlpha: function() {
      return l;
    },
    setClearAlpha: function(x) {
      l = x, f(o, l);
    },
    render: b,
    addToRenderList: p
  };
}
function KE(i, e) {
  const t = i.getParameter(i.MAX_VERTEX_ATTRIBS), n = {}, r = d(null);
  let s = r, a = !1;
  function o(E, R, q, G, V) {
    let B = !1;
    const U = h(G, q, R);
    s !== U && (s = U, c(s.object)), B = m(E, G, q, V), B && v(E, G, q, V), V !== null && e.update(V, i.ELEMENT_ARRAY_BUFFER), (B || a) && (a = !1, _(E, R, q, G), V !== null && i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, e.get(V).buffer));
  }
  function l() {
    return i.createVertexArray();
  }
  function c(E) {
    return i.bindVertexArray(E);
  }
  function u(E) {
    return i.deleteVertexArray(E);
  }
  function h(E, R, q) {
    const G = q.wireframe === !0;
    let V = n[E.id];
    V === void 0 && (V = {}, n[E.id] = V);
    let B = V[R.id];
    B === void 0 && (B = {}, V[R.id] = B);
    let U = B[G];
    return U === void 0 && (U = d(l()), B[G] = U), U;
  }
  function d(E) {
    const R = [], q = [], G = [];
    for (let V = 0; V < t; V++)
      R[V] = 0, q[V] = 0, G[V] = 0;
    return {
      // for backward compatibility on non-VAO support browser
      geometry: null,
      program: null,
      wireframe: !1,
      newAttributes: R,
      enabledAttributes: q,
      attributeDivisors: G,
      object: E,
      attributes: {},
      index: null
    };
  }
  function m(E, R, q, G) {
    const V = s.attributes, B = R.attributes;
    let U = 0;
    const Y = q.getAttributes();
    for (const z in Y)
      if (Y[z].location >= 0) {
        const oe = V[z];
        let ce = B[z];
        if (ce === void 0 && (z === "instanceMatrix" && E.instanceMatrix && (ce = E.instanceMatrix), z === "instanceColor" && E.instanceColor && (ce = E.instanceColor)), oe === void 0 || oe.attribute !== ce || ce && oe.data !== ce.data) return !0;
        U++;
      }
    return s.attributesNum !== U || s.index !== G;
  }
  function v(E, R, q, G) {
    const V = {}, B = R.attributes;
    let U = 0;
    const Y = q.getAttributes();
    for (const z in Y)
      if (Y[z].location >= 0) {
        let oe = B[z];
        oe === void 0 && (z === "instanceMatrix" && E.instanceMatrix && (oe = E.instanceMatrix), z === "instanceColor" && E.instanceColor && (oe = E.instanceColor));
        const ce = {};
        ce.attribute = oe, oe && oe.data && (ce.data = oe.data), V[z] = ce, U++;
      }
    s.attributes = V, s.attributesNum = U, s.index = G;
  }
  function b() {
    const E = s.newAttributes;
    for (let R = 0, q = E.length; R < q; R++)
      E[R] = 0;
  }
  function p(E) {
    f(E, 0);
  }
  function f(E, R) {
    const q = s.newAttributes, G = s.enabledAttributes, V = s.attributeDivisors;
    q[E] = 1, G[E] === 0 && (i.enableVertexAttribArray(E), G[E] = 1), V[E] !== R && (i.vertexAttribDivisor(E, R), V[E] = R);
  }
  function x() {
    const E = s.newAttributes, R = s.enabledAttributes;
    for (let q = 0, G = R.length; q < G; q++)
      R[q] !== E[q] && (i.disableVertexAttribArray(q), R[q] = 0);
  }
  function g(E, R, q, G, V, B, U) {
    U === !0 ? i.vertexAttribIPointer(E, R, q, V, B) : i.vertexAttribPointer(E, R, q, G, V, B);
  }
  function _(E, R, q, G) {
    b();
    const V = G.attributes, B = q.getAttributes(), U = R.defaultAttributeValues;
    for (const Y in B) {
      const z = B[Y];
      if (z.location >= 0) {
        let ie = V[Y];
        if (ie === void 0 && (Y === "instanceMatrix" && E.instanceMatrix && (ie = E.instanceMatrix), Y === "instanceColor" && E.instanceColor && (ie = E.instanceColor)), ie !== void 0) {
          const oe = ie.normalized, ce = ie.itemSize, ye = e.get(ie);
          if (ye === void 0) continue;
          const je = ye.buffer, K = ye.type, Q = ye.bytesPerElement, re = K === i.INT || K === i.UNSIGNED_INT || ie.gpuType === Sc;
          if (ie.isInterleavedBufferAttribute) {
            const ne = ie.data, he = ne.stride, me = ie.offset;
            if (ne.isInstancedInterleavedBuffer) {
              for (let we = 0; we < z.locationSize; we++)
                f(z.location + we, ne.meshPerAttribute);
              E.isInstancedMesh !== !0 && G._maxInstanceCount === void 0 && (G._maxInstanceCount = ne.meshPerAttribute * ne.count);
            } else
              for (let we = 0; we < z.locationSize; we++)
                p(z.location + we);
            i.bindBuffer(i.ARRAY_BUFFER, je);
            for (let we = 0; we < z.locationSize; we++)
              g(
                z.location + we,
                ce / z.locationSize,
                K,
                oe,
                he * Q,
                (me + ce / z.locationSize * we) * Q,
                re
              );
          } else {
            if (ie.isInstancedBufferAttribute) {
              for (let ne = 0; ne < z.locationSize; ne++)
                f(z.location + ne, ie.meshPerAttribute);
              E.isInstancedMesh !== !0 && G._maxInstanceCount === void 0 && (G._maxInstanceCount = ie.meshPerAttribute * ie.count);
            } else
              for (let ne = 0; ne < z.locationSize; ne++)
                p(z.location + ne);
            i.bindBuffer(i.ARRAY_BUFFER, je);
            for (let ne = 0; ne < z.locationSize; ne++)
              g(
                z.location + ne,
                ce / z.locationSize,
                K,
                oe,
                ce * Q,
                ce / z.locationSize * ne * Q,
                re
              );
          }
        } else if (U !== void 0) {
          const oe = U[Y];
          if (oe !== void 0)
            switch (oe.length) {
              case 2:
                i.vertexAttrib2fv(z.location, oe);
                break;
              case 3:
                i.vertexAttrib3fv(z.location, oe);
                break;
              case 4:
                i.vertexAttrib4fv(z.location, oe);
                break;
              default:
                i.vertexAttrib1fv(z.location, oe);
            }
        }
      }
    }
    x();
  }
  function T() {
    C();
    for (const E in n) {
      const R = n[E];
      for (const q in R) {
        const G = R[q];
        for (const V in G)
          u(G[V].object), delete G[V];
        delete R[q];
      }
      delete n[E];
    }
  }
  function A(E) {
    if (n[E.id] === void 0) return;
    const R = n[E.id];
    for (const q in R) {
      const G = R[q];
      for (const V in G)
        u(G[V].object), delete G[V];
      delete R[q];
    }
    delete n[E.id];
  }
  function M(E) {
    for (const R in n) {
      const q = n[R];
      if (q[E.id] === void 0) continue;
      const G = q[E.id];
      for (const V in G)
        u(G[V].object), delete G[V];
      delete q[E.id];
    }
  }
  function C() {
    y(), a = !0, s !== r && (s = r, c(s.object));
  }
  function y() {
    r.geometry = null, r.program = null, r.wireframe = !1;
  }
  return {
    setup: o,
    reset: C,
    resetDefaultState: y,
    dispose: T,
    releaseStatesOfGeometry: A,
    releaseStatesOfProgram: M,
    initAttributes: b,
    enableAttribute: p,
    disableUnusedAttributes: x
  };
}
function $E(i, e, t) {
  let n;
  function r(c) {
    n = c;
  }
  function s(c, u) {
    i.drawArrays(n, c, u), t.update(u, n, 1);
  }
  function a(c, u, h) {
    h !== 0 && (i.drawArraysInstanced(n, c, u, h), t.update(u, n, h));
  }
  function o(c, u, h) {
    if (h === 0) return;
    e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n, c, 0, u, 0, h);
    let m = 0;
    for (let v = 0; v < h; v++)
      m += u[v];
    t.update(m, n, 1);
  }
  function l(c, u, h, d) {
    if (h === 0) return;
    const m = e.get("WEBGL_multi_draw");
    if (m === null)
      for (let v = 0; v < c.length; v++)
        a(c[v], u[v], d[v]);
    else {
      m.multiDrawArraysInstancedWEBGL(n, c, 0, u, 0, d, 0, h);
      let v = 0;
      for (let b = 0; b < h; b++)
        v += u[b] * d[b];
      t.update(v, n, 1);
    }
  }
  this.setMode = r, this.render = s, this.renderInstances = a, this.renderMultiDraw = o, this.renderMultiDrawInstances = l;
}
function JE(i, e, t, n) {
  let r;
  function s() {
    if (r !== void 0) return r;
    if (e.has("EXT_texture_filter_anisotropic") === !0) {
      const M = e.get("EXT_texture_filter_anisotropic");
      r = i.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
    } else
      r = 0;
    return r;
  }
  function a(M) {
    return !(M !== _n && n.convert(M) !== i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT));
  }
  function o(M) {
    const C = M === Cs && (e.has("EXT_color_buffer_half_float") || e.has("EXT_color_buffer_float"));
    return !(M !== ai && n.convert(M) !== i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)
    M !== wn && !C);
  }
  function l(M) {
    if (M === "highp") {
      if (i.getShaderPrecisionFormat(i.VERTEX_SHADER, i.HIGH_FLOAT).precision > 0 && i.getShaderPrecisionFormat(i.FRAGMENT_SHADER, i.HIGH_FLOAT).precision > 0)
        return "highp";
      M = "mediump";
    }
    return M === "mediump" && i.getShaderPrecisionFormat(i.VERTEX_SHADER, i.MEDIUM_FLOAT).precision > 0 && i.getShaderPrecisionFormat(i.FRAGMENT_SHADER, i.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp";
  }
  let c = t.precision !== void 0 ? t.precision : "highp";
  const u = l(c);
  u !== c && (console.warn("THREE.WebGLRenderer:", c, "not supported, using", u, "instead."), c = u);
  const h = t.logarithmicDepthBuffer === !0, d = t.reverseDepthBuffer === !0 && e.has("EXT_clip_control"), m = i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS), v = i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS), b = i.getParameter(i.MAX_TEXTURE_SIZE), p = i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE), f = i.getParameter(i.MAX_VERTEX_ATTRIBS), x = i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS), g = i.getParameter(i.MAX_VARYING_VECTORS), _ = i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS), T = v > 0, A = i.getParameter(i.MAX_SAMPLES);
  return {
    isWebGL2: !0,
    // keeping this for backwards compatibility
    getMaxAnisotropy: s,
    getMaxPrecision: l,
    textureFormatReadable: a,
    textureTypeReadable: o,
    precision: c,
    logarithmicDepthBuffer: h,
    reverseDepthBuffer: d,
    maxTextures: m,
    maxVertexTextures: v,
    maxTextureSize: b,
    maxCubemapSize: p,
    maxAttributes: f,
    maxVertexUniforms: x,
    maxVaryings: g,
    maxFragmentUniforms: _,
    vertexTextures: T,
    maxSamples: A
  };
}
function QE(i) {
  const e = this;
  let t = null, n = 0, r = !1, s = !1;
  const a = new _i(), o = new We(), l = { value: null, needsUpdate: !1 };
  this.uniform = l, this.numPlanes = 0, this.numIntersection = 0, this.init = function(h, d) {
    const m = h.length !== 0 || d || // enable state of previous frame - the clipping code has to
    // run another frame in order to reset the state:
    n !== 0 || r;
    return r = d, n = h.length, m;
  }, this.beginShadows = function() {
    s = !0, u(null);
  }, this.endShadows = function() {
    s = !1;
  }, this.setGlobalState = function(h, d) {
    t = u(h, d, 0);
  }, this.setState = function(h, d, m) {
    const v = h.clippingPlanes, b = h.clipIntersection, p = h.clipShadows, f = i.get(h);
    if (!r || v === null || v.length === 0 || s && !p)
      s ? u(null) : c();
    else {
      const x = s ? 0 : n, g = x * 4;
      let _ = f.clippingState || null;
      l.value = _, _ = u(v, d, g, m);
      for (let T = 0; T !== g; ++T)
        _[T] = t[T];
      f.clippingState = _, this.numIntersection = b ? this.numPlanes : 0, this.numPlanes += x;
    }
  };
  function c() {
    l.value !== t && (l.value = t, l.needsUpdate = n > 0), e.numPlanes = n, e.numIntersection = 0;
  }
  function u(h, d, m, v) {
    const b = h !== null ? h.length : 0;
    let p = null;
    if (b !== 0) {
      if (p = l.value, v !== !0 || p === null) {
        const f = m + b * 4, x = d.matrixWorldInverse;
        o.getNormalMatrix(x), (p === null || p.length < f) && (p = new Float32Array(f));
        for (let g = 0, _ = m; g !== b; ++g, _ += 4)
          a.copy(h[g]).applyMatrix4(x, o), a.normal.toArray(p, _), p[_ + 3] = a.constant;
      }
      l.value = p, l.needsUpdate = !0;
    }
    return e.numPlanes = b, e.numIntersection = 0, p;
  }
}
function ey(i) {
  let e = /* @__PURE__ */ new WeakMap();
  function t(a, o) {
    return o === Ml ? a.mapping = Rr : o === Al && (a.mapping = Cr), a;
  }
  function n(a) {
    if (a && a.isTexture) {
      const o = a.mapping;
      if (o === Ml || o === Al)
        if (e.has(a)) {
          const l = e.get(a).texture;
          return t(l, a.mapping);
        } else {
          const l = a.image;
          if (l && l.height > 0) {
            const c = new hx(l.height);
            return c.fromEquirectangularTexture(i, a), e.set(a, c), a.addEventListener("dispose", r), t(c.texture, a.mapping);
          } else
            return null;
        }
    }
    return a;
  }
  function r(a) {
    const o = a.target;
    o.removeEventListener("dispose", r);
    const l = e.get(o);
    l !== void 0 && (e.delete(o), l.dispose());
  }
  function s() {
    e = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: n,
    dispose: s
  };
}
class Lc extends jd {
  constructor(e = -1, t = 1, n = 1, r = -1, s = 0.1, a = 2e3) {
    super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = n, this.bottom = r, this.near = s, this.far = a, this.updateProjectionMatrix();
  }
  copy(e, t) {
    return super.copy(e, t), this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.near = e.near, this.far = e.far, this.zoom = e.zoom, this.view = e.view === null ? null : Object.assign({}, e.view), this;
  }
  setViewOffset(e, t, n, r, s, a) {
    this.view === null && (this.view = {
      enabled: !0,
      fullWidth: 1,
      fullHeight: 1,
      offsetX: 0,
      offsetY: 0,
      width: 1,
      height: 1
    }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = r, this.view.width = s, this.view.height = a, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, r = (this.top + this.bottom) / 2;
    let s = n - e, a = n + e, o = r + t, l = r - t;
    if (this.view !== null && this.view.enabled) {
      const c = (this.right - this.left) / this.view.fullWidth / this.zoom, u = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
      s += c * this.view.offsetX, a = s + c * this.view.width, o -= u * this.view.offsetY, l = o - u * this.view.height;
    }
    this.projectionMatrix.makeOrthographic(s, a, o, l, this.near, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return t.object.zoom = this.zoom, t.object.left = this.left, t.object.right = this.right, t.object.top = this.top, t.object.bottom = this.bottom, t.object.near = this.near, t.object.far = this.far, this.view !== null && (t.object.view = Object.assign({}, this.view)), t;
  }
}
const _r = 4, vh = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], Bi = 20, Fo = /* @__PURE__ */ new Lc(), xh = /* @__PURE__ */ new Ue();
let No = null, Uo = 0, Oo = 0, Bo = !1;
const Fi = (1 + Math.sqrt(5)) / 2, fr = 1 / Fi, bh = [
  /* @__PURE__ */ new L(-Fi, fr, 0),
  /* @__PURE__ */ new L(Fi, fr, 0),
  /* @__PURE__ */ new L(-fr, 0, Fi),
  /* @__PURE__ */ new L(fr, 0, Fi),
  /* @__PURE__ */ new L(0, Fi, -fr),
  /* @__PURE__ */ new L(0, Fi, fr),
  /* @__PURE__ */ new L(-1, 1, -1),
  /* @__PURE__ */ new L(1, 1, -1),
  /* @__PURE__ */ new L(-1, 1, 1),
  /* @__PURE__ */ new L(1, 1, 1)
];
class Eh {
  constructor(e) {
    this._renderer = e, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._lodPlanes = [], this._sizeLods = [], this._sigmas = [], this._blurMaterial = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._compileMaterial(this._blurMaterial);
  }
  /**
   * Generates a PMREM from a supplied Scene, which can be faster than using an
   * image if networking bandwidth is low. Optional sigma specifies a blur radius
   * in radians to be applied to the scene before PMREM generation. Optional near
   * and far planes ensure the scene is rendered in its entirety (the cubeCamera
   * is placed at the origin).
   */
  fromScene(e, t = 0, n = 0.1, r = 100) {
    No = this._renderer.getRenderTarget(), Uo = this._renderer.getActiveCubeFace(), Oo = this._renderer.getActiveMipmapLevel(), Bo = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(256);
    const s = this._allocateTargets();
    return s.depthBuffer = !0, this._sceneToCubeUV(e, n, r, s), t > 0 && this._blur(s, 0, 0, t), this._applyPMREM(s), this._cleanup(s), s;
  }
  /**
   * Generates a PMREM from an equirectangular texture, which can be either LDR
   * or HDR. The ideal input image size is 1k (1024 x 512),
   * as this matches best with the 256 x 256 cubemap output.
   * The smallest supported equirectangular image size is 64 x 32.
   */
  fromEquirectangular(e, t = null) {
    return this._fromTexture(e, t);
  }
  /**
   * Generates a PMREM from an cubemap texture, which can be either LDR
   * or HDR. The ideal input cube size is 256 x 256,
   * as this matches best with the 256 x 256 cubemap output.
   * The smallest supported cube size is 16 x 16.
   */
  fromCubemap(e, t = null) {
    return this._fromTexture(e, t);
  }
  /**
   * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
   * your texture's network fetch for increased concurrency.
   */
  compileCubemapShader() {
    this._cubemapMaterial === null && (this._cubemapMaterial = Mh(), this._compileMaterial(this._cubemapMaterial));
  }
  /**
   * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
   * your texture's network fetch for increased concurrency.
   */
  compileEquirectangularShader() {
    this._equirectMaterial === null && (this._equirectMaterial = Sh(), this._compileMaterial(this._equirectMaterial));
  }
  /**
   * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,
   * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on
   * one of them will cause any others to also become unusable.
   */
  dispose() {
    this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose();
  }
  // private interface
  _setSize(e) {
    this._lodMax = Math.floor(Math.log2(e)), this._cubeSize = Math.pow(2, this._lodMax);
  }
  _dispose() {
    this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose();
    for (let e = 0; e < this._lodPlanes.length; e++)
      this._lodPlanes[e].dispose();
  }
  _cleanup(e) {
    this._renderer.setRenderTarget(No, Uo, Oo), this._renderer.xr.enabled = Bo, e.scissorTest = !1, sa(e, 0, 0, e.width, e.height);
  }
  _fromTexture(e, t) {
    e.mapping === Rr || e.mapping === Cr ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), No = this._renderer.getRenderTarget(), Uo = this._renderer.getActiveCubeFace(), Oo = this._renderer.getActiveMipmapLevel(), Bo = this._renderer.xr.enabled, this._renderer.xr.enabled = !1;
    const n = t || this._allocateTargets();
    return this._textureToCubeUV(e, n), this._applyPMREM(n), this._cleanup(n), n;
  }
  _allocateTargets() {
    const e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, n = {
      magFilter: un,
      minFilter: un,
      generateMipmaps: !1,
      type: Cs,
      format: _n,
      colorSpace: en,
      depthBuffer: !1
    }, r = yh(e, t, n);
    if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) {
      this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = yh(e, t, n);
      const { _lodMax: s } = this;
      ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = ty(s)), this._blurMaterial = ny(s, e, t);
    }
    return r;
  }
  _compileMaterial(e) {
    const t = new hn(this._lodPlanes[0], e);
    this._renderer.compile(t, Fo);
  }
  _sceneToCubeUV(e, t, n, r) {
    const o = new $t(90, 1, t, n), l = [1, -1, 1, 1, 1, 1], c = [1, 1, 1, -1, -1, -1], u = this._renderer, h = u.autoClear, d = u.toneMapping;
    u.getClearColor(xh), u.toneMapping = Ai, u.autoClear = !1;
    const m = new ki({
      name: "PMREM.Background",
      side: sn,
      depthWrite: !1,
      depthTest: !1
    }), v = new hn(new Ls(), m);
    let b = !1;
    const p = e.background;
    p ? p.isColor && (m.color.copy(p), e.background = null, b = !0) : (m.color.copy(xh), b = !0);
    for (let f = 0; f < 6; f++) {
      const x = f % 3;
      x === 0 ? (o.up.set(0, l[f], 0), o.lookAt(c[f], 0, 0)) : x === 1 ? (o.up.set(0, 0, l[f]), o.lookAt(0, c[f], 0)) : (o.up.set(0, l[f], 0), o.lookAt(0, 0, c[f]));
      const g = this._cubeSize;
      sa(r, x * g, f > 2 ? g : 0, g, g), u.setRenderTarget(r), b && u.render(v, o), u.render(e, o);
    }
    v.geometry.dispose(), v.material.dispose(), u.toneMapping = d, u.autoClear = h, e.background = p;
  }
  _textureToCubeUV(e, t) {
    const n = this._renderer, r = e.mapping === Rr || e.mapping === Cr;
    r ? (this._cubemapMaterial === null && (this._cubemapMaterial = Mh()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = Sh());
    const s = r ? this._cubemapMaterial : this._equirectMaterial, a = new hn(this._lodPlanes[0], s), o = s.uniforms;
    o.envMap.value = e;
    const l = this._cubeSize;
    sa(t, 0, 0, 3 * l, 2 * l), n.setRenderTarget(t), n.render(a, Fo);
  }
  _applyPMREM(e) {
    const t = this._renderer, n = t.autoClear;
    t.autoClear = !1;
    const r = this._lodPlanes.length;
    for (let s = 1; s < r; s++) {
      const a = Math.sqrt(this._sigmas[s] * this._sigmas[s] - this._sigmas[s - 1] * this._sigmas[s - 1]), o = bh[(r - s - 1) % bh.length];
      this._blur(e, s - 1, s, a, o);
    }
    t.autoClear = n;
  }
  /**
   * This is a two-pass Gaussian blur for a cubemap. Normally this is done
   * vertically and horizontally, but this breaks down on a cube. Here we apply
   * the blur latitudinally (around the poles), and then longitudinally (towards
   * the poles) to approximate the orthogonally-separable blur. It is least
   * accurate at the poles, but still does a decent job.
   */
  _blur(e, t, n, r, s) {
    const a = this._pingPongRenderTarget;
    this._halfBlur(
      e,
      a,
      t,
      n,
      r,
      "latitudinal",
      s
    ), this._halfBlur(
      a,
      e,
      n,
      n,
      r,
      "longitudinal",
      s
    );
  }
  _halfBlur(e, t, n, r, s, a, o) {
    const l = this._renderer, c = this._blurMaterial;
    a !== "latitudinal" && a !== "longitudinal" && console.error(
      "blur direction must be either latitudinal or longitudinal!"
    );
    const u = 3, h = new hn(this._lodPlanes[r], c), d = c.uniforms, m = this._sizeLods[n] - 1, v = isFinite(s) ? Math.PI / (2 * m) : 2 * Math.PI / (2 * Bi - 1), b = s / v, p = isFinite(s) ? 1 + Math.floor(u * b) : Bi;
    p > Bi && console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Bi}`);
    const f = [];
    let x = 0;
    for (let M = 0; M < Bi; ++M) {
      const C = M / b, y = Math.exp(-C * C / 2);
      f.push(y), M === 0 ? x += y : M < p && (x += 2 * y);
    }
    for (let M = 0; M < f.length; M++)
      f[M] = f[M] / x;
    d.envMap.value = e.texture, d.samples.value = p, d.weights.value = f, d.latitudinal.value = a === "latitudinal", o && (d.poleAxis.value = o);
    const { _lodMax: g } = this;
    d.dTheta.value = v, d.mipInt.value = g - n;
    const _ = this._sizeLods[r], T = 3 * _ * (r > g - _r ? r - g + _r : 0), A = 4 * (this._cubeSize - _);
    sa(t, T, A, 3 * _, 2 * _), l.setRenderTarget(t), l.render(h, Fo);
  }
}
function ty(i) {
  const e = [], t = [], n = [];
  let r = i;
  const s = i - _r + 1 + vh.length;
  for (let a = 0; a < s; a++) {
    const o = Math.pow(2, r);
    t.push(o);
    let l = 1 / o;
    a > i - _r ? l = vh[a - i + _r - 1] : a === 0 && (l = 0), n.push(l);
    const c = 1 / (o - 2), u = -c, h = 1 + c, d = [u, u, h, u, h, h, u, u, h, h, u, h], m = 6, v = 6, b = 3, p = 2, f = 1, x = new Float32Array(b * v * m), g = new Float32Array(p * v * m), _ = new Float32Array(f * v * m);
    for (let A = 0; A < m; A++) {
      const M = A % 3 * 2 / 3 - 1, C = A > 2 ? 0 : -1, y = [
        M,
        C,
        0,
        M + 2 / 3,
        C,
        0,
        M + 2 / 3,
        C + 1,
        0,
        M,
        C,
        0,
        M + 2 / 3,
        C + 1,
        0,
        M,
        C + 1,
        0
      ];
      x.set(y, b * v * A), g.set(d, p * v * A);
      const E = [A, A, A, A, A, A];
      _.set(E, f * v * A);
    }
    const T = new fn();
    T.setAttribute("position", new Qt(x, b)), T.setAttribute("uv", new Qt(g, p)), T.setAttribute("faceIndex", new Qt(_, f)), e.push(T), r > _r && r--;
  }
  return { lodPlanes: e, sizeLods: t, sigmas: n };
}
function yh(i, e, t) {
  const n = new Xi(i, e, t);
  return n.texture.mapping = ja, n.texture.name = "PMREM.cubeUv", n.scissorTest = !0, n;
}
function sa(i, e, t, n, r) {
  i.viewport.set(e, t, n, r), i.scissor.set(e, t, n, r);
}
function ny(i, e, t) {
  const n = new Float32Array(Bi), r = new L(0, 1, 0);
  return new Ti({
    name: "SphericalGaussianBlur",
    defines: {
      n: Bi,
      CUBEUV_TEXEL_WIDTH: 1 / e,
      CUBEUV_TEXEL_HEIGHT: 1 / t,
      CUBEUV_MAX_MIP: `${i}.0`
    },
    uniforms: {
      envMap: { value: null },
      samples: { value: 1 },
      weights: { value: n },
      latitudinal: { value: !1 },
      dTheta: { value: 0 },
      mipInt: { value: 0 },
      poleAxis: { value: r }
    },
    vertexShader: Ic(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`
    ),
    blending: Mi,
    depthTest: !1,
    depthWrite: !1
  });
}
function Sh() {
  return new Ti({
    name: "EquirectangularToCubeUV",
    uniforms: {
      envMap: { value: null }
    },
    vertexShader: Ic(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`
    ),
    blending: Mi,
    depthTest: !1,
    depthWrite: !1
  });
}
function Mh() {
  return new Ti({
    name: "CubemapToCubeUV",
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 }
    },
    vertexShader: Ic(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`
    ),
    blending: Mi,
    depthTest: !1,
    depthWrite: !1
  });
}
function Ic() {
  return (
    /* glsl */
    `

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`
  );
}
function iy(i) {
  let e = /* @__PURE__ */ new WeakMap(), t = null;
  function n(o) {
    if (o && o.isTexture) {
      const l = o.mapping, c = l === Ml || l === Al, u = l === Rr || l === Cr;
      if (c || u) {
        let h = e.get(o);
        const d = h !== void 0 ? h.texture.pmremVersion : 0;
        if (o.isRenderTargetTexture && o.pmremVersion !== d)
          return t === null && (t = new Eh(i)), h = c ? t.fromEquirectangular(o, h) : t.fromCubemap(o, h), h.texture.pmremVersion = o.pmremVersion, e.set(o, h), h.texture;
        if (h !== void 0)
          return h.texture;
        {
          const m = o.image;
          return c && m && m.height > 0 || u && m && r(m) ? (t === null && (t = new Eh(i)), h = c ? t.fromEquirectangular(o) : t.fromCubemap(o), h.texture.pmremVersion = o.pmremVersion, e.set(o, h), o.addEventListener("dispose", s), h.texture) : null;
        }
      }
    }
    return o;
  }
  function r(o) {
    let l = 0;
    const c = 6;
    for (let u = 0; u < c; u++)
      o[u] !== void 0 && l++;
    return l === c;
  }
  function s(o) {
    const l = o.target;
    l.removeEventListener("dispose", s);
    const c = e.get(l);
    c !== void 0 && (e.delete(l), c.dispose());
  }
  function a() {
    e = /* @__PURE__ */ new WeakMap(), t !== null && (t.dispose(), t = null);
  }
  return {
    get: n,
    dispose: a
  };
}
function ry(i) {
  const e = {};
  function t(n) {
    if (e[n] !== void 0)
      return e[n];
    let r;
    switch (n) {
      case "WEBGL_depth_texture":
        r = i.getExtension("WEBGL_depth_texture") || i.getExtension("MOZ_WEBGL_depth_texture") || i.getExtension("WEBKIT_WEBGL_depth_texture");
        break;
      case "EXT_texture_filter_anisotropic":
        r = i.getExtension("EXT_texture_filter_anisotropic") || i.getExtension("MOZ_EXT_texture_filter_anisotropic") || i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
        break;
      case "WEBGL_compressed_texture_s3tc":
        r = i.getExtension("WEBGL_compressed_texture_s3tc") || i.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
        break;
      case "WEBGL_compressed_texture_pvrtc":
        r = i.getExtension("WEBGL_compressed_texture_pvrtc") || i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
        break;
      default:
        r = i.getExtension(n);
    }
    return e[n] = r, r;
  }
  return {
    has: function(n) {
      return t(n) !== null;
    },
    init: function() {
      t("EXT_color_buffer_float"), t("WEBGL_clip_cull_distance"), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture"), t("WEBGL_render_shared_exponent");
    },
    get: function(n) {
      const r = t(n);
      return r === null && ds("THREE.WebGLRenderer: " + n + " extension not supported."), r;
    }
  };
}
function sy(i, e, t, n) {
  const r = {}, s = /* @__PURE__ */ new WeakMap();
  function a(h) {
    const d = h.target;
    d.index !== null && e.remove(d.index);
    for (const v in d.attributes)
      e.remove(d.attributes[v]);
    for (const v in d.morphAttributes) {
      const b = d.morphAttributes[v];
      for (let p = 0, f = b.length; p < f; p++)
        e.remove(b[p]);
    }
    d.removeEventListener("dispose", a), delete r[d.id];
    const m = s.get(d);
    m && (e.remove(m), s.delete(d)), n.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount, t.memory.geometries--;
  }
  function o(h, d) {
    return r[d.id] === !0 || (d.addEventListener("dispose", a), r[d.id] = !0, t.memory.geometries++), d;
  }
  function l(h) {
    const d = h.attributes;
    for (const v in d)
      e.update(d[v], i.ARRAY_BUFFER);
    const m = h.morphAttributes;
    for (const v in m) {
      const b = m[v];
      for (let p = 0, f = b.length; p < f; p++)
        e.update(b[p], i.ARRAY_BUFFER);
    }
  }
  function c(h) {
    const d = [], m = h.index, v = h.attributes.position;
    let b = 0;
    if (m !== null) {
      const x = m.array;
      b = m.version;
      for (let g = 0, _ = x.length; g < _; g += 3) {
        const T = x[g + 0], A = x[g + 1], M = x[g + 2];
        d.push(T, A, A, M, M, T);
      }
    } else if (v !== void 0) {
      const x = v.array;
      b = v.version;
      for (let g = 0, _ = x.length / 3 - 1; g < _; g += 3) {
        const T = g + 0, A = g + 1, M = g + 2;
        d.push(T, A, A, M, M, T);
      }
    } else
      return;
    const p = new (Bd(d) ? Wd : Vd)(d, 1);
    p.version = b;
    const f = s.get(h);
    f && e.remove(f), s.set(h, p);
  }
  function u(h) {
    const d = s.get(h);
    if (d) {
      const m = h.index;
      m !== null && d.version < m.version && c(h);
    } else
      c(h);
    return s.get(h);
  }
  return {
    get: o,
    update: l,
    getWireframeAttribute: u
  };
}
function ay(i, e, t) {
  let n;
  function r(d) {
    n = d;
  }
  let s, a;
  function o(d) {
    s = d.type, a = d.bytesPerElement;
  }
  function l(d, m) {
    i.drawElements(n, m, s, d * a), t.update(m, n, 1);
  }
  function c(d, m, v) {
    v !== 0 && (i.drawElementsInstanced(n, m, s, d * a, v), t.update(m, n, v));
  }
  function u(d, m, v) {
    if (v === 0) return;
    e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n, m, 0, s, d, 0, v);
    let p = 0;
    for (let f = 0; f < v; f++)
      p += m[f];
    t.update(p, n, 1);
  }
  function h(d, m, v, b) {
    if (v === 0) return;
    const p = e.get("WEBGL_multi_draw");
    if (p === null)
      for (let f = 0; f < d.length; f++)
        c(d[f] / a, m[f], b[f]);
    else {
      p.multiDrawElementsInstancedWEBGL(n, m, 0, s, d, 0, b, 0, v);
      let f = 0;
      for (let x = 0; x < v; x++)
        f += m[x] * b[x];
      t.update(f, n, 1);
    }
  }
  this.setMode = r, this.setIndex = o, this.render = l, this.renderInstances = c, this.renderMultiDraw = u, this.renderMultiDrawInstances = h;
}
function oy(i) {
  const e = {
    geometries: 0,
    textures: 0
  }, t = {
    frame: 0,
    calls: 0,
    triangles: 0,
    points: 0,
    lines: 0
  };
  function n(s, a, o) {
    switch (t.calls++, a) {
      case i.TRIANGLES:
        t.triangles += o * (s / 3);
        break;
      case i.LINES:
        t.lines += o * (s / 2);
        break;
      case i.LINE_STRIP:
        t.lines += o * (s - 1);
        break;
      case i.LINE_LOOP:
        t.lines += o * s;
        break;
      case i.POINTS:
        t.points += o * s;
        break;
      default:
        console.error("THREE.WebGLInfo: Unknown draw mode:", a);
        break;
    }
  }
  function r() {
    t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0;
  }
  return {
    memory: e,
    render: t,
    programs: null,
    autoReset: !0,
    reset: r,
    update: n
  };
}
function ly(i, e, t) {
  const n = /* @__PURE__ */ new WeakMap(), r = new lt();
  function s(a, o, l) {
    const c = a.morphTargetInfluences, u = o.morphAttributes.position || o.morphAttributes.normal || o.morphAttributes.color, h = u !== void 0 ? u.length : 0;
    let d = n.get(o);
    if (d === void 0 || d.count !== h) {
      let y = function() {
        M.dispose(), n.delete(o), o.removeEventListener("dispose", y);
      };
      d !== void 0 && d.texture.dispose();
      const m = o.morphAttributes.position !== void 0, v = o.morphAttributes.normal !== void 0, b = o.morphAttributes.color !== void 0, p = o.morphAttributes.position || [], f = o.morphAttributes.normal || [], x = o.morphAttributes.color || [];
      let g = 0;
      m === !0 && (g = 1), v === !0 && (g = 2), b === !0 && (g = 3);
      let _ = o.attributes.position.count * g, T = 1;
      _ > e.maxTextureSize && (T = Math.ceil(_ / e.maxTextureSize), _ = e.maxTextureSize);
      const A = new Float32Array(_ * T * 4 * h), M = new Hd(A, _, T, h);
      M.type = wn, M.needsUpdate = !0;
      const C = g * 4;
      for (let E = 0; E < h; E++) {
        const R = p[E], q = f[E], G = x[E], V = _ * T * 4 * E;
        for (let B = 0; B < R.count; B++) {
          const U = B * C;
          m === !0 && (r.fromBufferAttribute(R, B), A[V + U + 0] = r.x, A[V + U + 1] = r.y, A[V + U + 2] = r.z, A[V + U + 3] = 0), v === !0 && (r.fromBufferAttribute(q, B), A[V + U + 4] = r.x, A[V + U + 5] = r.y, A[V + U + 6] = r.z, A[V + U + 7] = 0), b === !0 && (r.fromBufferAttribute(G, B), A[V + U + 8] = r.x, A[V + U + 9] = r.y, A[V + U + 10] = r.z, A[V + U + 11] = G.itemSize === 4 ? r.w : 1);
        }
      }
      d = {
        count: h,
        texture: M,
        size: new ze(_, T)
      }, n.set(o, d), o.addEventListener("dispose", y);
    }
    if (a.isInstancedMesh === !0 && a.morphTexture !== null)
      l.getUniforms().setValue(i, "morphTexture", a.morphTexture, t);
    else {
      let m = 0;
      for (let b = 0; b < c.length; b++)
        m += c[b];
      const v = o.morphTargetsRelative ? 1 : 1 - m;
      l.getUniforms().setValue(i, "morphTargetBaseInfluence", v), l.getUniforms().setValue(i, "morphTargetInfluences", c);
    }
    l.getUniforms().setValue(i, "morphTargetsTexture", d.texture, t), l.getUniforms().setValue(i, "morphTargetsTextureSize", d.size);
  }
  return {
    update: s
  };
}
function cy(i, e, t, n) {
  let r = /* @__PURE__ */ new WeakMap();
  function s(l) {
    const c = n.render.frame, u = l.geometry, h = e.get(l, u);
    if (r.get(h) !== c && (e.update(h), r.set(h, c)), l.isInstancedMesh && (l.hasEventListener("dispose", o) === !1 && l.addEventListener("dispose", o), r.get(l) !== c && (t.update(l.instanceMatrix, i.ARRAY_BUFFER), l.instanceColor !== null && t.update(l.instanceColor, i.ARRAY_BUFFER), r.set(l, c))), l.isSkinnedMesh) {
      const d = l.skeleton;
      r.get(d) !== c && (d.update(), r.set(d, c));
    }
    return h;
  }
  function a() {
    r = /* @__PURE__ */ new WeakMap();
  }
  function o(l) {
    const c = l.target;
    c.removeEventListener("dispose", o), t.remove(c.instanceMatrix), c.instanceColor !== null && t.remove(c.instanceColor);
  }
  return {
    update: s,
    dispose: a
  };
}
class Zd extends zt {
  constructor(e, t, n, r, s, a, o, l, c, u = Er) {
    if (u !== Er && u !== Ir)
      throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
    n === void 0 && u === Er && (n = Wi), n === void 0 && u === Ir && (n = Lr), super(null, r, s, a, o, l, u, n, c), this.isDepthTexture = !0, this.image = { width: e, height: t }, this.magFilter = o !== void 0 ? o : Jt, this.minFilter = l !== void 0 ? l : Jt, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
  }
  copy(e) {
    return super.copy(e), this.compareFunction = e.compareFunction, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return this.compareFunction !== null && (t.compareFunction = this.compareFunction), t;
  }
}
const Kd = /* @__PURE__ */ new zt(), Ah = /* @__PURE__ */ new Zd(1, 1), $d = /* @__PURE__ */ new Hd(), Jd = /* @__PURE__ */ new Zv(), Qd = /* @__PURE__ */ new qd(), Th = [], wh = [], Dh = new Float32Array(16), Rh = new Float32Array(9), Ch = new Float32Array(4);
function Xr(i, e, t) {
  const n = i[0];
  if (n <= 0 || n > 0) return i;
  const r = e * t;
  let s = Th[r];
  if (s === void 0 && (s = new Float32Array(r), Th[r] = s), e !== 0) {
    n.toArray(s, 0);
    for (let a = 1, o = 0; a !== e; ++a)
      o += t, i[a].toArray(s, o);
  }
  return s;
}
function Bt(i, e) {
  if (i.length !== e.length) return !1;
  for (let t = 0, n = i.length; t < n; t++)
    if (i[t] !== e[t]) return !1;
  return !0;
}
function kt(i, e) {
  for (let t = 0, n = e.length; t < n; t++)
    i[t] = e[t];
}
function Za(i, e) {
  let t = wh[e];
  t === void 0 && (t = new Int32Array(e), wh[e] = t);
  for (let n = 0; n !== e; ++n)
    t[n] = i.allocateTextureUnit();
  return t;
}
function uy(i, e) {
  const t = this.cache;
  t[0] !== e && (i.uniform1f(this.addr, e), t[0] = e);
}
function hy(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (i.uniform2f(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (Bt(t, e)) return;
    i.uniform2fv(this.addr, e), kt(t, e);
  }
}
function fy(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3f(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else if (e.r !== void 0)
    (t[0] !== e.r || t[1] !== e.g || t[2] !== e.b) && (i.uniform3f(this.addr, e.r, e.g, e.b), t[0] = e.r, t[1] = e.g, t[2] = e.b);
  else {
    if (Bt(t, e)) return;
    i.uniform3fv(this.addr, e), kt(t, e);
  }
}
function dy(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4f(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (Bt(t, e)) return;
    i.uniform4fv(this.addr, e), kt(t, e);
  }
}
function py(i, e) {
  const t = this.cache, n = e.elements;
  if (n === void 0) {
    if (Bt(t, e)) return;
    i.uniformMatrix2fv(this.addr, !1, e), kt(t, e);
  } else {
    if (Bt(t, n)) return;
    Ch.set(n), i.uniformMatrix2fv(this.addr, !1, Ch), kt(t, n);
  }
}
function my(i, e) {
  const t = this.cache, n = e.elements;
  if (n === void 0) {
    if (Bt(t, e)) return;
    i.uniformMatrix3fv(this.addr, !1, e), kt(t, e);
  } else {
    if (Bt(t, n)) return;
    Rh.set(n), i.uniformMatrix3fv(this.addr, !1, Rh), kt(t, n);
  }
}
function gy(i, e) {
  const t = this.cache, n = e.elements;
  if (n === void 0) {
    if (Bt(t, e)) return;
    i.uniformMatrix4fv(this.addr, !1, e), kt(t, e);
  } else {
    if (Bt(t, n)) return;
    Dh.set(n), i.uniformMatrix4fv(this.addr, !1, Dh), kt(t, n);
  }
}
function _y(i, e) {
  const t = this.cache;
  t[0] !== e && (i.uniform1i(this.addr, e), t[0] = e);
}
function vy(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (i.uniform2i(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (Bt(t, e)) return;
    i.uniform2iv(this.addr, e), kt(t, e);
  }
}
function xy(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3i(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else {
    if (Bt(t, e)) return;
    i.uniform3iv(this.addr, e), kt(t, e);
  }
}
function by(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4i(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (Bt(t, e)) return;
    i.uniform4iv(this.addr, e), kt(t, e);
  }
}
function Ey(i, e) {
  const t = this.cache;
  t[0] !== e && (i.uniform1ui(this.addr, e), t[0] = e);
}
function yy(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (i.uniform2ui(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (Bt(t, e)) return;
    i.uniform2uiv(this.addr, e), kt(t, e);
  }
}
function Sy(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3ui(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else {
    if (Bt(t, e)) return;
    i.uniform3uiv(this.addr, e), kt(t, e);
  }
}
function My(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4ui(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (Bt(t, e)) return;
    i.uniform4uiv(this.addr, e), kt(t, e);
  }
}
function Ay(i, e, t) {
  const n = this.cache, r = t.allocateTextureUnit();
  n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r);
  let s;
  this.type === i.SAMPLER_2D_SHADOW ? (Ah.compareFunction = Ud, s = Ah) : s = Kd, t.setTexture2D(e || s, r);
}
function Ty(i, e, t) {
  const n = this.cache, r = t.allocateTextureUnit();
  n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTexture3D(e || Jd, r);
}
function wy(i, e, t) {
  const n = this.cache, r = t.allocateTextureUnit();
  n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTextureCube(e || Qd, r);
}
function Dy(i, e, t) {
  const n = this.cache, r = t.allocateTextureUnit();
  n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTexture2DArray(e || $d, r);
}
function Ry(i) {
  switch (i) {
    case 5126:
      return uy;
    // FLOAT
    case 35664:
      return hy;
    // _VEC2
    case 35665:
      return fy;
    // _VEC3
    case 35666:
      return dy;
    // _VEC4
    case 35674:
      return py;
    // _MAT2
    case 35675:
      return my;
    // _MAT3
    case 35676:
      return gy;
    // _MAT4
    case 5124:
    case 35670:
      return _y;
    // INT, BOOL
    case 35667:
    case 35671:
      return vy;
    // _VEC2
    case 35668:
    case 35672:
      return xy;
    // _VEC3
    case 35669:
    case 35673:
      return by;
    // _VEC4
    case 5125:
      return Ey;
    // UINT
    case 36294:
      return yy;
    // _VEC2
    case 36295:
      return Sy;
    // _VEC3
    case 36296:
      return My;
    // _VEC4
    case 35678:
    // SAMPLER_2D
    case 36198:
    // SAMPLER_EXTERNAL_OES
    case 36298:
    // INT_SAMPLER_2D
    case 36306:
    // UNSIGNED_INT_SAMPLER_2D
    case 35682:
      return Ay;
    case 35679:
    // SAMPLER_3D
    case 36299:
    // INT_SAMPLER_3D
    case 36307:
      return Ty;
    case 35680:
    // SAMPLER_CUBE
    case 36300:
    // INT_SAMPLER_CUBE
    case 36308:
    // UNSIGNED_INT_SAMPLER_CUBE
    case 36293:
      return wy;
    case 36289:
    // SAMPLER_2D_ARRAY
    case 36303:
    // INT_SAMPLER_2D_ARRAY
    case 36311:
    // UNSIGNED_INT_SAMPLER_2D_ARRAY
    case 36292:
      return Dy;
  }
}
function Cy(i, e) {
  i.uniform1fv(this.addr, e);
}
function Py(i, e) {
  const t = Xr(e, this.size, 2);
  i.uniform2fv(this.addr, t);
}
function Ly(i, e) {
  const t = Xr(e, this.size, 3);
  i.uniform3fv(this.addr, t);
}
function Iy(i, e) {
  const t = Xr(e, this.size, 4);
  i.uniform4fv(this.addr, t);
}
function Fy(i, e) {
  const t = Xr(e, this.size, 4);
  i.uniformMatrix2fv(this.addr, !1, t);
}
function Ny(i, e) {
  const t = Xr(e, this.size, 9);
  i.uniformMatrix3fv(this.addr, !1, t);
}
function Uy(i, e) {
  const t = Xr(e, this.size, 16);
  i.uniformMatrix4fv(this.addr, !1, t);
}
function Oy(i, e) {
  i.uniform1iv(this.addr, e);
}
function By(i, e) {
  i.uniform2iv(this.addr, e);
}
function ky(i, e) {
  i.uniform3iv(this.addr, e);
}
function Hy(i, e) {
  i.uniform4iv(this.addr, e);
}
function zy(i, e) {
  i.uniform1uiv(this.addr, e);
}
function Gy(i, e) {
  i.uniform2uiv(this.addr, e);
}
function Vy(i, e) {
  i.uniform3uiv(this.addr, e);
}
function Wy(i, e) {
  i.uniform4uiv(this.addr, e);
}
function Xy(i, e, t) {
  const n = this.cache, r = e.length, s = Za(t, r);
  Bt(n, s) || (i.uniform1iv(this.addr, s), kt(n, s));
  for (let a = 0; a !== r; ++a)
    t.setTexture2D(e[a] || Kd, s[a]);
}
function jy(i, e, t) {
  const n = this.cache, r = e.length, s = Za(t, r);
  Bt(n, s) || (i.uniform1iv(this.addr, s), kt(n, s));
  for (let a = 0; a !== r; ++a)
    t.setTexture3D(e[a] || Jd, s[a]);
}
function qy(i, e, t) {
  const n = this.cache, r = e.length, s = Za(t, r);
  Bt(n, s) || (i.uniform1iv(this.addr, s), kt(n, s));
  for (let a = 0; a !== r; ++a)
    t.setTextureCube(e[a] || Qd, s[a]);
}
function Yy(i, e, t) {
  const n = this.cache, r = e.length, s = Za(t, r);
  Bt(n, s) || (i.uniform1iv(this.addr, s), kt(n, s));
  for (let a = 0; a !== r; ++a)
    t.setTexture2DArray(e[a] || $d, s[a]);
}
function Zy(i) {
  switch (i) {
    case 5126:
      return Cy;
    // FLOAT
    case 35664:
      return Py;
    // _VEC2
    case 35665:
      return Ly;
    // _VEC3
    case 35666:
      return Iy;
    // _VEC4
    case 35674:
      return Fy;
    // _MAT2
    case 35675:
      return Ny;
    // _MAT3
    case 35676:
      return Uy;
    // _MAT4
    case 5124:
    case 35670:
      return Oy;
    // INT, BOOL
    case 35667:
    case 35671:
      return By;
    // _VEC2
    case 35668:
    case 35672:
      return ky;
    // _VEC3
    case 35669:
    case 35673:
      return Hy;
    // _VEC4
    case 5125:
      return zy;
    // UINT
    case 36294:
      return Gy;
    // _VEC2
    case 36295:
      return Vy;
    // _VEC3
    case 36296:
      return Wy;
    // _VEC4
    case 35678:
    // SAMPLER_2D
    case 36198:
    // SAMPLER_EXTERNAL_OES
    case 36298:
    // INT_SAMPLER_2D
    case 36306:
    // UNSIGNED_INT_SAMPLER_2D
    case 35682:
      return Xy;
    case 35679:
    // SAMPLER_3D
    case 36299:
    // INT_SAMPLER_3D
    case 36307:
      return jy;
    case 35680:
    // SAMPLER_CUBE
    case 36300:
    // INT_SAMPLER_CUBE
    case 36308:
    // UNSIGNED_INT_SAMPLER_CUBE
    case 36293:
      return qy;
    case 36289:
    // SAMPLER_2D_ARRAY
    case 36303:
    // INT_SAMPLER_2D_ARRAY
    case 36311:
    // UNSIGNED_INT_SAMPLER_2D_ARRAY
    case 36292:
      return Yy;
  }
}
class Ky {
  constructor(e, t, n) {
    this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = Ry(t.type);
  }
}
class $y {
  constructor(e, t, n) {
    this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = Zy(t.type);
  }
}
class Jy {
  constructor(e) {
    this.id = e, this.seq = [], this.map = {};
  }
  setValue(e, t, n) {
    const r = this.seq;
    for (let s = 0, a = r.length; s !== a; ++s) {
      const o = r[s];
      o.setValue(e, t[o.id], n);
    }
  }
}
const ko = /(\w+)(\])?(\[|\.)?/g;
function Ph(i, e) {
  i.seq.push(e), i.map[e.id] = e;
}
function Qy(i, e, t) {
  const n = i.name, r = n.length;
  for (ko.lastIndex = 0; ; ) {
    const s = ko.exec(n), a = ko.lastIndex;
    let o = s[1];
    const l = s[2] === "]", c = s[3];
    if (l && (o = o | 0), c === void 0 || c === "[" && a + 2 === r) {
      Ph(t, c === void 0 ? new Ky(o, i, e) : new $y(o, i, e));
      break;
    } else {
      let h = t.map[o];
      h === void 0 && (h = new Jy(o), Ph(t, h)), t = h;
    }
  }
}
class Aa {
  constructor(e, t) {
    this.seq = [], this.map = {};
    const n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS);
    for (let r = 0; r < n; ++r) {
      const s = e.getActiveUniform(t, r), a = e.getUniformLocation(t, s.name);
      Qy(s, a, this);
    }
  }
  setValue(e, t, n, r) {
    const s = this.map[t];
    s !== void 0 && s.setValue(e, n, r);
  }
  setOptional(e, t, n) {
    const r = t[n];
    r !== void 0 && this.setValue(e, n, r);
  }
  static upload(e, t, n, r) {
    for (let s = 0, a = t.length; s !== a; ++s) {
      const o = t[s], l = n[o.id];
      l.needsUpdate !== !1 && o.setValue(e, l.value, r);
    }
  }
  static seqWithValue(e, t) {
    const n = [];
    for (let r = 0, s = e.length; r !== s; ++r) {
      const a = e[r];
      a.id in t && n.push(a);
    }
    return n;
  }
}
function Lh(i, e, t) {
  const n = i.createShader(e);
  return i.shaderSource(n, t), i.compileShader(n), n;
}
const eS = 37297;
let tS = 0;
function nS(i, e) {
  const t = i.split(`
`), n = [], r = Math.max(e - 6, 0), s = Math.min(e + 6, t.length);
  for (let a = r; a < s; a++) {
    const o = a + 1;
    n.push(`${o === e ? ">" : " "} ${o}: ${t[a]}`);
  }
  return n.join(`
`);
}
const Ih = /* @__PURE__ */ new We();
function iS(i) {
  nt._getMatrix(Ih, nt.workingColorSpace, i);
  const e = `mat3( ${Ih.elements.map((t) => t.toFixed(4))} )`;
  switch (nt.getTransfer(i)) {
    case qa:
      return [e, "LinearTransferOETF"];
    case mt:
      return [e, "sRGBTransferOETF"];
    default:
      return console.warn("THREE.WebGLProgram: Unsupported color space: ", i), [e, "LinearTransferOETF"];
  }
}
function Fh(i, e, t) {
  const n = i.getShaderParameter(e, i.COMPILE_STATUS), r = i.getShaderInfoLog(e).trim();
  if (n && r === "") return "";
  const s = /ERROR: 0:(\d+)/.exec(r);
  if (s) {
    const a = parseInt(s[1]);
    return t.toUpperCase() + `

` + r + `

` + nS(i.getShaderSource(e), a);
  } else
    return r;
}
function rS(i, e) {
  const t = iS(e);
  return [
    `vec4 ${i}( vec4 value ) {`,
    `	return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,
    "}"
  ].join(`
`);
}
function sS(i, e) {
  let t;
  switch (e) {
    case sv:
      t = "Linear";
      break;
    case av:
      t = "Reinhard";
      break;
    case ov:
      t = "Cineon";
      break;
    case lv:
      t = "ACESFilmic";
      break;
    case uv:
      t = "AgX";
      break;
    case hv:
      t = "Neutral";
      break;
    case cv:
      t = "Custom";
      break;
    default:
      console.warn("THREE.WebGLProgram: Unsupported toneMapping:", e), t = "Linear";
  }
  return "vec3 " + i + "( vec3 color ) { return " + t + "ToneMapping( color ); }";
}
const aa = /* @__PURE__ */ new L();
function aS() {
  nt.getLuminanceCoefficients(aa);
  const i = aa.x.toFixed(4), e = aa.y.toFixed(4), t = aa.z.toFixed(4);
  return [
    "float luminance( const in vec3 rgb ) {",
    `	const vec3 weights = vec3( ${i}, ${e}, ${t} );`,
    "	return dot( weights, rgb );",
    "}"
  ].join(`
`);
}
function oS(i) {
  return [
    i.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "",
    i.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""
  ].filter(ps).join(`
`);
}
function lS(i) {
  const e = [];
  for (const t in i) {
    const n = i[t];
    n !== !1 && e.push("#define " + t + " " + n);
  }
  return e.join(`
`);
}
function cS(i, e) {
  const t = {}, n = i.getProgramParameter(e, i.ACTIVE_ATTRIBUTES);
  for (let r = 0; r < n; r++) {
    const s = i.getActiveAttrib(e, r), a = s.name;
    let o = 1;
    s.type === i.FLOAT_MAT2 && (o = 2), s.type === i.FLOAT_MAT3 && (o = 3), s.type === i.FLOAT_MAT4 && (o = 4), t[a] = {
      type: s.type,
      location: i.getAttribLocation(e, a),
      locationSize: o
    };
  }
  return t;
}
function ps(i) {
  return i !== "";
}
function Nh(i, e) {
  const t = e.numSpotLightShadows + e.numSpotLightMaps - e.numSpotLightShadowsWithMaps;
  return i.replace(/NUM_DIR_LIGHTS/g, e.numDirLights).replace(/NUM_SPOT_LIGHTS/g, e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, t).replace(/NUM_RECT_AREA_LIGHTS/g, e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, e.numPointLights).replace(/NUM_HEMI_LIGHTS/g, e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, e.numPointLightShadows);
}
function Uh(i, e) {
  return i.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection);
}
const uS = /^[ \t]*#include +<([\w\d./]+)>/gm;
function ec(i) {
  return i.replace(uS, fS);
}
const hS = /* @__PURE__ */ new Map();
function fS(i, e) {
  let t = Ye[e];
  if (t === void 0) {
    const n = hS.get(e);
    if (n !== void 0)
      t = Ye[n], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', e, n);
    else
      throw new Error("Can not resolve #include <" + e + ">");
  }
  return ec(t);
}
const dS = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;
function Oh(i) {
  return i.replace(dS, pS);
}
function pS(i, e, t, n) {
  let r = "";
  for (let s = parseInt(e); s < parseInt(t); s++)
    r += n.replace(/\[\s*i\s*\]/g, "[ " + s + " ]").replace(/UNROLLED_LOOP_INDEX/g, s);
  return r;
}
function Bh(i) {
  let e = `precision ${i.precision} float;
	precision ${i.precision} int;
	precision ${i.precision} sampler2D;
	precision ${i.precision} samplerCube;
	precision ${i.precision} sampler3D;
	precision ${i.precision} sampler2DArray;
	precision ${i.precision} sampler2DShadow;
	precision ${i.precision} samplerCubeShadow;
	precision ${i.precision} sampler2DArrayShadow;
	precision ${i.precision} isampler2D;
	precision ${i.precision} isampler3D;
	precision ${i.precision} isamplerCube;
	precision ${i.precision} isampler2DArray;
	precision ${i.precision} usampler2D;
	precision ${i.precision} usampler3D;
	precision ${i.precision} usamplerCube;
	precision ${i.precision} usampler2DArray;
	`;
  return i.precision === "highp" ? e += `
#define HIGH_PRECISION` : i.precision === "mediump" ? e += `
#define MEDIUM_PRECISION` : i.precision === "lowp" && (e += `
#define LOW_PRECISION`), e;
}
function mS(i) {
  let e = "SHADOWMAP_TYPE_BASIC";
  return i.shadowMapType === Ed ? e = "SHADOWMAP_TYPE_PCF" : i.shadowMapType === B0 ? e = "SHADOWMAP_TYPE_PCF_SOFT" : i.shadowMapType === Jn && (e = "SHADOWMAP_TYPE_VSM"), e;
}
function gS(i) {
  let e = "ENVMAP_TYPE_CUBE";
  if (i.envMap)
    switch (i.envMapMode) {
      case Rr:
      case Cr:
        e = "ENVMAP_TYPE_CUBE";
        break;
      case ja:
        e = "ENVMAP_TYPE_CUBE_UV";
        break;
    }
  return e;
}
function _S(i) {
  let e = "ENVMAP_MODE_REFLECTION";
  return i.envMap && i.envMapMode === Cr && (e = "ENVMAP_MODE_REFRACTION"), e;
}
function vS(i) {
  let e = "ENVMAP_BLENDING_NONE";
  if (i.envMap)
    switch (i.combine) {
      case yd:
        e = "ENVMAP_BLENDING_MULTIPLY";
        break;
      case iv:
        e = "ENVMAP_BLENDING_MIX";
        break;
      case rv:
        e = "ENVMAP_BLENDING_ADD";
        break;
    }
  return e;
}
function xS(i) {
  const e = i.envMapCubeUVHeight;
  if (e === null) return null;
  const t = Math.log2(e) - 2, n = 1 / e;
  return { texelWidth: 1 / (3 * Math.max(Math.pow(2, t), 112)), texelHeight: n, maxMip: t };
}
function bS(i, e, t, n) {
  const r = i.getContext(), s = t.defines;
  let a = t.vertexShader, o = t.fragmentShader;
  const l = mS(t), c = gS(t), u = _S(t), h = vS(t), d = xS(t), m = oS(t), v = lS(s), b = r.createProgram();
  let p, f, x = t.glslVersion ? "#version " + t.glslVersion + `
` : "";
  t.isRawShaderMaterial ? (p = [
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    v
  ].filter(ps).join(`
`), p.length > 0 && (p += `
`), f = [
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    v
  ].filter(ps).join(`
`), f.length > 0 && (f += `
`)) : (p = [
    Bh(t),
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    v,
    t.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "",
    t.batching ? "#define USE_BATCHING" : "",
    t.batchingColor ? "#define USE_BATCHING_COLOR" : "",
    t.instancing ? "#define USE_INSTANCING" : "",
    t.instancingColor ? "#define USE_INSTANCING_COLOR" : "",
    t.instancingMorph ? "#define USE_INSTANCING_MORPH" : "",
    t.useFog && t.fog ? "#define USE_FOG" : "",
    t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "",
    t.map ? "#define USE_MAP" : "",
    t.envMap ? "#define USE_ENVMAP" : "",
    t.envMap ? "#define " + u : "",
    t.lightMap ? "#define USE_LIGHTMAP" : "",
    t.aoMap ? "#define USE_AOMAP" : "",
    t.bumpMap ? "#define USE_BUMPMAP" : "",
    t.normalMap ? "#define USE_NORMALMAP" : "",
    t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    t.displacementMap ? "#define USE_DISPLACEMENTMAP" : "",
    t.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    t.anisotropy ? "#define USE_ANISOTROPY" : "",
    t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    t.specularMap ? "#define USE_SPECULARMAP" : "",
    t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    t.metalnessMap ? "#define USE_METALNESSMAP" : "",
    t.alphaMap ? "#define USE_ALPHAMAP" : "",
    t.alphaHash ? "#define USE_ALPHAHASH" : "",
    t.transmission ? "#define USE_TRANSMISSION" : "",
    t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    t.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    //
    t.mapUv ? "#define MAP_UV " + t.mapUv : "",
    t.alphaMapUv ? "#define ALPHAMAP_UV " + t.alphaMapUv : "",
    t.lightMapUv ? "#define LIGHTMAP_UV " + t.lightMapUv : "",
    t.aoMapUv ? "#define AOMAP_UV " + t.aoMapUv : "",
    t.emissiveMapUv ? "#define EMISSIVEMAP_UV " + t.emissiveMapUv : "",
    t.bumpMapUv ? "#define BUMPMAP_UV " + t.bumpMapUv : "",
    t.normalMapUv ? "#define NORMALMAP_UV " + t.normalMapUv : "",
    t.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + t.displacementMapUv : "",
    t.metalnessMapUv ? "#define METALNESSMAP_UV " + t.metalnessMapUv : "",
    t.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + t.roughnessMapUv : "",
    t.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + t.anisotropyMapUv : "",
    t.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + t.clearcoatMapUv : "",
    t.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + t.clearcoatNormalMapUv : "",
    t.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + t.clearcoatRoughnessMapUv : "",
    t.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + t.iridescenceMapUv : "",
    t.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + t.iridescenceThicknessMapUv : "",
    t.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + t.sheenColorMapUv : "",
    t.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + t.sheenRoughnessMapUv : "",
    t.specularMapUv ? "#define SPECULARMAP_UV " + t.specularMapUv : "",
    t.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + t.specularColorMapUv : "",
    t.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + t.specularIntensityMapUv : "",
    t.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + t.transmissionMapUv : "",
    t.thicknessMapUv ? "#define THICKNESSMAP_UV " + t.thicknessMapUv : "",
    //
    t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "",
    t.vertexColors ? "#define USE_COLOR" : "",
    t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    t.vertexUv1s ? "#define USE_UV1" : "",
    t.vertexUv2s ? "#define USE_UV2" : "",
    t.vertexUv3s ? "#define USE_UV3" : "",
    t.pointsUvs ? "#define USE_POINTS_UV" : "",
    t.flatShading ? "#define FLAT_SHADED" : "",
    t.skinning ? "#define USE_SKINNING" : "",
    t.morphTargets ? "#define USE_MORPHTARGETS" : "",
    t.morphNormals && t.flatShading === !1 ? "#define USE_MORPHNORMALS" : "",
    t.morphColors ? "#define USE_MORPHCOLORS" : "",
    t.morphTargetsCount > 0 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + t.morphTextureStride : "",
    t.morphTargetsCount > 0 ? "#define MORPHTARGETS_COUNT " + t.morphTargetsCount : "",
    t.doubleSided ? "#define DOUBLE_SIDED" : "",
    t.flipSided ? "#define FLIP_SIDED" : "",
    t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    t.shadowMapEnabled ? "#define " + l : "",
    t.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",
    t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    t.reverseDepthBuffer ? "#define USE_REVERSEDEPTHBUF" : "",
    "uniform mat4 modelMatrix;",
    "uniform mat4 modelViewMatrix;",
    "uniform mat4 projectionMatrix;",
    "uniform mat4 viewMatrix;",
    "uniform mat3 normalMatrix;",
    "uniform vec3 cameraPosition;",
    "uniform bool isOrthographic;",
    "#ifdef USE_INSTANCING",
    "	attribute mat4 instanceMatrix;",
    "#endif",
    "#ifdef USE_INSTANCING_COLOR",
    "	attribute vec3 instanceColor;",
    "#endif",
    "#ifdef USE_INSTANCING_MORPH",
    "	uniform sampler2D morphTexture;",
    "#endif",
    "attribute vec3 position;",
    "attribute vec3 normal;",
    "attribute vec2 uv;",
    "#ifdef USE_UV1",
    "	attribute vec2 uv1;",
    "#endif",
    "#ifdef USE_UV2",
    "	attribute vec2 uv2;",
    "#endif",
    "#ifdef USE_UV3",
    "	attribute vec2 uv3;",
    "#endif",
    "#ifdef USE_TANGENT",
    "	attribute vec4 tangent;",
    "#endif",
    "#if defined( USE_COLOR_ALPHA )",
    "	attribute vec4 color;",
    "#elif defined( USE_COLOR )",
    "	attribute vec3 color;",
    "#endif",
    "#ifdef USE_SKINNING",
    "	attribute vec4 skinIndex;",
    "	attribute vec4 skinWeight;",
    "#endif",
    `
`
  ].filter(ps).join(`
`), f = [
    Bh(t),
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    v,
    t.useFog && t.fog ? "#define USE_FOG" : "",
    t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "",
    t.alphaToCoverage ? "#define ALPHA_TO_COVERAGE" : "",
    t.map ? "#define USE_MAP" : "",
    t.matcap ? "#define USE_MATCAP" : "",
    t.envMap ? "#define USE_ENVMAP" : "",
    t.envMap ? "#define " + c : "",
    t.envMap ? "#define " + u : "",
    t.envMap ? "#define " + h : "",
    d ? "#define CUBEUV_TEXEL_WIDTH " + d.texelWidth : "",
    d ? "#define CUBEUV_TEXEL_HEIGHT " + d.texelHeight : "",
    d ? "#define CUBEUV_MAX_MIP " + d.maxMip + ".0" : "",
    t.lightMap ? "#define USE_LIGHTMAP" : "",
    t.aoMap ? "#define USE_AOMAP" : "",
    t.bumpMap ? "#define USE_BUMPMAP" : "",
    t.normalMap ? "#define USE_NORMALMAP" : "",
    t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    t.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    t.anisotropy ? "#define USE_ANISOTROPY" : "",
    t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    t.clearcoat ? "#define USE_CLEARCOAT" : "",
    t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    t.dispersion ? "#define USE_DISPERSION" : "",
    t.iridescence ? "#define USE_IRIDESCENCE" : "",
    t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    t.specularMap ? "#define USE_SPECULARMAP" : "",
    t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    t.metalnessMap ? "#define USE_METALNESSMAP" : "",
    t.alphaMap ? "#define USE_ALPHAMAP" : "",
    t.alphaTest ? "#define USE_ALPHATEST" : "",
    t.alphaHash ? "#define USE_ALPHAHASH" : "",
    t.sheen ? "#define USE_SHEEN" : "",
    t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    t.transmission ? "#define USE_TRANSMISSION" : "",
    t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    t.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "",
    t.vertexColors || t.instancingColor || t.batchingColor ? "#define USE_COLOR" : "",
    t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    t.vertexUv1s ? "#define USE_UV1" : "",
    t.vertexUv2s ? "#define USE_UV2" : "",
    t.vertexUv3s ? "#define USE_UV3" : "",
    t.pointsUvs ? "#define USE_POINTS_UV" : "",
    t.gradientMap ? "#define USE_GRADIENTMAP" : "",
    t.flatShading ? "#define FLAT_SHADED" : "",
    t.doubleSided ? "#define DOUBLE_SIDED" : "",
    t.flipSided ? "#define FLIP_SIDED" : "",
    t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    t.shadowMapEnabled ? "#define " + l : "",
    t.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
    t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    t.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
    t.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
    t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    t.reverseDepthBuffer ? "#define USE_REVERSEDEPTHBUF" : "",
    "uniform mat4 viewMatrix;",
    "uniform vec3 cameraPosition;",
    "uniform bool isOrthographic;",
    t.toneMapping !== Ai ? "#define TONE_MAPPING" : "",
    t.toneMapping !== Ai ? Ye.tonemapping_pars_fragment : "",
    // this code is required here because it is used by the toneMapping() function defined below
    t.toneMapping !== Ai ? sS("toneMapping", t.toneMapping) : "",
    t.dithering ? "#define DITHERING" : "",
    t.opaque ? "#define OPAQUE" : "",
    Ye.colorspace_pars_fragment,
    // this code is required here because it is used by the various encoding/decoding function defined below
    rS("linearToOutputTexel", t.outputColorSpace),
    aS(),
    t.useDepthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "",
    `
`
  ].filter(ps).join(`
`)), a = ec(a), a = Nh(a, t), a = Uh(a, t), o = ec(o), o = Nh(o, t), o = Uh(o, t), a = Oh(a), o = Oh(o), t.isRawShaderMaterial !== !0 && (x = `#version 300 es
`, p = [
    m,
    "#define attribute in",
    "#define varying out",
    "#define texture2D texture"
  ].join(`
`) + `
` + p, f = [
    "#define varying in",
    t.glslVersion === Ku ? "" : "layout(location = 0) out highp vec4 pc_fragColor;",
    t.glslVersion === Ku ? "" : "#define gl_FragColor pc_fragColor",
    "#define gl_FragDepthEXT gl_FragDepth",
    "#define texture2D texture",
    "#define textureCube texture",
    "#define texture2DProj textureProj",
    "#define texture2DLodEXT textureLod",
    "#define texture2DProjLodEXT textureProjLod",
    "#define textureCubeLodEXT textureLod",
    "#define texture2DGradEXT textureGrad",
    "#define texture2DProjGradEXT textureProjGrad",
    "#define textureCubeGradEXT textureGrad"
  ].join(`
`) + `
` + f);
  const g = x + p + a, _ = x + f + o, T = Lh(r, r.VERTEX_SHADER, g), A = Lh(r, r.FRAGMENT_SHADER, _);
  r.attachShader(b, T), r.attachShader(b, A), t.index0AttributeName !== void 0 ? r.bindAttribLocation(b, 0, t.index0AttributeName) : t.morphTargets === !0 && r.bindAttribLocation(b, 0, "position"), r.linkProgram(b);
  function M(R) {
    if (i.debug.checkShaderErrors) {
      const q = r.getProgramInfoLog(b).trim(), G = r.getShaderInfoLog(T).trim(), V = r.getShaderInfoLog(A).trim();
      let B = !0, U = !0;
      if (r.getProgramParameter(b, r.LINK_STATUS) === !1)
        if (B = !1, typeof i.debug.onShaderError == "function")
          i.debug.onShaderError(r, b, T, A);
        else {
          const Y = Fh(r, T, "vertex"), z = Fh(r, A, "fragment");
          console.error(
            "THREE.WebGLProgram: Shader Error " + r.getError() + " - VALIDATE_STATUS " + r.getProgramParameter(b, r.VALIDATE_STATUS) + `

Material Name: ` + R.name + `
Material Type: ` + R.type + `

Program Info Log: ` + q + `
` + Y + `
` + z
          );
        }
      else q !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", q) : (G === "" || V === "") && (U = !1);
      U && (R.diagnostics = {
        runnable: B,
        programLog: q,
        vertexShader: {
          log: G,
          prefix: p
        },
        fragmentShader: {
          log: V,
          prefix: f
        }
      });
    }
    r.deleteShader(T), r.deleteShader(A), C = new Aa(r, b), y = cS(r, b);
  }
  let C;
  this.getUniforms = function() {
    return C === void 0 && M(this), C;
  };
  let y;
  this.getAttributes = function() {
    return y === void 0 && M(this), y;
  };
  let E = t.rendererExtensionParallelShaderCompile === !1;
  return this.isReady = function() {
    return E === !1 && (E = r.getProgramParameter(b, eS)), E;
  }, this.destroy = function() {
    n.releaseStatesOfProgram(this), r.deleteProgram(b), this.program = void 0;
  }, this.type = t.shaderType, this.name = t.shaderName, this.id = tS++, this.cacheKey = e, this.usedTimes = 1, this.program = b, this.vertexShader = T, this.fragmentShader = A, this;
}
let ES = 0;
class yS {
  constructor() {
    this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();
  }
  update(e) {
    const t = e.vertexShader, n = e.fragmentShader, r = this._getShaderStage(t), s = this._getShaderStage(n), a = this._getShaderCacheForMaterial(e);
    return a.has(r) === !1 && (a.add(r), r.usedTimes++), a.has(s) === !1 && (a.add(s), s.usedTimes++), this;
  }
  remove(e) {
    const t = this.materialCache.get(e);
    for (const n of t)
      n.usedTimes--, n.usedTimes === 0 && this.shaderCache.delete(n.code);
    return this.materialCache.delete(e), this;
  }
  getVertexShaderID(e) {
    return this._getShaderStage(e.vertexShader).id;
  }
  getFragmentShaderID(e) {
    return this._getShaderStage(e.fragmentShader).id;
  }
  dispose() {
    this.shaderCache.clear(), this.materialCache.clear();
  }
  _getShaderCacheForMaterial(e) {
    const t = this.materialCache;
    let n = t.get(e);
    return n === void 0 && (n = /* @__PURE__ */ new Set(), t.set(e, n)), n;
  }
  _getShaderStage(e) {
    const t = this.shaderCache;
    let n = t.get(e);
    return n === void 0 && (n = new SS(e), t.set(e, n)), n;
  }
}
class SS {
  constructor(e) {
    this.id = ES++, this.code = e, this.usedTimes = 0;
  }
}
function MS(i, e, t, n, r, s, a) {
  const o = new zd(), l = new yS(), c = /* @__PURE__ */ new Set(), u = [], h = r.logarithmicDepthBuffer, d = r.vertexTextures;
  let m = r.precision;
  const v = {
    MeshDepthMaterial: "depth",
    MeshDistanceMaterial: "distanceRGBA",
    MeshNormalMaterial: "normal",
    MeshBasicMaterial: "basic",
    MeshLambertMaterial: "lambert",
    MeshPhongMaterial: "phong",
    MeshToonMaterial: "toon",
    MeshStandardMaterial: "physical",
    MeshPhysicalMaterial: "physical",
    MeshMatcapMaterial: "matcap",
    LineBasicMaterial: "basic",
    LineDashedMaterial: "dashed",
    PointsMaterial: "points",
    ShadowMaterial: "shadow",
    SpriteMaterial: "sprite"
  };
  function b(y) {
    return c.add(y), y === 0 ? "uv" : `uv${y}`;
  }
  function p(y, E, R, q, G) {
    const V = q.fog, B = G.geometry, U = y.isMeshStandardMaterial ? q.environment : null, Y = (y.isMeshStandardMaterial ? t : e).get(y.envMap || U), z = Y && Y.mapping === ja ? Y.image.height : null, ie = v[y.type];
    y.precision !== null && (m = r.getMaxPrecision(y.precision), m !== y.precision && console.warn("THREE.WebGLProgram.getParameters:", y.precision, "not supported, using", m, "instead."));
    const oe = B.morphAttributes.position || B.morphAttributes.normal || B.morphAttributes.color, ce = oe !== void 0 ? oe.length : 0;
    let ye = 0;
    B.morphAttributes.position !== void 0 && (ye = 1), B.morphAttributes.normal !== void 0 && (ye = 2), B.morphAttributes.color !== void 0 && (ye = 3);
    let je, K, Q, re;
    if (ie) {
      const Fe = Ln[ie];
      je = Fe.vertexShader, K = Fe.fragmentShader;
    } else
      je = y.vertexShader, K = y.fragmentShader, l.update(y), Q = l.getVertexShaderID(y), re = l.getFragmentShaderID(y);
    const ne = i.getRenderTarget(), he = i.state.buffers.depth.getReversed(), me = G.isInstancedMesh === !0, we = G.isBatchedMesh === !0, qe = !!y.map, Pe = !!y.matcap, Je = !!Y, F = !!y.aoMap, Gt = !!y.lightMap, $e = !!y.bumpMap, Ze = !!y.normalMap, Le = !!y.displacementMap, ht = !!y.emissiveMap, Ie = !!y.metalnessMap, D = !!y.roughnessMap, S = y.anisotropy > 0, k = y.clearcoat > 0, J = y.dispersion > 0, te = y.iridescence > 0, $ = y.sheen > 0, be = y.transmission > 0, fe = S && !!y.anisotropyMap, ge = k && !!y.clearcoatMap, He = k && !!y.clearcoatNormalMap, se = k && !!y.clearcoatRoughnessMap, _e = te && !!y.iridescenceMap, Re = te && !!y.iridescenceThicknessMap, Ce = $ && !!y.sheenColorMap, pe = $ && !!y.sheenRoughnessMap, Be = !!y.specularMap, Oe = !!y.specularColorMap, et = !!y.specularIntensityMap, I = be && !!y.transmissionMap, ue = be && !!y.thicknessMap, Z = !!y.gradientMap, ee = !!y.alphaMap, H = y.alphaTest > 0, X = !!y.alphaHash, ae = !!y.extensions;
    let xe = Ai;
    y.toneMapped && (ne === null || ne.isXRRenderTarget === !0) && (xe = i.toneMapping);
    const Ne = {
      shaderID: ie,
      shaderType: y.type,
      shaderName: y.name,
      vertexShader: je,
      fragmentShader: K,
      defines: y.defines,
      customVertexShaderID: Q,
      customFragmentShaderID: re,
      isRawShaderMaterial: y.isRawShaderMaterial === !0,
      glslVersion: y.glslVersion,
      precision: m,
      batching: we,
      batchingColor: we && G._colorsTexture !== null,
      instancing: me,
      instancingColor: me && G.instanceColor !== null,
      instancingMorph: me && G.morphTexture !== null,
      supportsVertexTextures: d,
      outputColorSpace: ne === null ? i.outputColorSpace : ne.isXRRenderTarget === !0 ? ne.texture.colorSpace : en,
      alphaToCoverage: !!y.alphaToCoverage,
      map: qe,
      matcap: Pe,
      envMap: Je,
      envMapMode: Je && Y.mapping,
      envMapCubeUVHeight: z,
      aoMap: F,
      lightMap: Gt,
      bumpMap: $e,
      normalMap: Ze,
      displacementMap: d && Le,
      emissiveMap: ht,
      normalMapObjectSpace: Ze && y.normalMapType === _v,
      normalMapTangentSpace: Ze && y.normalMapType === Nd,
      metalnessMap: Ie,
      roughnessMap: D,
      anisotropy: S,
      anisotropyMap: fe,
      clearcoat: k,
      clearcoatMap: ge,
      clearcoatNormalMap: He,
      clearcoatRoughnessMap: se,
      dispersion: J,
      iridescence: te,
      iridescenceMap: _e,
      iridescenceThicknessMap: Re,
      sheen: $,
      sheenColorMap: Ce,
      sheenRoughnessMap: pe,
      specularMap: Be,
      specularColorMap: Oe,
      specularIntensityMap: et,
      transmission: be,
      transmissionMap: I,
      thicknessMap: ue,
      gradientMap: Z,
      opaque: y.transparent === !1 && y.blending === br && y.alphaToCoverage === !1,
      alphaMap: ee,
      alphaTest: H,
      alphaHash: X,
      combine: y.combine,
      //
      mapUv: qe && b(y.map.channel),
      aoMapUv: F && b(y.aoMap.channel),
      lightMapUv: Gt && b(y.lightMap.channel),
      bumpMapUv: $e && b(y.bumpMap.channel),
      normalMapUv: Ze && b(y.normalMap.channel),
      displacementMapUv: Le && b(y.displacementMap.channel),
      emissiveMapUv: ht && b(y.emissiveMap.channel),
      metalnessMapUv: Ie && b(y.metalnessMap.channel),
      roughnessMapUv: D && b(y.roughnessMap.channel),
      anisotropyMapUv: fe && b(y.anisotropyMap.channel),
      clearcoatMapUv: ge && b(y.clearcoatMap.channel),
      clearcoatNormalMapUv: He && b(y.clearcoatNormalMap.channel),
      clearcoatRoughnessMapUv: se && b(y.clearcoatRoughnessMap.channel),
      iridescenceMapUv: _e && b(y.iridescenceMap.channel),
      iridescenceThicknessMapUv: Re && b(y.iridescenceThicknessMap.channel),
      sheenColorMapUv: Ce && b(y.sheenColorMap.channel),
      sheenRoughnessMapUv: pe && b(y.sheenRoughnessMap.channel),
      specularMapUv: Be && b(y.specularMap.channel),
      specularColorMapUv: Oe && b(y.specularColorMap.channel),
      specularIntensityMapUv: et && b(y.specularIntensityMap.channel),
      transmissionMapUv: I && b(y.transmissionMap.channel),
      thicknessMapUv: ue && b(y.thicknessMap.channel),
      alphaMapUv: ee && b(y.alphaMap.channel),
      //
      vertexTangents: !!B.attributes.tangent && (Ze || S),
      vertexColors: y.vertexColors,
      vertexAlphas: y.vertexColors === !0 && !!B.attributes.color && B.attributes.color.itemSize === 4,
      pointsUvs: G.isPoints === !0 && !!B.attributes.uv && (qe || ee),
      fog: !!V,
      useFog: y.fog === !0,
      fogExp2: !!V && V.isFogExp2,
      flatShading: y.flatShading === !0,
      sizeAttenuation: y.sizeAttenuation === !0,
      logarithmicDepthBuffer: h,
      reverseDepthBuffer: he,
      skinning: G.isSkinnedMesh === !0,
      morphTargets: B.morphAttributes.position !== void 0,
      morphNormals: B.morphAttributes.normal !== void 0,
      morphColors: B.morphAttributes.color !== void 0,
      morphTargetsCount: ce,
      morphTextureStride: ye,
      numDirLights: E.directional.length,
      numPointLights: E.point.length,
      numSpotLights: E.spot.length,
      numSpotLightMaps: E.spotLightMap.length,
      numRectAreaLights: E.rectArea.length,
      numHemiLights: E.hemi.length,
      numDirLightShadows: E.directionalShadowMap.length,
      numPointLightShadows: E.pointShadowMap.length,
      numSpotLightShadows: E.spotShadowMap.length,
      numSpotLightShadowsWithMaps: E.numSpotLightShadowsWithMaps,
      numLightProbes: E.numLightProbes,
      numClippingPlanes: a.numPlanes,
      numClipIntersection: a.numIntersection,
      dithering: y.dithering,
      shadowMapEnabled: i.shadowMap.enabled && R.length > 0,
      shadowMapType: i.shadowMap.type,
      toneMapping: xe,
      decodeVideoTexture: qe && y.map.isVideoTexture === !0 && nt.getTransfer(y.map.colorSpace) === mt,
      decodeVideoTextureEmissive: ht && y.emissiveMap.isVideoTexture === !0 && nt.getTransfer(y.emissiveMap.colorSpace) === mt,
      premultipliedAlpha: y.premultipliedAlpha,
      doubleSided: y.side === Fn,
      flipSided: y.side === sn,
      useDepthPacking: y.depthPacking >= 0,
      depthPacking: y.depthPacking || 0,
      index0AttributeName: y.index0AttributeName,
      extensionClipCullDistance: ae && y.extensions.clipCullDistance === !0 && n.has("WEBGL_clip_cull_distance"),
      extensionMultiDraw: (ae && y.extensions.multiDraw === !0 || we) && n.has("WEBGL_multi_draw"),
      rendererExtensionParallelShaderCompile: n.has("KHR_parallel_shader_compile"),
      customProgramCacheKey: y.customProgramCacheKey()
    };
    return Ne.vertexUv1s = c.has(1), Ne.vertexUv2s = c.has(2), Ne.vertexUv3s = c.has(3), c.clear(), Ne;
  }
  function f(y) {
    const E = [];
    if (y.shaderID ? E.push(y.shaderID) : (E.push(y.customVertexShaderID), E.push(y.customFragmentShaderID)), y.defines !== void 0)
      for (const R in y.defines)
        E.push(R), E.push(y.defines[R]);
    return y.isRawShaderMaterial === !1 && (x(E, y), g(E, y), E.push(i.outputColorSpace)), E.push(y.customProgramCacheKey), E.join();
  }
  function x(y, E) {
    y.push(E.precision), y.push(E.outputColorSpace), y.push(E.envMapMode), y.push(E.envMapCubeUVHeight), y.push(E.mapUv), y.push(E.alphaMapUv), y.push(E.lightMapUv), y.push(E.aoMapUv), y.push(E.bumpMapUv), y.push(E.normalMapUv), y.push(E.displacementMapUv), y.push(E.emissiveMapUv), y.push(E.metalnessMapUv), y.push(E.roughnessMapUv), y.push(E.anisotropyMapUv), y.push(E.clearcoatMapUv), y.push(E.clearcoatNormalMapUv), y.push(E.clearcoatRoughnessMapUv), y.push(E.iridescenceMapUv), y.push(E.iridescenceThicknessMapUv), y.push(E.sheenColorMapUv), y.push(E.sheenRoughnessMapUv), y.push(E.specularMapUv), y.push(E.specularColorMapUv), y.push(E.specularIntensityMapUv), y.push(E.transmissionMapUv), y.push(E.thicknessMapUv), y.push(E.combine), y.push(E.fogExp2), y.push(E.sizeAttenuation), y.push(E.morphTargetsCount), y.push(E.morphAttributeCount), y.push(E.numDirLights), y.push(E.numPointLights), y.push(E.numSpotLights), y.push(E.numSpotLightMaps), y.push(E.numHemiLights), y.push(E.numRectAreaLights), y.push(E.numDirLightShadows), y.push(E.numPointLightShadows), y.push(E.numSpotLightShadows), y.push(E.numSpotLightShadowsWithMaps), y.push(E.numLightProbes), y.push(E.shadowMapType), y.push(E.toneMapping), y.push(E.numClippingPlanes), y.push(E.numClipIntersection), y.push(E.depthPacking);
  }
  function g(y, E) {
    o.disableAll(), E.supportsVertexTextures && o.enable(0), E.instancing && o.enable(1), E.instancingColor && o.enable(2), E.instancingMorph && o.enable(3), E.matcap && o.enable(4), E.envMap && o.enable(5), E.normalMapObjectSpace && o.enable(6), E.normalMapTangentSpace && o.enable(7), E.clearcoat && o.enable(8), E.iridescence && o.enable(9), E.alphaTest && o.enable(10), E.vertexColors && o.enable(11), E.vertexAlphas && o.enable(12), E.vertexUv1s && o.enable(13), E.vertexUv2s && o.enable(14), E.vertexUv3s && o.enable(15), E.vertexTangents && o.enable(16), E.anisotropy && o.enable(17), E.alphaHash && o.enable(18), E.batching && o.enable(19), E.dispersion && o.enable(20), E.batchingColor && o.enable(21), y.push(o.mask), o.disableAll(), E.fog && o.enable(0), E.useFog && o.enable(1), E.flatShading && o.enable(2), E.logarithmicDepthBuffer && o.enable(3), E.reverseDepthBuffer && o.enable(4), E.skinning && o.enable(5), E.morphTargets && o.enable(6), E.morphNormals && o.enable(7), E.morphColors && o.enable(8), E.premultipliedAlpha && o.enable(9), E.shadowMapEnabled && o.enable(10), E.doubleSided && o.enable(11), E.flipSided && o.enable(12), E.useDepthPacking && o.enable(13), E.dithering && o.enable(14), E.transmission && o.enable(15), E.sheen && o.enable(16), E.opaque && o.enable(17), E.pointsUvs && o.enable(18), E.decodeVideoTexture && o.enable(19), E.decodeVideoTextureEmissive && o.enable(20), E.alphaToCoverage && o.enable(21), y.push(o.mask);
  }
  function _(y) {
    const E = v[y.type];
    let R;
    if (E) {
      const q = Ln[E];
      R = ox.clone(q.uniforms);
    } else
      R = y.uniforms;
    return R;
  }
  function T(y, E) {
    let R;
    for (let q = 0, G = u.length; q < G; q++) {
      const V = u[q];
      if (V.cacheKey === E) {
        R = V, ++R.usedTimes;
        break;
      }
    }
    return R === void 0 && (R = new bS(i, E, y, s), u.push(R)), R;
  }
  function A(y) {
    if (--y.usedTimes === 0) {
      const E = u.indexOf(y);
      u[E] = u[u.length - 1], u.pop(), y.destroy();
    }
  }
  function M(y) {
    l.remove(y);
  }
  function C() {
    l.dispose();
  }
  return {
    getParameters: p,
    getProgramCacheKey: f,
    getUniforms: _,
    acquireProgram: T,
    releaseProgram: A,
    releaseShaderCache: M,
    // Exposed for resource monitoring & error feedback via renderer.info:
    programs: u,
    dispose: C
  };
}
function AS() {
  let i = /* @__PURE__ */ new WeakMap();
  function e(a) {
    return i.has(a);
  }
  function t(a) {
    let o = i.get(a);
    return o === void 0 && (o = {}, i.set(a, o)), o;
  }
  function n(a) {
    i.delete(a);
  }
  function r(a, o, l) {
    i.get(a)[o] = l;
  }
  function s() {
    i = /* @__PURE__ */ new WeakMap();
  }
  return {
    has: e,
    get: t,
    remove: n,
    update: r,
    dispose: s
  };
}
function TS(i, e) {
  return i.groupOrder !== e.groupOrder ? i.groupOrder - e.groupOrder : i.renderOrder !== e.renderOrder ? i.renderOrder - e.renderOrder : i.material.id !== e.material.id ? i.material.id - e.material.id : i.z !== e.z ? i.z - e.z : i.id - e.id;
}
function kh(i, e) {
  return i.groupOrder !== e.groupOrder ? i.groupOrder - e.groupOrder : i.renderOrder !== e.renderOrder ? i.renderOrder - e.renderOrder : i.z !== e.z ? e.z - i.z : i.id - e.id;
}
function Hh() {
  const i = [];
  let e = 0;
  const t = [], n = [], r = [];
  function s() {
    e = 0, t.length = 0, n.length = 0, r.length = 0;
  }
  function a(h, d, m, v, b, p) {
    let f = i[e];
    return f === void 0 ? (f = {
      id: h.id,
      object: h,
      geometry: d,
      material: m,
      groupOrder: v,
      renderOrder: h.renderOrder,
      z: b,
      group: p
    }, i[e] = f) : (f.id = h.id, f.object = h, f.geometry = d, f.material = m, f.groupOrder = v, f.renderOrder = h.renderOrder, f.z = b, f.group = p), e++, f;
  }
  function o(h, d, m, v, b, p) {
    const f = a(h, d, m, v, b, p);
    m.transmission > 0 ? n.push(f) : m.transparent === !0 ? r.push(f) : t.push(f);
  }
  function l(h, d, m, v, b, p) {
    const f = a(h, d, m, v, b, p);
    m.transmission > 0 ? n.unshift(f) : m.transparent === !0 ? r.unshift(f) : t.unshift(f);
  }
  function c(h, d) {
    t.length > 1 && t.sort(h || TS), n.length > 1 && n.sort(d || kh), r.length > 1 && r.sort(d || kh);
  }
  function u() {
    for (let h = e, d = i.length; h < d; h++) {
      const m = i[h];
      if (m.id === null) break;
      m.id = null, m.object = null, m.geometry = null, m.material = null, m.group = null;
    }
  }
  return {
    opaque: t,
    transmissive: n,
    transparent: r,
    init: s,
    push: o,
    unshift: l,
    finish: u,
    sort: c
  };
}
function wS() {
  let i = /* @__PURE__ */ new WeakMap();
  function e(n, r) {
    const s = i.get(n);
    let a;
    return s === void 0 ? (a = new Hh(), i.set(n, [a])) : r >= s.length ? (a = new Hh(), s.push(a)) : a = s[r], a;
  }
  function t() {
    i = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: e,
    dispose: t
  };
}
function DS() {
  const i = {};
  return {
    get: function(e) {
      if (i[e.id] !== void 0)
        return i[e.id];
      let t;
      switch (e.type) {
        case "DirectionalLight":
          t = {
            direction: new L(),
            color: new Ue()
          };
          break;
        case "SpotLight":
          t = {
            position: new L(),
            direction: new L(),
            color: new Ue(),
            distance: 0,
            coneCos: 0,
            penumbraCos: 0,
            decay: 0
          };
          break;
        case "PointLight":
          t = {
            position: new L(),
            color: new Ue(),
            distance: 0,
            decay: 0
          };
          break;
        case "HemisphereLight":
          t = {
            direction: new L(),
            skyColor: new Ue(),
            groundColor: new Ue()
          };
          break;
        case "RectAreaLight":
          t = {
            color: new Ue(),
            position: new L(),
            halfWidth: new L(),
            halfHeight: new L()
          };
          break;
      }
      return i[e.id] = t, t;
    }
  };
}
function RS() {
  const i = {};
  return {
    get: function(e) {
      if (i[e.id] !== void 0)
        return i[e.id];
      let t;
      switch (e.type) {
        case "DirectionalLight":
          t = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new ze()
          };
          break;
        case "SpotLight":
          t = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new ze()
          };
          break;
        case "PointLight":
          t = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new ze(),
            shadowCameraNear: 1,
            shadowCameraFar: 1e3
          };
          break;
      }
      return i[e.id] = t, t;
    }
  };
}
let CS = 0;
function PS(i, e) {
  return (e.castShadow ? 2 : 0) - (i.castShadow ? 2 : 0) + (e.map ? 1 : 0) - (i.map ? 1 : 0);
}
function LS(i) {
  const e = new DS(), t = RS(), n = {
    version: 0,
    hash: {
      directionalLength: -1,
      pointLength: -1,
      spotLength: -1,
      rectAreaLength: -1,
      hemiLength: -1,
      numDirectionalShadows: -1,
      numPointShadows: -1,
      numSpotShadows: -1,
      numSpotMaps: -1,
      numLightProbes: -1
    },
    ambient: [0, 0, 0],
    probe: [],
    directional: [],
    directionalShadow: [],
    directionalShadowMap: [],
    directionalShadowMatrix: [],
    spot: [],
    spotLightMap: [],
    spotShadow: [],
    spotShadowMap: [],
    spotLightMatrix: [],
    rectArea: [],
    rectAreaLTC1: null,
    rectAreaLTC2: null,
    point: [],
    pointShadow: [],
    pointShadowMap: [],
    pointShadowMatrix: [],
    hemi: [],
    numSpotLightShadowsWithMaps: 0,
    numLightProbes: 0
  };
  for (let c = 0; c < 9; c++) n.probe.push(new L());
  const r = new L(), s = new Xe(), a = new Xe();
  function o(c) {
    let u = 0, h = 0, d = 0;
    for (let y = 0; y < 9; y++) n.probe[y].set(0, 0, 0);
    let m = 0, v = 0, b = 0, p = 0, f = 0, x = 0, g = 0, _ = 0, T = 0, A = 0, M = 0;
    c.sort(PS);
    for (let y = 0, E = c.length; y < E; y++) {
      const R = c[y], q = R.color, G = R.intensity, V = R.distance, B = R.shadow && R.shadow.map ? R.shadow.map.texture : null;
      if (R.isAmbientLight)
        u += q.r * G, h += q.g * G, d += q.b * G;
      else if (R.isLightProbe) {
        for (let U = 0; U < 9; U++)
          n.probe[U].addScaledVector(R.sh.coefficients[U], G);
        M++;
      } else if (R.isDirectionalLight) {
        const U = e.get(R);
        if (U.color.copy(R.color).multiplyScalar(R.intensity), R.castShadow) {
          const Y = R.shadow, z = t.get(R);
          z.shadowIntensity = Y.intensity, z.shadowBias = Y.bias, z.shadowNormalBias = Y.normalBias, z.shadowRadius = Y.radius, z.shadowMapSize = Y.mapSize, n.directionalShadow[m] = z, n.directionalShadowMap[m] = B, n.directionalShadowMatrix[m] = R.shadow.matrix, x++;
        }
        n.directional[m] = U, m++;
      } else if (R.isSpotLight) {
        const U = e.get(R);
        U.position.setFromMatrixPosition(R.matrixWorld), U.color.copy(q).multiplyScalar(G), U.distance = V, U.coneCos = Math.cos(R.angle), U.penumbraCos = Math.cos(R.angle * (1 - R.penumbra)), U.decay = R.decay, n.spot[b] = U;
        const Y = R.shadow;
        if (R.map && (n.spotLightMap[T] = R.map, T++, Y.updateMatrices(R), R.castShadow && A++), n.spotLightMatrix[b] = Y.matrix, R.castShadow) {
          const z = t.get(R);
          z.shadowIntensity = Y.intensity, z.shadowBias = Y.bias, z.shadowNormalBias = Y.normalBias, z.shadowRadius = Y.radius, z.shadowMapSize = Y.mapSize, n.spotShadow[b] = z, n.spotShadowMap[b] = B, _++;
        }
        b++;
      } else if (R.isRectAreaLight) {
        const U = e.get(R);
        U.color.copy(q).multiplyScalar(G), U.halfWidth.set(R.width * 0.5, 0, 0), U.halfHeight.set(0, R.height * 0.5, 0), n.rectArea[p] = U, p++;
      } else if (R.isPointLight) {
        const U = e.get(R);
        if (U.color.copy(R.color).multiplyScalar(R.intensity), U.distance = R.distance, U.decay = R.decay, R.castShadow) {
          const Y = R.shadow, z = t.get(R);
          z.shadowIntensity = Y.intensity, z.shadowBias = Y.bias, z.shadowNormalBias = Y.normalBias, z.shadowRadius = Y.radius, z.shadowMapSize = Y.mapSize, z.shadowCameraNear = Y.camera.near, z.shadowCameraFar = Y.camera.far, n.pointShadow[v] = z, n.pointShadowMap[v] = B, n.pointShadowMatrix[v] = R.shadow.matrix, g++;
        }
        n.point[v] = U, v++;
      } else if (R.isHemisphereLight) {
        const U = e.get(R);
        U.skyColor.copy(R.color).multiplyScalar(G), U.groundColor.copy(R.groundColor).multiplyScalar(G), n.hemi[f] = U, f++;
      }
    }
    p > 0 && (i.has("OES_texture_float_linear") === !0 ? (n.rectAreaLTC1 = de.LTC_FLOAT_1, n.rectAreaLTC2 = de.LTC_FLOAT_2) : (n.rectAreaLTC1 = de.LTC_HALF_1, n.rectAreaLTC2 = de.LTC_HALF_2)), n.ambient[0] = u, n.ambient[1] = h, n.ambient[2] = d;
    const C = n.hash;
    (C.directionalLength !== m || C.pointLength !== v || C.spotLength !== b || C.rectAreaLength !== p || C.hemiLength !== f || C.numDirectionalShadows !== x || C.numPointShadows !== g || C.numSpotShadows !== _ || C.numSpotMaps !== T || C.numLightProbes !== M) && (n.directional.length = m, n.spot.length = b, n.rectArea.length = p, n.point.length = v, n.hemi.length = f, n.directionalShadow.length = x, n.directionalShadowMap.length = x, n.pointShadow.length = g, n.pointShadowMap.length = g, n.spotShadow.length = _, n.spotShadowMap.length = _, n.directionalShadowMatrix.length = x, n.pointShadowMatrix.length = g, n.spotLightMatrix.length = _ + T - A, n.spotLightMap.length = T, n.numSpotLightShadowsWithMaps = A, n.numLightProbes = M, C.directionalLength = m, C.pointLength = v, C.spotLength = b, C.rectAreaLength = p, C.hemiLength = f, C.numDirectionalShadows = x, C.numPointShadows = g, C.numSpotShadows = _, C.numSpotMaps = T, C.numLightProbes = M, n.version = CS++);
  }
  function l(c, u) {
    let h = 0, d = 0, m = 0, v = 0, b = 0;
    const p = u.matrixWorldInverse;
    for (let f = 0, x = c.length; f < x; f++) {
      const g = c[f];
      if (g.isDirectionalLight) {
        const _ = n.directional[h];
        _.direction.setFromMatrixPosition(g.matrixWorld), r.setFromMatrixPosition(g.target.matrixWorld), _.direction.sub(r), _.direction.transformDirection(p), h++;
      } else if (g.isSpotLight) {
        const _ = n.spot[m];
        _.position.setFromMatrixPosition(g.matrixWorld), _.position.applyMatrix4(p), _.direction.setFromMatrixPosition(g.matrixWorld), r.setFromMatrixPosition(g.target.matrixWorld), _.direction.sub(r), _.direction.transformDirection(p), m++;
      } else if (g.isRectAreaLight) {
        const _ = n.rectArea[v];
        _.position.setFromMatrixPosition(g.matrixWorld), _.position.applyMatrix4(p), a.identity(), s.copy(g.matrixWorld), s.premultiply(p), a.extractRotation(s), _.halfWidth.set(g.width * 0.5, 0, 0), _.halfHeight.set(0, g.height * 0.5, 0), _.halfWidth.applyMatrix4(a), _.halfHeight.applyMatrix4(a), v++;
      } else if (g.isPointLight) {
        const _ = n.point[d];
        _.position.setFromMatrixPosition(g.matrixWorld), _.position.applyMatrix4(p), d++;
      } else if (g.isHemisphereLight) {
        const _ = n.hemi[b];
        _.direction.setFromMatrixPosition(g.matrixWorld), _.direction.transformDirection(p), b++;
      }
    }
  }
  return {
    setup: o,
    setupView: l,
    state: n
  };
}
function zh(i) {
  const e = new LS(i), t = [], n = [];
  function r(u) {
    c.camera = u, t.length = 0, n.length = 0;
  }
  function s(u) {
    t.push(u);
  }
  function a(u) {
    n.push(u);
  }
  function o() {
    e.setup(t);
  }
  function l(u) {
    e.setupView(t, u);
  }
  const c = {
    lightsArray: t,
    shadowsArray: n,
    camera: null,
    lights: e,
    transmissionRenderTarget: {}
  };
  return {
    init: r,
    state: c,
    setupLights: o,
    setupLightsView: l,
    pushLight: s,
    pushShadow: a
  };
}
function IS(i) {
  let e = /* @__PURE__ */ new WeakMap();
  function t(r, s = 0) {
    const a = e.get(r);
    let o;
    return a === void 0 ? (o = new zh(i), e.set(r, [o])) : s >= a.length ? (o = new zh(i), a.push(o)) : o = a[s], o;
  }
  function n() {
    e = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: t,
    dispose: n
  };
}
class FS extends Bn {
  static get type() {
    return "MeshDepthMaterial";
  }
  constructor(e) {
    super(), this.isMeshDepthMaterial = !0, this.depthPacking = mv, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this;
  }
}
class NS extends Bn {
  static get type() {
    return "MeshDistanceMaterial";
  }
  constructor(e) {
    super(), this.isMeshDistanceMaterial = !0, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this;
  }
}
const US = `void main() {
	gl_Position = vec4( position, 1.0 );
}`, OS = `uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;
function BS(i, e, t) {
  let n = new Pc();
  const r = new ze(), s = new ze(), a = new lt(), o = new FS({ depthPacking: gv }), l = new NS(), c = {}, u = t.maxTextureSize, h = { [si]: sn, [sn]: si, [Fn]: Fn }, d = new Ti({
    defines: {
      VSM_SAMPLES: 8
    },
    uniforms: {
      shadow_pass: { value: null },
      resolution: { value: new ze() },
      radius: { value: 4 }
    },
    vertexShader: US,
    fragmentShader: OS
  }), m = d.clone();
  m.defines.HORIZONTAL_PASS = 1;
  const v = new fn();
  v.setAttribute(
    "position",
    new Qt(
      new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),
      3
    )
  );
  const b = new hn(v, d), p = this;
  this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = Ed;
  let f = this.type;
  this.render = function(A, M, C) {
    if (p.enabled === !1 || p.autoUpdate === !1 && p.needsUpdate === !1 || A.length === 0) return;
    const y = i.getRenderTarget(), E = i.getActiveCubeFace(), R = i.getActiveMipmapLevel(), q = i.state;
    q.setBlending(Mi), q.buffers.color.setClear(1, 1, 1, 1), q.buffers.depth.setTest(!0), q.setScissorTest(!1);
    const G = f !== Jn && this.type === Jn, V = f === Jn && this.type !== Jn;
    for (let B = 0, U = A.length; B < U; B++) {
      const Y = A[B], z = Y.shadow;
      if (z === void 0) {
        console.warn("THREE.WebGLShadowMap:", Y, "has no shadow.");
        continue;
      }
      if (z.autoUpdate === !1 && z.needsUpdate === !1) continue;
      r.copy(z.mapSize);
      const ie = z.getFrameExtents();
      if (r.multiply(ie), s.copy(z.mapSize), (r.x > u || r.y > u) && (r.x > u && (s.x = Math.floor(u / ie.x), r.x = s.x * ie.x, z.mapSize.x = s.x), r.y > u && (s.y = Math.floor(u / ie.y), r.y = s.y * ie.y, z.mapSize.y = s.y)), z.map === null || G === !0 || V === !0) {
        const ce = this.type !== Jn ? { minFilter: Jt, magFilter: Jt } : {};
        z.map !== null && z.map.dispose(), z.map = new Xi(r.x, r.y, ce), z.map.texture.name = Y.name + ".shadowMap", z.camera.updateProjectionMatrix();
      }
      i.setRenderTarget(z.map), i.clear();
      const oe = z.getViewportCount();
      for (let ce = 0; ce < oe; ce++) {
        const ye = z.getViewport(ce);
        a.set(
          s.x * ye.x,
          s.y * ye.y,
          s.x * ye.z,
          s.y * ye.w
        ), q.viewport(a), z.updateMatrices(Y, ce), n = z.getFrustum(), _(M, C, z.camera, Y, this.type);
      }
      z.isPointLightShadow !== !0 && this.type === Jn && x(z, C), z.needsUpdate = !1;
    }
    f = this.type, p.needsUpdate = !1, i.setRenderTarget(y, E, R);
  };
  function x(A, M) {
    const C = e.update(b);
    d.defines.VSM_SAMPLES !== A.blurSamples && (d.defines.VSM_SAMPLES = A.blurSamples, m.defines.VSM_SAMPLES = A.blurSamples, d.needsUpdate = !0, m.needsUpdate = !0), A.mapPass === null && (A.mapPass = new Xi(r.x, r.y)), d.uniforms.shadow_pass.value = A.map.texture, d.uniforms.resolution.value = A.mapSize, d.uniforms.radius.value = A.radius, i.setRenderTarget(A.mapPass), i.clear(), i.renderBufferDirect(M, null, C, d, b, null), m.uniforms.shadow_pass.value = A.mapPass.texture, m.uniforms.resolution.value = A.mapSize, m.uniforms.radius.value = A.radius, i.setRenderTarget(A.map), i.clear(), i.renderBufferDirect(M, null, C, m, b, null);
  }
  function g(A, M, C, y) {
    let E = null;
    const R = C.isPointLight === !0 ? A.customDistanceMaterial : A.customDepthMaterial;
    if (R !== void 0)
      E = R;
    else if (E = C.isPointLight === !0 ? l : o, i.localClippingEnabled && M.clipShadows === !0 && Array.isArray(M.clippingPlanes) && M.clippingPlanes.length !== 0 || M.displacementMap && M.displacementScale !== 0 || M.alphaMap && M.alphaTest > 0 || M.map && M.alphaTest > 0) {
      const q = E.uuid, G = M.uuid;
      let V = c[q];
      V === void 0 && (V = {}, c[q] = V);
      let B = V[G];
      B === void 0 && (B = E.clone(), V[G] = B, M.addEventListener("dispose", T)), E = B;
    }
    if (E.visible = M.visible, E.wireframe = M.wireframe, y === Jn ? E.side = M.shadowSide !== null ? M.shadowSide : M.side : E.side = M.shadowSide !== null ? M.shadowSide : h[M.side], E.alphaMap = M.alphaMap, E.alphaTest = M.alphaTest, E.map = M.map, E.clipShadows = M.clipShadows, E.clippingPlanes = M.clippingPlanes, E.clipIntersection = M.clipIntersection, E.displacementMap = M.displacementMap, E.displacementScale = M.displacementScale, E.displacementBias = M.displacementBias, E.wireframeLinewidth = M.wireframeLinewidth, E.linewidth = M.linewidth, C.isPointLight === !0 && E.isMeshDistanceMaterial === !0) {
      const q = i.properties.get(E);
      q.light = C;
    }
    return E;
  }
  function _(A, M, C, y, E) {
    if (A.visible === !1) return;
    if (A.layers.test(M.layers) && (A.isMesh || A.isLine || A.isPoints) && (A.castShadow || A.receiveShadow && E === Jn) && (!A.frustumCulled || n.intersectsObject(A))) {
      A.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse, A.matrixWorld);
      const G = e.update(A), V = A.material;
      if (Array.isArray(V)) {
        const B = G.groups;
        for (let U = 0, Y = B.length; U < Y; U++) {
          const z = B[U], ie = V[z.materialIndex];
          if (ie && ie.visible) {
            const oe = g(A, ie, y, E);
            A.onBeforeShadow(i, A, M, C, G, oe, z), i.renderBufferDirect(C, null, G, oe, A, z), A.onAfterShadow(i, A, M, C, G, oe, z);
          }
        }
      } else if (V.visible) {
        const B = g(A, V, y, E);
        A.onBeforeShadow(i, A, M, C, G, B, null), i.renderBufferDirect(C, null, G, B, A, null), A.onAfterShadow(i, A, M, C, G, B, null);
      }
    }
    const q = A.children;
    for (let G = 0, V = q.length; G < V; G++)
      _(q[G], M, C, y, E);
  }
  function T(A) {
    A.target.removeEventListener("dispose", T);
    for (const C in c) {
      const y = c[C], E = A.target.uuid;
      E in y && (y[E].dispose(), delete y[E]);
    }
  }
}
const kS = {
  [_l]: vl,
  [xl]: yl,
  [bl]: Sl,
  [Dr]: El,
  [vl]: _l,
  [yl]: xl,
  [Sl]: bl,
  [El]: Dr
};
function HS(i, e) {
  function t() {
    let I = !1;
    const ue = new lt();
    let Z = null;
    const ee = new lt(0, 0, 0, 0);
    return {
      setMask: function(H) {
        Z !== H && !I && (i.colorMask(H, H, H, H), Z = H);
      },
      setLocked: function(H) {
        I = H;
      },
      setClear: function(H, X, ae, xe, Ne) {
        Ne === !0 && (H *= xe, X *= xe, ae *= xe), ue.set(H, X, ae, xe), ee.equals(ue) === !1 && (i.clearColor(H, X, ae, xe), ee.copy(ue));
      },
      reset: function() {
        I = !1, Z = null, ee.set(-1, 0, 0, 0);
      }
    };
  }
  function n() {
    let I = !1, ue = !1, Z = null, ee = null, H = null;
    return {
      setReversed: function(X) {
        if (ue !== X) {
          const ae = e.get("EXT_clip_control");
          ue ? ae.clipControlEXT(ae.LOWER_LEFT_EXT, ae.ZERO_TO_ONE_EXT) : ae.clipControlEXT(ae.LOWER_LEFT_EXT, ae.NEGATIVE_ONE_TO_ONE_EXT);
          const xe = H;
          H = null, this.setClear(xe);
        }
        ue = X;
      },
      getReversed: function() {
        return ue;
      },
      setTest: function(X) {
        X ? ne(i.DEPTH_TEST) : he(i.DEPTH_TEST);
      },
      setMask: function(X) {
        Z !== X && !I && (i.depthMask(X), Z = X);
      },
      setFunc: function(X) {
        if (ue && (X = kS[X]), ee !== X) {
          switch (X) {
            case _l:
              i.depthFunc(i.NEVER);
              break;
            case vl:
              i.depthFunc(i.ALWAYS);
              break;
            case xl:
              i.depthFunc(i.LESS);
              break;
            case Dr:
              i.depthFunc(i.LEQUAL);
              break;
            case bl:
              i.depthFunc(i.EQUAL);
              break;
            case El:
              i.depthFunc(i.GEQUAL);
              break;
            case yl:
              i.depthFunc(i.GREATER);
              break;
            case Sl:
              i.depthFunc(i.NOTEQUAL);
              break;
            default:
              i.depthFunc(i.LEQUAL);
          }
          ee = X;
        }
      },
      setLocked: function(X) {
        I = X;
      },
      setClear: function(X) {
        H !== X && (ue && (X = 1 - X), i.clearDepth(X), H = X);
      },
      reset: function() {
        I = !1, Z = null, ee = null, H = null, ue = !1;
      }
    };
  }
  function r() {
    let I = !1, ue = null, Z = null, ee = null, H = null, X = null, ae = null, xe = null, Ne = null;
    return {
      setTest: function(Fe) {
        I || (Fe ? ne(i.STENCIL_TEST) : he(i.STENCIL_TEST));
      },
      setMask: function(Fe) {
        ue !== Fe && !I && (i.stencilMask(Fe), ue = Fe);
      },
      setFunc: function(Fe, ke, it) {
        (Z !== Fe || ee !== ke || H !== it) && (i.stencilFunc(Fe, ke, it), Z = Fe, ee = ke, H = it);
      },
      setOp: function(Fe, ke, it) {
        (X !== Fe || ae !== ke || xe !== it) && (i.stencilOp(Fe, ke, it), X = Fe, ae = ke, xe = it);
      },
      setLocked: function(Fe) {
        I = Fe;
      },
      setClear: function(Fe) {
        Ne !== Fe && (i.clearStencil(Fe), Ne = Fe);
      },
      reset: function() {
        I = !1, ue = null, Z = null, ee = null, H = null, X = null, ae = null, xe = null, Ne = null;
      }
    };
  }
  const s = new t(), a = new n(), o = new r(), l = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap();
  let u = {}, h = {}, d = /* @__PURE__ */ new WeakMap(), m = [], v = null, b = !1, p = null, f = null, x = null, g = null, _ = null, T = null, A = null, M = new Ue(0, 0, 0), C = 0, y = !1, E = null, R = null, q = null, G = null, V = null;
  const B = i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  let U = !1, Y = 0;
  const z = i.getParameter(i.VERSION);
  z.indexOf("WebGL") !== -1 ? (Y = parseFloat(/^WebGL (\d)/.exec(z)[1]), U = Y >= 1) : z.indexOf("OpenGL ES") !== -1 && (Y = parseFloat(/^OpenGL ES (\d)/.exec(z)[1]), U = Y >= 2);
  let ie = null, oe = {};
  const ce = i.getParameter(i.SCISSOR_BOX), ye = i.getParameter(i.VIEWPORT), je = new lt().fromArray(ce), K = new lt().fromArray(ye);
  function Q(I, ue, Z, ee) {
    const H = new Uint8Array(4), X = i.createTexture();
    i.bindTexture(I, X), i.texParameteri(I, i.TEXTURE_MIN_FILTER, i.NEAREST), i.texParameteri(I, i.TEXTURE_MAG_FILTER, i.NEAREST);
    for (let ae = 0; ae < Z; ae++)
      I === i.TEXTURE_3D || I === i.TEXTURE_2D_ARRAY ? i.texImage3D(ue, 0, i.RGBA, 1, 1, ee, 0, i.RGBA, i.UNSIGNED_BYTE, H) : i.texImage2D(ue + ae, 0, i.RGBA, 1, 1, 0, i.RGBA, i.UNSIGNED_BYTE, H);
    return X;
  }
  const re = {};
  re[i.TEXTURE_2D] = Q(i.TEXTURE_2D, i.TEXTURE_2D, 1), re[i.TEXTURE_CUBE_MAP] = Q(i.TEXTURE_CUBE_MAP, i.TEXTURE_CUBE_MAP_POSITIVE_X, 6), re[i.TEXTURE_2D_ARRAY] = Q(i.TEXTURE_2D_ARRAY, i.TEXTURE_2D_ARRAY, 1, 1), re[i.TEXTURE_3D] = Q(i.TEXTURE_3D, i.TEXTURE_3D, 1, 1), s.setClear(0, 0, 0, 1), a.setClear(1), o.setClear(0), ne(i.DEPTH_TEST), a.setFunc(Dr), $e(!1), Ze(zu), ne(i.CULL_FACE), F(Mi);
  function ne(I) {
    u[I] !== !0 && (i.enable(I), u[I] = !0);
  }
  function he(I) {
    u[I] !== !1 && (i.disable(I), u[I] = !1);
  }
  function me(I, ue) {
    return h[I] !== ue ? (i.bindFramebuffer(I, ue), h[I] = ue, I === i.DRAW_FRAMEBUFFER && (h[i.FRAMEBUFFER] = ue), I === i.FRAMEBUFFER && (h[i.DRAW_FRAMEBUFFER] = ue), !0) : !1;
  }
  function we(I, ue) {
    let Z = m, ee = !1;
    if (I) {
      Z = d.get(ue), Z === void 0 && (Z = [], d.set(ue, Z));
      const H = I.textures;
      if (Z.length !== H.length || Z[0] !== i.COLOR_ATTACHMENT0) {
        for (let X = 0, ae = H.length; X < ae; X++)
          Z[X] = i.COLOR_ATTACHMENT0 + X;
        Z.length = H.length, ee = !0;
      }
    } else
      Z[0] !== i.BACK && (Z[0] = i.BACK, ee = !0);
    ee && i.drawBuffers(Z);
  }
  function qe(I) {
    return v !== I ? (i.useProgram(I), v = I, !0) : !1;
  }
  const Pe = {
    [Oi]: i.FUNC_ADD,
    [H0]: i.FUNC_SUBTRACT,
    [z0]: i.FUNC_REVERSE_SUBTRACT
  };
  Pe[G0] = i.MIN, Pe[V0] = i.MAX;
  const Je = {
    [W0]: i.ZERO,
    [X0]: i.ONE,
    [j0]: i.SRC_COLOR,
    [ml]: i.SRC_ALPHA,
    [J0]: i.SRC_ALPHA_SATURATE,
    [K0]: i.DST_COLOR,
    [Y0]: i.DST_ALPHA,
    [q0]: i.ONE_MINUS_SRC_COLOR,
    [gl]: i.ONE_MINUS_SRC_ALPHA,
    [$0]: i.ONE_MINUS_DST_COLOR,
    [Z0]: i.ONE_MINUS_DST_ALPHA,
    [Q0]: i.CONSTANT_COLOR,
    [ev]: i.ONE_MINUS_CONSTANT_COLOR,
    [tv]: i.CONSTANT_ALPHA,
    [nv]: i.ONE_MINUS_CONSTANT_ALPHA
  };
  function F(I, ue, Z, ee, H, X, ae, xe, Ne, Fe) {
    if (I === Mi) {
      b === !0 && (he(i.BLEND), b = !1);
      return;
    }
    if (b === !1 && (ne(i.BLEND), b = !0), I !== k0) {
      if (I !== p || Fe !== y) {
        if ((f !== Oi || _ !== Oi) && (i.blendEquation(i.FUNC_ADD), f = Oi, _ = Oi), Fe)
          switch (I) {
            case br:
              i.blendFuncSeparate(i.ONE, i.ONE_MINUS_SRC_ALPHA, i.ONE, i.ONE_MINUS_SRC_ALPHA);
              break;
            case Gu:
              i.blendFunc(i.ONE, i.ONE);
              break;
            case Vu:
              i.blendFuncSeparate(i.ZERO, i.ONE_MINUS_SRC_COLOR, i.ZERO, i.ONE);
              break;
            case Wu:
              i.blendFuncSeparate(i.ZERO, i.SRC_COLOR, i.ZERO, i.SRC_ALPHA);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", I);
              break;
          }
        else
          switch (I) {
            case br:
              i.blendFuncSeparate(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA, i.ONE, i.ONE_MINUS_SRC_ALPHA);
              break;
            case Gu:
              i.blendFunc(i.SRC_ALPHA, i.ONE);
              break;
            case Vu:
              i.blendFuncSeparate(i.ZERO, i.ONE_MINUS_SRC_COLOR, i.ZERO, i.ONE);
              break;
            case Wu:
              i.blendFunc(i.ZERO, i.SRC_COLOR);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", I);
              break;
          }
        x = null, g = null, T = null, A = null, M.set(0, 0, 0), C = 0, p = I, y = Fe;
      }
      return;
    }
    H = H || ue, X = X || Z, ae = ae || ee, (ue !== f || H !== _) && (i.blendEquationSeparate(Pe[ue], Pe[H]), f = ue, _ = H), (Z !== x || ee !== g || X !== T || ae !== A) && (i.blendFuncSeparate(Je[Z], Je[ee], Je[X], Je[ae]), x = Z, g = ee, T = X, A = ae), (xe.equals(M) === !1 || Ne !== C) && (i.blendColor(xe.r, xe.g, xe.b, Ne), M.copy(xe), C = Ne), p = I, y = !1;
  }
  function Gt(I, ue) {
    I.side === Fn ? he(i.CULL_FACE) : ne(i.CULL_FACE);
    let Z = I.side === sn;
    ue && (Z = !Z), $e(Z), I.blending === br && I.transparent === !1 ? F(Mi) : F(I.blending, I.blendEquation, I.blendSrc, I.blendDst, I.blendEquationAlpha, I.blendSrcAlpha, I.blendDstAlpha, I.blendColor, I.blendAlpha, I.premultipliedAlpha), a.setFunc(I.depthFunc), a.setTest(I.depthTest), a.setMask(I.depthWrite), s.setMask(I.colorWrite);
    const ee = I.stencilWrite;
    o.setTest(ee), ee && (o.setMask(I.stencilWriteMask), o.setFunc(I.stencilFunc, I.stencilRef, I.stencilFuncMask), o.setOp(I.stencilFail, I.stencilZFail, I.stencilZPass)), ht(I.polygonOffset, I.polygonOffsetFactor, I.polygonOffsetUnits), I.alphaToCoverage === !0 ? ne(i.SAMPLE_ALPHA_TO_COVERAGE) : he(i.SAMPLE_ALPHA_TO_COVERAGE);
  }
  function $e(I) {
    E !== I && (I ? i.frontFace(i.CW) : i.frontFace(i.CCW), E = I);
  }
  function Ze(I) {
    I !== U0 ? (ne(i.CULL_FACE), I !== R && (I === zu ? i.cullFace(i.BACK) : I === O0 ? i.cullFace(i.FRONT) : i.cullFace(i.FRONT_AND_BACK))) : he(i.CULL_FACE), R = I;
  }
  function Le(I) {
    I !== q && (U && i.lineWidth(I), q = I);
  }
  function ht(I, ue, Z) {
    I ? (ne(i.POLYGON_OFFSET_FILL), (G !== ue || V !== Z) && (i.polygonOffset(ue, Z), G = ue, V = Z)) : he(i.POLYGON_OFFSET_FILL);
  }
  function Ie(I) {
    I ? ne(i.SCISSOR_TEST) : he(i.SCISSOR_TEST);
  }
  function D(I) {
    I === void 0 && (I = i.TEXTURE0 + B - 1), ie !== I && (i.activeTexture(I), ie = I);
  }
  function S(I, ue, Z) {
    Z === void 0 && (ie === null ? Z = i.TEXTURE0 + B - 1 : Z = ie);
    let ee = oe[Z];
    ee === void 0 && (ee = { type: void 0, texture: void 0 }, oe[Z] = ee), (ee.type !== I || ee.texture !== ue) && (ie !== Z && (i.activeTexture(Z), ie = Z), i.bindTexture(I, ue || re[I]), ee.type = I, ee.texture = ue);
  }
  function k() {
    const I = oe[ie];
    I !== void 0 && I.type !== void 0 && (i.bindTexture(I.type, null), I.type = void 0, I.texture = void 0);
  }
  function J() {
    try {
      i.compressedTexImage2D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function te() {
    try {
      i.compressedTexImage3D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function $() {
    try {
      i.texSubImage2D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function be() {
    try {
      i.texSubImage3D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function fe() {
    try {
      i.compressedTexSubImage2D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function ge() {
    try {
      i.compressedTexSubImage3D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function He() {
    try {
      i.texStorage2D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function se() {
    try {
      i.texStorage3D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function _e() {
    try {
      i.texImage2D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function Re() {
    try {
      i.texImage3D.apply(i, arguments);
    } catch (I) {
      console.error("THREE.WebGLState:", I);
    }
  }
  function Ce(I) {
    je.equals(I) === !1 && (i.scissor(I.x, I.y, I.z, I.w), je.copy(I));
  }
  function pe(I) {
    K.equals(I) === !1 && (i.viewport(I.x, I.y, I.z, I.w), K.copy(I));
  }
  function Be(I, ue) {
    let Z = c.get(ue);
    Z === void 0 && (Z = /* @__PURE__ */ new WeakMap(), c.set(ue, Z));
    let ee = Z.get(I);
    ee === void 0 && (ee = i.getUniformBlockIndex(ue, I.name), Z.set(I, ee));
  }
  function Oe(I, ue) {
    const ee = c.get(ue).get(I);
    l.get(ue) !== ee && (i.uniformBlockBinding(ue, ee, I.__bindingPointIndex), l.set(ue, ee));
  }
  function et() {
    i.disable(i.BLEND), i.disable(i.CULL_FACE), i.disable(i.DEPTH_TEST), i.disable(i.POLYGON_OFFSET_FILL), i.disable(i.SCISSOR_TEST), i.disable(i.STENCIL_TEST), i.disable(i.SAMPLE_ALPHA_TO_COVERAGE), i.blendEquation(i.FUNC_ADD), i.blendFunc(i.ONE, i.ZERO), i.blendFuncSeparate(i.ONE, i.ZERO, i.ONE, i.ZERO), i.blendColor(0, 0, 0, 0), i.colorMask(!0, !0, !0, !0), i.clearColor(0, 0, 0, 0), i.depthMask(!0), i.depthFunc(i.LESS), a.setReversed(!1), i.clearDepth(1), i.stencilMask(4294967295), i.stencilFunc(i.ALWAYS, 0, 4294967295), i.stencilOp(i.KEEP, i.KEEP, i.KEEP), i.clearStencil(0), i.cullFace(i.BACK), i.frontFace(i.CCW), i.polygonOffset(0, 0), i.activeTexture(i.TEXTURE0), i.bindFramebuffer(i.FRAMEBUFFER, null), i.bindFramebuffer(i.DRAW_FRAMEBUFFER, null), i.bindFramebuffer(i.READ_FRAMEBUFFER, null), i.useProgram(null), i.lineWidth(1), i.scissor(0, 0, i.canvas.width, i.canvas.height), i.viewport(0, 0, i.canvas.width, i.canvas.height), u = {}, ie = null, oe = {}, h = {}, d = /* @__PURE__ */ new WeakMap(), m = [], v = null, b = !1, p = null, f = null, x = null, g = null, _ = null, T = null, A = null, M = new Ue(0, 0, 0), C = 0, y = !1, E = null, R = null, q = null, G = null, V = null, je.set(0, 0, i.canvas.width, i.canvas.height), K.set(0, 0, i.canvas.width, i.canvas.height), s.reset(), a.reset(), o.reset();
  }
  return {
    buffers: {
      color: s,
      depth: a,
      stencil: o
    },
    enable: ne,
    disable: he,
    bindFramebuffer: me,
    drawBuffers: we,
    useProgram: qe,
    setBlending: F,
    setMaterial: Gt,
    setFlipSided: $e,
    setCullFace: Ze,
    setLineWidth: Le,
    setPolygonOffset: ht,
    setScissorTest: Ie,
    activeTexture: D,
    bindTexture: S,
    unbindTexture: k,
    compressedTexImage2D: J,
    compressedTexImage3D: te,
    texImage2D: _e,
    texImage3D: Re,
    updateUBOMapping: Be,
    uniformBlockBinding: Oe,
    texStorage2D: He,
    texStorage3D: se,
    texSubImage2D: $,
    texSubImage3D: be,
    compressedTexSubImage2D: fe,
    compressedTexSubImage3D: ge,
    scissor: Ce,
    viewport: pe,
    reset: et
  };
}
function Gh(i, e, t, n) {
  const r = zS(n);
  switch (t) {
    // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
    case Dd:
      return i * e;
    case Cd:
      return i * e;
    case Pd:
      return i * e * 2;
    case Tc:
      return i * e / r.components * r.byteLength;
    case wc:
      return i * e / r.components * r.byteLength;
    case Ld:
      return i * e * 2 / r.components * r.byteLength;
    case Dc:
      return i * e * 2 / r.components * r.byteLength;
    case Rd:
      return i * e * 3 / r.components * r.byteLength;
    case _n:
      return i * e * 4 / r.components * r.byteLength;
    case Rc:
      return i * e * 4 / r.components * r.byteLength;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
    case ba:
    case Ea:
      return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 8;
    case ya:
    case Sa:
      return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
    case wl:
    case Rl:
      return Math.max(i, 16) * Math.max(e, 8) / 4;
    case Tl:
    case Dl:
      return Math.max(i, 8) * Math.max(e, 8) / 2;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
    case Cl:
    case Pl:
      return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 8;
    case Ll:
      return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
    case Il:
      return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 16;
    case Fl:
      return Math.floor((i + 4) / 5) * Math.floor((e + 3) / 4) * 16;
    case Nl:
      return Math.floor((i + 4) / 5) * Math.floor((e + 4) / 5) * 16;
    case Ul:
      return Math.floor((i + 5) / 6) * Math.floor((e + 4) / 5) * 16;
    case Ol:
      return Math.floor((i + 5) / 6) * Math.floor((e + 5) / 6) * 16;
    case Bl:
      return Math.floor((i + 7) / 8) * Math.floor((e + 4) / 5) * 16;
    case kl:
      return Math.floor((i + 7) / 8) * Math.floor((e + 5) / 6) * 16;
    case Hl:
      return Math.floor((i + 7) / 8) * Math.floor((e + 7) / 8) * 16;
    case zl:
      return Math.floor((i + 9) / 10) * Math.floor((e + 4) / 5) * 16;
    case Gl:
      return Math.floor((i + 9) / 10) * Math.floor((e + 5) / 6) * 16;
    case Vl:
      return Math.floor((i + 9) / 10) * Math.floor((e + 7) / 8) * 16;
    case Wl:
      return Math.floor((i + 9) / 10) * Math.floor((e + 9) / 10) * 16;
    case Xl:
      return Math.floor((i + 11) / 12) * Math.floor((e + 9) / 10) * 16;
    case jl:
      return Math.floor((i + 11) / 12) * Math.floor((e + 11) / 12) * 16;
    // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
    case Ma:
    case ql:
    case Yl:
      return Math.ceil(i / 4) * Math.ceil(e / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
    case Id:
    case Zl:
      return Math.ceil(i / 4) * Math.ceil(e / 4) * 8;
    case Kl:
    case $l:
      return Math.ceil(i / 4) * Math.ceil(e / 4) * 16;
  }
  throw new Error(
    `Unable to determine texture byte length for ${t} format.`
  );
}
function zS(i) {
  switch (i) {
    case ai:
    case Ad:
      return { byteLength: 1, components: 1 };
    case bs:
    case Td:
    case Cs:
      return { byteLength: 2, components: 1 };
    case Mc:
    case Ac:
      return { byteLength: 2, components: 4 };
    case Wi:
    case Sc:
    case wn:
      return { byteLength: 4, components: 1 };
    case wd:
      return { byteLength: 4, components: 3 };
  }
  throw new Error(`Unknown texture type ${i}.`);
}
function GS(i, e, t, n, r, s, a) {
  const o = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : null, l = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), c = new ze(), u = /* @__PURE__ */ new WeakMap();
  let h;
  const d = /* @__PURE__ */ new WeakMap();
  let m = !1;
  try {
    m = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
  } catch {
  }
  function v(D, S) {
    return m ? (
      // eslint-disable-next-line compat/compat
      new OffscreenCanvas(D, S)
    ) : Ss("canvas");
  }
  function b(D, S, k) {
    let J = 1;
    const te = Ie(D);
    if ((te.width > k || te.height > k) && (J = k / Math.max(te.width, te.height)), J < 1)
      if (typeof HTMLImageElement < "u" && D instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && D instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && D instanceof ImageBitmap || typeof VideoFrame < "u" && D instanceof VideoFrame) {
        const $ = Math.floor(J * te.width), be = Math.floor(J * te.height);
        h === void 0 && (h = v($, be));
        const fe = S ? v($, be) : h;
        return fe.width = $, fe.height = be, fe.getContext("2d").drawImage(D, 0, 0, $, be), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + te.width + "x" + te.height + ") to (" + $ + "x" + be + ")."), fe;
      } else
        return "data" in D && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + te.width + "x" + te.height + ")."), D;
    return D;
  }
  function p(D) {
    return D.generateMipmaps;
  }
  function f(D) {
    i.generateMipmap(D);
  }
  function x(D) {
    return D.isWebGLCubeRenderTarget ? i.TEXTURE_CUBE_MAP : D.isWebGL3DRenderTarget ? i.TEXTURE_3D : D.isWebGLArrayRenderTarget || D.isCompressedArrayTexture ? i.TEXTURE_2D_ARRAY : i.TEXTURE_2D;
  }
  function g(D, S, k, J, te = !1) {
    if (D !== null) {
      if (i[D] !== void 0) return i[D];
      console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + D + "'");
    }
    let $ = S;
    if (S === i.RED && (k === i.FLOAT && ($ = i.R32F), k === i.HALF_FLOAT && ($ = i.R16F), k === i.UNSIGNED_BYTE && ($ = i.R8)), S === i.RED_INTEGER && (k === i.UNSIGNED_BYTE && ($ = i.R8UI), k === i.UNSIGNED_SHORT && ($ = i.R16UI), k === i.UNSIGNED_INT && ($ = i.R32UI), k === i.BYTE && ($ = i.R8I), k === i.SHORT && ($ = i.R16I), k === i.INT && ($ = i.R32I)), S === i.RG && (k === i.FLOAT && ($ = i.RG32F), k === i.HALF_FLOAT && ($ = i.RG16F), k === i.UNSIGNED_BYTE && ($ = i.RG8)), S === i.RG_INTEGER && (k === i.UNSIGNED_BYTE && ($ = i.RG8UI), k === i.UNSIGNED_SHORT && ($ = i.RG16UI), k === i.UNSIGNED_INT && ($ = i.RG32UI), k === i.BYTE && ($ = i.RG8I), k === i.SHORT && ($ = i.RG16I), k === i.INT && ($ = i.RG32I)), S === i.RGB_INTEGER && (k === i.UNSIGNED_BYTE && ($ = i.RGB8UI), k === i.UNSIGNED_SHORT && ($ = i.RGB16UI), k === i.UNSIGNED_INT && ($ = i.RGB32UI), k === i.BYTE && ($ = i.RGB8I), k === i.SHORT && ($ = i.RGB16I), k === i.INT && ($ = i.RGB32I)), S === i.RGBA_INTEGER && (k === i.UNSIGNED_BYTE && ($ = i.RGBA8UI), k === i.UNSIGNED_SHORT && ($ = i.RGBA16UI), k === i.UNSIGNED_INT && ($ = i.RGBA32UI), k === i.BYTE && ($ = i.RGBA8I), k === i.SHORT && ($ = i.RGBA16I), k === i.INT && ($ = i.RGBA32I)), S === i.RGB && k === i.UNSIGNED_INT_5_9_9_9_REV && ($ = i.RGB9_E5), S === i.RGBA) {
      const be = te ? qa : nt.getTransfer(J);
      k === i.FLOAT && ($ = i.RGBA32F), k === i.HALF_FLOAT && ($ = i.RGBA16F), k === i.UNSIGNED_BYTE && ($ = be === mt ? i.SRGB8_ALPHA8 : i.RGBA8), k === i.UNSIGNED_SHORT_4_4_4_4 && ($ = i.RGBA4), k === i.UNSIGNED_SHORT_5_5_5_1 && ($ = i.RGB5_A1);
    }
    return ($ === i.R16F || $ === i.R32F || $ === i.RG16F || $ === i.RG32F || $ === i.RGBA16F || $ === i.RGBA32F) && e.get("EXT_color_buffer_float"), $;
  }
  function _(D, S) {
    let k;
    return D ? S === null || S === Wi || S === Lr ? k = i.DEPTH24_STENCIL8 : S === wn ? k = i.DEPTH32F_STENCIL8 : S === bs && (k = i.DEPTH24_STENCIL8, console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : S === null || S === Wi || S === Lr ? k = i.DEPTH_COMPONENT24 : S === wn ? k = i.DEPTH_COMPONENT32F : S === bs && (k = i.DEPTH_COMPONENT16), k;
  }
  function T(D, S) {
    return p(D) === !0 || D.isFramebufferTexture && D.minFilter !== Jt && D.minFilter !== un ? Math.log2(Math.max(S.width, S.height)) + 1 : D.mipmaps !== void 0 && D.mipmaps.length > 0 ? D.mipmaps.length : D.isCompressedTexture && Array.isArray(D.image) ? S.mipmaps.length : 1;
  }
  function A(D) {
    const S = D.target;
    S.removeEventListener("dispose", A), C(S), S.isVideoTexture && u.delete(S);
  }
  function M(D) {
    const S = D.target;
    S.removeEventListener("dispose", M), E(S);
  }
  function C(D) {
    const S = n.get(D);
    if (S.__webglInit === void 0) return;
    const k = D.source, J = d.get(k);
    if (J) {
      const te = J[S.__cacheKey];
      te.usedTimes--, te.usedTimes === 0 && y(D), Object.keys(J).length === 0 && d.delete(k);
    }
    n.remove(D);
  }
  function y(D) {
    const S = n.get(D);
    i.deleteTexture(S.__webglTexture);
    const k = D.source, J = d.get(k);
    delete J[S.__cacheKey], a.memory.textures--;
  }
  function E(D) {
    const S = n.get(D);
    if (D.depthTexture && (D.depthTexture.dispose(), n.remove(D.depthTexture)), D.isWebGLCubeRenderTarget)
      for (let J = 0; J < 6; J++) {
        if (Array.isArray(S.__webglFramebuffer[J]))
          for (let te = 0; te < S.__webglFramebuffer[J].length; te++) i.deleteFramebuffer(S.__webglFramebuffer[J][te]);
        else
          i.deleteFramebuffer(S.__webglFramebuffer[J]);
        S.__webglDepthbuffer && i.deleteRenderbuffer(S.__webglDepthbuffer[J]);
      }
    else {
      if (Array.isArray(S.__webglFramebuffer))
        for (let J = 0; J < S.__webglFramebuffer.length; J++) i.deleteFramebuffer(S.__webglFramebuffer[J]);
      else
        i.deleteFramebuffer(S.__webglFramebuffer);
      if (S.__webglDepthbuffer && i.deleteRenderbuffer(S.__webglDepthbuffer), S.__webglMultisampledFramebuffer && i.deleteFramebuffer(S.__webglMultisampledFramebuffer), S.__webglColorRenderbuffer)
        for (let J = 0; J < S.__webglColorRenderbuffer.length; J++)
          S.__webglColorRenderbuffer[J] && i.deleteRenderbuffer(S.__webglColorRenderbuffer[J]);
      S.__webglDepthRenderbuffer && i.deleteRenderbuffer(S.__webglDepthRenderbuffer);
    }
    const k = D.textures;
    for (let J = 0, te = k.length; J < te; J++) {
      const $ = n.get(k[J]);
      $.__webglTexture && (i.deleteTexture($.__webglTexture), a.memory.textures--), n.remove(k[J]);
    }
    n.remove(D);
  }
  let R = 0;
  function q() {
    R = 0;
  }
  function G() {
    const D = R;
    return D >= r.maxTextures && console.warn("THREE.WebGLTextures: Trying to use " + D + " texture units while this GPU supports only " + r.maxTextures), R += 1, D;
  }
  function V(D) {
    const S = [];
    return S.push(D.wrapS), S.push(D.wrapT), S.push(D.wrapR || 0), S.push(D.magFilter), S.push(D.minFilter), S.push(D.anisotropy), S.push(D.internalFormat), S.push(D.format), S.push(D.type), S.push(D.generateMipmaps), S.push(D.premultiplyAlpha), S.push(D.flipY), S.push(D.unpackAlignment), S.push(D.colorSpace), S.join();
  }
  function B(D, S) {
    const k = n.get(D);
    if (D.isVideoTexture && Le(D), D.isRenderTargetTexture === !1 && D.version > 0 && k.__version !== D.version) {
      const J = D.image;
      if (J === null)
        console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");
      else if (J.complete === !1)
        console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");
      else {
        K(k, D, S);
        return;
      }
    }
    t.bindTexture(i.TEXTURE_2D, k.__webglTexture, i.TEXTURE0 + S);
  }
  function U(D, S) {
    const k = n.get(D);
    if (D.version > 0 && k.__version !== D.version) {
      K(k, D, S);
      return;
    }
    t.bindTexture(i.TEXTURE_2D_ARRAY, k.__webglTexture, i.TEXTURE0 + S);
  }
  function Y(D, S) {
    const k = n.get(D);
    if (D.version > 0 && k.__version !== D.version) {
      K(k, D, S);
      return;
    }
    t.bindTexture(i.TEXTURE_3D, k.__webglTexture, i.TEXTURE0 + S);
  }
  function z(D, S) {
    const k = n.get(D);
    if (D.version > 0 && k.__version !== D.version) {
      Q(k, D, S);
      return;
    }
    t.bindTexture(i.TEXTURE_CUBE_MAP, k.__webglTexture, i.TEXTURE0 + S);
  }
  const ie = {
    [Pr]: i.REPEAT,
    [bi]: i.CLAMP_TO_EDGE,
    [La]: i.MIRRORED_REPEAT
  }, oe = {
    [Jt]: i.NEAREST,
    [Md]: i.NEAREST_MIPMAP_NEAREST,
    [fs]: i.NEAREST_MIPMAP_LINEAR,
    [un]: i.LINEAR,
    [xa]: i.LINEAR_MIPMAP_NEAREST,
    [ti]: i.LINEAR_MIPMAP_LINEAR
  }, ce = {
    [vv]: i.NEVER,
    [Mv]: i.ALWAYS,
    [xv]: i.LESS,
    [Ud]: i.LEQUAL,
    [bv]: i.EQUAL,
    [Sv]: i.GEQUAL,
    [Ev]: i.GREATER,
    [yv]: i.NOTEQUAL
  };
  function ye(D, S) {
    if (S.type === wn && e.has("OES_texture_float_linear") === !1 && (S.magFilter === un || S.magFilter === xa || S.magFilter === fs || S.magFilter === ti || S.minFilter === un || S.minFilter === xa || S.minFilter === fs || S.minFilter === ti) && console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), i.texParameteri(D, i.TEXTURE_WRAP_S, ie[S.wrapS]), i.texParameteri(D, i.TEXTURE_WRAP_T, ie[S.wrapT]), (D === i.TEXTURE_3D || D === i.TEXTURE_2D_ARRAY) && i.texParameteri(D, i.TEXTURE_WRAP_R, ie[S.wrapR]), i.texParameteri(D, i.TEXTURE_MAG_FILTER, oe[S.magFilter]), i.texParameteri(D, i.TEXTURE_MIN_FILTER, oe[S.minFilter]), S.compareFunction && (i.texParameteri(D, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE), i.texParameteri(D, i.TEXTURE_COMPARE_FUNC, ce[S.compareFunction])), e.has("EXT_texture_filter_anisotropic") === !0) {
      if (S.magFilter === Jt || S.minFilter !== fs && S.minFilter !== ti || S.type === wn && e.has("OES_texture_float_linear") === !1) return;
      if (S.anisotropy > 1 || n.get(S).__currentAnisotropy) {
        const k = e.get("EXT_texture_filter_anisotropic");
        i.texParameterf(D, k.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(S.anisotropy, r.getMaxAnisotropy())), n.get(S).__currentAnisotropy = S.anisotropy;
      }
    }
  }
  function je(D, S) {
    let k = !1;
    D.__webglInit === void 0 && (D.__webglInit = !0, S.addEventListener("dispose", A));
    const J = S.source;
    let te = d.get(J);
    te === void 0 && (te = {}, d.set(J, te));
    const $ = V(S);
    if ($ !== D.__cacheKey) {
      te[$] === void 0 && (te[$] = {
        texture: i.createTexture(),
        usedTimes: 0
      }, a.memory.textures++, k = !0), te[$].usedTimes++;
      const be = te[D.__cacheKey];
      be !== void 0 && (te[D.__cacheKey].usedTimes--, be.usedTimes === 0 && y(S)), D.__cacheKey = $, D.__webglTexture = te[$].texture;
    }
    return k;
  }
  function K(D, S, k) {
    let J = i.TEXTURE_2D;
    (S.isDataArrayTexture || S.isCompressedArrayTexture) && (J = i.TEXTURE_2D_ARRAY), S.isData3DTexture && (J = i.TEXTURE_3D);
    const te = je(D, S), $ = S.source;
    t.bindTexture(J, D.__webglTexture, i.TEXTURE0 + k);
    const be = n.get($);
    if ($.version !== be.__version || te === !0) {
      t.activeTexture(i.TEXTURE0 + k);
      const fe = nt.getPrimaries(nt.workingColorSpace), ge = S.colorSpace === vi ? null : nt.getPrimaries(S.colorSpace), He = S.colorSpace === vi || fe === ge ? i.NONE : i.BROWSER_DEFAULT_WEBGL;
      i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, S.flipY), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, S.premultiplyAlpha), i.pixelStorei(i.UNPACK_ALIGNMENT, S.unpackAlignment), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, He);
      let se = b(S.image, !1, r.maxTextureSize);
      se = ht(S, se);
      const _e = s.convert(S.format, S.colorSpace), Re = s.convert(S.type);
      let Ce = g(S.internalFormat, _e, Re, S.colorSpace, S.isVideoTexture);
      ye(J, S);
      let pe;
      const Be = S.mipmaps, Oe = S.isVideoTexture !== !0, et = be.__version === void 0 || te === !0, I = $.dataReady, ue = T(S, se);
      if (S.isDepthTexture)
        Ce = _(S.format === Ir, S.type), et && (Oe ? t.texStorage2D(i.TEXTURE_2D, 1, Ce, se.width, se.height) : t.texImage2D(i.TEXTURE_2D, 0, Ce, se.width, se.height, 0, _e, Re, null));
      else if (S.isDataTexture)
        if (Be.length > 0) {
          Oe && et && t.texStorage2D(i.TEXTURE_2D, ue, Ce, Be[0].width, Be[0].height);
          for (let Z = 0, ee = Be.length; Z < ee; Z++)
            pe = Be[Z], Oe ? I && t.texSubImage2D(i.TEXTURE_2D, Z, 0, 0, pe.width, pe.height, _e, Re, pe.data) : t.texImage2D(i.TEXTURE_2D, Z, Ce, pe.width, pe.height, 0, _e, Re, pe.data);
          S.generateMipmaps = !1;
        } else
          Oe ? (et && t.texStorage2D(i.TEXTURE_2D, ue, Ce, se.width, se.height), I && t.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, se.width, se.height, _e, Re, se.data)) : t.texImage2D(i.TEXTURE_2D, 0, Ce, se.width, se.height, 0, _e, Re, se.data);
      else if (S.isCompressedTexture)
        if (S.isCompressedArrayTexture) {
          Oe && et && t.texStorage3D(i.TEXTURE_2D_ARRAY, ue, Ce, Be[0].width, Be[0].height, se.depth);
          for (let Z = 0, ee = Be.length; Z < ee; Z++)
            if (pe = Be[Z], S.format !== _n)
              if (_e !== null)
                if (Oe) {
                  if (I)
                    if (S.layerUpdates.size > 0) {
                      const H = Gh(pe.width, pe.height, S.format, S.type);
                      for (const X of S.layerUpdates) {
                        const ae = pe.data.subarray(
                          X * H / pe.data.BYTES_PER_ELEMENT,
                          (X + 1) * H / pe.data.BYTES_PER_ELEMENT
                        );
                        t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY, Z, 0, 0, X, pe.width, pe.height, 1, _e, ae);
                      }
                      S.clearLayerUpdates();
                    } else
                      t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY, Z, 0, 0, 0, pe.width, pe.height, se.depth, _e, pe.data);
                } else
                  t.compressedTexImage3D(i.TEXTURE_2D_ARRAY, Z, Ce, pe.width, pe.height, se.depth, 0, pe.data, 0, 0);
              else
                console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");
            else
              Oe ? I && t.texSubImage3D(i.TEXTURE_2D_ARRAY, Z, 0, 0, 0, pe.width, pe.height, se.depth, _e, Re, pe.data) : t.texImage3D(i.TEXTURE_2D_ARRAY, Z, Ce, pe.width, pe.height, se.depth, 0, _e, Re, pe.data);
        } else {
          Oe && et && t.texStorage2D(i.TEXTURE_2D, ue, Ce, Be[0].width, Be[0].height);
          for (let Z = 0, ee = Be.length; Z < ee; Z++)
            pe = Be[Z], S.format !== _n ? _e !== null ? Oe ? I && t.compressedTexSubImage2D(i.TEXTURE_2D, Z, 0, 0, pe.width, pe.height, _e, pe.data) : t.compressedTexImage2D(i.TEXTURE_2D, Z, Ce, pe.width, pe.height, 0, pe.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Oe ? I && t.texSubImage2D(i.TEXTURE_2D, Z, 0, 0, pe.width, pe.height, _e, Re, pe.data) : t.texImage2D(i.TEXTURE_2D, Z, Ce, pe.width, pe.height, 0, _e, Re, pe.data);
        }
      else if (S.isDataArrayTexture)
        if (Oe) {
          if (et && t.texStorage3D(i.TEXTURE_2D_ARRAY, ue, Ce, se.width, se.height, se.depth), I)
            if (S.layerUpdates.size > 0) {
              const Z = Gh(se.width, se.height, S.format, S.type);
              for (const ee of S.layerUpdates) {
                const H = se.data.subarray(
                  ee * Z / se.data.BYTES_PER_ELEMENT,
                  (ee + 1) * Z / se.data.BYTES_PER_ELEMENT
                );
                t.texSubImage3D(i.TEXTURE_2D_ARRAY, 0, 0, 0, ee, se.width, se.height, 1, _e, Re, H);
              }
              S.clearLayerUpdates();
            } else
              t.texSubImage3D(i.TEXTURE_2D_ARRAY, 0, 0, 0, 0, se.width, se.height, se.depth, _e, Re, se.data);
        } else
          t.texImage3D(i.TEXTURE_2D_ARRAY, 0, Ce, se.width, se.height, se.depth, 0, _e, Re, se.data);
      else if (S.isData3DTexture)
        Oe ? (et && t.texStorage3D(i.TEXTURE_3D, ue, Ce, se.width, se.height, se.depth), I && t.texSubImage3D(i.TEXTURE_3D, 0, 0, 0, 0, se.width, se.height, se.depth, _e, Re, se.data)) : t.texImage3D(i.TEXTURE_3D, 0, Ce, se.width, se.height, se.depth, 0, _e, Re, se.data);
      else if (S.isFramebufferTexture) {
        if (et)
          if (Oe)
            t.texStorage2D(i.TEXTURE_2D, ue, Ce, se.width, se.height);
          else {
            let Z = se.width, ee = se.height;
            for (let H = 0; H < ue; H++)
              t.texImage2D(i.TEXTURE_2D, H, Ce, Z, ee, 0, _e, Re, null), Z >>= 1, ee >>= 1;
          }
      } else if (Be.length > 0) {
        if (Oe && et) {
          const Z = Ie(Be[0]);
          t.texStorage2D(i.TEXTURE_2D, ue, Ce, Z.width, Z.height);
        }
        for (let Z = 0, ee = Be.length; Z < ee; Z++)
          pe = Be[Z], Oe ? I && t.texSubImage2D(i.TEXTURE_2D, Z, 0, 0, _e, Re, pe) : t.texImage2D(i.TEXTURE_2D, Z, Ce, _e, Re, pe);
        S.generateMipmaps = !1;
      } else if (Oe) {
        if (et) {
          const Z = Ie(se);
          t.texStorage2D(i.TEXTURE_2D, ue, Ce, Z.width, Z.height);
        }
        I && t.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, _e, Re, se);
      } else
        t.texImage2D(i.TEXTURE_2D, 0, Ce, _e, Re, se);
      p(S) && f(J), be.__version = $.version, S.onUpdate && S.onUpdate(S);
    }
    D.__version = S.version;
  }
  function Q(D, S, k) {
    if (S.image.length !== 6) return;
    const J = je(D, S), te = S.source;
    t.bindTexture(i.TEXTURE_CUBE_MAP, D.__webglTexture, i.TEXTURE0 + k);
    const $ = n.get(te);
    if (te.version !== $.__version || J === !0) {
      t.activeTexture(i.TEXTURE0 + k);
      const be = nt.getPrimaries(nt.workingColorSpace), fe = S.colorSpace === vi ? null : nt.getPrimaries(S.colorSpace), ge = S.colorSpace === vi || be === fe ? i.NONE : i.BROWSER_DEFAULT_WEBGL;
      i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, S.flipY), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, S.premultiplyAlpha), i.pixelStorei(i.UNPACK_ALIGNMENT, S.unpackAlignment), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, ge);
      const He = S.isCompressedTexture || S.image[0].isCompressedTexture, se = S.image[0] && S.image[0].isDataTexture, _e = [];
      for (let ee = 0; ee < 6; ee++)
        !He && !se ? _e[ee] = b(S.image[ee], !0, r.maxCubemapSize) : _e[ee] = se ? S.image[ee].image : S.image[ee], _e[ee] = ht(S, _e[ee]);
      const Re = _e[0], Ce = s.convert(S.format, S.colorSpace), pe = s.convert(S.type), Be = g(S.internalFormat, Ce, pe, S.colorSpace), Oe = S.isVideoTexture !== !0, et = $.__version === void 0 || J === !0, I = te.dataReady;
      let ue = T(S, Re);
      ye(i.TEXTURE_CUBE_MAP, S);
      let Z;
      if (He) {
        Oe && et && t.texStorage2D(i.TEXTURE_CUBE_MAP, ue, Be, Re.width, Re.height);
        for (let ee = 0; ee < 6; ee++) {
          Z = _e[ee].mipmaps;
          for (let H = 0; H < Z.length; H++) {
            const X = Z[H];
            S.format !== _n ? Ce !== null ? Oe ? I && t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, H, 0, 0, X.width, X.height, Ce, X.data) : t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, H, Be, X.width, X.height, 0, X.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : Oe ? I && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, H, 0, 0, X.width, X.height, Ce, pe, X.data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, H, Be, X.width, X.height, 0, Ce, pe, X.data);
          }
        }
      } else {
        if (Z = S.mipmaps, Oe && et) {
          Z.length > 0 && ue++;
          const ee = Ie(_e[0]);
          t.texStorage2D(i.TEXTURE_CUBE_MAP, ue, Be, ee.width, ee.height);
        }
        for (let ee = 0; ee < 6; ee++)
          if (se) {
            Oe ? I && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, 0, 0, 0, _e[ee].width, _e[ee].height, Ce, pe, _e[ee].data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, 0, Be, _e[ee].width, _e[ee].height, 0, Ce, pe, _e[ee].data);
            for (let H = 0; H < Z.length; H++) {
              const ae = Z[H].image[ee].image;
              Oe ? I && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, H + 1, 0, 0, ae.width, ae.height, Ce, pe, ae.data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, H + 1, Be, ae.width, ae.height, 0, Ce, pe, ae.data);
            }
          } else {
            Oe ? I && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, 0, 0, 0, Ce, pe, _e[ee]) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, 0, Be, Ce, pe, _e[ee]);
            for (let H = 0; H < Z.length; H++) {
              const X = Z[H];
              Oe ? I && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, H + 1, 0, 0, Ce, pe, X.image[ee]) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + ee, H + 1, Be, Ce, pe, X.image[ee]);
            }
          }
      }
      p(S) && f(i.TEXTURE_CUBE_MAP), $.__version = te.version, S.onUpdate && S.onUpdate(S);
    }
    D.__version = S.version;
  }
  function re(D, S, k, J, te, $) {
    const be = s.convert(k.format, k.colorSpace), fe = s.convert(k.type), ge = g(k.internalFormat, be, fe, k.colorSpace), He = n.get(S), se = n.get(k);
    if (se.__renderTarget = S, !He.__hasExternalTextures) {
      const _e = Math.max(1, S.width >> $), Re = Math.max(1, S.height >> $);
      te === i.TEXTURE_3D || te === i.TEXTURE_2D_ARRAY ? t.texImage3D(te, $, ge, _e, Re, S.depth, 0, be, fe, null) : t.texImage2D(te, $, ge, _e, Re, 0, be, fe, null);
    }
    t.bindFramebuffer(i.FRAMEBUFFER, D), Ze(S) ? o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, J, te, se.__webglTexture, 0, $e(S)) : (te === i.TEXTURE_2D || te >= i.TEXTURE_CUBE_MAP_POSITIVE_X && te <= i.TEXTURE_CUBE_MAP_NEGATIVE_Z) && i.framebufferTexture2D(i.FRAMEBUFFER, J, te, se.__webglTexture, $), t.bindFramebuffer(i.FRAMEBUFFER, null);
  }
  function ne(D, S, k) {
    if (i.bindRenderbuffer(i.RENDERBUFFER, D), S.depthBuffer) {
      const J = S.depthTexture, te = J && J.isDepthTexture ? J.type : null, $ = _(S.stencilBuffer, te), be = S.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, fe = $e(S);
      Ze(S) ? o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, fe, $, S.width, S.height) : k ? i.renderbufferStorageMultisample(i.RENDERBUFFER, fe, $, S.width, S.height) : i.renderbufferStorage(i.RENDERBUFFER, $, S.width, S.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, be, i.RENDERBUFFER, D);
    } else {
      const J = S.textures;
      for (let te = 0; te < J.length; te++) {
        const $ = J[te], be = s.convert($.format, $.colorSpace), fe = s.convert($.type), ge = g($.internalFormat, be, fe, $.colorSpace), He = $e(S);
        k && Ze(S) === !1 ? i.renderbufferStorageMultisample(i.RENDERBUFFER, He, ge, S.width, S.height) : Ze(S) ? o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, He, ge, S.width, S.height) : i.renderbufferStorage(i.RENDERBUFFER, ge, S.width, S.height);
      }
    }
    i.bindRenderbuffer(i.RENDERBUFFER, null);
  }
  function he(D, S) {
    if (S && S.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported");
    if (t.bindFramebuffer(i.FRAMEBUFFER, D), !(S.depthTexture && S.depthTexture.isDepthTexture))
      throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
    const J = n.get(S.depthTexture);
    J.__renderTarget = S, (!J.__webglTexture || S.depthTexture.image.width !== S.width || S.depthTexture.image.height !== S.height) && (S.depthTexture.image.width = S.width, S.depthTexture.image.height = S.height, S.depthTexture.needsUpdate = !0), B(S.depthTexture, 0);
    const te = J.__webglTexture, $ = $e(S);
    if (S.depthTexture.format === Er)
      Ze(S) ? o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, te, 0, $) : i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, te, 0);
    else if (S.depthTexture.format === Ir)
      Ze(S) ? o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, te, 0, $) : i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, te, 0);
    else
      throw new Error("Unknown depthTexture format");
  }
  function me(D) {
    const S = n.get(D), k = D.isWebGLCubeRenderTarget === !0;
    if (S.__boundDepthTexture !== D.depthTexture) {
      const J = D.depthTexture;
      if (S.__depthDisposeCallback && S.__depthDisposeCallback(), J) {
        const te = () => {
          delete S.__boundDepthTexture, delete S.__depthDisposeCallback, J.removeEventListener("dispose", te);
        };
        J.addEventListener("dispose", te), S.__depthDisposeCallback = te;
      }
      S.__boundDepthTexture = J;
    }
    if (D.depthTexture && !S.__autoAllocateDepthBuffer) {
      if (k) throw new Error("target.depthTexture not supported in Cube render targets");
      he(S.__webglFramebuffer, D);
    } else if (k) {
      S.__webglDepthbuffer = [];
      for (let J = 0; J < 6; J++)
        if (t.bindFramebuffer(i.FRAMEBUFFER, S.__webglFramebuffer[J]), S.__webglDepthbuffer[J] === void 0)
          S.__webglDepthbuffer[J] = i.createRenderbuffer(), ne(S.__webglDepthbuffer[J], D, !1);
        else {
          const te = D.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, $ = S.__webglDepthbuffer[J];
          i.bindRenderbuffer(i.RENDERBUFFER, $), i.framebufferRenderbuffer(i.FRAMEBUFFER, te, i.RENDERBUFFER, $);
        }
    } else if (t.bindFramebuffer(i.FRAMEBUFFER, S.__webglFramebuffer), S.__webglDepthbuffer === void 0)
      S.__webglDepthbuffer = i.createRenderbuffer(), ne(S.__webglDepthbuffer, D, !1);
    else {
      const J = D.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, te = S.__webglDepthbuffer;
      i.bindRenderbuffer(i.RENDERBUFFER, te), i.framebufferRenderbuffer(i.FRAMEBUFFER, J, i.RENDERBUFFER, te);
    }
    t.bindFramebuffer(i.FRAMEBUFFER, null);
  }
  function we(D, S, k) {
    const J = n.get(D);
    S !== void 0 && re(J.__webglFramebuffer, D, D.texture, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, 0), k !== void 0 && me(D);
  }
  function qe(D) {
    const S = D.texture, k = n.get(D), J = n.get(S);
    D.addEventListener("dispose", M);
    const te = D.textures, $ = D.isWebGLCubeRenderTarget === !0, be = te.length > 1;
    if (be || (J.__webglTexture === void 0 && (J.__webglTexture = i.createTexture()), J.__version = S.version, a.memory.textures++), $) {
      k.__webglFramebuffer = [];
      for (let fe = 0; fe < 6; fe++)
        if (S.mipmaps && S.mipmaps.length > 0) {
          k.__webglFramebuffer[fe] = [];
          for (let ge = 0; ge < S.mipmaps.length; ge++)
            k.__webglFramebuffer[fe][ge] = i.createFramebuffer();
        } else
          k.__webglFramebuffer[fe] = i.createFramebuffer();
    } else {
      if (S.mipmaps && S.mipmaps.length > 0) {
        k.__webglFramebuffer = [];
        for (let fe = 0; fe < S.mipmaps.length; fe++)
          k.__webglFramebuffer[fe] = i.createFramebuffer();
      } else
        k.__webglFramebuffer = i.createFramebuffer();
      if (be)
        for (let fe = 0, ge = te.length; fe < ge; fe++) {
          const He = n.get(te[fe]);
          He.__webglTexture === void 0 && (He.__webglTexture = i.createTexture(), a.memory.textures++);
        }
      if (D.samples > 0 && Ze(D) === !1) {
        k.__webglMultisampledFramebuffer = i.createFramebuffer(), k.__webglColorRenderbuffer = [], t.bindFramebuffer(i.FRAMEBUFFER, k.__webglMultisampledFramebuffer);
        for (let fe = 0; fe < te.length; fe++) {
          const ge = te[fe];
          k.__webglColorRenderbuffer[fe] = i.createRenderbuffer(), i.bindRenderbuffer(i.RENDERBUFFER, k.__webglColorRenderbuffer[fe]);
          const He = s.convert(ge.format, ge.colorSpace), se = s.convert(ge.type), _e = g(ge.internalFormat, He, se, ge.colorSpace, D.isXRRenderTarget === !0), Re = $e(D);
          i.renderbufferStorageMultisample(i.RENDERBUFFER, Re, _e, D.width, D.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + fe, i.RENDERBUFFER, k.__webglColorRenderbuffer[fe]);
        }
        i.bindRenderbuffer(i.RENDERBUFFER, null), D.depthBuffer && (k.__webglDepthRenderbuffer = i.createRenderbuffer(), ne(k.__webglDepthRenderbuffer, D, !0)), t.bindFramebuffer(i.FRAMEBUFFER, null);
      }
    }
    if ($) {
      t.bindTexture(i.TEXTURE_CUBE_MAP, J.__webglTexture), ye(i.TEXTURE_CUBE_MAP, S);
      for (let fe = 0; fe < 6; fe++)
        if (S.mipmaps && S.mipmaps.length > 0)
          for (let ge = 0; ge < S.mipmaps.length; ge++)
            re(k.__webglFramebuffer[fe][ge], D, S, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + fe, ge);
        else
          re(k.__webglFramebuffer[fe], D, S, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + fe, 0);
      p(S) && f(i.TEXTURE_CUBE_MAP), t.unbindTexture();
    } else if (be) {
      for (let fe = 0, ge = te.length; fe < ge; fe++) {
        const He = te[fe], se = n.get(He);
        t.bindTexture(i.TEXTURE_2D, se.__webglTexture), ye(i.TEXTURE_2D, He), re(k.__webglFramebuffer, D, He, i.COLOR_ATTACHMENT0 + fe, i.TEXTURE_2D, 0), p(He) && f(i.TEXTURE_2D);
      }
      t.unbindTexture();
    } else {
      let fe = i.TEXTURE_2D;
      if ((D.isWebGL3DRenderTarget || D.isWebGLArrayRenderTarget) && (fe = D.isWebGL3DRenderTarget ? i.TEXTURE_3D : i.TEXTURE_2D_ARRAY), t.bindTexture(fe, J.__webglTexture), ye(fe, S), S.mipmaps && S.mipmaps.length > 0)
        for (let ge = 0; ge < S.mipmaps.length; ge++)
          re(k.__webglFramebuffer[ge], D, S, i.COLOR_ATTACHMENT0, fe, ge);
      else
        re(k.__webglFramebuffer, D, S, i.COLOR_ATTACHMENT0, fe, 0);
      p(S) && f(fe), t.unbindTexture();
    }
    D.depthBuffer && me(D);
  }
  function Pe(D) {
    const S = D.textures;
    for (let k = 0, J = S.length; k < J; k++) {
      const te = S[k];
      if (p(te)) {
        const $ = x(D), be = n.get(te).__webglTexture;
        t.bindTexture($, be), f($), t.unbindTexture();
      }
    }
  }
  const Je = [], F = [];
  function Gt(D) {
    if (D.samples > 0) {
      if (Ze(D) === !1) {
        const S = D.textures, k = D.width, J = D.height;
        let te = i.COLOR_BUFFER_BIT;
        const $ = D.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, be = n.get(D), fe = S.length > 1;
        if (fe)
          for (let ge = 0; ge < S.length; ge++)
            t.bindFramebuffer(i.FRAMEBUFFER, be.__webglMultisampledFramebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ge, i.RENDERBUFFER, null), t.bindFramebuffer(i.FRAMEBUFFER, be.__webglFramebuffer), i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ge, i.TEXTURE_2D, null, 0);
        t.bindFramebuffer(i.READ_FRAMEBUFFER, be.__webglMultisampledFramebuffer), t.bindFramebuffer(i.DRAW_FRAMEBUFFER, be.__webglFramebuffer);
        for (let ge = 0; ge < S.length; ge++) {
          if (D.resolveDepthBuffer && (D.depthBuffer && (te |= i.DEPTH_BUFFER_BIT), D.stencilBuffer && D.resolveStencilBuffer && (te |= i.STENCIL_BUFFER_BIT)), fe) {
            i.framebufferRenderbuffer(i.READ_FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.RENDERBUFFER, be.__webglColorRenderbuffer[ge]);
            const He = n.get(S[ge]).__webglTexture;
            i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, He, 0);
          }
          i.blitFramebuffer(0, 0, k, J, 0, 0, k, J, te, i.NEAREST), l === !0 && (Je.length = 0, F.length = 0, Je.push(i.COLOR_ATTACHMENT0 + ge), D.depthBuffer && D.resolveDepthBuffer === !1 && (Je.push($), F.push($), i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER, F)), i.invalidateFramebuffer(i.READ_FRAMEBUFFER, Je));
        }
        if (t.bindFramebuffer(i.READ_FRAMEBUFFER, null), t.bindFramebuffer(i.DRAW_FRAMEBUFFER, null), fe)
          for (let ge = 0; ge < S.length; ge++) {
            t.bindFramebuffer(i.FRAMEBUFFER, be.__webglMultisampledFramebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ge, i.RENDERBUFFER, be.__webglColorRenderbuffer[ge]);
            const He = n.get(S[ge]).__webglTexture;
            t.bindFramebuffer(i.FRAMEBUFFER, be.__webglFramebuffer), i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ge, i.TEXTURE_2D, He, 0);
          }
        t.bindFramebuffer(i.DRAW_FRAMEBUFFER, be.__webglMultisampledFramebuffer);
      } else if (D.depthBuffer && D.resolveDepthBuffer === !1 && l) {
        const S = D.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT;
        i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER, [S]);
      }
    }
  }
  function $e(D) {
    return Math.min(r.maxSamples, D.samples);
  }
  function Ze(D) {
    const S = n.get(D);
    return D.samples > 0 && e.has("WEBGL_multisampled_render_to_texture") === !0 && S.__useRenderToTexture !== !1;
  }
  function Le(D) {
    const S = a.render.frame;
    u.get(D) !== S && (u.set(D, S), D.update());
  }
  function ht(D, S) {
    const k = D.colorSpace, J = D.format, te = D.type;
    return D.isCompressedTexture === !0 || D.isVideoTexture === !0 || k !== en && k !== vi && (nt.getTransfer(k) === mt ? (J !== _n || te !== ai) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", k)), S;
  }
  function Ie(D) {
    return typeof HTMLImageElement < "u" && D instanceof HTMLImageElement ? (c.width = D.naturalWidth || D.width, c.height = D.naturalHeight || D.height) : typeof VideoFrame < "u" && D instanceof VideoFrame ? (c.width = D.displayWidth, c.height = D.displayHeight) : (c.width = D.width, c.height = D.height), c;
  }
  this.allocateTextureUnit = G, this.resetTextureUnits = q, this.setTexture2D = B, this.setTexture2DArray = U, this.setTexture3D = Y, this.setTextureCube = z, this.rebindTextures = we, this.setupRenderTarget = qe, this.updateRenderTargetMipmap = Pe, this.updateMultisampleRenderTarget = Gt, this.setupDepthRenderbuffer = me, this.setupFrameBufferTexture = re, this.useMultisampledRTT = Ze;
}
function VS(i, e) {
  function t(n, r = vi) {
    let s;
    const a = nt.getTransfer(r);
    if (n === ai) return i.UNSIGNED_BYTE;
    if (n === Mc) return i.UNSIGNED_SHORT_4_4_4_4;
    if (n === Ac) return i.UNSIGNED_SHORT_5_5_5_1;
    if (n === wd) return i.UNSIGNED_INT_5_9_9_9_REV;
    if (n === Ad) return i.BYTE;
    if (n === Td) return i.SHORT;
    if (n === bs) return i.UNSIGNED_SHORT;
    if (n === Sc) return i.INT;
    if (n === Wi) return i.UNSIGNED_INT;
    if (n === wn) return i.FLOAT;
    if (n === Cs) return i.HALF_FLOAT;
    if (n === Dd) return i.ALPHA;
    if (n === Rd) return i.RGB;
    if (n === _n) return i.RGBA;
    if (n === Cd) return i.LUMINANCE;
    if (n === Pd) return i.LUMINANCE_ALPHA;
    if (n === Er) return i.DEPTH_COMPONENT;
    if (n === Ir) return i.DEPTH_STENCIL;
    if (n === Tc) return i.RED;
    if (n === wc) return i.RED_INTEGER;
    if (n === Ld) return i.RG;
    if (n === Dc) return i.RG_INTEGER;
    if (n === Rc) return i.RGBA_INTEGER;
    if (n === ba || n === Ea || n === ya || n === Sa)
      if (a === mt)
        if (s = e.get("WEBGL_compressed_texture_s3tc_srgb"), s !== null) {
          if (n === ba) return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;
          if (n === Ea) return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
          if (n === ya) return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
          if (n === Sa) return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
        } else
          return null;
      else if (s = e.get("WEBGL_compressed_texture_s3tc"), s !== null) {
        if (n === ba) return s.COMPRESSED_RGB_S3TC_DXT1_EXT;
        if (n === Ea) return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;
        if (n === ya) return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;
        if (n === Sa) return s.COMPRESSED_RGBA_S3TC_DXT5_EXT;
      } else
        return null;
    if (n === Tl || n === wl || n === Dl || n === Rl)
      if (s = e.get("WEBGL_compressed_texture_pvrtc"), s !== null) {
        if (n === Tl) return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
        if (n === wl) return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
        if (n === Dl) return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
        if (n === Rl) return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
      } else
        return null;
    if (n === Cl || n === Pl || n === Ll)
      if (s = e.get("WEBGL_compressed_texture_etc"), s !== null) {
        if (n === Cl || n === Pl) return a === mt ? s.COMPRESSED_SRGB8_ETC2 : s.COMPRESSED_RGB8_ETC2;
        if (n === Ll) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : s.COMPRESSED_RGBA8_ETC2_EAC;
      } else
        return null;
    if (n === Il || n === Fl || n === Nl || n === Ul || n === Ol || n === Bl || n === kl || n === Hl || n === zl || n === Gl || n === Vl || n === Wl || n === Xl || n === jl)
      if (s = e.get("WEBGL_compressed_texture_astc"), s !== null) {
        if (n === Il) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : s.COMPRESSED_RGBA_ASTC_4x4_KHR;
        if (n === Fl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : s.COMPRESSED_RGBA_ASTC_5x4_KHR;
        if (n === Nl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : s.COMPRESSED_RGBA_ASTC_5x5_KHR;
        if (n === Ul) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : s.COMPRESSED_RGBA_ASTC_6x5_KHR;
        if (n === Ol) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : s.COMPRESSED_RGBA_ASTC_6x6_KHR;
        if (n === Bl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : s.COMPRESSED_RGBA_ASTC_8x5_KHR;
        if (n === kl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : s.COMPRESSED_RGBA_ASTC_8x6_KHR;
        if (n === Hl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : s.COMPRESSED_RGBA_ASTC_8x8_KHR;
        if (n === zl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : s.COMPRESSED_RGBA_ASTC_10x5_KHR;
        if (n === Gl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : s.COMPRESSED_RGBA_ASTC_10x6_KHR;
        if (n === Vl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : s.COMPRESSED_RGBA_ASTC_10x8_KHR;
        if (n === Wl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : s.COMPRESSED_RGBA_ASTC_10x10_KHR;
        if (n === Xl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : s.COMPRESSED_RGBA_ASTC_12x10_KHR;
        if (n === jl) return a === mt ? s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : s.COMPRESSED_RGBA_ASTC_12x12_KHR;
      } else
        return null;
    if (n === Ma || n === ql || n === Yl)
      if (s = e.get("EXT_texture_compression_bptc"), s !== null) {
        if (n === Ma) return a === mt ? s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : s.COMPRESSED_RGBA_BPTC_UNORM_EXT;
        if (n === ql) return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
        if (n === Yl) return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
      } else
        return null;
    if (n === Id || n === Zl || n === Kl || n === $l)
      if (s = e.get("EXT_texture_compression_rgtc"), s !== null) {
        if (n === Ma) return s.COMPRESSED_RED_RGTC1_EXT;
        if (n === Zl) return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;
        if (n === Kl) return s.COMPRESSED_RED_GREEN_RGTC2_EXT;
        if (n === $l) return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
      } else
        return null;
    return n === Lr ? i.UNSIGNED_INT_24_8 : i[n] !== void 0 ? i[n] : null;
  }
  return { convert: t };
}
class WS extends $t {
  constructor(e = []) {
    super(), this.isArrayCamera = !0, this.cameras = e;
  }
}
class Hi extends Rt {
  constructor() {
    super(), this.isGroup = !0, this.type = "Group";
  }
}
const XS = { type: "move" };
class Ho {
  constructor() {
    this._targetRay = null, this._grip = null, this._hand = null;
  }
  getHandSpace() {
    return this._hand === null && (this._hand = new Hi(), this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand;
  }
  getTargetRaySpace() {
    return this._targetRay === null && (this._targetRay = new Hi(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new L(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new L()), this._targetRay;
  }
  getGripSpace() {
    return this._grip === null && (this._grip = new Hi(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new L(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new L()), this._grip;
  }
  dispatchEvent(e) {
    return this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), this;
  }
  connect(e) {
    if (e && e.hand) {
      const t = this._hand;
      if (t)
        for (const n of e.hand.values())
          this._getHandJoint(t, n);
    }
    return this.dispatchEvent({ type: "connected", data: e }), this;
  }
  disconnect(e) {
    return this.dispatchEvent({ type: "disconnected", data: e }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this;
  }
  update(e, t, n) {
    let r = null, s = null, a = null;
    const o = this._targetRay, l = this._grip, c = this._hand;
    if (e && t.session.visibilityState !== "visible-blurred") {
      if (c && e.hand) {
        a = !0;
        for (const b of e.hand.values()) {
          const p = t.getJointPose(b, n), f = this._getHandJoint(c, b);
          p !== null && (f.matrix.fromArray(p.transform.matrix), f.matrix.decompose(f.position, f.rotation, f.scale), f.matrixWorldNeedsUpdate = !0, f.jointRadius = p.radius), f.visible = p !== null;
        }
        const u = c.joints["index-finger-tip"], h = c.joints["thumb-tip"], d = u.position.distanceTo(h.position), m = 0.02, v = 5e-3;
        c.inputState.pinching && d > m + v ? (c.inputState.pinching = !1, this.dispatchEvent({
          type: "pinchend",
          handedness: e.handedness,
          target: this
        })) : !c.inputState.pinching && d <= m - v && (c.inputState.pinching = !0, this.dispatchEvent({
          type: "pinchstart",
          handedness: e.handedness,
          target: this
        }));
      } else
        l !== null && e.gripSpace && (s = t.getPose(e.gripSpace, n), s !== null && (l.matrix.fromArray(s.transform.matrix), l.matrix.decompose(l.position, l.rotation, l.scale), l.matrixWorldNeedsUpdate = !0, s.linearVelocity ? (l.hasLinearVelocity = !0, l.linearVelocity.copy(s.linearVelocity)) : l.hasLinearVelocity = !1, s.angularVelocity ? (l.hasAngularVelocity = !0, l.angularVelocity.copy(s.angularVelocity)) : l.hasAngularVelocity = !1));
      o !== null && (r = t.getPose(e.targetRaySpace, n), r === null && s !== null && (r = s), r !== null && (o.matrix.fromArray(r.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), o.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (o.hasLinearVelocity = !0, o.linearVelocity.copy(r.linearVelocity)) : o.hasLinearVelocity = !1, r.angularVelocity ? (o.hasAngularVelocity = !0, o.angularVelocity.copy(r.angularVelocity)) : o.hasAngularVelocity = !1, this.dispatchEvent(XS)));
    }
    return o !== null && (o.visible = r !== null), l !== null && (l.visible = s !== null), c !== null && (c.visible = a !== null), this;
  }
  // private method
  _getHandJoint(e, t) {
    if (e.joints[t.jointName] === void 0) {
      const n = new Hi();
      n.matrixAutoUpdate = !1, n.visible = !1, e.joints[t.jointName] = n, e.add(n);
    }
    return e.joints[t.jointName];
  }
}
const jS = `
void main() {

	gl_Position = vec4( position, 1.0 );

}`, qS = `
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;

void main() {

	vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );

	if ( coord.x >= 1.0 ) {

		gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;

	} else {

		gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;

	}

}`;
class YS {
  constructor() {
    this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0;
  }
  init(e, t, n) {
    if (this.texture === null) {
      const r = new zt(), s = e.properties.get(r);
      s.__webglTexture = t.texture, (t.depthNear != n.depthNear || t.depthFar != n.depthFar) && (this.depthNear = t.depthNear, this.depthFar = t.depthFar), this.texture = r;
    }
  }
  getMesh(e) {
    if (this.texture !== null && this.mesh === null) {
      const t = e.cameras[0].viewport, n = new Ti({
        vertexShader: jS,
        fragmentShader: qS,
        uniforms: {
          depthColor: { value: this.texture },
          depthWidth: { value: t.z },
          depthHeight: { value: t.w }
        }
      });
      this.mesh = new hn(new Ya(20, 20), n);
    }
    return this.mesh;
  }
  reset() {
    this.texture = null, this.mesh = null;
  }
  getDepthTexture() {
    return this.texture;
  }
}
class ZS extends Yi {
  constructor(e, t) {
    super();
    const n = this;
    let r = null, s = 1, a = null, o = "local-floor", l = 1, c = null, u = null, h = null, d = null, m = null, v = null;
    const b = new YS(), p = t.getContextAttributes();
    let f = null, x = null;
    const g = [], _ = [], T = new ze();
    let A = null;
    const M = new $t();
    M.viewport = new lt();
    const C = new $t();
    C.viewport = new lt();
    const y = [M, C], E = new WS();
    let R = null, q = null;
    this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(K) {
      let Q = g[K];
      return Q === void 0 && (Q = new Ho(), g[K] = Q), Q.getTargetRaySpace();
    }, this.getControllerGrip = function(K) {
      let Q = g[K];
      return Q === void 0 && (Q = new Ho(), g[K] = Q), Q.getGripSpace();
    }, this.getHand = function(K) {
      let Q = g[K];
      return Q === void 0 && (Q = new Ho(), g[K] = Q), Q.getHandSpace();
    };
    function G(K) {
      const Q = _.indexOf(K.inputSource);
      if (Q === -1)
        return;
      const re = g[Q];
      re !== void 0 && (re.update(K.inputSource, K.frame, c || a), re.dispatchEvent({ type: K.type, data: K.inputSource }));
    }
    function V() {
      r.removeEventListener("select", G), r.removeEventListener("selectstart", G), r.removeEventListener("selectend", G), r.removeEventListener("squeeze", G), r.removeEventListener("squeezestart", G), r.removeEventListener("squeezeend", G), r.removeEventListener("end", V), r.removeEventListener("inputsourceschange", B);
      for (let K = 0; K < g.length; K++) {
        const Q = _[K];
        Q !== null && (_[K] = null, g[K].disconnect(Q));
      }
      R = null, q = null, b.reset(), e.setRenderTarget(f), m = null, d = null, h = null, r = null, x = null, je.stop(), n.isPresenting = !1, e.setPixelRatio(A), e.setSize(T.width, T.height, !1), n.dispatchEvent({ type: "sessionend" });
    }
    this.setFramebufferScaleFactor = function(K) {
      s = K, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.");
    }, this.setReferenceSpaceType = function(K) {
      o = K, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.");
    }, this.getReferenceSpace = function() {
      return c || a;
    }, this.setReferenceSpace = function(K) {
      c = K;
    }, this.getBaseLayer = function() {
      return d !== null ? d : m;
    }, this.getBinding = function() {
      return h;
    }, this.getFrame = function() {
      return v;
    }, this.getSession = function() {
      return r;
    }, this.setSession = async function(K) {
      if (r = K, r !== null) {
        if (f = e.getRenderTarget(), r.addEventListener("select", G), r.addEventListener("selectstart", G), r.addEventListener("selectend", G), r.addEventListener("squeeze", G), r.addEventListener("squeezestart", G), r.addEventListener("squeezeend", G), r.addEventListener("end", V), r.addEventListener("inputsourceschange", B), p.xrCompatible !== !0 && await t.makeXRCompatible(), A = e.getPixelRatio(), e.getSize(T), r.renderState.layers === void 0) {
          const Q = {
            antialias: p.antialias,
            alpha: !0,
            depth: p.depth,
            stencil: p.stencil,
            framebufferScaleFactor: s
          };
          m = new XRWebGLLayer(r, t, Q), r.updateRenderState({ baseLayer: m }), e.setPixelRatio(1), e.setSize(m.framebufferWidth, m.framebufferHeight, !1), x = new Xi(
            m.framebufferWidth,
            m.framebufferHeight,
            {
              format: _n,
              type: ai,
              colorSpace: e.outputColorSpace,
              stencilBuffer: p.stencil
            }
          );
        } else {
          let Q = null, re = null, ne = null;
          p.depth && (ne = p.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, Q = p.stencil ? Ir : Er, re = p.stencil ? Lr : Wi);
          const he = {
            colorFormat: t.RGBA8,
            depthFormat: ne,
            scaleFactor: s
          };
          h = new XRWebGLBinding(r, t), d = h.createProjectionLayer(he), r.updateRenderState({ layers: [d] }), e.setPixelRatio(1), e.setSize(d.textureWidth, d.textureHeight, !1), x = new Xi(
            d.textureWidth,
            d.textureHeight,
            {
              format: _n,
              type: ai,
              depthTexture: new Zd(d.textureWidth, d.textureHeight, re, void 0, void 0, void 0, void 0, void 0, void 0, Q),
              stencilBuffer: p.stencil,
              colorSpace: e.outputColorSpace,
              samples: p.antialias ? 4 : 0,
              resolveDepthBuffer: d.ignoreDepthValues === !1
            }
          );
        }
        x.isXRRenderTarget = !0, this.setFoveation(l), c = null, a = await r.requestReferenceSpace(o), je.setContext(r), je.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" });
      }
    }, this.getEnvironmentBlendMode = function() {
      if (r !== null)
        return r.environmentBlendMode;
    }, this.getDepthTexture = function() {
      return b.getDepthTexture();
    };
    function B(K) {
      for (let Q = 0; Q < K.removed.length; Q++) {
        const re = K.removed[Q], ne = _.indexOf(re);
        ne >= 0 && (_[ne] = null, g[ne].disconnect(re));
      }
      for (let Q = 0; Q < K.added.length; Q++) {
        const re = K.added[Q];
        let ne = _.indexOf(re);
        if (ne === -1) {
          for (let me = 0; me < g.length; me++)
            if (me >= _.length) {
              _.push(re), ne = me;
              break;
            } else if (_[me] === null) {
              _[me] = re, ne = me;
              break;
            }
          if (ne === -1) break;
        }
        const he = g[ne];
        he && he.connect(re);
      }
    }
    const U = new L(), Y = new L();
    function z(K, Q, re) {
      U.setFromMatrixPosition(Q.matrixWorld), Y.setFromMatrixPosition(re.matrixWorld);
      const ne = U.distanceTo(Y), he = Q.projectionMatrix.elements, me = re.projectionMatrix.elements, we = he[14] / (he[10] - 1), qe = he[14] / (he[10] + 1), Pe = (he[9] + 1) / he[5], Je = (he[9] - 1) / he[5], F = (he[8] - 1) / he[0], Gt = (me[8] + 1) / me[0], $e = we * F, Ze = we * Gt, Le = ne / (-F + Gt), ht = Le * -F;
      if (Q.matrixWorld.decompose(K.position, K.quaternion, K.scale), K.translateX(ht), K.translateZ(Le), K.matrixWorld.compose(K.position, K.quaternion, K.scale), K.matrixWorldInverse.copy(K.matrixWorld).invert(), he[10] === -1)
        K.projectionMatrix.copy(Q.projectionMatrix), K.projectionMatrixInverse.copy(Q.projectionMatrixInverse);
      else {
        const Ie = we + Le, D = qe + Le, S = $e - ht, k = Ze + (ne - ht), J = Pe * qe / D * Ie, te = Je * qe / D * Ie;
        K.projectionMatrix.makePerspective(S, k, J, te, Ie, D), K.projectionMatrixInverse.copy(K.projectionMatrix).invert();
      }
    }
    function ie(K, Q) {
      Q === null ? K.matrixWorld.copy(K.matrix) : K.matrixWorld.multiplyMatrices(Q.matrixWorld, K.matrix), K.matrixWorldInverse.copy(K.matrixWorld).invert();
    }
    this.updateCamera = function(K) {
      if (r === null) return;
      let Q = K.near, re = K.far;
      b.texture !== null && (b.depthNear > 0 && (Q = b.depthNear), b.depthFar > 0 && (re = b.depthFar)), E.near = C.near = M.near = Q, E.far = C.far = M.far = re, (R !== E.near || q !== E.far) && (r.updateRenderState({
        depthNear: E.near,
        depthFar: E.far
      }), R = E.near, q = E.far), M.layers.mask = K.layers.mask | 2, C.layers.mask = K.layers.mask | 4, E.layers.mask = M.layers.mask | C.layers.mask;
      const ne = K.parent, he = E.cameras;
      ie(E, ne);
      for (let me = 0; me < he.length; me++)
        ie(he[me], ne);
      he.length === 2 ? z(E, M, C) : E.projectionMatrix.copy(M.projectionMatrix), oe(K, E, ne);
    };
    function oe(K, Q, re) {
      re === null ? K.matrix.copy(Q.matrixWorld) : (K.matrix.copy(re.matrixWorld), K.matrix.invert(), K.matrix.multiply(Q.matrixWorld)), K.matrix.decompose(K.position, K.quaternion, K.scale), K.updateMatrixWorld(!0), K.projectionMatrix.copy(Q.projectionMatrix), K.projectionMatrixInverse.copy(Q.projectionMatrixInverse), K.isPerspectiveCamera && (K.fov = Fr * 2 * Math.atan(1 / K.projectionMatrix.elements[5]), K.zoom = 1);
    }
    this.getCamera = function() {
      return E;
    }, this.getFoveation = function() {
      if (!(d === null && m === null))
        return l;
    }, this.setFoveation = function(K) {
      l = K, d !== null && (d.fixedFoveation = K), m !== null && m.fixedFoveation !== void 0 && (m.fixedFoveation = K);
    }, this.hasDepthSensing = function() {
      return b.texture !== null;
    }, this.getDepthSensingMesh = function() {
      return b.getMesh(E);
    };
    let ce = null;
    function ye(K, Q) {
      if (u = Q.getViewerPose(c || a), v = Q, u !== null) {
        const re = u.views;
        m !== null && (e.setRenderTargetFramebuffer(x, m.framebuffer), e.setRenderTarget(x));
        let ne = !1;
        re.length !== E.cameras.length && (E.cameras.length = 0, ne = !0);
        for (let me = 0; me < re.length; me++) {
          const we = re[me];
          let qe = null;
          if (m !== null)
            qe = m.getViewport(we);
          else {
            const Je = h.getViewSubImage(d, we);
            qe = Je.viewport, me === 0 && (e.setRenderTargetTextures(
              x,
              Je.colorTexture,
              d.ignoreDepthValues ? void 0 : Je.depthStencilTexture
            ), e.setRenderTarget(x));
          }
          let Pe = y[me];
          Pe === void 0 && (Pe = new $t(), Pe.layers.enable(me), Pe.viewport = new lt(), y[me] = Pe), Pe.matrix.fromArray(we.transform.matrix), Pe.matrix.decompose(Pe.position, Pe.quaternion, Pe.scale), Pe.projectionMatrix.fromArray(we.projectionMatrix), Pe.projectionMatrixInverse.copy(Pe.projectionMatrix).invert(), Pe.viewport.set(qe.x, qe.y, qe.width, qe.height), me === 0 && (E.matrix.copy(Pe.matrix), E.matrix.decompose(E.position, E.quaternion, E.scale)), ne === !0 && E.cameras.push(Pe);
        }
        const he = r.enabledFeatures;
        if (he && he.includes("depth-sensing")) {
          const me = h.getDepthInformation(re[0]);
          me && me.isValid && me.texture && b.init(e, me, r.renderState);
        }
      }
      for (let re = 0; re < g.length; re++) {
        const ne = _[re], he = g[re];
        ne !== null && he !== void 0 && he.update(ne, Q, c || a);
      }
      ce && ce(K, Q), Q.detectedPlanes && n.dispatchEvent({ type: "planesdetected", data: Q }), v = null;
    }
    const je = new Yd();
    je.setAnimationLoop(ye), this.setAnimationLoop = function(K) {
      ce = K;
    }, this.dispose = function() {
    };
  }
}
const Li = /* @__PURE__ */ new Hn(), KS = /* @__PURE__ */ new Xe();
function $S(i, e) {
  function t(p, f) {
    p.matrixAutoUpdate === !0 && p.updateMatrix(), f.value.copy(p.matrix);
  }
  function n(p, f) {
    f.color.getRGB(p.fogColor.value, Xd(i)), f.isFog ? (p.fogNear.value = f.near, p.fogFar.value = f.far) : f.isFogExp2 && (p.fogDensity.value = f.density);
  }
  function r(p, f, x, g, _) {
    f.isMeshBasicMaterial || f.isMeshLambertMaterial ? s(p, f) : f.isMeshToonMaterial ? (s(p, f), h(p, f)) : f.isMeshPhongMaterial ? (s(p, f), u(p, f)) : f.isMeshStandardMaterial ? (s(p, f), d(p, f), f.isMeshPhysicalMaterial && m(p, f, _)) : f.isMeshMatcapMaterial ? (s(p, f), v(p, f)) : f.isMeshDepthMaterial ? s(p, f) : f.isMeshDistanceMaterial ? (s(p, f), b(p, f)) : f.isMeshNormalMaterial ? s(p, f) : f.isLineBasicMaterial ? (a(p, f), f.isLineDashedMaterial && o(p, f)) : f.isPointsMaterial ? l(p, f, x, g) : f.isSpriteMaterial ? c(p, f) : f.isShadowMaterial ? (p.color.value.copy(f.color), p.opacity.value = f.opacity) : f.isShaderMaterial && (f.uniformsNeedUpdate = !1);
  }
  function s(p, f) {
    p.opacity.value = f.opacity, f.color && p.diffuse.value.copy(f.color), f.emissive && p.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity), f.map && (p.map.value = f.map, t(f.map, p.mapTransform)), f.alphaMap && (p.alphaMap.value = f.alphaMap, t(f.alphaMap, p.alphaMapTransform)), f.bumpMap && (p.bumpMap.value = f.bumpMap, t(f.bumpMap, p.bumpMapTransform), p.bumpScale.value = f.bumpScale, f.side === sn && (p.bumpScale.value *= -1)), f.normalMap && (p.normalMap.value = f.normalMap, t(f.normalMap, p.normalMapTransform), p.normalScale.value.copy(f.normalScale), f.side === sn && p.normalScale.value.negate()), f.displacementMap && (p.displacementMap.value = f.displacementMap, t(f.displacementMap, p.displacementMapTransform), p.displacementScale.value = f.displacementScale, p.displacementBias.value = f.displacementBias), f.emissiveMap && (p.emissiveMap.value = f.emissiveMap, t(f.emissiveMap, p.emissiveMapTransform)), f.specularMap && (p.specularMap.value = f.specularMap, t(f.specularMap, p.specularMapTransform)), f.alphaTest > 0 && (p.alphaTest.value = f.alphaTest);
    const x = e.get(f), g = x.envMap, _ = x.envMapRotation;
    g && (p.envMap.value = g, Li.copy(_), Li.x *= -1, Li.y *= -1, Li.z *= -1, g.isCubeTexture && g.isRenderTargetTexture === !1 && (Li.y *= -1, Li.z *= -1), p.envMapRotation.value.setFromMatrix4(KS.makeRotationFromEuler(Li)), p.flipEnvMap.value = g.isCubeTexture && g.isRenderTargetTexture === !1 ? -1 : 1, p.reflectivity.value = f.reflectivity, p.ior.value = f.ior, p.refractionRatio.value = f.refractionRatio), f.lightMap && (p.lightMap.value = f.lightMap, p.lightMapIntensity.value = f.lightMapIntensity, t(f.lightMap, p.lightMapTransform)), f.aoMap && (p.aoMap.value = f.aoMap, p.aoMapIntensity.value = f.aoMapIntensity, t(f.aoMap, p.aoMapTransform));
  }
  function a(p, f) {
    p.diffuse.value.copy(f.color), p.opacity.value = f.opacity, f.map && (p.map.value = f.map, t(f.map, p.mapTransform));
  }
  function o(p, f) {
    p.dashSize.value = f.dashSize, p.totalSize.value = f.dashSize + f.gapSize, p.scale.value = f.scale;
  }
  function l(p, f, x, g) {
    p.diffuse.value.copy(f.color), p.opacity.value = f.opacity, p.size.value = f.size * x, p.scale.value = g * 0.5, f.map && (p.map.value = f.map, t(f.map, p.uvTransform)), f.alphaMap && (p.alphaMap.value = f.alphaMap, t(f.alphaMap, p.alphaMapTransform)), f.alphaTest > 0 && (p.alphaTest.value = f.alphaTest);
  }
  function c(p, f) {
    p.diffuse.value.copy(f.color), p.opacity.value = f.opacity, p.rotation.value = f.rotation, f.map && (p.map.value = f.map, t(f.map, p.mapTransform)), f.alphaMap && (p.alphaMap.value = f.alphaMap, t(f.alphaMap, p.alphaMapTransform)), f.alphaTest > 0 && (p.alphaTest.value = f.alphaTest);
  }
  function u(p, f) {
    p.specular.value.copy(f.specular), p.shininess.value = Math.max(f.shininess, 1e-4);
  }
  function h(p, f) {
    f.gradientMap && (p.gradientMap.value = f.gradientMap);
  }
  function d(p, f) {
    p.metalness.value = f.metalness, f.metalnessMap && (p.metalnessMap.value = f.metalnessMap, t(f.metalnessMap, p.metalnessMapTransform)), p.roughness.value = f.roughness, f.roughnessMap && (p.roughnessMap.value = f.roughnessMap, t(f.roughnessMap, p.roughnessMapTransform)), f.envMap && (p.envMapIntensity.value = f.envMapIntensity);
  }
  function m(p, f, x) {
    p.ior.value = f.ior, f.sheen > 0 && (p.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen), p.sheenRoughness.value = f.sheenRoughness, f.sheenColorMap && (p.sheenColorMap.value = f.sheenColorMap, t(f.sheenColorMap, p.sheenColorMapTransform)), f.sheenRoughnessMap && (p.sheenRoughnessMap.value = f.sheenRoughnessMap, t(f.sheenRoughnessMap, p.sheenRoughnessMapTransform))), f.clearcoat > 0 && (p.clearcoat.value = f.clearcoat, p.clearcoatRoughness.value = f.clearcoatRoughness, f.clearcoatMap && (p.clearcoatMap.value = f.clearcoatMap, t(f.clearcoatMap, p.clearcoatMapTransform)), f.clearcoatRoughnessMap && (p.clearcoatRoughnessMap.value = f.clearcoatRoughnessMap, t(f.clearcoatRoughnessMap, p.clearcoatRoughnessMapTransform)), f.clearcoatNormalMap && (p.clearcoatNormalMap.value = f.clearcoatNormalMap, t(f.clearcoatNormalMap, p.clearcoatNormalMapTransform), p.clearcoatNormalScale.value.copy(f.clearcoatNormalScale), f.side === sn && p.clearcoatNormalScale.value.negate())), f.dispersion > 0 && (p.dispersion.value = f.dispersion), f.iridescence > 0 && (p.iridescence.value = f.iridescence, p.iridescenceIOR.value = f.iridescenceIOR, p.iridescenceThicknessMinimum.value = f.iridescenceThicknessRange[0], p.iridescenceThicknessMaximum.value = f.iridescenceThicknessRange[1], f.iridescenceMap && (p.iridescenceMap.value = f.iridescenceMap, t(f.iridescenceMap, p.iridescenceMapTransform)), f.iridescenceThicknessMap && (p.iridescenceThicknessMap.value = f.iridescenceThicknessMap, t(f.iridescenceThicknessMap, p.iridescenceThicknessMapTransform))), f.transmission > 0 && (p.transmission.value = f.transmission, p.transmissionSamplerMap.value = x.texture, p.transmissionSamplerSize.value.set(x.width, x.height), f.transmissionMap && (p.transmissionMap.value = f.transmissionMap, t(f.transmissionMap, p.transmissionMapTransform)), p.thickness.value = f.thickness, f.thicknessMap && (p.thicknessMap.value = f.thicknessMap, t(f.thicknessMap, p.thicknessMapTransform)), p.attenuationDistance.value = f.attenuationDistance, p.attenuationColor.value.copy(f.attenuationColor)), f.anisotropy > 0 && (p.anisotropyVector.value.set(f.anisotropy * Math.cos(f.anisotropyRotation), f.anisotropy * Math.sin(f.anisotropyRotation)), f.anisotropyMap && (p.anisotropyMap.value = f.anisotropyMap, t(f.anisotropyMap, p.anisotropyMapTransform))), p.specularIntensity.value = f.specularIntensity, p.specularColor.value.copy(f.specularColor), f.specularColorMap && (p.specularColorMap.value = f.specularColorMap, t(f.specularColorMap, p.specularColorMapTransform)), f.specularIntensityMap && (p.specularIntensityMap.value = f.specularIntensityMap, t(f.specularIntensityMap, p.specularIntensityMapTransform));
  }
  function v(p, f) {
    f.matcap && (p.matcap.value = f.matcap);
  }
  function b(p, f) {
    const x = e.get(f).light;
    p.referencePosition.value.setFromMatrixPosition(x.matrixWorld), p.nearDistance.value = x.shadow.camera.near, p.farDistance.value = x.shadow.camera.far;
  }
  return {
    refreshFogUniforms: n,
    refreshMaterialUniforms: r
  };
}
function JS(i, e, t, n) {
  let r = {}, s = {}, a = [];
  const o = i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);
  function l(x, g) {
    const _ = g.program;
    n.uniformBlockBinding(x, _);
  }
  function c(x, g) {
    let _ = r[x.id];
    _ === void 0 && (v(x), _ = u(x), r[x.id] = _, x.addEventListener("dispose", p));
    const T = g.program;
    n.updateUBOMapping(x, T);
    const A = e.render.frame;
    s[x.id] !== A && (d(x), s[x.id] = A);
  }
  function u(x) {
    const g = h();
    x.__bindingPointIndex = g;
    const _ = i.createBuffer(), T = x.__size, A = x.usage;
    return i.bindBuffer(i.UNIFORM_BUFFER, _), i.bufferData(i.UNIFORM_BUFFER, T, A), i.bindBuffer(i.UNIFORM_BUFFER, null), i.bindBufferBase(i.UNIFORM_BUFFER, g, _), _;
  }
  function h() {
    for (let x = 0; x < o; x++)
      if (a.indexOf(x) === -1)
        return a.push(x), x;
    return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0;
  }
  function d(x) {
    const g = r[x.id], _ = x.uniforms, T = x.__cache;
    i.bindBuffer(i.UNIFORM_BUFFER, g);
    for (let A = 0, M = _.length; A < M; A++) {
      const C = Array.isArray(_[A]) ? _[A] : [_[A]];
      for (let y = 0, E = C.length; y < E; y++) {
        const R = C[y];
        if (m(R, A, y, T) === !0) {
          const q = R.__offset, G = Array.isArray(R.value) ? R.value : [R.value];
          let V = 0;
          for (let B = 0; B < G.length; B++) {
            const U = G[B], Y = b(U);
            typeof U == "number" || typeof U == "boolean" ? (R.__data[0] = U, i.bufferSubData(i.UNIFORM_BUFFER, q + V, R.__data)) : U.isMatrix3 ? (R.__data[0] = U.elements[0], R.__data[1] = U.elements[1], R.__data[2] = U.elements[2], R.__data[3] = 0, R.__data[4] = U.elements[3], R.__data[5] = U.elements[4], R.__data[6] = U.elements[5], R.__data[7] = 0, R.__data[8] = U.elements[6], R.__data[9] = U.elements[7], R.__data[10] = U.elements[8], R.__data[11] = 0) : (U.toArray(R.__data, V), V += Y.storage / Float32Array.BYTES_PER_ELEMENT);
          }
          i.bufferSubData(i.UNIFORM_BUFFER, q, R.__data);
        }
      }
    }
    i.bindBuffer(i.UNIFORM_BUFFER, null);
  }
  function m(x, g, _, T) {
    const A = x.value, M = g + "_" + _;
    if (T[M] === void 0)
      return typeof A == "number" || typeof A == "boolean" ? T[M] = A : T[M] = A.clone(), !0;
    {
      const C = T[M];
      if (typeof A == "number" || typeof A == "boolean") {
        if (C !== A)
          return T[M] = A, !0;
      } else if (C.equals(A) === !1)
        return C.copy(A), !0;
    }
    return !1;
  }
  function v(x) {
    const g = x.uniforms;
    let _ = 0;
    const T = 16;
    for (let M = 0, C = g.length; M < C; M++) {
      const y = Array.isArray(g[M]) ? g[M] : [g[M]];
      for (let E = 0, R = y.length; E < R; E++) {
        const q = y[E], G = Array.isArray(q.value) ? q.value : [q.value];
        for (let V = 0, B = G.length; V < B; V++) {
          const U = G[V], Y = b(U), z = _ % T, ie = z % Y.boundary, oe = z + ie;
          _ += ie, oe !== 0 && T - oe < Y.storage && (_ += T - oe), q.__data = new Float32Array(Y.storage / Float32Array.BYTES_PER_ELEMENT), q.__offset = _, _ += Y.storage;
        }
      }
    }
    const A = _ % T;
    return A > 0 && (_ += T - A), x.__size = _, x.__cache = {}, this;
  }
  function b(x) {
    const g = {
      boundary: 0,
      // bytes
      storage: 0
      // bytes
    };
    return typeof x == "number" || typeof x == "boolean" ? (g.boundary = 4, g.storage = 4) : x.isVector2 ? (g.boundary = 8, g.storage = 8) : x.isVector3 || x.isColor ? (g.boundary = 16, g.storage = 12) : x.isVector4 ? (g.boundary = 16, g.storage = 16) : x.isMatrix3 ? (g.boundary = 48, g.storage = 48) : x.isMatrix4 ? (g.boundary = 64, g.storage = 64) : x.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", x), g;
  }
  function p(x) {
    const g = x.target;
    g.removeEventListener("dispose", p);
    const _ = a.indexOf(g.__bindingPointIndex);
    a.splice(_, 1), i.deleteBuffer(r[g.id]), delete r[g.id], delete s[g.id];
  }
  function f() {
    for (const x in r)
      i.deleteBuffer(r[x]);
    a = [], r = {}, s = {};
  }
  return {
    bind: l,
    update: c,
    dispose: f
  };
}
class QS {
  constructor(e = {}) {
    const {
      canvas: t = zv(),
      context: n = null,
      depth: r = !0,
      stencil: s = !1,
      alpha: a = !1,
      antialias: o = !1,
      premultipliedAlpha: l = !0,
      preserveDrawingBuffer: c = !1,
      powerPreference: u = "default",
      failIfMajorPerformanceCaveat: h = !1,
      reverseDepthBuffer: d = !1
    } = e;
    this.isWebGLRenderer = !0;
    let m;
    if (n !== null) {
      if (typeof WebGLRenderingContext < "u" && n instanceof WebGLRenderingContext)
        throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");
      m = n.getContextAttributes().alpha;
    } else
      m = a;
    const v = new Uint32Array(4), b = new Int32Array(4);
    let p = null, f = null;
    const x = [], g = [];
    this.domElement = t, this.debug = {
      /**
       * Enables error checking and reporting when shader programs are being compiled
       * @type {boolean}
       */
      checkShaderErrors: !0,
      /**
       * Callback for custom error reporting.
       * @type {?Function}
       */
      onShaderError: null
    }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this._outputColorSpace = Ut, this.toneMapping = Ai, this.toneMappingExposure = 1;
    const _ = this;
    let T = !1, A = 0, M = 0, C = null, y = -1, E = null;
    const R = new lt(), q = new lt();
    let G = null;
    const V = new Ue(0);
    let B = 0, U = t.width, Y = t.height, z = 1, ie = null, oe = null;
    const ce = new lt(0, 0, U, Y), ye = new lt(0, 0, U, Y);
    let je = !1;
    const K = new Pc();
    let Q = !1, re = !1;
    const ne = new Xe(), he = new Xe(), me = new L(), we = new lt(), qe = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 };
    let Pe = !1;
    function Je() {
      return C === null ? z : 1;
    }
    let F = n;
    function Gt(w, N) {
      return t.getContext(w, N);
    }
    try {
      const w = {
        alpha: !0,
        depth: r,
        stencil: s,
        antialias: o,
        premultipliedAlpha: l,
        preserveDrawingBuffer: c,
        powerPreference: u,
        failIfMajorPerformanceCaveat: h
      };
      if ("setAttribute" in t && t.setAttribute("data-engine", `three.js r${yc}`), t.addEventListener("webglcontextlost", ee, !1), t.addEventListener("webglcontextrestored", H, !1), t.addEventListener("webglcontextcreationerror", X, !1), F === null) {
        const N = "webgl2";
        if (F = Gt(N, w), F === null)
          throw Gt(N) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context.");
      }
    } catch (w) {
      throw console.error("THREE.WebGLRenderer: " + w.message), w;
    }
    let $e, Ze, Le, ht, Ie, D, S, k, J, te, $, be, fe, ge, He, se, _e, Re, Ce, pe, Be, Oe, et, I;
    function ue() {
      $e = new ry(F), $e.init(), Oe = new VS(F, $e), Ze = new JE(F, $e, e, Oe), Le = new HS(F, $e), Ze.reverseDepthBuffer && d && Le.buffers.depth.setReversed(!0), ht = new oy(F), Ie = new AS(), D = new GS(F, $e, Le, Ie, Ze, Oe, ht), S = new ey(_), k = new iy(_), J = new px(F), et = new KE(F, J), te = new sy(F, J, ht, et), $ = new cy(F, te, J, ht), Ce = new ly(F, Ze, D), se = new QE(Ie), be = new MS(_, S, k, $e, Ze, et, se), fe = new $S(_, Ie), ge = new wS(), He = new IS($e), Re = new ZE(_, S, k, Le, $, m, l), _e = new BS(_, $, Ze), I = new JS(F, ht, Ze, Le), pe = new $E(F, $e, ht), Be = new ay(F, $e, ht), ht.programs = be.programs, _.capabilities = Ze, _.extensions = $e, _.properties = Ie, _.renderLists = ge, _.shadowMap = _e, _.state = Le, _.info = ht;
    }
    ue();
    const Z = new ZS(_, F);
    this.xr = Z, this.getContext = function() {
      return F;
    }, this.getContextAttributes = function() {
      return F.getContextAttributes();
    }, this.forceContextLoss = function() {
      const w = $e.get("WEBGL_lose_context");
      w && w.loseContext();
    }, this.forceContextRestore = function() {
      const w = $e.get("WEBGL_lose_context");
      w && w.restoreContext();
    }, this.getPixelRatio = function() {
      return z;
    }, this.setPixelRatio = function(w) {
      w !== void 0 && (z = w, this.setSize(U, Y, !1));
    }, this.getSize = function(w) {
      return w.set(U, Y);
    }, this.setSize = function(w, N, W = !0) {
      if (Z.isPresenting) {
        console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
        return;
      }
      U = w, Y = N, t.width = Math.floor(w * z), t.height = Math.floor(N * z), W === !0 && (t.style.width = w + "px", t.style.height = N + "px"), this.setViewport(0, 0, w, N);
    }, this.getDrawingBufferSize = function(w) {
      return w.set(U * z, Y * z).floor();
    }, this.setDrawingBufferSize = function(w, N, W) {
      U = w, Y = N, z = W, t.width = Math.floor(w * W), t.height = Math.floor(N * W), this.setViewport(0, 0, w, N);
    }, this.getCurrentViewport = function(w) {
      return w.copy(R);
    }, this.getViewport = function(w) {
      return w.copy(ce);
    }, this.setViewport = function(w, N, W, j) {
      w.isVector4 ? ce.set(w.x, w.y, w.z, w.w) : ce.set(w, N, W, j), Le.viewport(R.copy(ce).multiplyScalar(z).round());
    }, this.getScissor = function(w) {
      return w.copy(ye);
    }, this.setScissor = function(w, N, W, j) {
      w.isVector4 ? ye.set(w.x, w.y, w.z, w.w) : ye.set(w, N, W, j), Le.scissor(q.copy(ye).multiplyScalar(z).round());
    }, this.getScissorTest = function() {
      return je;
    }, this.setScissorTest = function(w) {
      Le.setScissorTest(je = w);
    }, this.setOpaqueSort = function(w) {
      ie = w;
    }, this.setTransparentSort = function(w) {
      oe = w;
    }, this.getClearColor = function(w) {
      return w.copy(Re.getClearColor());
    }, this.setClearColor = function() {
      Re.setClearColor.apply(Re, arguments);
    }, this.getClearAlpha = function() {
      return Re.getClearAlpha();
    }, this.setClearAlpha = function() {
      Re.setClearAlpha.apply(Re, arguments);
    }, this.clear = function(w = !0, N = !0, W = !0) {
      let j = 0;
      if (w) {
        let O = !1;
        if (C !== null) {
          const le = C.texture.format;
          O = le === Rc || le === Dc || le === wc;
        }
        if (O) {
          const le = C.texture.type, ve = le === ai || le === Wi || le === bs || le === Lr || le === Mc || le === Ac, Se = Re.getClearColor(), Me = Re.getClearAlpha(), Ge = Se.r, Ve = Se.g, Ae = Se.b;
          ve ? (v[0] = Ge, v[1] = Ve, v[2] = Ae, v[3] = Me, F.clearBufferuiv(F.COLOR, 0, v)) : (b[0] = Ge, b[1] = Ve, b[2] = Ae, b[3] = Me, F.clearBufferiv(F.COLOR, 0, b));
        } else
          j |= F.COLOR_BUFFER_BIT;
      }
      N && (j |= F.DEPTH_BUFFER_BIT), W && (j |= F.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), F.clear(j);
    }, this.clearColor = function() {
      this.clear(!0, !1, !1);
    }, this.clearDepth = function() {
      this.clear(!1, !0, !1);
    }, this.clearStencil = function() {
      this.clear(!1, !1, !0);
    }, this.dispose = function() {
      t.removeEventListener("webglcontextlost", ee, !1), t.removeEventListener("webglcontextrestored", H, !1), t.removeEventListener("webglcontextcreationerror", X, !1), ge.dispose(), He.dispose(), Ie.dispose(), S.dispose(), k.dispose(), $.dispose(), et.dispose(), I.dispose(), be.dispose(), Z.dispose(), Z.removeEventListener("sessionstart", Et), Z.removeEventListener("sessionend", It), xt.stop();
    };
    function ee(w) {
      w.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), T = !0;
    }
    function H() {
      console.log("THREE.WebGLRenderer: Context Restored."), T = !1;
      const w = ht.autoReset, N = _e.enabled, W = _e.autoUpdate, j = _e.needsUpdate, O = _e.type;
      ue(), ht.autoReset = w, _e.enabled = N, _e.autoUpdate = W, _e.needsUpdate = j, _e.type = O;
    }
    function X(w) {
      console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", w.statusMessage);
    }
    function ae(w) {
      const N = w.target;
      N.removeEventListener("dispose", ae), xe(N);
    }
    function xe(w) {
      Ne(w), Ie.remove(w);
    }
    function Ne(w) {
      const N = Ie.get(w).programs;
      N !== void 0 && (N.forEach(function(W) {
        be.releaseProgram(W);
      }), w.isShaderMaterial && be.releaseShaderCache(w));
    }
    this.renderBufferDirect = function(w, N, W, j, O, le) {
      N === null && (N = qe);
      const ve = O.isMesh && O.matrixWorld.determinant() < 0, Se = up(w, N, W, j, O);
      Le.setMaterial(j, ve);
      let Me = W.index, Ge = 1;
      if (j.wireframe === !0) {
        if (Me = te.getWireframeAttribute(W), Me === void 0) return;
        Ge = 2;
      }
      const Ve = W.drawRange, Ae = W.attributes.position;
      let at = Ve.start * Ge, bt = (Ve.start + Ve.count) * Ge;
      le !== null && (at = Math.max(at, le.start * Ge), bt = Math.min(bt, (le.start + le.count) * Ge)), Me !== null ? (at = Math.max(at, 0), bt = Math.min(bt, Me.count)) : Ae != null && (at = Math.max(at, 0), bt = Math.min(bt, Ae.count));
      const yt = bt - at;
      if (yt < 0 || yt === 1 / 0) return;
      et.setup(O, j, Se, W, Me);
      let tn, ct = pe;
      if (Me !== null && (tn = J.get(Me), ct = Be, ct.setIndex(tn)), O.isMesh)
        j.wireframe === !0 ? (Le.setLineWidth(j.wireframeLinewidth * Je()), ct.setMode(F.LINES)) : ct.setMode(F.TRIANGLES);
      else if (O.isLine) {
        let De = j.linewidth;
        De === void 0 && (De = 1), Le.setLineWidth(De * Je()), O.isLineSegments ? ct.setMode(F.LINES) : O.isLineLoop ? ct.setMode(F.LINE_LOOP) : ct.setMode(F.LINE_STRIP);
      } else O.isPoints ? ct.setMode(F.POINTS) : O.isSprite && ct.setMode(F.TRIANGLES);
      if (O.isBatchedMesh)
        if (O._multiDrawInstances !== null)
          ct.renderMultiDrawInstances(O._multiDrawStarts, O._multiDrawCounts, O._multiDrawCount, O._multiDrawInstances);
        else if ($e.get("WEBGL_multi_draw"))
          ct.renderMultiDraw(O._multiDrawStarts, O._multiDrawCounts, O._multiDrawCount);
        else {
          const De = O._multiDrawStarts, Wn = O._multiDrawCounts, ut = O._multiDrawCount, xn = Me ? J.get(Me).bytesPerElement : 1, $i = Ie.get(j).currentProgram.getUniforms();
          for (let an = 0; an < ut; an++)
            $i.setValue(F, "_gl_DrawID", an), ct.render(De[an] / xn, Wn[an]);
        }
      else if (O.isInstancedMesh)
        ct.renderInstances(at, yt, O.count);
      else if (W.isInstancedBufferGeometry) {
        const De = W._maxInstanceCount !== void 0 ? W._maxInstanceCount : 1 / 0, Wn = Math.min(W.instanceCount, De);
        ct.renderInstances(at, yt, Wn);
      } else
        ct.render(at, yt);
    };
    function Fe(w, N, W) {
      w.transparent === !0 && w.side === Fn && w.forceSinglePass === !1 ? (w.side = sn, w.needsUpdate = !0, Ns(w, N, W), w.side = si, w.needsUpdate = !0, Ns(w, N, W), w.side = Fn) : Ns(w, N, W);
    }
    this.compile = function(w, N, W = null) {
      W === null && (W = w), f = He.get(W), f.init(N), g.push(f), W.traverseVisible(function(O) {
        O.isLight && O.layers.test(N.layers) && (f.pushLight(O), O.castShadow && f.pushShadow(O));
      }), w !== W && w.traverseVisible(function(O) {
        O.isLight && O.layers.test(N.layers) && (f.pushLight(O), O.castShadow && f.pushShadow(O));
      }), f.setupLights();
      const j = /* @__PURE__ */ new Set();
      return w.traverse(function(O) {
        if (!(O.isMesh || O.isPoints || O.isLine || O.isSprite))
          return;
        const le = O.material;
        if (le)
          if (Array.isArray(le))
            for (let ve = 0; ve < le.length; ve++) {
              const Se = le[ve];
              Fe(Se, W, O), j.add(Se);
            }
          else
            Fe(le, W, O), j.add(le);
      }), g.pop(), f = null, j;
    }, this.compileAsync = function(w, N, W = null) {
      const j = this.compile(w, N, W);
      return new Promise((O) => {
        function le() {
          if (j.forEach(function(ve) {
            Ie.get(ve).currentProgram.isReady() && j.delete(ve);
          }), j.size === 0) {
            O(w);
            return;
          }
          setTimeout(le, 10);
        }
        $e.get("KHR_parallel_shader_compile") !== null ? le() : setTimeout(le, 10);
      });
    };
    let ke = null;
    function it(w) {
      ke && ke(w);
    }
    function Et() {
      xt.stop();
    }
    function It() {
      xt.start();
    }
    const xt = new Yd();
    xt.setAnimationLoop(it), typeof self < "u" && xt.setContext(self), this.setAnimationLoop = function(w) {
      ke = w, Z.setAnimationLoop(w), w === null ? xt.stop() : xt.start();
    }, Z.addEventListener("sessionstart", Et), Z.addEventListener("sessionend", It), this.render = function(w, N) {
      if (N !== void 0 && N.isCamera !== !0) {
        console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
        return;
      }
      if (T === !0) return;
      if (w.matrixWorldAutoUpdate === !0 && w.updateMatrixWorld(), N.parent === null && N.matrixWorldAutoUpdate === !0 && N.updateMatrixWorld(), Z.enabled === !0 && Z.isPresenting === !0 && (Z.cameraAutoUpdate === !0 && Z.updateCamera(N), N = Z.getCamera()), w.isScene === !0 && w.onBeforeRender(_, w, N, C), f = He.get(w, g.length), f.init(N), g.push(f), he.multiplyMatrices(N.projectionMatrix, N.matrixWorldInverse), K.setFromProjectionMatrix(he), re = this.localClippingEnabled, Q = se.init(this.clippingPlanes, re), p = ge.get(w, x.length), p.init(), x.push(p), Z.enabled === !0 && Z.isPresenting === !0) {
        const le = _.xr.getDepthSensingMesh();
        le !== null && Cn(le, N, -1 / 0, _.sortObjects);
      }
      Cn(w, N, 0, _.sortObjects), p.finish(), _.sortObjects === !0 && p.sort(ie, oe), Pe = Z.enabled === !1 || Z.isPresenting === !1 || Z.hasDepthSensing() === !1, Pe && Re.addToRenderList(p, w), this.info.render.frame++, Q === !0 && se.beginShadows();
      const W = f.state.shadowsArray;
      _e.render(W, w, N), Q === !0 && se.endShadows(), this.info.autoReset === !0 && this.info.reset();
      const j = p.opaque, O = p.transmissive;
      if (f.setupLights(), N.isArrayCamera) {
        const le = N.cameras;
        if (O.length > 0)
          for (let ve = 0, Se = le.length; ve < Se; ve++) {
            const Me = le[ve];
            Yr(j, O, w, Me);
          }
        Pe && Re.render(w);
        for (let ve = 0, Se = le.length; ve < Se; ve++) {
          const Me = le[ve];
          Fs(p, w, Me, Me.viewport);
        }
      } else
        O.length > 0 && Yr(j, O, w, N), Pe && Re.render(w), Fs(p, w, N);
      C !== null && (D.updateMultisampleRenderTarget(C), D.updateRenderTargetMipmap(C)), w.isScene === !0 && w.onAfterRender(_, w, N), et.resetDefaultState(), y = -1, E = null, g.pop(), g.length > 0 ? (f = g[g.length - 1], Q === !0 && se.setGlobalState(_.clippingPlanes, f.state.camera)) : f = null, x.pop(), x.length > 0 ? p = x[x.length - 1] : p = null;
    };
    function Cn(w, N, W, j) {
      if (w.visible === !1) return;
      if (w.layers.test(N.layers)) {
        if (w.isGroup)
          W = w.renderOrder;
        else if (w.isLOD)
          w.autoUpdate === !0 && w.update(N);
        else if (w.isLight)
          f.pushLight(w), w.castShadow && f.pushShadow(w);
        else if (w.isSprite) {
          if (!w.frustumCulled || K.intersectsSprite(w)) {
            j && we.setFromMatrixPosition(w.matrixWorld).applyMatrix4(he);
            const ve = $.update(w), Se = w.material;
            Se.visible && p.push(w, ve, Se, W, we.z, null);
          }
        } else if ((w.isMesh || w.isLine || w.isPoints) && (!w.frustumCulled || K.intersectsObject(w))) {
          const ve = $.update(w), Se = w.material;
          if (j && (w.boundingSphere !== void 0 ? (w.boundingSphere === null && w.computeBoundingSphere(), we.copy(w.boundingSphere.center)) : (ve.boundingSphere === null && ve.computeBoundingSphere(), we.copy(ve.boundingSphere.center)), we.applyMatrix4(w.matrixWorld).applyMatrix4(he)), Array.isArray(Se)) {
            const Me = ve.groups;
            for (let Ge = 0, Ve = Me.length; Ge < Ve; Ge++) {
              const Ae = Me[Ge], at = Se[Ae.materialIndex];
              at && at.visible && p.push(w, ve, at, W, we.z, Ae);
            }
          } else Se.visible && p.push(w, ve, Se, W, we.z, null);
        }
      }
      const le = w.children;
      for (let ve = 0, Se = le.length; ve < Se; ve++)
        Cn(le[ve], N, W, j);
    }
    function Fs(w, N, W, j) {
      const O = w.opaque, le = w.transmissive, ve = w.transparent;
      f.setupLightsView(W), Q === !0 && se.setGlobalState(_.clippingPlanes, W), j && Le.viewport(R.copy(j)), O.length > 0 && Ki(O, N, W), le.length > 0 && Ki(le, N, W), ve.length > 0 && Ki(ve, N, W), Le.buffers.depth.setTest(!0), Le.buffers.depth.setMask(!0), Le.buffers.color.setMask(!0), Le.setPolygonOffset(!1);
    }
    function Yr(w, N, W, j) {
      if ((W.isScene === !0 ? W.overrideMaterial : null) !== null)
        return;
      f.state.transmissionRenderTarget[j.id] === void 0 && (f.state.transmissionRenderTarget[j.id] = new Xi(1, 1, {
        generateMipmaps: !0,
        type: $e.has("EXT_color_buffer_half_float") || $e.has("EXT_color_buffer_float") ? Cs : ai,
        minFilter: ti,
        samples: 4,
        stencilBuffer: s,
        resolveDepthBuffer: !1,
        resolveStencilBuffer: !1,
        colorSpace: nt.workingColorSpace
      }));
      const le = f.state.transmissionRenderTarget[j.id], ve = j.viewport || R;
      le.setSize(ve.z, ve.w);
      const Se = _.getRenderTarget();
      _.setRenderTarget(le), _.getClearColor(V), B = _.getClearAlpha(), B < 1 && _.setClearColor(16777215, 0.5), _.clear(), Pe && Re.render(W);
      const Me = _.toneMapping;
      _.toneMapping = Ai;
      const Ge = j.viewport;
      if (j.viewport !== void 0 && (j.viewport = void 0), f.setupLightsView(j), Q === !0 && se.setGlobalState(_.clippingPlanes, j), Ki(w, W, j), D.updateMultisampleRenderTarget(le), D.updateRenderTargetMipmap(le), $e.has("WEBGL_multisampled_render_to_texture") === !1) {
        let Ve = !1;
        for (let Ae = 0, at = N.length; Ae < at; Ae++) {
          const bt = N[Ae], yt = bt.object, tn = bt.geometry, ct = bt.material, De = bt.group;
          if (ct.side === Fn && yt.layers.test(j.layers)) {
            const Wn = ct.side;
            ct.side = sn, ct.needsUpdate = !0, Vc(yt, W, j, tn, ct, De), ct.side = Wn, ct.needsUpdate = !0, Ve = !0;
          }
        }
        Ve === !0 && (D.updateMultisampleRenderTarget(le), D.updateRenderTargetMipmap(le));
      }
      _.setRenderTarget(Se), _.setClearColor(V, B), Ge !== void 0 && (j.viewport = Ge), _.toneMapping = Me;
    }
    function Ki(w, N, W) {
      const j = N.isScene === !0 ? N.overrideMaterial : null;
      for (let O = 0, le = w.length; O < le; O++) {
        const ve = w[O], Se = ve.object, Me = ve.geometry, Ge = j === null ? ve.material : j, Ve = ve.group;
        Se.layers.test(W.layers) && Vc(Se, N, W, Me, Ge, Ve);
      }
    }
    function Vc(w, N, W, j, O, le) {
      w.onBeforeRender(_, N, W, j, O, le), w.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse, w.matrixWorld), w.normalMatrix.getNormalMatrix(w.modelViewMatrix), O.onBeforeRender(_, N, W, j, w, le), O.transparent === !0 && O.side === Fn && O.forceSinglePass === !1 ? (O.side = sn, O.needsUpdate = !0, _.renderBufferDirect(W, N, j, O, w, le), O.side = si, O.needsUpdate = !0, _.renderBufferDirect(W, N, j, O, w, le), O.side = Fn) : _.renderBufferDirect(W, N, j, O, w, le), w.onAfterRender(_, N, W, j, O, le);
    }
    function Ns(w, N, W) {
      N.isScene !== !0 && (N = qe);
      const j = Ie.get(w), O = f.state.lights, le = f.state.shadowsArray, ve = O.state.version, Se = be.getParameters(w, O.state, le, N, W), Me = be.getProgramCacheKey(Se);
      let Ge = j.programs;
      j.environment = w.isMeshStandardMaterial ? N.environment : null, j.fog = N.fog, j.envMap = (w.isMeshStandardMaterial ? k : S).get(w.envMap || j.environment), j.envMapRotation = j.environment !== null && w.envMap === null ? N.environmentRotation : w.envMapRotation, Ge === void 0 && (w.addEventListener("dispose", ae), Ge = /* @__PURE__ */ new Map(), j.programs = Ge);
      let Ve = Ge.get(Me);
      if (Ve !== void 0) {
        if (j.currentProgram === Ve && j.lightsStateVersion === ve)
          return Xc(w, Se), Ve;
      } else
        Se.uniforms = be.getUniforms(w), w.onBeforeCompile(Se, _), Ve = be.acquireProgram(Se, Me), Ge.set(Me, Ve), j.uniforms = Se.uniforms;
      const Ae = j.uniforms;
      return (!w.isShaderMaterial && !w.isRawShaderMaterial || w.clipping === !0) && (Ae.clippingPlanes = se.uniform), Xc(w, Se), j.needsLights = fp(w), j.lightsStateVersion = ve, j.needsLights && (Ae.ambientLightColor.value = O.state.ambient, Ae.lightProbe.value = O.state.probe, Ae.directionalLights.value = O.state.directional, Ae.directionalLightShadows.value = O.state.directionalShadow, Ae.spotLights.value = O.state.spot, Ae.spotLightShadows.value = O.state.spotShadow, Ae.rectAreaLights.value = O.state.rectArea, Ae.ltc_1.value = O.state.rectAreaLTC1, Ae.ltc_2.value = O.state.rectAreaLTC2, Ae.pointLights.value = O.state.point, Ae.pointLightShadows.value = O.state.pointShadow, Ae.hemisphereLights.value = O.state.hemi, Ae.directionalShadowMap.value = O.state.directionalShadowMap, Ae.directionalShadowMatrix.value = O.state.directionalShadowMatrix, Ae.spotShadowMap.value = O.state.spotShadowMap, Ae.spotLightMatrix.value = O.state.spotLightMatrix, Ae.spotLightMap.value = O.state.spotLightMap, Ae.pointShadowMap.value = O.state.pointShadowMap, Ae.pointShadowMatrix.value = O.state.pointShadowMatrix), j.currentProgram = Ve, j.uniformsList = null, Ve;
    }
    function Wc(w) {
      if (w.uniformsList === null) {
        const N = w.currentProgram.getUniforms();
        w.uniformsList = Aa.seqWithValue(N.seq, w.uniforms);
      }
      return w.uniformsList;
    }
    function Xc(w, N) {
      const W = Ie.get(w);
      W.outputColorSpace = N.outputColorSpace, W.batching = N.batching, W.batchingColor = N.batchingColor, W.instancing = N.instancing, W.instancingColor = N.instancingColor, W.instancingMorph = N.instancingMorph, W.skinning = N.skinning, W.morphTargets = N.morphTargets, W.morphNormals = N.morphNormals, W.morphColors = N.morphColors, W.morphTargetsCount = N.morphTargetsCount, W.numClippingPlanes = N.numClippingPlanes, W.numIntersection = N.numClipIntersection, W.vertexAlphas = N.vertexAlphas, W.vertexTangents = N.vertexTangents, W.toneMapping = N.toneMapping;
    }
    function up(w, N, W, j, O) {
      N.isScene !== !0 && (N = qe), D.resetTextureUnits();
      const le = N.fog, ve = j.isMeshStandardMaterial ? N.environment : null, Se = C === null ? _.outputColorSpace : C.isXRRenderTarget === !0 ? C.texture.colorSpace : en, Me = (j.isMeshStandardMaterial ? k : S).get(j.envMap || ve), Ge = j.vertexColors === !0 && !!W.attributes.color && W.attributes.color.itemSize === 4, Ve = !!W.attributes.tangent && (!!j.normalMap || j.anisotropy > 0), Ae = !!W.morphAttributes.position, at = !!W.morphAttributes.normal, bt = !!W.morphAttributes.color;
      let yt = Ai;
      j.toneMapped && (C === null || C.isXRRenderTarget === !0) && (yt = _.toneMapping);
      const tn = W.morphAttributes.position || W.morphAttributes.normal || W.morphAttributes.color, ct = tn !== void 0 ? tn.length : 0, De = Ie.get(j), Wn = f.state.lights;
      if (Q === !0 && (re === !0 || w !== E)) {
        const dn = w === E && j.id === y;
        se.setState(j, w, dn);
      }
      let ut = !1;
      j.version === De.__version ? (De.needsLights && De.lightsStateVersion !== Wn.state.version || De.outputColorSpace !== Se || O.isBatchedMesh && De.batching === !1 || !O.isBatchedMesh && De.batching === !0 || O.isBatchedMesh && De.batchingColor === !0 && O.colorTexture === null || O.isBatchedMesh && De.batchingColor === !1 && O.colorTexture !== null || O.isInstancedMesh && De.instancing === !1 || !O.isInstancedMesh && De.instancing === !0 || O.isSkinnedMesh && De.skinning === !1 || !O.isSkinnedMesh && De.skinning === !0 || O.isInstancedMesh && De.instancingColor === !0 && O.instanceColor === null || O.isInstancedMesh && De.instancingColor === !1 && O.instanceColor !== null || O.isInstancedMesh && De.instancingMorph === !0 && O.morphTexture === null || O.isInstancedMesh && De.instancingMorph === !1 && O.morphTexture !== null || De.envMap !== Me || j.fog === !0 && De.fog !== le || De.numClippingPlanes !== void 0 && (De.numClippingPlanes !== se.numPlanes || De.numIntersection !== se.numIntersection) || De.vertexAlphas !== Ge || De.vertexTangents !== Ve || De.morphTargets !== Ae || De.morphNormals !== at || De.morphColors !== bt || De.toneMapping !== yt || De.morphTargetsCount !== ct) && (ut = !0) : (ut = !0, De.__version = j.version);
      let xn = De.currentProgram;
      ut === !0 && (xn = Ns(j, N, O));
      let $i = !1, an = !1, Zr = !1;
      const St = xn.getUniforms(), Pn = De.uniforms;
      if (Le.useProgram(xn.program) && ($i = !0, an = !0, Zr = !0), j.id !== y && (y = j.id, an = !0), $i || E !== w) {
        Le.buffers.depth.getReversed() ? (ne.copy(w.projectionMatrix), Vv(ne), Wv(ne), St.setValue(F, "projectionMatrix", ne)) : St.setValue(F, "projectionMatrix", w.projectionMatrix), St.setValue(F, "viewMatrix", w.matrixWorldInverse);
        const oi = St.map.cameraPosition;
        oi !== void 0 && oi.setValue(F, me.setFromMatrixPosition(w.matrixWorld)), Ze.logarithmicDepthBuffer && St.setValue(
          F,
          "logDepthBufFC",
          2 / (Math.log(w.far + 1) / Math.LN2)
        ), (j.isMeshPhongMaterial || j.isMeshToonMaterial || j.isMeshLambertMaterial || j.isMeshBasicMaterial || j.isMeshStandardMaterial || j.isShaderMaterial) && St.setValue(F, "isOrthographic", w.isOrthographicCamera === !0), E !== w && (E = w, an = !0, Zr = !0);
      }
      if (O.isSkinnedMesh) {
        St.setOptional(F, O, "bindMatrix"), St.setOptional(F, O, "bindMatrixInverse");
        const dn = O.skeleton;
        dn && (dn.boneTexture === null && dn.computeBoneTexture(), St.setValue(F, "boneTexture", dn.boneTexture, D));
      }
      O.isBatchedMesh && (St.setOptional(F, O, "batchingTexture"), St.setValue(F, "batchingTexture", O._matricesTexture, D), St.setOptional(F, O, "batchingIdTexture"), St.setValue(F, "batchingIdTexture", O._indirectTexture, D), St.setOptional(F, O, "batchingColorTexture"), O._colorsTexture !== null && St.setValue(F, "batchingColorTexture", O._colorsTexture, D));
      const Kr = W.morphAttributes;
      if ((Kr.position !== void 0 || Kr.normal !== void 0 || Kr.color !== void 0) && Ce.update(O, W, xn), (an || De.receiveShadow !== O.receiveShadow) && (De.receiveShadow = O.receiveShadow, St.setValue(F, "receiveShadow", O.receiveShadow)), j.isMeshGouraudMaterial && j.envMap !== null && (Pn.envMap.value = Me, Pn.flipEnvMap.value = Me.isCubeTexture && Me.isRenderTargetTexture === !1 ? -1 : 1), j.isMeshStandardMaterial && j.envMap === null && N.environment !== null && (Pn.envMapIntensity.value = N.environmentIntensity), an && (St.setValue(F, "toneMappingExposure", _.toneMappingExposure), De.needsLights && hp(Pn, Zr), le && j.fog === !0 && fe.refreshFogUniforms(Pn, le), fe.refreshMaterialUniforms(Pn, j, z, Y, f.state.transmissionRenderTarget[w.id]), Aa.upload(F, Wc(De), Pn, D)), j.isShaderMaterial && j.uniformsNeedUpdate === !0 && (Aa.upload(F, Wc(De), Pn, D), j.uniformsNeedUpdate = !1), j.isSpriteMaterial && St.setValue(F, "center", O.center), St.setValue(F, "modelViewMatrix", O.modelViewMatrix), St.setValue(F, "normalMatrix", O.normalMatrix), St.setValue(F, "modelMatrix", O.matrixWorld), j.isShaderMaterial || j.isRawShaderMaterial) {
        const dn = j.uniformsGroups;
        for (let oi = 0, li = dn.length; oi < li; oi++) {
          const jc = dn[oi];
          I.update(jc, xn), I.bind(jc, xn);
        }
      }
      return xn;
    }
    function hp(w, N) {
      w.ambientLightColor.needsUpdate = N, w.lightProbe.needsUpdate = N, w.directionalLights.needsUpdate = N, w.directionalLightShadows.needsUpdate = N, w.pointLights.needsUpdate = N, w.pointLightShadows.needsUpdate = N, w.spotLights.needsUpdate = N, w.spotLightShadows.needsUpdate = N, w.rectAreaLights.needsUpdate = N, w.hemisphereLights.needsUpdate = N;
    }
    function fp(w) {
      return w.isMeshLambertMaterial || w.isMeshToonMaterial || w.isMeshPhongMaterial || w.isMeshStandardMaterial || w.isShadowMaterial || w.isShaderMaterial && w.lights === !0;
    }
    this.getActiveCubeFace = function() {
      return A;
    }, this.getActiveMipmapLevel = function() {
      return M;
    }, this.getRenderTarget = function() {
      return C;
    }, this.setRenderTargetTextures = function(w, N, W) {
      Ie.get(w.texture).__webglTexture = N, Ie.get(w.depthTexture).__webglTexture = W;
      const j = Ie.get(w);
      j.__hasExternalTextures = !0, j.__autoAllocateDepthBuffer = W === void 0, j.__autoAllocateDepthBuffer || $e.has("WEBGL_multisampled_render_to_texture") === !0 && (console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"), j.__useRenderToTexture = !1);
    }, this.setRenderTargetFramebuffer = function(w, N) {
      const W = Ie.get(w);
      W.__webglFramebuffer = N, W.__useDefaultFramebuffer = N === void 0;
    }, this.setRenderTarget = function(w, N = 0, W = 0) {
      C = w, A = N, M = W;
      let j = !0, O = null, le = !1, ve = !1;
      if (w) {
        const Me = Ie.get(w);
        if (Me.__useDefaultFramebuffer !== void 0)
          Le.bindFramebuffer(F.FRAMEBUFFER, null), j = !1;
        else if (Me.__webglFramebuffer === void 0)
          D.setupRenderTarget(w);
        else if (Me.__hasExternalTextures)
          D.rebindTextures(w, Ie.get(w.texture).__webglTexture, Ie.get(w.depthTexture).__webglTexture);
        else if (w.depthBuffer) {
          const Ae = w.depthTexture;
          if (Me.__boundDepthTexture !== Ae) {
            if (Ae !== null && Ie.has(Ae) && (w.width !== Ae.image.width || w.height !== Ae.image.height))
              throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");
            D.setupDepthRenderbuffer(w);
          }
        }
        const Ge = w.texture;
        (Ge.isData3DTexture || Ge.isDataArrayTexture || Ge.isCompressedArrayTexture) && (ve = !0);
        const Ve = Ie.get(w).__webglFramebuffer;
        w.isWebGLCubeRenderTarget ? (Array.isArray(Ve[N]) ? O = Ve[N][W] : O = Ve[N], le = !0) : w.samples > 0 && D.useMultisampledRTT(w) === !1 ? O = Ie.get(w).__webglMultisampledFramebuffer : Array.isArray(Ve) ? O = Ve[W] : O = Ve, R.copy(w.viewport), q.copy(w.scissor), G = w.scissorTest;
      } else
        R.copy(ce).multiplyScalar(z).floor(), q.copy(ye).multiplyScalar(z).floor(), G = je;
      if (Le.bindFramebuffer(F.FRAMEBUFFER, O) && j && Le.drawBuffers(w, O), Le.viewport(R), Le.scissor(q), Le.setScissorTest(G), le) {
        const Me = Ie.get(w.texture);
        F.framebufferTexture2D(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0, F.TEXTURE_CUBE_MAP_POSITIVE_X + N, Me.__webglTexture, W);
      } else if (ve) {
        const Me = Ie.get(w.texture), Ge = N || 0;
        F.framebufferTextureLayer(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0, Me.__webglTexture, W || 0, Ge);
      }
      y = -1;
    }, this.readRenderTargetPixels = function(w, N, W, j, O, le, ve) {
      if (!(w && w.isWebGLRenderTarget)) {
        console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
        return;
      }
      let Se = Ie.get(w).__webglFramebuffer;
      if (w.isWebGLCubeRenderTarget && ve !== void 0 && (Se = Se[ve]), Se) {
        Le.bindFramebuffer(F.FRAMEBUFFER, Se);
        try {
          const Me = w.texture, Ge = Me.format, Ve = Me.type;
          if (!Ze.textureFormatReadable(Ge)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
            return;
          }
          if (!Ze.textureTypeReadable(Ve)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
            return;
          }
          N >= 0 && N <= w.width - j && W >= 0 && W <= w.height - O && F.readPixels(N, W, j, O, Oe.convert(Ge), Oe.convert(Ve), le);
        } finally {
          const Me = C !== null ? Ie.get(C).__webglFramebuffer : null;
          Le.bindFramebuffer(F.FRAMEBUFFER, Me);
        }
      }
    }, this.readRenderTargetPixelsAsync = async function(w, N, W, j, O, le, ve) {
      if (!(w && w.isWebGLRenderTarget))
        throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
      let Se = Ie.get(w).__webglFramebuffer;
      if (w.isWebGLCubeRenderTarget && ve !== void 0 && (Se = Se[ve]), Se) {
        const Me = w.texture, Ge = Me.format, Ve = Me.type;
        if (!Ze.textureFormatReadable(Ge))
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");
        if (!Ze.textureTypeReadable(Ve))
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");
        if (N >= 0 && N <= w.width - j && W >= 0 && W <= w.height - O) {
          Le.bindFramebuffer(F.FRAMEBUFFER, Se);
          const Ae = F.createBuffer();
          F.bindBuffer(F.PIXEL_PACK_BUFFER, Ae), F.bufferData(F.PIXEL_PACK_BUFFER, le.byteLength, F.STREAM_READ), F.readPixels(N, W, j, O, Oe.convert(Ge), Oe.convert(Ve), 0);
          const at = C !== null ? Ie.get(C).__webglFramebuffer : null;
          Le.bindFramebuffer(F.FRAMEBUFFER, at);
          const bt = F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE, 0);
          return F.flush(), await Gv(F, bt, 4), F.bindBuffer(F.PIXEL_PACK_BUFFER, Ae), F.getBufferSubData(F.PIXEL_PACK_BUFFER, 0, le), F.deleteBuffer(Ae), F.deleteSync(bt), le;
        } else
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");
      }
    }, this.copyFramebufferToTexture = function(w, N = null, W = 0) {
      w.isTexture !== !0 && (ds("WebGLRenderer: copyFramebufferToTexture function signature has changed."), N = arguments[0] || null, w = arguments[1]);
      const j = Math.pow(2, -W), O = Math.floor(w.image.width * j), le = Math.floor(w.image.height * j), ve = N !== null ? N.x : 0, Se = N !== null ? N.y : 0;
      D.setTexture2D(w, 0), F.copyTexSubImage2D(F.TEXTURE_2D, W, 0, 0, ve, Se, O, le), Le.unbindTexture();
    }, this.copyTextureToTexture = function(w, N, W = null, j = null, O = 0) {
      w.isTexture !== !0 && (ds("WebGLRenderer: copyTextureToTexture function signature has changed."), j = arguments[0] || null, w = arguments[1], N = arguments[2], O = arguments[3] || 0, W = null);
      let le, ve, Se, Me, Ge, Ve, Ae, at, bt;
      const yt = w.isCompressedTexture ? w.mipmaps[O] : w.image;
      W !== null ? (le = W.max.x - W.min.x, ve = W.max.y - W.min.y, Se = W.isBox3 ? W.max.z - W.min.z : 1, Me = W.min.x, Ge = W.min.y, Ve = W.isBox3 ? W.min.z : 0) : (le = yt.width, ve = yt.height, Se = yt.depth || 1, Me = 0, Ge = 0, Ve = 0), j !== null ? (Ae = j.x, at = j.y, bt = j.z) : (Ae = 0, at = 0, bt = 0);
      const tn = Oe.convert(N.format), ct = Oe.convert(N.type);
      let De;
      N.isData3DTexture ? (D.setTexture3D(N, 0), De = F.TEXTURE_3D) : N.isDataArrayTexture || N.isCompressedArrayTexture ? (D.setTexture2DArray(N, 0), De = F.TEXTURE_2D_ARRAY) : (D.setTexture2D(N, 0), De = F.TEXTURE_2D), F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL, N.flipY), F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL, N.premultiplyAlpha), F.pixelStorei(F.UNPACK_ALIGNMENT, N.unpackAlignment);
      const Wn = F.getParameter(F.UNPACK_ROW_LENGTH), ut = F.getParameter(F.UNPACK_IMAGE_HEIGHT), xn = F.getParameter(F.UNPACK_SKIP_PIXELS), $i = F.getParameter(F.UNPACK_SKIP_ROWS), an = F.getParameter(F.UNPACK_SKIP_IMAGES);
      F.pixelStorei(F.UNPACK_ROW_LENGTH, yt.width), F.pixelStorei(F.UNPACK_IMAGE_HEIGHT, yt.height), F.pixelStorei(F.UNPACK_SKIP_PIXELS, Me), F.pixelStorei(F.UNPACK_SKIP_ROWS, Ge), F.pixelStorei(F.UNPACK_SKIP_IMAGES, Ve);
      const Zr = w.isDataArrayTexture || w.isData3DTexture, St = N.isDataArrayTexture || N.isData3DTexture;
      if (w.isRenderTargetTexture || w.isDepthTexture) {
        const Pn = Ie.get(w), Kr = Ie.get(N), dn = Ie.get(Pn.__renderTarget), oi = Ie.get(Kr.__renderTarget);
        Le.bindFramebuffer(F.READ_FRAMEBUFFER, dn.__webglFramebuffer), Le.bindFramebuffer(F.DRAW_FRAMEBUFFER, oi.__webglFramebuffer);
        for (let li = 0; li < Se; li++)
          Zr && F.framebufferTextureLayer(F.READ_FRAMEBUFFER, F.COLOR_ATTACHMENT0, Ie.get(w).__webglTexture, O, Ve + li), w.isDepthTexture ? (St && F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER, F.COLOR_ATTACHMENT0, Ie.get(N).__webglTexture, O, bt + li), F.blitFramebuffer(Me, Ge, le, ve, Ae, at, le, ve, F.DEPTH_BUFFER_BIT, F.NEAREST)) : St ? F.copyTexSubImage3D(De, O, Ae, at, bt + li, Me, Ge, le, ve) : F.copyTexSubImage2D(De, O, Ae, at, bt + li, Me, Ge, le, ve);
        Le.bindFramebuffer(F.READ_FRAMEBUFFER, null), Le.bindFramebuffer(F.DRAW_FRAMEBUFFER, null);
      } else
        St ? w.isDataTexture || w.isData3DTexture ? F.texSubImage3D(De, O, Ae, at, bt, le, ve, Se, tn, ct, yt.data) : N.isCompressedArrayTexture ? F.compressedTexSubImage3D(De, O, Ae, at, bt, le, ve, Se, tn, yt.data) : F.texSubImage3D(De, O, Ae, at, bt, le, ve, Se, tn, ct, yt) : w.isDataTexture ? F.texSubImage2D(F.TEXTURE_2D, O, Ae, at, le, ve, tn, ct, yt.data) : w.isCompressedTexture ? F.compressedTexSubImage2D(F.TEXTURE_2D, O, Ae, at, yt.width, yt.height, tn, yt.data) : F.texSubImage2D(F.TEXTURE_2D, O, Ae, at, le, ve, tn, ct, yt);
      F.pixelStorei(F.UNPACK_ROW_LENGTH, Wn), F.pixelStorei(F.UNPACK_IMAGE_HEIGHT, ut), F.pixelStorei(F.UNPACK_SKIP_PIXELS, xn), F.pixelStorei(F.UNPACK_SKIP_ROWS, $i), F.pixelStorei(F.UNPACK_SKIP_IMAGES, an), O === 0 && N.generateMipmaps && F.generateMipmap(De), Le.unbindTexture();
    }, this.copyTextureToTexture3D = function(w, N, W = null, j = null, O = 0) {
      return w.isTexture !== !0 && (ds("WebGLRenderer: copyTextureToTexture3D function signature has changed."), W = arguments[0] || null, j = arguments[1] || null, w = arguments[2], N = arguments[3], O = arguments[4] || 0), ds('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'), this.copyTextureToTexture(w, N, W, j, O);
    }, this.initRenderTarget = function(w) {
      Ie.get(w).__webglFramebuffer === void 0 && D.setupRenderTarget(w);
    }, this.initTexture = function(w) {
      w.isCubeTexture ? D.setTextureCube(w, 0) : w.isData3DTexture ? D.setTexture3D(w, 0) : w.isDataArrayTexture || w.isCompressedArrayTexture ? D.setTexture2DArray(w, 0) : D.setTexture2D(w, 0), Le.unbindTexture();
    }, this.resetState = function() {
      A = 0, M = 0, C = null, Le.reset(), et.reset();
    }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  get coordinateSystem() {
    return ni;
  }
  get outputColorSpace() {
    return this._outputColorSpace;
  }
  set outputColorSpace(e) {
    this._outputColorSpace = e;
    const t = this.getContext();
    t.drawingBufferColorspace = nt._getDrawingBufferColorSpace(e), t.unpackColorSpace = nt._getUnpackColorSpace();
  }
}
class eM extends Rt {
  constructor() {
    super(), this.isScene = !0, this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.backgroundBlurriness = 0, this.backgroundIntensity = 1, this.backgroundRotation = new Hn(), this.environmentIntensity = 1, this.environmentRotation = new Hn(), this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  copy(e, t) {
    return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), this.backgroundBlurriness = e.backgroundBlurriness, this.backgroundIntensity = e.backgroundIntensity, this.backgroundRotation.copy(e.backgroundRotation), this.environmentIntensity = e.environmentIntensity, this.environmentRotation.copy(e.environmentRotation), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.matrixAutoUpdate = e.matrixAutoUpdate, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return this.fog !== null && (t.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (t.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (t.object.backgroundIntensity = this.backgroundIntensity), t.object.backgroundRotation = this.backgroundRotation.toArray(), this.environmentIntensity !== 1 && (t.object.environmentIntensity = this.environmentIntensity), t.object.environmentRotation = this.environmentRotation.toArray(), t;
  }
}
class tM {
  constructor(e, t) {
    this.isInterleavedBuffer = !0, this.array = e, this.stride = t, this.count = e !== void 0 ? e.length / t : 0, this.usage = Ql, this.updateRanges = [], this.version = 0, this.uuid = Rn();
  }
  onUploadCallback() {
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
  setUsage(e) {
    return this.usage = e, this;
  }
  addUpdateRange(e, t) {
    this.updateRanges.push({ start: e, count: t });
  }
  clearUpdateRanges() {
    this.updateRanges.length = 0;
  }
  copy(e) {
    return this.array = new e.array.constructor(e.array), this.count = e.count, this.stride = e.stride, this.usage = e.usage, this;
  }
  copyAt(e, t, n) {
    e *= this.stride, n *= t.stride;
    for (let r = 0, s = this.stride; r < s; r++)
      this.array[e + r] = t.array[n + r];
    return this;
  }
  set(e, t = 0) {
    return this.array.set(e, t), this;
  }
  clone(e) {
    e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Rn()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer);
    const t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(t, this.stride);
    return n.setUsage(this.usage), n;
  }
  onUpload(e) {
    return this.onUploadCallback = e, this;
  }
  toJSON(e) {
    return e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Rn()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer))), {
      uuid: this.uuid,
      buffer: this.array.buffer._uuid,
      type: this.array.constructor.name,
      stride: this.stride
    };
  }
}
const jt = /* @__PURE__ */ new L();
class Fc {
  constructor(e, t, n, r = !1) {
    this.isInterleavedBufferAttribute = !0, this.name = "", this.data = e, this.itemSize = t, this.offset = n, this.normalized = r;
  }
  get count() {
    return this.data.count;
  }
  get array() {
    return this.data.array;
  }
  set needsUpdate(e) {
    this.data.needsUpdate = e;
  }
  applyMatrix4(e) {
    for (let t = 0, n = this.data.count; t < n; t++)
      jt.fromBufferAttribute(this, t), jt.applyMatrix4(e), this.setXYZ(t, jt.x, jt.y, jt.z);
    return this;
  }
  applyNormalMatrix(e) {
    for (let t = 0, n = this.count; t < n; t++)
      jt.fromBufferAttribute(this, t), jt.applyNormalMatrix(e), this.setXYZ(t, jt.x, jt.y, jt.z);
    return this;
  }
  transformDirection(e) {
    for (let t = 0, n = this.count; t < n; t++)
      jt.fromBufferAttribute(this, t), jt.transformDirection(e), this.setXYZ(t, jt.x, jt.y, jt.z);
    return this;
  }
  getComponent(e, t) {
    let n = this.array[e * this.data.stride + this.offset + t];
    return this.normalized && (n = An(n, this.array)), n;
  }
  setComponent(e, t, n) {
    return this.normalized && (n = ft(n, this.array)), this.data.array[e * this.data.stride + this.offset + t] = n, this;
  }
  setX(e, t) {
    return this.normalized && (t = ft(t, this.array)), this.data.array[e * this.data.stride + this.offset] = t, this;
  }
  setY(e, t) {
    return this.normalized && (t = ft(t, this.array)), this.data.array[e * this.data.stride + this.offset + 1] = t, this;
  }
  setZ(e, t) {
    return this.normalized && (t = ft(t, this.array)), this.data.array[e * this.data.stride + this.offset + 2] = t, this;
  }
  setW(e, t) {
    return this.normalized && (t = ft(t, this.array)), this.data.array[e * this.data.stride + this.offset + 3] = t, this;
  }
  getX(e) {
    let t = this.data.array[e * this.data.stride + this.offset];
    return this.normalized && (t = An(t, this.array)), t;
  }
  getY(e) {
    let t = this.data.array[e * this.data.stride + this.offset + 1];
    return this.normalized && (t = An(t, this.array)), t;
  }
  getZ(e) {
    let t = this.data.array[e * this.data.stride + this.offset + 2];
    return this.normalized && (t = An(t, this.array)), t;
  }
  getW(e) {
    let t = this.data.array[e * this.data.stride + this.offset + 3];
    return this.normalized && (t = An(t, this.array)), t;
  }
  setXY(e, t, n) {
    return e = e * this.data.stride + this.offset, this.normalized && (t = ft(t, this.array), n = ft(n, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this;
  }
  setXYZ(e, t, n, r) {
    return e = e * this.data.stride + this.offset, this.normalized && (t = ft(t, this.array), n = ft(n, this.array), r = ft(r, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = r, this;
  }
  setXYZW(e, t, n, r, s) {
    return e = e * this.data.stride + this.offset, this.normalized && (t = ft(t, this.array), n = ft(n, this.array), r = ft(r, this.array), s = ft(s, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = r, this.data.array[e + 3] = s, this;
  }
  clone(e) {
    if (e === void 0) {
      console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");
      const t = [];
      for (let n = 0; n < this.count; n++) {
        const r = n * this.data.stride + this.offset;
        for (let s = 0; s < this.itemSize; s++)
          t.push(this.data.array[r + s]);
      }
      return new Qt(new this.array.constructor(t), this.itemSize, this.normalized);
    } else
      return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.clone(e)), new Fc(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized);
  }
  toJSON(e) {
    if (e === void 0) {
      console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");
      const t = [];
      for (let n = 0; n < this.count; n++) {
        const r = n * this.data.stride + this.offset;
        for (let s = 0; s < this.itemSize; s++)
          t.push(this.data.array[r + s]);
      }
      return {
        itemSize: this.itemSize,
        type: this.array.constructor.name,
        array: t,
        normalized: this.normalized
      };
    } else
      return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), {
        isInterleavedBufferAttribute: !0,
        itemSize: this.itemSize,
        data: this.data.uuid,
        offset: this.offset,
        normalized: this.normalized
      };
  }
}
const Vh = /* @__PURE__ */ new L(), Wh = /* @__PURE__ */ new lt(), Xh = /* @__PURE__ */ new lt(), nM = /* @__PURE__ */ new L(), jh = /* @__PURE__ */ new Xe(), oa = /* @__PURE__ */ new L(), zo = /* @__PURE__ */ new zn(), qh = /* @__PURE__ */ new Xe(), Go = /* @__PURE__ */ new Ps();
class iM extends hn {
  constructor(e, t) {
    super(e, t), this.isSkinnedMesh = !0, this.type = "SkinnedMesh", this.bindMode = Xu, this.bindMatrix = new Xe(), this.bindMatrixInverse = new Xe(), this.boundingBox = null, this.boundingSphere = null;
  }
  computeBoundingBox() {
    const e = this.geometry;
    this.boundingBox === null && (this.boundingBox = new vn()), this.boundingBox.makeEmpty();
    const t = e.getAttribute("position");
    for (let n = 0; n < t.count; n++)
      this.getVertexPosition(n, oa), this.boundingBox.expandByPoint(oa);
  }
  computeBoundingSphere() {
    const e = this.geometry;
    this.boundingSphere === null && (this.boundingSphere = new zn()), this.boundingSphere.makeEmpty();
    const t = e.getAttribute("position");
    for (let n = 0; n < t.count; n++)
      this.getVertexPosition(n, oa), this.boundingSphere.expandByPoint(oa);
  }
  copy(e, t) {
    return super.copy(e, t), this.bindMode = e.bindMode, this.bindMatrix.copy(e.bindMatrix), this.bindMatrixInverse.copy(e.bindMatrixInverse), this.skeleton = e.skeleton, e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), this;
  }
  raycast(e, t) {
    const n = this.material, r = this.matrixWorld;
    n !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), zo.copy(this.boundingSphere), zo.applyMatrix4(r), e.ray.intersectsSphere(zo) !== !1 && (qh.copy(r).invert(), Go.copy(e.ray).applyMatrix4(qh), !(this.boundingBox !== null && Go.intersectsBox(this.boundingBox) === !1) && this._computeIntersections(e, t, Go)));
  }
  getVertexPosition(e, t) {
    return super.getVertexPosition(e, t), this.applyBoneTransform(e, t), t;
  }
  bind(e, t) {
    this.skeleton = e, t === void 0 && (this.updateMatrixWorld(!0), this.skeleton.calculateInverses(), t = this.matrixWorld), this.bindMatrix.copy(t), this.bindMatrixInverse.copy(t).invert();
  }
  pose() {
    this.skeleton.pose();
  }
  normalizeSkinWeights() {
    const e = new lt(), t = this.geometry.attributes.skinWeight;
    for (let n = 0, r = t.count; n < r; n++) {
      e.fromBufferAttribute(t, n);
      const s = 1 / e.manhattanLength();
      s !== 1 / 0 ? e.multiplyScalar(s) : e.set(1, 0, 0, 0), t.setXYZW(n, e.x, e.y, e.z, e.w);
    }
  }
  updateMatrixWorld(e) {
    super.updateMatrixWorld(e), this.bindMode === Xu ? this.bindMatrixInverse.copy(this.matrixWorld).invert() : this.bindMode === fv ? this.bindMatrixInverse.copy(this.bindMatrix).invert() : console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode);
  }
  applyBoneTransform(e, t) {
    const n = this.skeleton, r = this.geometry;
    Wh.fromBufferAttribute(r.attributes.skinIndex, e), Xh.fromBufferAttribute(r.attributes.skinWeight, e), Vh.copy(t).applyMatrix4(this.bindMatrix), t.set(0, 0, 0);
    for (let s = 0; s < 4; s++) {
      const a = Xh.getComponent(s);
      if (a !== 0) {
        const o = Wh.getComponent(s);
        jh.multiplyMatrices(n.bones[o].matrixWorld, n.boneInverses[o]), t.addScaledVector(nM.copy(Vh).applyMatrix4(jh), a);
      }
    }
    return t.applyMatrix4(this.bindMatrixInverse);
  }
}
class ep extends Rt {
  constructor() {
    super(), this.isBone = !0, this.type = "Bone";
  }
}
class tp extends zt {
  constructor(e = null, t = 1, n = 1, r, s, a, o, l, c = Jt, u = Jt, h, d) {
    super(null, a, o, l, c, u, r, s, h, d), this.isDataTexture = !0, this.image = { data: e, width: t, height: n }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
const Yh = /* @__PURE__ */ new Xe(), rM = /* @__PURE__ */ new Xe();
class Nc {
  constructor(e = [], t = []) {
    this.uuid = Rn(), this.bones = e.slice(0), this.boneInverses = t, this.boneMatrices = null, this.boneTexture = null, this.init();
  }
  init() {
    const e = this.bones, t = this.boneInverses;
    if (this.boneMatrices = new Float32Array(e.length * 16), t.length === 0)
      this.calculateInverses();
    else if (e.length !== t.length) {
      console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."), this.boneInverses = [];
      for (let n = 0, r = this.bones.length; n < r; n++)
        this.boneInverses.push(new Xe());
    }
  }
  calculateInverses() {
    this.boneInverses.length = 0;
    for (let e = 0, t = this.bones.length; e < t; e++) {
      const n = new Xe();
      this.bones[e] && n.copy(this.bones[e].matrixWorld).invert(), this.boneInverses.push(n);
    }
  }
  pose() {
    for (let e = 0, t = this.bones.length; e < t; e++) {
      const n = this.bones[e];
      n && n.matrixWorld.copy(this.boneInverses[e]).invert();
    }
    for (let e = 0, t = this.bones.length; e < t; e++) {
      const n = this.bones[e];
      n && (n.parent && n.parent.isBone ? (n.matrix.copy(n.parent.matrixWorld).invert(), n.matrix.multiply(n.matrixWorld)) : n.matrix.copy(n.matrixWorld), n.matrix.decompose(n.position, n.quaternion, n.scale));
    }
  }
  update() {
    const e = this.bones, t = this.boneInverses, n = this.boneMatrices, r = this.boneTexture;
    for (let s = 0, a = e.length; s < a; s++) {
      const o = e[s] ? e[s].matrixWorld : rM;
      Yh.multiplyMatrices(o, t[s]), Yh.toArray(n, s * 16);
    }
    r !== null && (r.needsUpdate = !0);
  }
  clone() {
    return new Nc(this.bones, this.boneInverses);
  }
  computeBoneTexture() {
    let e = Math.sqrt(this.bones.length * 4);
    e = Math.ceil(e / 4) * 4, e = Math.max(e, 4);
    const t = new Float32Array(e * e * 4);
    t.set(this.boneMatrices);
    const n = new tp(t, e, e, _n, wn);
    return n.needsUpdate = !0, this.boneMatrices = t, this.boneTexture = n, this;
  }
  getBoneByName(e) {
    for (let t = 0, n = this.bones.length; t < n; t++) {
      const r = this.bones[t];
      if (r.name === e)
        return r;
    }
  }
  dispose() {
    this.boneTexture !== null && (this.boneTexture.dispose(), this.boneTexture = null);
  }
  fromJSON(e, t) {
    this.uuid = e.uuid;
    for (let n = 0, r = e.bones.length; n < r; n++) {
      const s = e.bones[n];
      let a = t[s];
      a === void 0 && (console.warn("THREE.Skeleton: No bone found with UUID:", s), a = new ep()), this.bones.push(a), this.boneInverses.push(new Xe().fromArray(e.boneInverses[n]));
    }
    return this.init(), this;
  }
  toJSON() {
    const e = {
      metadata: {
        version: 4.6,
        type: "Skeleton",
        generator: "Skeleton.toJSON"
      },
      bones: [],
      boneInverses: []
    };
    e.uuid = this.uuid;
    const t = this.bones, n = this.boneInverses;
    for (let r = 0, s = t.length; r < s; r++) {
      const a = t[r];
      e.bones.push(a.uuid);
      const o = n[r];
      e.boneInverses.push(o.toArray());
    }
    return e;
  }
}
class tc extends Qt {
  constructor(e, t, n, r = 1) {
    super(e, t, n), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = r;
  }
  copy(e) {
    return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.meshPerAttribute = this.meshPerAttribute, e.isInstancedBufferAttribute = !0, e;
  }
}
const dr = /* @__PURE__ */ new Xe(), Zh = /* @__PURE__ */ new Xe(), la = [], Kh = /* @__PURE__ */ new vn(), sM = /* @__PURE__ */ new Xe(), ss = /* @__PURE__ */ new hn(), as = /* @__PURE__ */ new zn();
class aM extends hn {
  constructor(e, t, n) {
    super(e, t), this.isInstancedMesh = !0, this.instanceMatrix = new tc(new Float32Array(n * 16), 16), this.instanceColor = null, this.morphTexture = null, this.count = n, this.boundingBox = null, this.boundingSphere = null;
    for (let r = 0; r < n; r++)
      this.setMatrixAt(r, sM);
  }
  computeBoundingBox() {
    const e = this.geometry, t = this.count;
    this.boundingBox === null && (this.boundingBox = new vn()), e.boundingBox === null && e.computeBoundingBox(), this.boundingBox.makeEmpty();
    for (let n = 0; n < t; n++)
      this.getMatrixAt(n, dr), Kh.copy(e.boundingBox).applyMatrix4(dr), this.boundingBox.union(Kh);
  }
  computeBoundingSphere() {
    const e = this.geometry, t = this.count;
    this.boundingSphere === null && (this.boundingSphere = new zn()), e.boundingSphere === null && e.computeBoundingSphere(), this.boundingSphere.makeEmpty();
    for (let n = 0; n < t; n++)
      this.getMatrixAt(n, dr), as.copy(e.boundingSphere).applyMatrix4(dr), this.boundingSphere.union(as);
  }
  copy(e, t) {
    return super.copy(e, t), this.instanceMatrix.copy(e.instanceMatrix), e.morphTexture !== null && (this.morphTexture = e.morphTexture.clone()), e.instanceColor !== null && (this.instanceColor = e.instanceColor.clone()), this.count = e.count, e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), this;
  }
  getColorAt(e, t) {
    t.fromArray(this.instanceColor.array, e * 3);
  }
  getMatrixAt(e, t) {
    t.fromArray(this.instanceMatrix.array, e * 16);
  }
  getMorphAt(e, t) {
    const n = t.morphTargetInfluences, r = this.morphTexture.source.data.data, s = n.length + 1, a = e * s + 1;
    for (let o = 0; o < n.length; o++)
      n[o] = r[a + o];
  }
  raycast(e, t) {
    const n = this.matrixWorld, r = this.count;
    if (ss.geometry = this.geometry, ss.material = this.material, ss.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), as.copy(this.boundingSphere), as.applyMatrix4(n), e.ray.intersectsSphere(as) !== !1))
      for (let s = 0; s < r; s++) {
        this.getMatrixAt(s, dr), Zh.multiplyMatrices(n, dr), ss.matrixWorld = Zh, ss.raycast(e, la);
        for (let a = 0, o = la.length; a < o; a++) {
          const l = la[a];
          l.instanceId = s, l.object = this, t.push(l);
        }
        la.length = 0;
      }
  }
  setColorAt(e, t) {
    this.instanceColor === null && (this.instanceColor = new tc(new Float32Array(this.instanceMatrix.count * 3).fill(1), 3)), t.toArray(this.instanceColor.array, e * 3);
  }
  setMatrixAt(e, t) {
    t.toArray(this.instanceMatrix.array, e * 16);
  }
  setMorphAt(e, t) {
    const n = t.morphTargetInfluences, r = n.length + 1;
    this.morphTexture === null && (this.morphTexture = new tp(new Float32Array(r * this.count), r, this.count, Tc, wn));
    const s = this.morphTexture.source.data.data;
    let a = 0;
    for (let c = 0; c < n.length; c++)
      a += n[c];
    const o = this.geometry.morphTargetsRelative ? 1 : 1 - a, l = r * e;
    s[l] = o, s.set(n, l + 1);
  }
  updateMorphTargets() {
  }
  dispose() {
    return this.dispatchEvent({ type: "dispose" }), this.morphTexture !== null && (this.morphTexture.dispose(), this.morphTexture = null), this;
  }
}
class np extends Bn {
  static get type() {
    return "LineBasicMaterial";
  }
  constructor(e) {
    super(), this.isLineBasicMaterial = !0, this.color = new Ue(16777215), this.map = null, this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.fog = !0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.color.copy(e.color), this.map = e.map, this.linewidth = e.linewidth, this.linecap = e.linecap, this.linejoin = e.linejoin, this.fog = e.fog, this;
  }
}
const Fa = /* @__PURE__ */ new L(), Na = /* @__PURE__ */ new L(), $h = /* @__PURE__ */ new Xe(), os = /* @__PURE__ */ new Ps(), ca = /* @__PURE__ */ new zn(), Vo = /* @__PURE__ */ new L(), Jh = /* @__PURE__ */ new L();
class Uc extends Rt {
  constructor(e = new fn(), t = new np()) {
    super(), this.isLine = !0, this.type = "Line", this.geometry = e, this.material = t, this.updateMorphTargets();
  }
  copy(e, t) {
    return super.copy(e, t), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;
  }
  computeLineDistances() {
    const e = this.geometry;
    if (e.index === null) {
      const t = e.attributes.position, n = [0];
      for (let r = 1, s = t.count; r < s; r++)
        Fa.fromBufferAttribute(t, r - 1), Na.fromBufferAttribute(t, r), n[r] = n[r - 1], n[r] += Fa.distanceTo(Na);
      e.setAttribute("lineDistance", new Ot(n, 1));
    } else
      console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
  raycast(e, t) {
    const n = this.geometry, r = this.matrixWorld, s = e.params.Line.threshold, a = n.drawRange;
    if (n.boundingSphere === null && n.computeBoundingSphere(), ca.copy(n.boundingSphere), ca.applyMatrix4(r), ca.radius += s, e.ray.intersectsSphere(ca) === !1) return;
    $h.copy(r).invert(), os.copy(e.ray).applyMatrix4($h);
    const o = s / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = o * o, c = this.isLineSegments ? 2 : 1, u = n.index, d = n.attributes.position;
    if (u !== null) {
      const m = Math.max(0, a.start), v = Math.min(u.count, a.start + a.count);
      for (let b = m, p = v - 1; b < p; b += c) {
        const f = u.getX(b), x = u.getX(b + 1), g = ua(this, e, os, l, f, x);
        g && t.push(g);
      }
      if (this.isLineLoop) {
        const b = u.getX(v - 1), p = u.getX(m), f = ua(this, e, os, l, b, p);
        f && t.push(f);
      }
    } else {
      const m = Math.max(0, a.start), v = Math.min(d.count, a.start + a.count);
      for (let b = m, p = v - 1; b < p; b += c) {
        const f = ua(this, e, os, l, b, b + 1);
        f && t.push(f);
      }
      if (this.isLineLoop) {
        const b = ua(this, e, os, l, v - 1, m);
        b && t.push(b);
      }
    }
  }
  updateMorphTargets() {
    const t = this.geometry.morphAttributes, n = Object.keys(t);
    if (n.length > 0) {
      const r = t[n[0]];
      if (r !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let s = 0, a = r.length; s < a; s++) {
          const o = r[s].name || String(s);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = s;
        }
      }
    }
  }
}
function ua(i, e, t, n, r, s) {
  const a = i.geometry.attributes.position;
  if (Fa.fromBufferAttribute(a, r), Na.fromBufferAttribute(a, s), t.distanceSqToSegment(Fa, Na, Vo, Jh) > n) return;
  Vo.applyMatrix4(i.matrixWorld);
  const l = e.ray.origin.distanceTo(Vo);
  if (!(l < e.near || l > e.far))
    return {
      distance: l,
      // What do we want? intersection point on the ray or on the segment??
      // point: raycaster.ray.at( distance ),
      point: Jh.clone().applyMatrix4(i.matrixWorld),
      index: r,
      face: null,
      faceIndex: null,
      barycoord: null,
      object: i
    };
}
const Qh = /* @__PURE__ */ new L(), ef = /* @__PURE__ */ new L();
class oM extends Uc {
  constructor(e, t) {
    super(e, t), this.isLineSegments = !0, this.type = "LineSegments";
  }
  computeLineDistances() {
    const e = this.geometry;
    if (e.index === null) {
      const t = e.attributes.position, n = [];
      for (let r = 0, s = t.count; r < s; r += 2)
        Qh.fromBufferAttribute(t, r), ef.fromBufferAttribute(t, r + 1), n[r] = r === 0 ? 0 : n[r - 1], n[r + 1] = n[r] + Qh.distanceTo(ef);
      e.setAttribute("lineDistance", new Ot(n, 1));
    } else
      console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
}
class lM extends Uc {
  constructor(e, t) {
    super(e, t), this.isLineLoop = !0, this.type = "LineLoop";
  }
}
class Ms extends Bn {
  static get type() {
    return "PointsMaterial";
  }
  constructor(e) {
    super(), this.isPointsMaterial = !0, this.color = new Ue(16777215), this.map = null, this.alphaMap = null, this.size = 1, this.sizeAttenuation = !0, this.fog = !0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.size = e.size, this.sizeAttenuation = e.sizeAttenuation, this.fog = e.fog, this;
  }
}
const tf = /* @__PURE__ */ new Xe(), nc = /* @__PURE__ */ new Ps(), ha = /* @__PURE__ */ new zn(), fa = /* @__PURE__ */ new L();
class Ua extends Rt {
  constructor(e = new fn(), t = new Ms()) {
    super(), this.isPoints = !0, this.type = "Points", this.geometry = e, this.material = t, this.updateMorphTargets();
  }
  copy(e, t) {
    return super.copy(e, t), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;
  }
  raycast(e, t) {
    const n = this.geometry, r = this.matrixWorld, s = e.params.Points.threshold, a = n.drawRange;
    if (n.boundingSphere === null && n.computeBoundingSphere(), ha.copy(n.boundingSphere), ha.applyMatrix4(r), ha.radius += s, e.ray.intersectsSphere(ha) === !1) return;
    tf.copy(r).invert(), nc.copy(e.ray).applyMatrix4(tf);
    const o = s / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = o * o, c = n.index, h = n.attributes.position;
    if (c !== null) {
      const d = Math.max(0, a.start), m = Math.min(c.count, a.start + a.count);
      for (let v = d, b = m; v < b; v++) {
        const p = c.getX(v);
        fa.fromBufferAttribute(h, p), nf(fa, p, l, r, e, t, this);
      }
    } else {
      const d = Math.max(0, a.start), m = Math.min(h.count, a.start + a.count);
      for (let v = d, b = m; v < b; v++)
        fa.fromBufferAttribute(h, v), nf(fa, v, l, r, e, t, this);
    }
  }
  updateMorphTargets() {
    const t = this.geometry.morphAttributes, n = Object.keys(t);
    if (n.length > 0) {
      const r = t[n[0]];
      if (r !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let s = 0, a = r.length; s < a; s++) {
          const o = r[s].name || String(s);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = s;
        }
      }
    }
  }
}
function nf(i, e, t, n, r, s, a) {
  const o = nc.distanceSqToPoint(i);
  if (o < t) {
    const l = new L();
    nc.closestPointToPoint(i, l), l.applyMatrix4(n);
    const c = r.ray.origin.distanceTo(l);
    if (c < r.near || c > r.far) return;
    s.push({
      distance: c,
      distanceToRay: Math.sqrt(o),
      point: l,
      index: e,
      face: null,
      faceIndex: null,
      barycoord: null,
      object: a
    });
  }
}
class Oc extends Bn {
  static get type() {
    return "MeshStandardMaterial";
  }
  constructor(e) {
    super(), this.isMeshStandardMaterial = !0, this.defines = { STANDARD: "" }, this.color = new Ue(16777215), this.roughness = 1, this.metalness = 0, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new Ue(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Nd, this.normalScale = new ze(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.roughnessMap = null, this.metalnessMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new Hn(), this.envMapIntensity = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.fog = !0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.defines = { STANDARD: "" }, this.color.copy(e.color), this.roughness = e.roughness, this.metalness = e.metalness, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.roughnessMap = e.roughnessMap, this.metalnessMap = e.metalnessMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.envMapIntensity = e.envMapIntensity, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this.fog = e.fog, this;
  }
}
class Gn extends Oc {
  static get type() {
    return "MeshPhysicalMaterial";
  }
  constructor(e) {
    super(), this.isMeshPhysicalMaterial = !0, this.defines = {
      STANDARD: "",
      PHYSICAL: ""
    }, this.anisotropyRotation = 0, this.anisotropyMap = null, this.clearcoatMap = null, this.clearcoatRoughness = 0, this.clearcoatRoughnessMap = null, this.clearcoatNormalScale = new ze(1, 1), this.clearcoatNormalMap = null, this.ior = 1.5, Object.defineProperty(this, "reflectivity", {
      get: function() {
        return Vt(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1);
      },
      set: function(t) {
        this.ior = (1 + 0.4 * t) / (1 - 0.4 * t);
      }
    }), this.iridescenceMap = null, this.iridescenceIOR = 1.3, this.iridescenceThicknessRange = [100, 400], this.iridescenceThicknessMap = null, this.sheenColor = new Ue(0), this.sheenColorMap = null, this.sheenRoughness = 1, this.sheenRoughnessMap = null, this.transmissionMap = null, this.thickness = 0, this.thicknessMap = null, this.attenuationDistance = 1 / 0, this.attenuationColor = new Ue(1, 1, 1), this.specularIntensity = 1, this.specularIntensityMap = null, this.specularColor = new Ue(1, 1, 1), this.specularColorMap = null, this._anisotropy = 0, this._clearcoat = 0, this._dispersion = 0, this._iridescence = 0, this._sheen = 0, this._transmission = 0, this.setValues(e);
  }
  get anisotropy() {
    return this._anisotropy;
  }
  set anisotropy(e) {
    this._anisotropy > 0 != e > 0 && this.version++, this._anisotropy = e;
  }
  get clearcoat() {
    return this._clearcoat;
  }
  set clearcoat(e) {
    this._clearcoat > 0 != e > 0 && this.version++, this._clearcoat = e;
  }
  get iridescence() {
    return this._iridescence;
  }
  set iridescence(e) {
    this._iridescence > 0 != e > 0 && this.version++, this._iridescence = e;
  }
  get dispersion() {
    return this._dispersion;
  }
  set dispersion(e) {
    this._dispersion > 0 != e > 0 && this.version++, this._dispersion = e;
  }
  get sheen() {
    return this._sheen;
  }
  set sheen(e) {
    this._sheen > 0 != e > 0 && this.version++, this._sheen = e;
  }
  get transmission() {
    return this._transmission;
  }
  set transmission(e) {
    this._transmission > 0 != e > 0 && this.version++, this._transmission = e;
  }
  copy(e) {
    return super.copy(e), this.defines = {
      STANDARD: "",
      PHYSICAL: ""
    }, this.anisotropy = e.anisotropy, this.anisotropyRotation = e.anisotropyRotation, this.anisotropyMap = e.anisotropyMap, this.clearcoat = e.clearcoat, this.clearcoatMap = e.clearcoatMap, this.clearcoatRoughness = e.clearcoatRoughness, this.clearcoatRoughnessMap = e.clearcoatRoughnessMap, this.clearcoatNormalMap = e.clearcoatNormalMap, this.clearcoatNormalScale.copy(e.clearcoatNormalScale), this.dispersion = e.dispersion, this.ior = e.ior, this.iridescence = e.iridescence, this.iridescenceMap = e.iridescenceMap, this.iridescenceIOR = e.iridescenceIOR, this.iridescenceThicknessRange = [...e.iridescenceThicknessRange], this.iridescenceThicknessMap = e.iridescenceThicknessMap, this.sheen = e.sheen, this.sheenColor.copy(e.sheenColor), this.sheenColorMap = e.sheenColorMap, this.sheenRoughness = e.sheenRoughness, this.sheenRoughnessMap = e.sheenRoughnessMap, this.transmission = e.transmission, this.transmissionMap = e.transmissionMap, this.thickness = e.thickness, this.thicknessMap = e.thicknessMap, this.attenuationDistance = e.attenuationDistance, this.attenuationColor.copy(e.attenuationColor), this.specularIntensity = e.specularIntensity, this.specularIntensityMap = e.specularIntensityMap, this.specularColor.copy(e.specularColor), this.specularColorMap = e.specularColorMap, this;
  }
}
function da(i, e, t) {
  return !i || // let 'undefined' and 'null' pass
  !t && i.constructor === e ? i : typeof e.BYTES_PER_ELEMENT == "number" ? new e(i) : Array.prototype.slice.call(i);
}
function cM(i) {
  return ArrayBuffer.isView(i) && !(i instanceof DataView);
}
function uM(i) {
  function e(r, s) {
    return i[r] - i[s];
  }
  const t = i.length, n = new Array(t);
  for (let r = 0; r !== t; ++r) n[r] = r;
  return n.sort(e), n;
}
function rf(i, e, t) {
  const n = i.length, r = new i.constructor(n);
  for (let s = 0, a = 0; a !== n; ++s) {
    const o = t[s] * e;
    for (let l = 0; l !== e; ++l)
      r[a++] = i[o + l];
  }
  return r;
}
function ip(i, e, t, n) {
  let r = 1, s = i[0];
  for (; s !== void 0 && s[n] === void 0; )
    s = i[r++];
  if (s === void 0) return;
  let a = s[n];
  if (a !== void 0)
    if (Array.isArray(a))
      do
        a = s[n], a !== void 0 && (e.push(s.time), t.push.apply(t, a)), s = i[r++];
      while (s !== void 0);
    else if (a.toArray !== void 0)
      do
        a = s[n], a !== void 0 && (e.push(s.time), a.toArray(t, t.length)), s = i[r++];
      while (s !== void 0);
    else
      do
        a = s[n], a !== void 0 && (e.push(s.time), t.push(a)), s = i[r++];
      while (s !== void 0);
}
class Is {
  constructor(e, t, n, r) {
    this.parameterPositions = e, this._cachedIndex = 0, this.resultBuffer = r !== void 0 ? r : new t.constructor(n), this.sampleValues = t, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {};
  }
  evaluate(e) {
    const t = this.parameterPositions;
    let n = this._cachedIndex, r = t[n], s = t[n - 1];
    e: {
      t: {
        let a;
        n: {
          i: if (!(e < r)) {
            for (let o = n + 2; ; ) {
              if (r === void 0) {
                if (e < s) break i;
                return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1);
              }
              if (n === o) break;
              if (s = r, r = t[++n], e < r)
                break t;
            }
            a = t.length;
            break n;
          }
          if (!(e >= s)) {
            const o = t[1];
            e < o && (n = 2, s = o);
            for (let l = n - 2; ; ) {
              if (s === void 0)
                return this._cachedIndex = 0, this.copySampleValue_(0);
              if (n === l) break;
              if (r = s, s = t[--n - 1], e >= s)
                break t;
            }
            a = n, n = 0;
            break n;
          }
          break e;
        }
        for (; n < a; ) {
          const o = n + a >>> 1;
          e < t[o] ? a = o : n = o + 1;
        }
        if (r = t[n], s = t[n - 1], s === void 0)
          return this._cachedIndex = 0, this.copySampleValue_(0);
        if (r === void 0)
          return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1);
      }
      this._cachedIndex = n, this.intervalChanged_(n, s, r);
    }
    return this.interpolate_(n, s, e, r);
  }
  getSettings_() {
    return this.settings || this.DefaultSettings_;
  }
  copySampleValue_(e) {
    const t = this.resultBuffer, n = this.sampleValues, r = this.valueSize, s = e * r;
    for (let a = 0; a !== r; ++a)
      t[a] = n[s + a];
    return t;
  }
  // Template methods for derived classes:
  interpolate_() {
    throw new Error("call to abstract method");
  }
  intervalChanged_() {
  }
}
class hM extends Is {
  constructor(e, t, n, r) {
    super(e, t, n, r), this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = {
      endingStart: ju,
      endingEnd: ju
    };
  }
  intervalChanged_(e, t, n) {
    const r = this.parameterPositions;
    let s = e - 2, a = e + 1, o = r[s], l = r[a];
    if (o === void 0)
      switch (this.getSettings_().endingStart) {
        case qu:
          s = e, o = 2 * t - n;
          break;
        case Yu:
          s = r.length - 2, o = t + r[s] - r[s + 1];
          break;
        default:
          s = e, o = n;
      }
    if (l === void 0)
      switch (this.getSettings_().endingEnd) {
        case qu:
          a = e, l = 2 * n - t;
          break;
        case Yu:
          a = 1, l = n + r[1] - r[0];
          break;
        default:
          a = e - 1, l = t;
      }
    const c = (n - t) * 0.5, u = this.valueSize;
    this._weightPrev = c / (t - o), this._weightNext = c / (l - n), this._offsetPrev = s * u, this._offsetNext = a * u;
  }
  interpolate_(e, t, n, r) {
    const s = this.resultBuffer, a = this.sampleValues, o = this.valueSize, l = e * o, c = l - o, u = this._offsetPrev, h = this._offsetNext, d = this._weightPrev, m = this._weightNext, v = (n - t) / (r - t), b = v * v, p = b * v, f = -d * p + 2 * d * b - d * v, x = (1 + d) * p + (-1.5 - 2 * d) * b + (-0.5 + d) * v + 1, g = (-1 - m) * p + (1.5 + m) * b + 0.5 * v, _ = m * p - m * b;
    for (let T = 0; T !== o; ++T)
      s[T] = f * a[u + T] + x * a[c + T] + g * a[l + T] + _ * a[h + T];
    return s;
  }
}
class fM extends Is {
  constructor(e, t, n, r) {
    super(e, t, n, r);
  }
  interpolate_(e, t, n, r) {
    const s = this.resultBuffer, a = this.sampleValues, o = this.valueSize, l = e * o, c = l - o, u = (n - t) / (r - t), h = 1 - u;
    for (let d = 0; d !== o; ++d)
      s[d] = a[c + d] * h + a[l + d] * u;
    return s;
  }
}
class dM extends Is {
  constructor(e, t, n, r) {
    super(e, t, n, r);
  }
  interpolate_(e) {
    return this.copySampleValue_(e - 1);
  }
}
class Vn {
  constructor(e, t, n, r) {
    if (e === void 0) throw new Error("THREE.KeyframeTrack: track name is undefined");
    if (t === void 0 || t.length === 0) throw new Error("THREE.KeyframeTrack: no keyframes in track named " + e);
    this.name = e, this.times = da(t, this.TimeBufferType), this.values = da(n, this.ValueBufferType), this.setInterpolation(r || this.DefaultInterpolation);
  }
  // Serialization (in static context, because of constructor invocation
  // and automatic invocation of .toJSON):
  static toJSON(e) {
    const t = e.constructor;
    let n;
    if (t.toJSON !== this.toJSON)
      n = t.toJSON(e);
    else {
      n = {
        name: e.name,
        times: da(e.times, Array),
        values: da(e.values, Array)
      };
      const r = e.getInterpolation();
      r !== e.DefaultInterpolation && (n.interpolation = r);
    }
    return n.type = e.ValueTypeName, n;
  }
  InterpolantFactoryMethodDiscrete(e) {
    return new dM(this.times, this.values, this.getValueSize(), e);
  }
  InterpolantFactoryMethodLinear(e) {
    return new fM(this.times, this.values, this.getValueSize(), e);
  }
  InterpolantFactoryMethodSmooth(e) {
    return new hM(this.times, this.values, this.getValueSize(), e);
  }
  setInterpolation(e) {
    let t;
    switch (e) {
      case Es:
        t = this.InterpolantFactoryMethodDiscrete;
        break;
      case ys:
        t = this.InterpolantFactoryMethodLinear;
        break;
      case fo:
        t = this.InterpolantFactoryMethodSmooth;
        break;
    }
    if (t === void 0) {
      const n = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name;
      if (this.createInterpolant === void 0)
        if (e !== this.DefaultInterpolation)
          this.setInterpolation(this.DefaultInterpolation);
        else
          throw new Error(n);
      return console.warn("THREE.KeyframeTrack:", n), this;
    }
    return this.createInterpolant = t, this;
  }
  getInterpolation() {
    switch (this.createInterpolant) {
      case this.InterpolantFactoryMethodDiscrete:
        return Es;
      case this.InterpolantFactoryMethodLinear:
        return ys;
      case this.InterpolantFactoryMethodSmooth:
        return fo;
    }
  }
  getValueSize() {
    return this.values.length / this.times.length;
  }
  // move all keyframes either forwards or backwards in time
  shift(e) {
    if (e !== 0) {
      const t = this.times;
      for (let n = 0, r = t.length; n !== r; ++n)
        t[n] += e;
    }
    return this;
  }
  // scale all keyframe times by a factor (useful for frame <-> seconds conversions)
  scale(e) {
    if (e !== 1) {
      const t = this.times;
      for (let n = 0, r = t.length; n !== r; ++n)
        t[n] *= e;
    }
    return this;
  }
  // removes keyframes before and after animation without changing any values within the range [startTime, endTime].
  // IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values
  trim(e, t) {
    const n = this.times, r = n.length;
    let s = 0, a = r - 1;
    for (; s !== r && n[s] < e; )
      ++s;
    for (; a !== -1 && n[a] > t; )
      --a;
    if (++a, s !== 0 || a !== r) {
      s >= a && (a = Math.max(a, 1), s = a - 1);
      const o = this.getValueSize();
      this.times = n.slice(s, a), this.values = this.values.slice(s * o, a * o);
    }
    return this;
  }
  // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
  validate() {
    let e = !0;
    const t = this.getValueSize();
    t - Math.floor(t) !== 0 && (console.error("THREE.KeyframeTrack: Invalid value size in track.", this), e = !1);
    const n = this.times, r = this.values, s = n.length;
    s === 0 && (console.error("THREE.KeyframeTrack: Track is empty.", this), e = !1);
    let a = null;
    for (let o = 0; o !== s; o++) {
      const l = n[o];
      if (typeof l == "number" && isNaN(l)) {
        console.error("THREE.KeyframeTrack: Time is not a valid number.", this, o, l), e = !1;
        break;
      }
      if (a !== null && a > l) {
        console.error("THREE.KeyframeTrack: Out of order keys.", this, o, l, a), e = !1;
        break;
      }
      a = l;
    }
    if (r !== void 0 && cM(r))
      for (let o = 0, l = r.length; o !== l; ++o) {
        const c = r[o];
        if (isNaN(c)) {
          console.error("THREE.KeyframeTrack: Value is not a valid number.", this, o, c), e = !1;
          break;
        }
      }
    return e;
  }
  // removes equivalent sequential keys as common in morph target sequences
  // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)
  optimize() {
    const e = this.times.slice(), t = this.values.slice(), n = this.getValueSize(), r = this.getInterpolation() === fo, s = e.length - 1;
    let a = 1;
    for (let o = 1; o < s; ++o) {
      let l = !1;
      const c = e[o], u = e[o + 1];
      if (c !== u && (o !== 1 || c !== e[0]))
        if (r)
          l = !0;
        else {
          const h = o * n, d = h - n, m = h + n;
          for (let v = 0; v !== n; ++v) {
            const b = t[h + v];
            if (b !== t[d + v] || b !== t[m + v]) {
              l = !0;
              break;
            }
          }
        }
      if (l) {
        if (o !== a) {
          e[a] = e[o];
          const h = o * n, d = a * n;
          for (let m = 0; m !== n; ++m)
            t[d + m] = t[h + m];
        }
        ++a;
      }
    }
    if (s > 0) {
      e[a] = e[s];
      for (let o = s * n, l = a * n, c = 0; c !== n; ++c)
        t[l + c] = t[o + c];
      ++a;
    }
    return a !== e.length ? (this.times = e.slice(0, a), this.values = t.slice(0, a * n)) : (this.times = e, this.values = t), this;
  }
  clone() {
    const e = this.times.slice(), t = this.values.slice(), n = this.constructor, r = new n(this.name, e, t);
    return r.createInterpolant = this.createInterpolant, r;
  }
}
Vn.prototype.TimeBufferType = Float32Array;
Vn.prototype.ValueBufferType = Float32Array;
Vn.prototype.DefaultInterpolation = ys;
class jr extends Vn {
  // No interpolation parameter because only InterpolateDiscrete is valid.
  constructor(e, t, n) {
    super(e, t, n);
  }
}
jr.prototype.ValueTypeName = "bool";
jr.prototype.ValueBufferType = Array;
jr.prototype.DefaultInterpolation = Es;
jr.prototype.InterpolantFactoryMethodLinear = void 0;
jr.prototype.InterpolantFactoryMethodSmooth = void 0;
class rp extends Vn {
}
rp.prototype.ValueTypeName = "color";
class Ur extends Vn {
}
Ur.prototype.ValueTypeName = "number";
class pM extends Is {
  constructor(e, t, n, r) {
    super(e, t, n, r);
  }
  interpolate_(e, t, n, r) {
    const s = this.resultBuffer, a = this.sampleValues, o = this.valueSize, l = (n - t) / (r - t);
    let c = e * o;
    for (let u = c + o; c !== u; c += 4)
      kn.slerpFlat(s, 0, a, c - o, a, c, l);
    return s;
  }
}
class Or extends Vn {
  InterpolantFactoryMethodLinear(e) {
    return new pM(this.times, this.values, this.getValueSize(), e);
  }
}
Or.prototype.ValueTypeName = "quaternion";
Or.prototype.InterpolantFactoryMethodSmooth = void 0;
class qr extends Vn {
  // No interpolation parameter because only InterpolateDiscrete is valid.
  constructor(e, t, n) {
    super(e, t, n);
  }
}
qr.prototype.ValueTypeName = "string";
qr.prototype.ValueBufferType = Array;
qr.prototype.DefaultInterpolation = Es;
qr.prototype.InterpolantFactoryMethodLinear = void 0;
qr.prototype.InterpolantFactoryMethodSmooth = void 0;
class Br extends Vn {
}
Br.prototype.ValueTypeName = "vector";
class mM {
  constructor(e = "", t = -1, n = [], r = dv) {
    this.name = e, this.tracks = n, this.duration = t, this.blendMode = r, this.uuid = Rn(), this.duration < 0 && this.resetDuration();
  }
  static parse(e) {
    const t = [], n = e.tracks, r = 1 / (e.fps || 1);
    for (let a = 0, o = n.length; a !== o; ++a)
      t.push(_M(n[a]).scale(r));
    const s = new this(e.name, e.duration, t, e.blendMode);
    return s.uuid = e.uuid, s;
  }
  static toJSON(e) {
    const t = [], n = e.tracks, r = {
      name: e.name,
      duration: e.duration,
      tracks: t,
      uuid: e.uuid,
      blendMode: e.blendMode
    };
    for (let s = 0, a = n.length; s !== a; ++s)
      t.push(Vn.toJSON(n[s]));
    return r;
  }
  static CreateFromMorphTargetSequence(e, t, n, r) {
    const s = t.length, a = [];
    for (let o = 0; o < s; o++) {
      let l = [], c = [];
      l.push(
        (o + s - 1) % s,
        o,
        (o + 1) % s
      ), c.push(0, 1, 0);
      const u = uM(l);
      l = rf(l, 1, u), c = rf(c, 1, u), !r && l[0] === 0 && (l.push(s), c.push(c[0])), a.push(
        new Ur(
          ".morphTargetInfluences[" + t[o].name + "]",
          l,
          c
        ).scale(1 / n)
      );
    }
    return new this(e, -1, a);
  }
  static findByName(e, t) {
    let n = e;
    if (!Array.isArray(e)) {
      const r = e;
      n = r.geometry && r.geometry.animations || r.animations;
    }
    for (let r = 0; r < n.length; r++)
      if (n[r].name === t)
        return n[r];
    return null;
  }
  static CreateClipsFromMorphTargetSequences(e, t, n) {
    const r = {}, s = /^([\w-]*?)([\d]+)$/;
    for (let o = 0, l = e.length; o < l; o++) {
      const c = e[o], u = c.name.match(s);
      if (u && u.length > 1) {
        const h = u[1];
        let d = r[h];
        d || (r[h] = d = []), d.push(c);
      }
    }
    const a = [];
    for (const o in r)
      a.push(this.CreateFromMorphTargetSequence(o, r[o], t, n));
    return a;
  }
  // parse the animation.hierarchy format
  static parseAnimation(e, t) {
    if (!e)
      return console.error("THREE.AnimationClip: No animation in JSONLoader data."), null;
    const n = function(h, d, m, v, b) {
      if (m.length !== 0) {
        const p = [], f = [];
        ip(m, p, f, v), p.length !== 0 && b.push(new h(d, p, f));
      }
    }, r = [], s = e.name || "default", a = e.fps || 30, o = e.blendMode;
    let l = e.length || -1;
    const c = e.hierarchy || [];
    for (let h = 0; h < c.length; h++) {
      const d = c[h].keys;
      if (!(!d || d.length === 0))
        if (d[0].morphTargets) {
          const m = {};
          let v;
          for (v = 0; v < d.length; v++)
            if (d[v].morphTargets)
              for (let b = 0; b < d[v].morphTargets.length; b++)
                m[d[v].morphTargets[b]] = -1;
          for (const b in m) {
            const p = [], f = [];
            for (let x = 0; x !== d[v].morphTargets.length; ++x) {
              const g = d[v];
              p.push(g.time), f.push(g.morphTarget === b ? 1 : 0);
            }
            r.push(new Ur(".morphTargetInfluence[" + b + "]", p, f));
          }
          l = m.length * a;
        } else {
          const m = ".bones[" + t[h].name + "]";
          n(
            Br,
            m + ".position",
            d,
            "pos",
            r
          ), n(
            Or,
            m + ".quaternion",
            d,
            "rot",
            r
          ), n(
            Br,
            m + ".scale",
            d,
            "scl",
            r
          );
        }
    }
    return r.length === 0 ? null : new this(s, l, r, o);
  }
  resetDuration() {
    const e = this.tracks;
    let t = 0;
    for (let n = 0, r = e.length; n !== r; ++n) {
      const s = this.tracks[n];
      t = Math.max(t, s.times[s.times.length - 1]);
    }
    return this.duration = t, this;
  }
  trim() {
    for (let e = 0; e < this.tracks.length; e++)
      this.tracks[e].trim(0, this.duration);
    return this;
  }
  validate() {
    let e = !0;
    for (let t = 0; t < this.tracks.length; t++)
      e = e && this.tracks[t].validate();
    return e;
  }
  optimize() {
    for (let e = 0; e < this.tracks.length; e++)
      this.tracks[e].optimize();
    return this;
  }
  clone() {
    const e = [];
    for (let t = 0; t < this.tracks.length; t++)
      e.push(this.tracks[t].clone());
    return new this.constructor(this.name, this.duration, e, this.blendMode);
  }
  toJSON() {
    return this.constructor.toJSON(this);
  }
}
function gM(i) {
  switch (i.toLowerCase()) {
    case "scalar":
    case "double":
    case "float":
    case "number":
    case "integer":
      return Ur;
    case "vector":
    case "vector2":
    case "vector3":
    case "vector4":
      return Br;
    case "color":
      return rp;
    case "quaternion":
      return Or;
    case "bool":
    case "boolean":
      return jr;
    case "string":
      return qr;
  }
  throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + i);
}
function _M(i) {
  if (i.type === void 0)
    throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");
  const e = gM(i.type);
  if (i.times === void 0) {
    const t = [], n = [];
    ip(i.keys, t, n, "value"), i.times = t, i.values = n;
  }
  return e.parse !== void 0 ? e.parse(i) : new e(i.name, i.times, i.values, i.interpolation);
}
const Ei = {
  enabled: !1,
  files: {},
  add: function(i, e) {
    this.enabled !== !1 && (this.files[i] = e);
  },
  get: function(i) {
    if (this.enabled !== !1)
      return this.files[i];
  },
  remove: function(i) {
    delete this.files[i];
  },
  clear: function() {
    this.files = {};
  }
};
class vM {
  constructor(e, t, n) {
    const r = this;
    let s = !1, a = 0, o = 0, l;
    const c = [];
    this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = n, this.itemStart = function(u) {
      o++, s === !1 && r.onStart !== void 0 && r.onStart(u, a, o), s = !0;
    }, this.itemEnd = function(u) {
      a++, r.onProgress !== void 0 && r.onProgress(u, a, o), a === o && (s = !1, r.onLoad !== void 0 && r.onLoad());
    }, this.itemError = function(u) {
      r.onError !== void 0 && r.onError(u);
    }, this.resolveURL = function(u) {
      return l ? l(u) : u;
    }, this.setURLModifier = function(u) {
      return l = u, this;
    }, this.addHandler = function(u, h) {
      return c.push(u, h), this;
    }, this.removeHandler = function(u) {
      const h = c.indexOf(u);
      return h !== -1 && c.splice(h, 2), this;
    }, this.getHandler = function(u) {
      for (let h = 0, d = c.length; h < d; h += 2) {
        const m = c[h], v = c[h + 1];
        if (m.global && (m.lastIndex = 0), m.test(u))
          return v;
      }
      return null;
    };
  }
}
const xM = /* @__PURE__ */ new vM();
class Zi {
  constructor(e) {
    this.manager = e !== void 0 ? e : xM, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {};
  }
  load() {
  }
  loadAsync(e, t) {
    const n = this;
    return new Promise(function(r, s) {
      n.load(e, r, t, s);
    });
  }
  parse() {
  }
  setCrossOrigin(e) {
    return this.crossOrigin = e, this;
  }
  setWithCredentials(e) {
    return this.withCredentials = e, this;
  }
  setPath(e) {
    return this.path = e, this;
  }
  setResourcePath(e) {
    return this.resourcePath = e, this;
  }
  setRequestHeader(e) {
    return this.requestHeader = e, this;
  }
}
Zi.DEFAULT_MATERIAL_NAME = "__DEFAULT";
const $n = {};
class bM extends Error {
  constructor(e, t) {
    super(e), this.response = t;
  }
}
class Bc extends Zi {
  constructor(e) {
    super(e);
  }
  load(e, t, n, r) {
    e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);
    const s = Ei.get(e);
    if (s !== void 0)
      return this.manager.itemStart(e), setTimeout(() => {
        t && t(s), this.manager.itemEnd(e);
      }, 0), s;
    if ($n[e] !== void 0) {
      $n[e].push({
        onLoad: t,
        onProgress: n,
        onError: r
      });
      return;
    }
    $n[e] = [], $n[e].push({
      onLoad: t,
      onProgress: n,
      onError: r
    });
    const a = new Request(e, {
      headers: new Headers(this.requestHeader),
      credentials: this.withCredentials ? "include" : "same-origin"
      // An abort controller could be added within a future PR
    }), o = this.mimeType, l = this.responseType;
    fetch(a).then((c) => {
      if (c.status === 200 || c.status === 0) {
        if (c.status === 0 && console.warn("THREE.FileLoader: HTTP Status 0 received."), typeof ReadableStream > "u" || c.body === void 0 || c.body.getReader === void 0)
          return c;
        const u = $n[e], h = c.body.getReader(), d = c.headers.get("X-File-Size") || c.headers.get("Content-Length"), m = d ? parseInt(d) : 0, v = m !== 0;
        let b = 0;
        const p = new ReadableStream({
          start(f) {
            x();
            function x() {
              h.read().then(({ done: g, value: _ }) => {
                if (g)
                  f.close();
                else {
                  b += _.byteLength;
                  const T = new ProgressEvent("progress", { lengthComputable: v, loaded: b, total: m });
                  for (let A = 0, M = u.length; A < M; A++) {
                    const C = u[A];
                    C.onProgress && C.onProgress(T);
                  }
                  f.enqueue(_), x();
                }
              }, (g) => {
                f.error(g);
              });
            }
          }
        });
        return new Response(p);
      } else
        throw new bM(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`, c);
    }).then((c) => {
      switch (l) {
        case "arraybuffer":
          return c.arrayBuffer();
        case "blob":
          return c.blob();
        case "document":
          return c.text().then((u) => new DOMParser().parseFromString(u, o));
        case "json":
          return c.json();
        default:
          if (o === void 0)
            return c.text();
          {
            const h = /charset="?([^;"\s]*)"?/i.exec(o), d = h && h[1] ? h[1].toLowerCase() : void 0, m = new TextDecoder(d);
            return c.arrayBuffer().then((v) => m.decode(v));
          }
      }
    }).then((c) => {
      Ei.add(e, c);
      const u = $n[e];
      delete $n[e];
      for (let h = 0, d = u.length; h < d; h++) {
        const m = u[h];
        m.onLoad && m.onLoad(c);
      }
    }).catch((c) => {
      const u = $n[e];
      if (u === void 0)
        throw this.manager.itemError(e), c;
      delete $n[e];
      for (let h = 0, d = u.length; h < d; h++) {
        const m = u[h];
        m.onError && m.onError(c);
      }
      this.manager.itemError(e);
    }).finally(() => {
      this.manager.itemEnd(e);
    }), this.manager.itemStart(e);
  }
  setResponseType(e) {
    return this.responseType = e, this;
  }
  setMimeType(e) {
    return this.mimeType = e, this;
  }
}
class EM extends Zi {
  constructor(e) {
    super(e);
  }
  load(e, t, n, r) {
    this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);
    const s = this, a = Ei.get(e);
    if (a !== void 0)
      return s.manager.itemStart(e), setTimeout(function() {
        t && t(a), s.manager.itemEnd(e);
      }, 0), a;
    const o = Ss("img");
    function l() {
      u(), Ei.add(e, this), t && t(this), s.manager.itemEnd(e);
    }
    function c(h) {
      u(), r && r(h), s.manager.itemError(e), s.manager.itemEnd(e);
    }
    function u() {
      o.removeEventListener("load", l, !1), o.removeEventListener("error", c, !1);
    }
    return o.addEventListener("load", l, !1), o.addEventListener("error", c, !1), e.slice(0, 5) !== "data:" && this.crossOrigin !== void 0 && (o.crossOrigin = this.crossOrigin), s.manager.itemStart(e), o.src = e, o;
  }
}
class yM extends Zi {
  constructor(e) {
    super(e);
  }
  load(e, t, n, r) {
    const s = new zt(), a = new EM(this.manager);
    return a.setCrossOrigin(this.crossOrigin), a.setPath(this.path), a.load(e, function(o) {
      s.image = o, s.needsUpdate = !0, t !== void 0 && t(s);
    }, n, r), s;
  }
}
class Ka extends Rt {
  constructor(e, t = 1) {
    super(), this.isLight = !0, this.type = "Light", this.color = new Ue(e), this.intensity = t;
  }
  dispose() {
  }
  copy(e, t) {
    return super.copy(e, t), this.color.copy(e.color), this.intensity = e.intensity, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return t.object.color = this.color.getHex(), t.object.intensity = this.intensity, this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (t.object.distance = this.distance), this.angle !== void 0 && (t.object.angle = this.angle), this.decay !== void 0 && (t.object.decay = this.decay), this.penumbra !== void 0 && (t.object.penumbra = this.penumbra), this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()), this.target !== void 0 && (t.object.target = this.target.uuid), t;
  }
}
const Wo = /* @__PURE__ */ new Xe(), sf = /* @__PURE__ */ new L(), af = /* @__PURE__ */ new L();
class kc {
  constructor(e) {
    this.camera = e, this.intensity = 1, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new ze(512, 512), this.map = null, this.mapPass = null, this.matrix = new Xe(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new Pc(), this._frameExtents = new ze(1, 1), this._viewportCount = 1, this._viewports = [
      new lt(0, 0, 1, 1)
    ];
  }
  getViewportCount() {
    return this._viewportCount;
  }
  getFrustum() {
    return this._frustum;
  }
  updateMatrices(e) {
    const t = this.camera, n = this.matrix;
    sf.setFromMatrixPosition(e.matrixWorld), t.position.copy(sf), af.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(af), t.updateMatrixWorld(), Wo.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(Wo), n.set(
      0.5,
      0,
      0,
      0.5,
      0,
      0.5,
      0,
      0.5,
      0,
      0,
      0.5,
      0.5,
      0,
      0,
      0,
      1
    ), n.multiply(Wo);
  }
  getViewport(e) {
    return this._viewports[e];
  }
  getFrameExtents() {
    return this._frameExtents;
  }
  dispose() {
    this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose();
  }
  copy(e) {
    return this.camera = e.camera.clone(), this.intensity = e.intensity, this.bias = e.bias, this.radius = e.radius, this.mapSize.copy(e.mapSize), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  toJSON() {
    const e = {};
    return this.intensity !== 1 && (e.intensity = this.intensity), this.bias !== 0 && (e.bias = this.bias), this.normalBias !== 0 && (e.normalBias = this.normalBias), this.radius !== 1 && (e.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()), e.camera = this.camera.toJSON(!1).object, delete e.camera.matrix, e;
  }
}
class SM extends kc {
  constructor() {
    super(new $t(50, 1, 0.5, 500)), this.isSpotLightShadow = !0, this.focus = 1;
  }
  updateMatrices(e) {
    const t = this.camera, n = Fr * 2 * e.angle * this.focus, r = this.mapSize.width / this.mapSize.height, s = e.distance || t.far;
    (n !== t.fov || r !== t.aspect || s !== t.far) && (t.fov = n, t.aspect = r, t.far = s, t.updateProjectionMatrix()), super.updateMatrices(e);
  }
  copy(e) {
    return super.copy(e), this.focus = e.focus, this;
  }
}
class MM extends Ka {
  constructor(e, t, n = 0, r = Math.PI / 3, s = 0, a = 2) {
    super(e, t), this.isSpotLight = !0, this.type = "SpotLight", this.position.copy(Rt.DEFAULT_UP), this.updateMatrix(), this.target = new Rt(), this.distance = n, this.angle = r, this.penumbra = s, this.decay = a, this.map = null, this.shadow = new SM();
  }
  get power() {
    return this.intensity * Math.PI;
  }
  set power(e) {
    this.intensity = e / Math.PI;
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(e, t) {
    return super.copy(e, t), this.distance = e.distance, this.angle = e.angle, this.penumbra = e.penumbra, this.decay = e.decay, this.target = e.target.clone(), this.shadow = e.shadow.clone(), this;
  }
}
const of = /* @__PURE__ */ new Xe(), ls = /* @__PURE__ */ new L(), Xo = /* @__PURE__ */ new L();
class AM extends kc {
  constructor() {
    super(new $t(90, 1, 0.5, 500)), this.isPointLightShadow = !0, this._frameExtents = new ze(4, 2), this._viewportCount = 6, this._viewports = [
      // These viewports map a cube-map onto a 2D texture with the
      // following orientation:
      //
      //  xzXZ
      //   y Y
      //
      // X - Positive x direction
      // x - Negative x direction
      // Y - Positive y direction
      // y - Negative y direction
      // Z - Positive z direction
      // z - Negative z direction
      // positive X
      new lt(2, 1, 1, 1),
      // negative X
      new lt(0, 1, 1, 1),
      // positive Z
      new lt(3, 1, 1, 1),
      // negative Z
      new lt(1, 1, 1, 1),
      // positive Y
      new lt(3, 0, 1, 1),
      // negative Y
      new lt(1, 0, 1, 1)
    ], this._cubeDirections = [
      new L(1, 0, 0),
      new L(-1, 0, 0),
      new L(0, 0, 1),
      new L(0, 0, -1),
      new L(0, 1, 0),
      new L(0, -1, 0)
    ], this._cubeUps = [
      new L(0, 1, 0),
      new L(0, 1, 0),
      new L(0, 1, 0),
      new L(0, 1, 0),
      new L(0, 0, 1),
      new L(0, 0, -1)
    ];
  }
  updateMatrices(e, t = 0) {
    const n = this.camera, r = this.matrix, s = e.distance || n.far;
    s !== n.far && (n.far = s, n.updateProjectionMatrix()), ls.setFromMatrixPosition(e.matrixWorld), n.position.copy(ls), Xo.copy(n.position), Xo.add(this._cubeDirections[t]), n.up.copy(this._cubeUps[t]), n.lookAt(Xo), n.updateMatrixWorld(), r.makeTranslation(-ls.x, -ls.y, -ls.z), of.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(of);
  }
}
class TM extends Ka {
  constructor(e, t, n = 0, r = 2) {
    super(e, t), this.isPointLight = !0, this.type = "PointLight", this.distance = n, this.decay = r, this.shadow = new AM();
  }
  get power() {
    return this.intensity * 4 * Math.PI;
  }
  set power(e) {
    this.intensity = e / (4 * Math.PI);
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(e, t) {
    return super.copy(e, t), this.distance = e.distance, this.decay = e.decay, this.shadow = e.shadow.clone(), this;
  }
}
class wM extends kc {
  constructor() {
    super(new Lc(-5, 5, 5, -5, 0.5, 500)), this.isDirectionalLightShadow = !0;
  }
}
class sp extends Ka {
  constructor(e, t) {
    super(e, t), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(Rt.DEFAULT_UP), this.updateMatrix(), this.target = new Rt(), this.shadow = new wM();
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(e) {
    return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this;
  }
}
class DM extends Ka {
  constructor(e, t) {
    super(e, t), this.isAmbientLight = !0, this.type = "AmbientLight";
  }
}
class vs {
  static decodeText(e) {
    if (console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."), typeof TextDecoder < "u")
      return new TextDecoder().decode(e);
    let t = "";
    for (let n = 0, r = e.length; n < r; n++)
      t += String.fromCharCode(e[n]);
    try {
      return decodeURIComponent(escape(t));
    } catch {
      return t;
    }
  }
  static extractUrlBase(e) {
    const t = e.lastIndexOf("/");
    return t === -1 ? "./" : e.slice(0, t + 1);
  }
  static resolveURL(e, t) {
    return typeof e != "string" || e === "" ? "" : (/^https?:\/\//i.test(t) && /^\//.test(e) && (t = t.replace(/(^https?:\/\/[^\/]+).*/i, "$1")), /^(https?:)?\/\//i.test(e) || /^data:.*,.*$/i.test(e) || /^blob:.*$/i.test(e) ? e : t + e);
  }
}
class RM extends Zi {
  constructor(e) {
    super(e), this.isImageBitmapLoader = !0, typeof createImageBitmap > "u" && console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."), typeof fetch > "u" && console.warn("THREE.ImageBitmapLoader: fetch() not supported."), this.options = { premultiplyAlpha: "none" };
  }
  setOptions(e) {
    return this.options = e, this;
  }
  load(e, t, n, r) {
    e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);
    const s = this, a = Ei.get(e);
    if (a !== void 0) {
      if (s.manager.itemStart(e), a.then) {
        a.then((c) => {
          t && t(c), s.manager.itemEnd(e);
        }).catch((c) => {
          r && r(c);
        });
        return;
      }
      return setTimeout(function() {
        t && t(a), s.manager.itemEnd(e);
      }, 0), a;
    }
    const o = {};
    o.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include", o.headers = this.requestHeader;
    const l = fetch(e, o).then(function(c) {
      return c.blob();
    }).then(function(c) {
      return createImageBitmap(c, Object.assign(s.options, { colorSpaceConversion: "none" }));
    }).then(function(c) {
      return Ei.add(e, c), t && t(c), s.manager.itemEnd(e), c;
    }).catch(function(c) {
      r && r(c), Ei.remove(e), s.manager.itemError(e), s.manager.itemEnd(e);
    });
    Ei.add(e, l), s.manager.itemStart(e);
  }
}
const Hc = "\\[\\]\\.:\\/", CM = new RegExp("[" + Hc + "]", "g"), zc = "[^" + Hc + "]", PM = "[^" + Hc.replace("\\.", "") + "]", LM = /* @__PURE__ */ /((?:WC+[\/:])*)/.source.replace("WC", zc), IM = /* @__PURE__ */ /(WCOD+)?/.source.replace("WCOD", PM), FM = /* @__PURE__ */ /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", zc), NM = /* @__PURE__ */ /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", zc), UM = new RegExp(
  "^" + LM + IM + FM + NM + "$"
), OM = ["material", "materials", "bones", "map"];
class BM {
  constructor(e, t, n) {
    const r = n || dt.parseTrackName(t);
    this._targetGroup = e, this._bindings = e.subscribe_(t, r);
  }
  getValue(e, t) {
    this.bind();
    const n = this._targetGroup.nCachedObjects_, r = this._bindings[n];
    r !== void 0 && r.getValue(e, t);
  }
  setValue(e, t) {
    const n = this._bindings;
    for (let r = this._targetGroup.nCachedObjects_, s = n.length; r !== s; ++r)
      n[r].setValue(e, t);
  }
  bind() {
    const e = this._bindings;
    for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)
      e[t].bind();
  }
  unbind() {
    const e = this._bindings;
    for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)
      e[t].unbind();
  }
}
class dt {
  constructor(e, t, n) {
    this.path = t, this.parsedPath = n || dt.parseTrackName(t), this.node = dt.findNode(e, this.parsedPath.nodeName), this.rootNode = e, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound;
  }
  static create(e, t, n) {
    return e && e.isAnimationObjectGroup ? new dt.Composite(e, t, n) : new dt(e, t, n);
  }
  /**
   * Replaces spaces with underscores and removes unsupported characters from
   * node names, to ensure compatibility with parseTrackName().
   *
   * @param {string} name Node name to be sanitized.
   * @return {string}
   */
  static sanitizeNodeName(e) {
    return e.replace(/\s/g, "_").replace(CM, "");
  }
  static parseTrackName(e) {
    const t = UM.exec(e);
    if (t === null)
      throw new Error("PropertyBinding: Cannot parse trackName: " + e);
    const n = {
      // directoryName: matches[ 1 ], // (tschw) currently unused
      nodeName: t[2],
      objectName: t[3],
      objectIndex: t[4],
      propertyName: t[5],
      // required
      propertyIndex: t[6]
    }, r = n.nodeName && n.nodeName.lastIndexOf(".");
    if (r !== void 0 && r !== -1) {
      const s = n.nodeName.substring(r + 1);
      OM.indexOf(s) !== -1 && (n.nodeName = n.nodeName.substring(0, r), n.objectName = s);
    }
    if (n.propertyName === null || n.propertyName.length === 0)
      throw new Error("PropertyBinding: can not parse propertyName from trackName: " + e);
    return n;
  }
  static findNode(e, t) {
    if (t === void 0 || t === "" || t === "." || t === -1 || t === e.name || t === e.uuid)
      return e;
    if (e.skeleton) {
      const n = e.skeleton.getBoneByName(t);
      if (n !== void 0)
        return n;
    }
    if (e.children) {
      const n = function(s) {
        for (let a = 0; a < s.length; a++) {
          const o = s[a];
          if (o.name === t || o.uuid === t)
            return o;
          const l = n(o.children);
          if (l) return l;
        }
        return null;
      }, r = n(e.children);
      if (r)
        return r;
    }
    return null;
  }
  // these are used to "bind" a nonexistent property
  _getValue_unavailable() {
  }
  _setValue_unavailable() {
  }
  // Getters
  _getValue_direct(e, t) {
    e[t] = this.targetObject[this.propertyName];
  }
  _getValue_array(e, t) {
    const n = this.resolvedProperty;
    for (let r = 0, s = n.length; r !== s; ++r)
      e[t++] = n[r];
  }
  _getValue_arrayElement(e, t) {
    e[t] = this.resolvedProperty[this.propertyIndex];
  }
  _getValue_toArray(e, t) {
    this.resolvedProperty.toArray(e, t);
  }
  // Direct
  _setValue_direct(e, t) {
    this.targetObject[this.propertyName] = e[t];
  }
  _setValue_direct_setNeedsUpdate(e, t) {
    this.targetObject[this.propertyName] = e[t], this.targetObject.needsUpdate = !0;
  }
  _setValue_direct_setMatrixWorldNeedsUpdate(e, t) {
    this.targetObject[this.propertyName] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0;
  }
  // EntireArray
  _setValue_array(e, t) {
    const n = this.resolvedProperty;
    for (let r = 0, s = n.length; r !== s; ++r)
      n[r] = e[t++];
  }
  _setValue_array_setNeedsUpdate(e, t) {
    const n = this.resolvedProperty;
    for (let r = 0, s = n.length; r !== s; ++r)
      n[r] = e[t++];
    this.targetObject.needsUpdate = !0;
  }
  _setValue_array_setMatrixWorldNeedsUpdate(e, t) {
    const n = this.resolvedProperty;
    for (let r = 0, s = n.length; r !== s; ++r)
      n[r] = e[t++];
    this.targetObject.matrixWorldNeedsUpdate = !0;
  }
  // ArrayElement
  _setValue_arrayElement(e, t) {
    this.resolvedProperty[this.propertyIndex] = e[t];
  }
  _setValue_arrayElement_setNeedsUpdate(e, t) {
    this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.needsUpdate = !0;
  }
  _setValue_arrayElement_setMatrixWorldNeedsUpdate(e, t) {
    this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0;
  }
  // HasToFromArray
  _setValue_fromArray(e, t) {
    this.resolvedProperty.fromArray(e, t);
  }
  _setValue_fromArray_setNeedsUpdate(e, t) {
    this.resolvedProperty.fromArray(e, t), this.targetObject.needsUpdate = !0;
  }
  _setValue_fromArray_setMatrixWorldNeedsUpdate(e, t) {
    this.resolvedProperty.fromArray(e, t), this.targetObject.matrixWorldNeedsUpdate = !0;
  }
  _getValue_unbound(e, t) {
    this.bind(), this.getValue(e, t);
  }
  _setValue_unbound(e, t) {
    this.bind(), this.setValue(e, t);
  }
  // create getter / setter pair for a property in the scene graph
  bind() {
    let e = this.node;
    const t = this.parsedPath, n = t.objectName, r = t.propertyName;
    let s = t.propertyIndex;
    if (e || (e = dt.findNode(this.rootNode, t.nodeName), this.node = e), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !e) {
      console.warn("THREE.PropertyBinding: No target node found for track: " + this.path + ".");
      return;
    }
    if (n) {
      let c = t.objectIndex;
      switch (n) {
        case "materials":
          if (!e.material) {
            console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this);
            return;
          }
          if (!e.material.materials) {
            console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this);
            return;
          }
          e = e.material.materials;
          break;
        case "bones":
          if (!e.skeleton) {
            console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this);
            return;
          }
          e = e.skeleton.bones;
          for (let u = 0; u < e.length; u++)
            if (e[u].name === c) {
              c = u;
              break;
            }
          break;
        case "map":
          if ("map" in e) {
            e = e.map;
            break;
          }
          if (!e.material) {
            console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this);
            return;
          }
          if (!e.material.map) {
            console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.", this);
            return;
          }
          e = e.material.map;
          break;
        default:
          if (e[n] === void 0) {
            console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this);
            return;
          }
          e = e[n];
      }
      if (c !== void 0) {
        if (e[c] === void 0) {
          console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, e);
          return;
        }
        e = e[c];
      }
    }
    const a = e[r];
    if (a === void 0) {
      const c = t.nodeName;
      console.error("THREE.PropertyBinding: Trying to update property for track: " + c + "." + r + " but it wasn't found.", e);
      return;
    }
    let o = this.Versioning.None;
    this.targetObject = e, e.needsUpdate !== void 0 ? o = this.Versioning.NeedsUpdate : e.matrixWorldNeedsUpdate !== void 0 && (o = this.Versioning.MatrixWorldNeedsUpdate);
    let l = this.BindingType.Direct;
    if (s !== void 0) {
      if (r === "morphTargetInfluences") {
        if (!e.geometry) {
          console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this);
          return;
        }
        if (!e.geometry.morphAttributes) {
          console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this);
          return;
        }
        e.morphTargetDictionary[s] !== void 0 && (s = e.morphTargetDictionary[s]);
      }
      l = this.BindingType.ArrayElement, this.resolvedProperty = a, this.propertyIndex = s;
    } else a.fromArray !== void 0 && a.toArray !== void 0 ? (l = this.BindingType.HasFromToArray, this.resolvedProperty = a) : Array.isArray(a) ? (l = this.BindingType.EntireArray, this.resolvedProperty = a) : this.propertyName = r;
    this.getValue = this.GetterByBindingType[l], this.setValue = this.SetterByBindingTypeAndVersioning[l][o];
  }
  unbind() {
    this.node = null, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound;
  }
}
dt.Composite = BM;
dt.prototype.BindingType = {
  Direct: 0,
  EntireArray: 1,
  ArrayElement: 2,
  HasFromToArray: 3
};
dt.prototype.Versioning = {
  None: 0,
  NeedsUpdate: 1,
  MatrixWorldNeedsUpdate: 2
};
dt.prototype.GetterByBindingType = [
  dt.prototype._getValue_direct,
  dt.prototype._getValue_array,
  dt.prototype._getValue_arrayElement,
  dt.prototype._getValue_toArray
];
dt.prototype.SetterByBindingTypeAndVersioning = [
  [
    // Direct
    dt.prototype._setValue_direct,
    dt.prototype._setValue_direct_setNeedsUpdate,
    dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate
  ],
  [
    // EntireArray
    dt.prototype._setValue_array,
    dt.prototype._setValue_array_setNeedsUpdate,
    dt.prototype._setValue_array_setMatrixWorldNeedsUpdate
  ],
  [
    // ArrayElement
    dt.prototype._setValue_arrayElement,
    dt.prototype._setValue_arrayElement_setNeedsUpdate,
    dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate
  ],
  [
    // HasToFromArray
    dt.prototype._setValue_fromArray,
    dt.prototype._setValue_fromArray_setNeedsUpdate,
    dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate
  ]
];
class lf {
  constructor(e = 1, t = 0, n = 0) {
    return this.radius = e, this.phi = t, this.theta = n, this;
  }
  set(e, t, n) {
    return this.radius = e, this.phi = t, this.theta = n, this;
  }
  copy(e) {
    return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this;
  }
  // restrict phi to be between EPS and PI-EPS
  makeSafe() {
    return this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi)), this;
  }
  setFromVector3(e) {
    return this.setFromCartesianCoords(e.x, e.y, e.z);
  }
  setFromCartesianCoords(e, t, n) {
    return this.radius = Math.sqrt(e * e + t * t + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, n), this.phi = Math.acos(Vt(t / this.radius, -1, 1))), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class kM extends Yi {
  constructor(e, t = null) {
    super(), this.object = e, this.domElement = t, this.enabled = !0, this.state = -1, this.keys = {}, this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null }, this.touches = { ONE: null, TWO: null };
  }
  connect() {
  }
  disconnect() {
  }
  dispose() {
  }
  update() {
  }
}
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  revision: yc
} }));
typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = yc);
const cf = { type: "change" }, Gc = { type: "start" }, ap = { type: "end" }, pa = new Ps(), uf = new _i(), HM = Math.cos(70 * Od.DEG2RAD), Ft = new L(), nn = 2 * Math.PI, gt = {
  NONE: -1,
  ROTATE: 0,
  DOLLY: 1,
  PAN: 2,
  TOUCH_ROTATE: 3,
  TOUCH_PAN: 4,
  TOUCH_DOLLY_PAN: 5,
  TOUCH_DOLLY_ROTATE: 6
}, jo = 1e-6;
class zM extends kM {
  constructor(e, t = null) {
    super(e, t), this.state = gt.NONE, this.enabled = !0, this.target = new L(), this.cursor = new L(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: xr.ROTATE, MIDDLE: xr.DOLLY, RIGHT: xr.PAN }, this.touches = { ONE: gr.ROTATE, TWO: gr.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new L(), this._lastQuaternion = new kn(), this._lastTargetPosition = new L(), this._quat = new kn().setFromUnitVectors(e.up, new L(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new lf(), this._sphericalDelta = new lf(), this._scale = 1, this._panOffset = new L(), this._rotateStart = new ze(), this._rotateEnd = new ze(), this._rotateDelta = new ze(), this._panStart = new ze(), this._panEnd = new ze(), this._panDelta = new ze(), this._dollyStart = new ze(), this._dollyEnd = new ze(), this._dollyDelta = new ze(), this._dollyDirection = new L(), this._mouse = new ze(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = VM.bind(this), this._onPointerDown = GM.bind(this), this._onPointerUp = WM.bind(this), this._onContextMenu = $M.bind(this), this._onMouseWheel = qM.bind(this), this._onKeyDown = YM.bind(this), this._onTouchStart = ZM.bind(this), this._onTouchMove = KM.bind(this), this._onMouseDown = XM.bind(this), this._onMouseMove = jM.bind(this), this._interceptControlDown = JM.bind(this), this._interceptControlUp = QM.bind(this), this.domElement !== null && this.connect(), this.update();
  }
  connect() {
    this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";
  }
  disconnect() {
    this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "auto";
  }
  dispose() {
    this.disconnect();
  }
  getPolarAngle() {
    return this._spherical.phi;
  }
  getAzimuthalAngle() {
    return this._spherical.theta;
  }
  getDistance() {
    return this.object.position.distanceTo(this.target);
  }
  listenToKeyEvents(e) {
    e.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = e;
  }
  stopListenToKeyEvents() {
    this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
  }
  saveState() {
    this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
  }
  reset() {
    this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(cf), this.update(), this.state = gt.NONE;
  }
  update(e = null) {
    const t = this.object.position;
    Ft.copy(t).sub(this.target), Ft.applyQuaternion(this._quat), this._spherical.setFromVector3(Ft), this.autoRotate && this.state === gt.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
    let n = this.minAzimuthAngle, r = this.maxAzimuthAngle;
    isFinite(n) && isFinite(r) && (n < -Math.PI ? n += nn : n > Math.PI && (n -= nn), r < -Math.PI ? r += nn : r > Math.PI && (r -= nn), n <= r ? this._spherical.theta = Math.max(n, Math.min(r, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (n + r) / 2 ? Math.max(n, this._spherical.theta) : Math.min(r, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
    let s = !1;
    if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
      this._spherical.radius = this._clampDistance(this._spherical.radius);
    else {
      const a = this._spherical.radius;
      this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), s = a != this._spherical.radius;
    }
    if (Ft.setFromSpherical(this._spherical), Ft.applyQuaternion(this._quatInverse), t.copy(this.target).add(Ft), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
      let a = null;
      if (this.object.isPerspectiveCamera) {
        const o = Ft.length();
        a = this._clampDistance(o * this._scale);
        const l = o - a;
        this.object.position.addScaledVector(this._dollyDirection, l), this.object.updateMatrixWorld(), s = !!l;
      } else if (this.object.isOrthographicCamera) {
        const o = new L(this._mouse.x, this._mouse.y, 0);
        o.unproject(this.object);
        const l = this.object.zoom;
        this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), s = l !== this.object.zoom;
        const c = new L(this._mouse.x, this._mouse.y, 0);
        c.unproject(this.object), this.object.position.sub(c).add(o), this.object.updateMatrixWorld(), a = Ft.length();
      } else
        console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
      a !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position) : (pa.origin.copy(this.object.position), pa.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(pa.direction)) < HM ? this.object.lookAt(this.target) : (uf.setFromNormalAndCoplanarPoint(this.object.up, this.target), pa.intersectPlane(uf, this.target))));
    } else if (this.object.isOrthographicCamera) {
      const a = this.object.zoom;
      this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), a !== this.object.zoom && (this.object.updateProjectionMatrix(), s = !0);
    }
    return this._scale = 1, this._performCursorZoom = !1, s || this._lastPosition.distanceToSquared(this.object.position) > jo || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > jo || this._lastTargetPosition.distanceToSquared(this.target) > jo ? (this.dispatchEvent(cf), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
  }
  _getAutoRotationAngle(e) {
    return e !== null ? nn / 60 * this.autoRotateSpeed * e : nn / 60 / 60 * this.autoRotateSpeed;
  }
  _getZoomScale(e) {
    const t = Math.abs(e * 0.01);
    return Math.pow(0.95, this.zoomSpeed * t);
  }
  _rotateLeft(e) {
    this._sphericalDelta.theta -= e;
  }
  _rotateUp(e) {
    this._sphericalDelta.phi -= e;
  }
  _panLeft(e, t) {
    Ft.setFromMatrixColumn(t, 0), Ft.multiplyScalar(-e), this._panOffset.add(Ft);
  }
  _panUp(e, t) {
    this.screenSpacePanning === !0 ? Ft.setFromMatrixColumn(t, 1) : (Ft.setFromMatrixColumn(t, 0), Ft.crossVectors(this.object.up, Ft)), Ft.multiplyScalar(e), this._panOffset.add(Ft);
  }
  // deltaX and deltaY are in pixels; right and down are positive
  _pan(e, t) {
    const n = this.domElement;
    if (this.object.isPerspectiveCamera) {
      const r = this.object.position;
      Ft.copy(r).sub(this.target);
      let s = Ft.length();
      s *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * s / n.clientHeight, this.object.matrix), this._panUp(2 * t * s / n.clientHeight, this.object.matrix);
    } else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / n.clientWidth, this.object.matrix), this._panUp(t * (this.object.top - this.object.bottom) / this.object.zoom / n.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
  }
  _dollyOut(e) {
    this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
  }
  _dollyIn(e) {
    this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
  }
  _updateZoomParameters(e, t) {
    if (!this.zoomToCursor)
      return;
    this._performCursorZoom = !0;
    const n = this.domElement.getBoundingClientRect(), r = e - n.left, s = t - n.top, a = n.width, o = n.height;
    this._mouse.x = r / a * 2 - 1, this._mouse.y = -(s / o) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
  }
  _clampDistance(e) {
    return Math.max(this.minDistance, Math.min(this.maxDistance, e));
  }
  //
  // event callbacks - update the object state
  //
  _handleMouseDownRotate(e) {
    this._rotateStart.set(e.clientX, e.clientY);
  }
  _handleMouseDownDolly(e) {
    this._updateZoomParameters(e.clientX, e.clientX), this._dollyStart.set(e.clientX, e.clientY);
  }
  _handleMouseDownPan(e) {
    this._panStart.set(e.clientX, e.clientY);
  }
  _handleMouseMoveRotate(e) {
    this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
    const t = this.domElement;
    this._rotateLeft(nn * this._rotateDelta.x / t.clientHeight), this._rotateUp(nn * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
  }
  _handleMouseMoveDolly(e) {
    this._dollyEnd.set(e.clientX, e.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update();
  }
  _handleMouseMovePan(e) {
    this._panEnd.set(e.clientX, e.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update();
  }
  _handleMouseWheel(e) {
    this._updateZoomParameters(e.clientX, e.clientY), e.deltaY < 0 ? this._dollyIn(this._getZoomScale(e.deltaY)) : e.deltaY > 0 && this._dollyOut(this._getZoomScale(e.deltaY)), this.update();
  }
  _handleKeyDown(e) {
    let t = !1;
    switch (e.code) {
      case this.keys.UP:
        e.ctrlKey || e.metaKey || e.shiftKey ? this._rotateUp(nn * this.rotateSpeed / this.domElement.clientHeight) : this._pan(0, this.keyPanSpeed), t = !0;
        break;
      case this.keys.BOTTOM:
        e.ctrlKey || e.metaKey || e.shiftKey ? this._rotateUp(-nn * this.rotateSpeed / this.domElement.clientHeight) : this._pan(0, -this.keyPanSpeed), t = !0;
        break;
      case this.keys.LEFT:
        e.ctrlKey || e.metaKey || e.shiftKey ? this._rotateLeft(nn * this.rotateSpeed / this.domElement.clientHeight) : this._pan(this.keyPanSpeed, 0), t = !0;
        break;
      case this.keys.RIGHT:
        e.ctrlKey || e.metaKey || e.shiftKey ? this._rotateLeft(-nn * this.rotateSpeed / this.domElement.clientHeight) : this._pan(-this.keyPanSpeed, 0), t = !0;
        break;
    }
    t && (e.preventDefault(), this.update());
  }
  _handleTouchStartRotate(e) {
    if (this._pointers.length === 1)
      this._rotateStart.set(e.pageX, e.pageY);
    else {
      const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), r = 0.5 * (e.pageY + t.y);
      this._rotateStart.set(n, r);
    }
  }
  _handleTouchStartPan(e) {
    if (this._pointers.length === 1)
      this._panStart.set(e.pageX, e.pageY);
    else {
      const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), r = 0.5 * (e.pageY + t.y);
      this._panStart.set(n, r);
    }
  }
  _handleTouchStartDolly(e) {
    const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, r = e.pageY - t.y, s = Math.sqrt(n * n + r * r);
    this._dollyStart.set(0, s);
  }
  _handleTouchStartDollyPan(e) {
    this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e);
  }
  _handleTouchStartDollyRotate(e) {
    this.enableZoom && this._handleTouchStartDolly(e), this.enableRotate && this._handleTouchStartRotate(e);
  }
  _handleTouchMoveRotate(e) {
    if (this._pointers.length == 1)
      this._rotateEnd.set(e.pageX, e.pageY);
    else {
      const n = this._getSecondPointerPosition(e), r = 0.5 * (e.pageX + n.x), s = 0.5 * (e.pageY + n.y);
      this._rotateEnd.set(r, s);
    }
    this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
    const t = this.domElement;
    this._rotateLeft(nn * this._rotateDelta.x / t.clientHeight), this._rotateUp(nn * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd);
  }
  _handleTouchMovePan(e) {
    if (this._pointers.length === 1)
      this._panEnd.set(e.pageX, e.pageY);
    else {
      const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), r = 0.5 * (e.pageY + t.y);
      this._panEnd.set(n, r);
    }
    this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
  }
  _handleTouchMoveDolly(e) {
    const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, r = e.pageY - t.y, s = Math.sqrt(n * n + r * r);
    this._dollyEnd.set(0, s), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
    const a = (e.pageX + t.x) * 0.5, o = (e.pageY + t.y) * 0.5;
    this._updateZoomParameters(a, o);
  }
  _handleTouchMoveDollyPan(e) {
    this.enableZoom && this._handleTouchMoveDolly(e), this.enablePan && this._handleTouchMovePan(e);
  }
  _handleTouchMoveDollyRotate(e) {
    this.enableZoom && this._handleTouchMoveDolly(e), this.enableRotate && this._handleTouchMoveRotate(e);
  }
  // pointers
  _addPointer(e) {
    this._pointers.push(e.pointerId);
  }
  _removePointer(e) {
    delete this._pointerPositions[e.pointerId];
    for (let t = 0; t < this._pointers.length; t++)
      if (this._pointers[t] == e.pointerId) {
        this._pointers.splice(t, 1);
        return;
      }
  }
  _isTrackingPointer(e) {
    for (let t = 0; t < this._pointers.length; t++)
      if (this._pointers[t] == e.pointerId) return !0;
    return !1;
  }
  _trackPointer(e) {
    let t = this._pointerPositions[e.pointerId];
    t === void 0 && (t = new ze(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
  }
  _getSecondPointerPosition(e) {
    const t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
    return this._pointerPositions[t];
  }
  //
  _customWheelEvent(e) {
    const t = e.deltaMode, n = {
      clientX: e.clientX,
      clientY: e.clientY,
      deltaY: e.deltaY
    };
    switch (t) {
      case 1:
        n.deltaY *= 16;
        break;
      case 2:
        n.deltaY *= 100;
        break;
    }
    return e.ctrlKey && !this._controlActive && (n.deltaY *= 10), n;
  }
}
function GM(i) {
  this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(i.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(i) && (this._addPointer(i), i.pointerType === "touch" ? this._onTouchStart(i) : this._onMouseDown(i)));
}
function VM(i) {
  this.enabled !== !1 && (i.pointerType === "touch" ? this._onTouchMove(i) : this._onMouseMove(i));
}
function WM(i) {
  switch (this._removePointer(i), this._pointers.length) {
    case 0:
      this.domElement.releasePointerCapture(i.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(ap), this.state = gt.NONE;
      break;
    case 1:
      const e = this._pointers[0], t = this._pointerPositions[e];
      this._onTouchStart({ pointerId: e, pageX: t.x, pageY: t.y });
      break;
  }
}
function XM(i) {
  let e;
  switch (i.button) {
    case 0:
      e = this.mouseButtons.LEFT;
      break;
    case 1:
      e = this.mouseButtons.MIDDLE;
      break;
    case 2:
      e = this.mouseButtons.RIGHT;
      break;
    default:
      e = -1;
  }
  switch (e) {
    case xr.DOLLY:
      if (this.enableZoom === !1) return;
      this._handleMouseDownDolly(i), this.state = gt.DOLLY;
      break;
    case xr.ROTATE:
      if (i.ctrlKey || i.metaKey || i.shiftKey) {
        if (this.enablePan === !1) return;
        this._handleMouseDownPan(i), this.state = gt.PAN;
      } else {
        if (this.enableRotate === !1) return;
        this._handleMouseDownRotate(i), this.state = gt.ROTATE;
      }
      break;
    case xr.PAN:
      if (i.ctrlKey || i.metaKey || i.shiftKey) {
        if (this.enableRotate === !1) return;
        this._handleMouseDownRotate(i), this.state = gt.ROTATE;
      } else {
        if (this.enablePan === !1) return;
        this._handleMouseDownPan(i), this.state = gt.PAN;
      }
      break;
    default:
      this.state = gt.NONE;
  }
  this.state !== gt.NONE && this.dispatchEvent(Gc);
}
function jM(i) {
  switch (this.state) {
    case gt.ROTATE:
      if (this.enableRotate === !1) return;
      this._handleMouseMoveRotate(i);
      break;
    case gt.DOLLY:
      if (this.enableZoom === !1) return;
      this._handleMouseMoveDolly(i);
      break;
    case gt.PAN:
      if (this.enablePan === !1) return;
      this._handleMouseMovePan(i);
      break;
  }
}
function qM(i) {
  this.enabled === !1 || this.enableZoom === !1 || this.state !== gt.NONE || (i.preventDefault(), this.dispatchEvent(Gc), this._handleMouseWheel(this._customWheelEvent(i)), this.dispatchEvent(ap));
}
function YM(i) {
  this.enabled === !1 || this.enablePan === !1 || this._handleKeyDown(i);
}
function ZM(i) {
  switch (this._trackPointer(i), this._pointers.length) {
    case 1:
      switch (this.touches.ONE) {
        case gr.ROTATE:
          if (this.enableRotate === !1) return;
          this._handleTouchStartRotate(i), this.state = gt.TOUCH_ROTATE;
          break;
        case gr.PAN:
          if (this.enablePan === !1) return;
          this._handleTouchStartPan(i), this.state = gt.TOUCH_PAN;
          break;
        default:
          this.state = gt.NONE;
      }
      break;
    case 2:
      switch (this.touches.TWO) {
        case gr.DOLLY_PAN:
          if (this.enableZoom === !1 && this.enablePan === !1) return;
          this._handleTouchStartDollyPan(i), this.state = gt.TOUCH_DOLLY_PAN;
          break;
        case gr.DOLLY_ROTATE:
          if (this.enableZoom === !1 && this.enableRotate === !1) return;
          this._handleTouchStartDollyRotate(i), this.state = gt.TOUCH_DOLLY_ROTATE;
          break;
        default:
          this.state = gt.NONE;
      }
      break;
    default:
      this.state = gt.NONE;
  }
  this.state !== gt.NONE && this.dispatchEvent(Gc);
}
function KM(i) {
  switch (this._trackPointer(i), this.state) {
    case gt.TOUCH_ROTATE:
      if (this.enableRotate === !1) return;
      this._handleTouchMoveRotate(i), this.update();
      break;
    case gt.TOUCH_PAN:
      if (this.enablePan === !1) return;
      this._handleTouchMovePan(i), this.update();
      break;
    case gt.TOUCH_DOLLY_PAN:
      if (this.enableZoom === !1 && this.enablePan === !1) return;
      this._handleTouchMoveDollyPan(i), this.update();
      break;
    case gt.TOUCH_DOLLY_ROTATE:
      if (this.enableZoom === !1 && this.enableRotate === !1) return;
      this._handleTouchMoveDollyRotate(i), this.update();
      break;
    default:
      this.state = gt.NONE;
  }
}
function $M(i) {
  this.enabled !== !1 && i.preventDefault();
}
function JM(i) {
  i.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
function QM(i) {
  i.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
var eA = /* @__PURE__ */ Ct('<div class="viewport-label svelte-1argyeb"> </div>'), tA = /* @__PURE__ */ Ct('<div class="overlay loading-overlay svelte-1argyeb"><div class="spinner svelte-1argyeb"></div> <span>Loading…</span></div>'), nA = /* @__PURE__ */ Ct('<div class="overlay error-overlay svelte-1argyeb"><span> </span></div>'), iA = /* @__PURE__ */ Ct('<div class="placeholder-frame svelte-1argyeb" aria-hidden="true"></div> <button class="overlay placeholder-overlay placeholder-button svelte-1argyeb" type="button" aria-label="Upload a .ply or .glb file"><div class="placeholder-icon svelte-1argyeb"><svg viewBox="0 0 24 24" aria-hidden="true" class="svelte-1argyeb"><path d="M12 16V6m0 0-4 4m4-4 4 4M5 19h14" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.7"></path></svg></div> <span class="placeholder-title svelte-1argyeb">Upload</span> <span class="placeholder-subtitle svelte-1argyeb">.ply / .glb</span></button>', 1), rA = /* @__PURE__ */ Ct('<div class="viewport-wrapper svelte-1argyeb"><!> <!> <!> <!> <canvas></canvas></div>');
function sA(i, e) {
  zr(e, !0);
  let t = Ee(e, "placeholder", 3, !1), n = Ee(e, "uploadable", 3, !1), r;
  const s = crypto.randomUUID();
  let a = wt(null), o = wt(null), l = wt(null), c = wt(null), u = null, h = null, d = null;
  Hf(() => (m(), () => f()));
  function m() {
    if (!r) return;
    const B = new QS({ canvas: r, antialias: !0 });
    B.setPixelRatio(window.devicePixelRatio), B.setClearColor(1710638);
    const U = new eM();
    U.add(new DM(16777215, 0.8));
    const Y = new sp(16777215, 0.5);
    Y.position.set(5, 10, 7), U.add(Y);
    const z = r.clientWidth || r.offsetWidth || 300, ie = e.height, oe = new $t(60, Math.max(z, 1) / ie, 1e-3, 1e5), ce = new zM(oe, B.domElement);
    ce.enableDamping = !0, ce.dampingFactor = 0.1, Te(a, B, !0), Te(o, U, !0), Te(l, oe, !0), Te(c, ce, !0), h = new ResizeObserver(() => b()), h.observe(r.parentElement), b(), p();
  }
  Lt(() => {
    const B = P(o), U = e.asset;
    B && (d && (B.remove(d), d = null), U?.object3d && (B.add(U.object3d), d = U.object3d), v());
  }), Lt(() => {
    const B = P(l), U = P(c), Y = e.initialCamera;
    !B || !U || !Y || (B.position.set(Y.position.x, Y.position.y, Y.position.z), B.up.set(Y.up.x, Y.up.y, Y.up.z), B.zoom = Y.zoom, B.updateProjectionMatrix(), U.target.set(Y.target.x, Y.target.y, Y.target.z), U.update(), v());
  }), Lt(() => {
    const B = P(l), U = P(c);
    !B || !U || e.syncManager.register({
      id: s,
      camera: B,
      controls: U,
      render: v
    });
  }), Lt(() => {
    const B = e.asset, U = e.pointSize;
    B?.object3d && (B.object3d.traverse((Y) => {
      const z = Y;
      z.isPoints && z.material && (z.material.size = U * 0.01);
    }), v());
  });
  function v() {
    !P(a) || !P(o) || !P(l) || P(a).render(P(o), P(l));
  }
  function b() {
    if (!r || !P(a) || !P(l)) return;
    const B = r.parentElement;
    if (!B) return;
    const U = B.clientWidth || B.offsetWidth;
    if (U === 0) {
      requestAnimationFrame(() => b());
      return;
    }
    const Y = e.height;
    P(a).setSize(U, Y, !1), P(l).aspect = U / Y, P(l).updateProjectionMatrix(), v();
  }
  function p() {
    function B() {
      var U, Y;
      u = requestAnimationFrame(B), P(c) === null || P(c) === void 0 || P(c).update(), P(a) && r && ((Y = (U = r.parentElement) === null || U === void 0 ? void 0 : U.clientWidth) !== null && Y !== void 0 ? Y : 0) > 0 && P(a).domElement.width === 0 && b(), v();
    }
    B();
  }
  function f() {
    u !== null && cancelAnimationFrame(u), e.syncManager.unregister(s), P(c) === null || P(c) === void 0 || P(c).dispose(), P(a) === null || P(a) === void 0 || P(a).dispose(), h?.disconnect();
  }
  function x(B) {
    var U, Y;
    if (B.preventDefault(), !e.drop_files) return;
    const z = Array.from((Y = (U = B.dataTransfer) === null || U === void 0 ? void 0 : U.files) !== null && Y !== void 0 ? Y : []);
    z.length > 0 && e.drop_files(z);
  }
  function g(B) {
    B.preventDefault();
  }
  var _ = rA(), T = pt(_);
  {
    var A = (B) => {
      var U = eA(), Y = pt(U);
      Dt(() => Yt(Y, e.label)), Ke(B, U);
    };
    At(T, (B) => {
      t() || B(A);
    });
  }
  var M = st(T, 2);
  {
    var C = (B) => {
      var U = tA();
      Ke(B, U);
    };
    At(M, (B) => {
      e.loading && B(C);
    });
  }
  var y = st(M, 2);
  {
    var E = (B) => {
      var U = nA(), Y = pt(U), z = pt(Y);
      Dt(() => Yt(z, `⚠ ${e.error ?? ""}`)), Ke(B, U);
    };
    At(y, (B) => {
      e.error && B(E);
    });
  }
  var R = st(y, 2);
  {
    var q = (B) => {
      var U = iA(), Y = st(Kt(U), 2);
      Dt(() => Y.disabled = !n()), ei("click", Y, function(...z) {
        e.request_upload?.apply(this, z);
      }), Jo("dragover", Y, g), Jo("drop", Y, x), Ke(B, U);
    };
    At(R, (B) => {
      t() && !e.loading && !e.error && B(q);
    });
  }
  var G = st(R, 2);
  let V;
  Ha(G, (B) => r = B, () => r), Dt(() => {
    Dn(_, `height: ${e.height ?? ""}px; position: relative;`), Dn(G, `width:100%; height:${e.height ?? ""}px; display:block;`), V = ri(G, 1, "svelte-1argyeb", null, V, {
      "placeholder-canvas": t() && !e.loading && !e.error
    });
  }), Ke(i, _), Hr();
}
kr(["click"]);
class aA {
  constructor() {
    this.viewports = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Map(), this.isSyncing = !1, this.syncEnabled = !0;
  }
  register(e) {
    const t = this.viewports.get(e.id), n = this.listeners.get(e.id);
    t && n && t.controls.removeEventListener("change", n), this.viewports.set(e.id, e);
    const r = () => {
      this.onControlChange(e.id);
    };
    this.listeners.set(e.id, r), e.controls.addEventListener("change", r);
  }
  unregister(e) {
    const t = this.viewports.get(e), n = this.listeners.get(e);
    t && n && t.controls.removeEventListener("change", n), this.viewports.delete(e), this.listeners.delete(e);
  }
  setEnabled(e) {
    this.syncEnabled = e;
  }
  setZoom(e) {
    for (const t of this.viewports.values())
      t.camera.zoom = e, t.camera.updateProjectionMatrix(), t.controls.update(), t.render();
  }
  resetAll(e) {
    for (const t of this.viewports.values())
      this.applyState(t, e), t.controls.update(), t.render();
  }
  onControlChange(e) {
    if (!(this.isSyncing || !this.syncEnabled)) {
      this.isSyncing = !0;
      try {
        const t = this.viewports.get(e);
        if (!t) return;
        const n = this.extractState(t);
        for (const [r, s] of this.viewports)
          r !== e && (this.applyState(s, n), s.controls.update(), s.render());
      } finally {
        this.isSyncing = !1;
      }
    }
  }
  extractState(e) {
    const t = e.camera.position, n = e.controls.target, r = e.camera.up;
    return {
      position: { x: t.x, y: t.y, z: t.z },
      target: { x: n.x, y: n.y, z: n.z },
      zoom: e.camera.zoom,
      up: { x: r.x, y: r.y, z: r.z }
    };
  }
  applyState(e, t) {
    e.camera.position.set(t.position.x, t.position.y, t.position.z), e.camera.up.set(t.up.x, t.up.y, t.up.z), e.camera.zoom = t.zoom, e.camera.updateProjectionMatrix(), e.controls.target.set(t.target.x, t.target.y, t.target.z);
  }
}
const rn = new Ue();
class oA extends Zi {
  constructor(e) {
    super(e), this.propertyNameMapping = {}, this.customPropertyMapping = {};
  }
  load(e, t, n, r) {
    const s = this, a = new Bc(this.manager);
    a.setPath(this.path), a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(o) {
      try {
        t(s.parse(o));
      } catch (l) {
        r ? r(l) : console.error(l), s.manager.itemError(e);
      }
    }, n, r);
  }
  setPropertyNameMapping(e) {
    this.propertyNameMapping = e;
  }
  setCustomPropertyNameMapping(e) {
    this.customPropertyMapping = e;
  }
  parse(e) {
    function t(p, f = 0) {
      const x = /^ply([\s\S]*)end_header(\r\n|\r|\n)/;
      let g = "";
      const _ = x.exec(p);
      _ !== null && (g = _[1]);
      const T = {
        comments: [],
        elements: [],
        headerLength: f,
        objInfo: ""
      }, A = g.split(/\r\n|\r|\n/);
      let M;
      function C(y, E) {
        const R = { type: y[0] };
        return R.type === "list" ? (R.name = y[3], R.countType = y[1], R.itemType = y[2]) : R.name = y[1], R.name in E && (R.name = E[R.name]), R;
      }
      for (let y = 0; y < A.length; y++) {
        let E = A[y];
        if (E = E.trim(), E === "") continue;
        const R = E.split(/\s+/), q = R.shift();
        switch (E = R.join(" "), q) {
          case "format":
            T.format = R[0], T.version = R[1];
            break;
          case "comment":
            T.comments.push(E);
            break;
          case "element":
            M !== void 0 && T.elements.push(M), M = {}, M.name = R[0], M.count = parseInt(R[1]), M.properties = [];
            break;
          case "property":
            M.properties.push(C(R, b.propertyNameMapping));
            break;
          case "obj_info":
            T.objInfo = E;
            break;
          default:
            console.log("unhandled", q, R);
        }
      }
      return M !== void 0 && T.elements.push(M), T;
    }
    function n(p, f) {
      switch (f) {
        case "char":
        case "uchar":
        case "short":
        case "ushort":
        case "int":
        case "uint":
        case "int8":
        case "uint8":
        case "int16":
        case "uint16":
        case "int32":
        case "uint32":
          return parseInt(p);
        case "float":
        case "double":
        case "float32":
        case "float64":
          return parseFloat(p);
      }
    }
    function r(p, f) {
      const x = {};
      for (let g = 0; g < p.length; g++) {
        if (f.empty()) return null;
        if (p[g].type === "list") {
          const _ = [], T = n(f.next(), p[g].countType);
          for (let A = 0; A < T; A++) {
            if (f.empty()) return null;
            _.push(n(f.next(), p[g].itemType));
          }
          x[p[g].name] = _;
        } else
          x[p[g].name] = n(f.next(), p[g].type);
      }
      return x;
    }
    function s() {
      const p = {
        indices: [],
        vertices: [],
        normals: [],
        uvs: [],
        faceVertexUvs: [],
        colors: [],
        faceVertexColors: []
      };
      for (const f of Object.keys(b.customPropertyMapping))
        p[f] = [];
      return p;
    }
    function a(p) {
      const f = p.map((g) => g.name);
      function x(g) {
        for (let _ = 0, T = g.length; _ < T; _++) {
          const A = g[_];
          if (f.includes(A)) return A;
        }
        return null;
      }
      return {
        attrX: x(["x", "px", "posx"]) || "x",
        attrY: x(["y", "py", "posy"]) || "y",
        attrZ: x(["z", "pz", "posz"]) || "z",
        attrNX: x(["nx", "normalx"]),
        attrNY: x(["ny", "normaly"]),
        attrNZ: x(["nz", "normalz"]),
        attrS: x(["s", "u", "texture_u", "tx"]),
        attrT: x(["t", "v", "texture_v", "ty"]),
        attrR: x(["red", "diffuse_red", "r", "diffuse_r"]),
        attrG: x(["green", "diffuse_green", "g", "diffuse_g"]),
        attrB: x(["blue", "diffuse_blue", "b", "diffuse_b"])
      };
    }
    function o(p, f) {
      const x = s(), g = /end_header\s+(\S[\s\S]*\S|\S)\s*$/;
      let _, T;
      (T = g.exec(p)) !== null ? _ = T[1].split(/\s+/) : _ = [];
      const A = new lA(_);
      e: for (let M = 0; M < f.elements.length; M++) {
        const C = f.elements[M], y = a(C.properties);
        for (let E = 0; E < C.count; E++) {
          const R = r(C.properties, A);
          if (!R) break e;
          c(x, C.name, R, y);
        }
      }
      return l(x);
    }
    function l(p) {
      let f = new fn();
      p.indices.length > 0 && f.setIndex(p.indices), f.setAttribute("position", new Ot(p.vertices, 3)), p.normals.length > 0 && f.setAttribute("normal", new Ot(p.normals, 3)), p.uvs.length > 0 && f.setAttribute("uv", new Ot(p.uvs, 2)), p.colors.length > 0 && f.setAttribute("color", new Ot(p.colors, 3)), (p.faceVertexUvs.length > 0 || p.faceVertexColors.length > 0) && (f = f.toNonIndexed(), p.faceVertexUvs.length > 0 && f.setAttribute("uv", new Ot(p.faceVertexUvs, 2)), p.faceVertexColors.length > 0 && f.setAttribute("color", new Ot(p.faceVertexColors, 3)));
      for (const x of Object.keys(b.customPropertyMapping))
        p[x].length > 0 && f.setAttribute(
          x,
          new Ot(
            p[x],
            b.customPropertyMapping[x].length
          )
        );
      return f.computeBoundingSphere(), f;
    }
    function c(p, f, x, g) {
      if (f === "vertex") {
        p.vertices.push(x[g.attrX], x[g.attrY], x[g.attrZ]), g.attrNX !== null && g.attrNY !== null && g.attrNZ !== null && p.normals.push(x[g.attrNX], x[g.attrNY], x[g.attrNZ]), g.attrS !== null && g.attrT !== null && p.uvs.push(x[g.attrS], x[g.attrT]), g.attrR !== null && g.attrG !== null && g.attrB !== null && (rn.setRGB(
          x[g.attrR] / 255,
          x[g.attrG] / 255,
          x[g.attrB] / 255,
          Ut
        ), p.colors.push(rn.r, rn.g, rn.b));
        for (const _ of Object.keys(b.customPropertyMapping))
          for (const T of b.customPropertyMapping[_])
            p[_].push(x[T]);
      } else if (f === "face") {
        const _ = x.vertex_indices || x.vertex_index, T = x.texcoord;
        _.length === 3 ? (p.indices.push(_[0], _[1], _[2]), T && T.length === 6 && (p.faceVertexUvs.push(T[0], T[1]), p.faceVertexUvs.push(T[2], T[3]), p.faceVertexUvs.push(T[4], T[5]))) : _.length === 4 && (p.indices.push(_[0], _[1], _[3]), p.indices.push(_[1], _[2], _[3])), g.attrR !== null && g.attrG !== null && g.attrB !== null && (rn.setRGB(
          x[g.attrR] / 255,
          x[g.attrG] / 255,
          x[g.attrB] / 255,
          Ut
        ), p.faceVertexColors.push(rn.r, rn.g, rn.b), p.faceVertexColors.push(rn.r, rn.g, rn.b), p.faceVertexColors.push(rn.r, rn.g, rn.b));
      }
    }
    function u(p, f) {
      const x = {};
      let g = 0;
      for (let _ = 0; _ < f.length; _++) {
        const T = f[_], A = T.valueReader;
        if (T.type === "list") {
          const M = [], C = T.countReader.read(p + g);
          g += T.countReader.size;
          for (let y = 0; y < C; y++)
            M.push(A.read(p + g)), g += A.size;
          x[T.name] = M;
        } else
          x[T.name] = A.read(p + g), g += A.size;
      }
      return [x, g];
    }
    function h(p, f, x) {
      function g(_, T, A) {
        switch (T) {
          // corespondences for non-specific length types here match rply:
          case "int8":
          case "char":
            return { read: (M) => _.getInt8(M), size: 1 };
          case "uint8":
          case "uchar":
            return { read: (M) => _.getUint8(M), size: 1 };
          case "int16":
          case "short":
            return { read: (M) => _.getInt16(M, A), size: 2 };
          case "uint16":
          case "ushort":
            return { read: (M) => _.getUint16(M, A), size: 2 };
          case "int32":
          case "int":
            return { read: (M) => _.getInt32(M, A), size: 4 };
          case "uint32":
          case "uint":
            return { read: (M) => _.getUint32(M, A), size: 4 };
          case "float32":
          case "float":
            return { read: (M) => _.getFloat32(M, A), size: 4 };
          case "float64":
          case "double":
            return { read: (M) => _.getFloat64(M, A), size: 8 };
        }
      }
      for (let _ = 0, T = p.length; _ < T; _++) {
        const A = p[_];
        A.type === "list" ? (A.countReader = g(f, A.countType, x), A.valueReader = g(f, A.itemType, x)) : A.valueReader = g(f, A.type, x);
      }
    }
    function d(p, f) {
      const x = s(), g = f.format === "binary_little_endian", _ = new DataView(p, f.headerLength);
      let T, A = 0;
      for (let M = 0; M < f.elements.length; M++) {
        const C = f.elements[M], y = C.properties, E = a(y);
        h(y, _, g);
        for (let R = 0; R < C.count; R++) {
          T = u(A, y), A += T[1];
          const q = T[0];
          c(x, C.name, q, E);
        }
      }
      return l(x);
    }
    function m(p) {
      let f = 0, x = !0, g = "";
      const _ = [], T = new TextDecoder().decode(p.subarray(0, 5)), A = /^ply\r\n/.test(T);
      do {
        const M = String.fromCharCode(p[f++]);
        M !== `
` && M !== "\r" ? g += M : (g === "end_header" && (x = !1), g !== "" && (_.push(g), g = ""));
      } while (x && f < p.length);
      return A === !0 && f++, { headerText: _.join("\r") + "\r", headerLength: f };
    }
    let v;
    const b = this;
    if (e instanceof ArrayBuffer) {
      const p = new Uint8Array(e), { headerText: f, headerLength: x } = m(p), g = t(f, x);
      if (g.format === "ascii") {
        const _ = new TextDecoder().decode(p);
        v = o(_, g);
      } else
        v = d(e, g);
    } else
      v = o(e, t(e));
    return v;
  }
}
class lA {
  constructor(e) {
    this.arr = e, this.i = 0;
  }
  empty() {
    return this.i >= this.arr.length;
  }
  next() {
    return this.arr[this.i++];
  }
}
function hf(i, e) {
  if (e === pv)
    return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), i;
  if (e === Jl || e === Fd) {
    let t = i.getIndex();
    if (t === null) {
      const a = [], o = i.getAttribute("position");
      if (o !== void 0) {
        for (let l = 0; l < o.count; l++)
          a.push(l);
        i.setIndex(a), t = i.getIndex();
      } else
        return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), i;
    }
    const n = t.count - 2, r = [];
    if (e === Jl)
      for (let a = 1; a <= n; a++)
        r.push(t.getX(0)), r.push(t.getX(a)), r.push(t.getX(a + 1));
    else
      for (let a = 0; a < n; a++)
        a % 2 === 0 ? (r.push(t.getX(a)), r.push(t.getX(a + 1)), r.push(t.getX(a + 2))) : (r.push(t.getX(a + 2)), r.push(t.getX(a + 1)), r.push(t.getX(a)));
    r.length / 3 !== n && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
    const s = i.clone();
    return s.setIndex(r), s.clearGroups(), s;
  } else
    return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), i;
}
class cA extends Zi {
  constructor(e) {
    super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
      return new pA(t);
    }), this.register(function(t) {
      return new mA(t);
    }), this.register(function(t) {
      return new MA(t);
    }), this.register(function(t) {
      return new AA(t);
    }), this.register(function(t) {
      return new TA(t);
    }), this.register(function(t) {
      return new _A(t);
    }), this.register(function(t) {
      return new vA(t);
    }), this.register(function(t) {
      return new xA(t);
    }), this.register(function(t) {
      return new bA(t);
    }), this.register(function(t) {
      return new dA(t);
    }), this.register(function(t) {
      return new EA(t);
    }), this.register(function(t) {
      return new gA(t);
    }), this.register(function(t) {
      return new SA(t);
    }), this.register(function(t) {
      return new yA(t);
    }), this.register(function(t) {
      return new hA(t);
    }), this.register(function(t) {
      return new wA(t);
    }), this.register(function(t) {
      return new DA(t);
    });
  }
  load(e, t, n, r) {
    const s = this;
    let a;
    if (this.resourcePath !== "")
      a = this.resourcePath;
    else if (this.path !== "") {
      const c = vs.extractUrlBase(e);
      a = vs.resolveURL(c, this.path);
    } else
      a = vs.extractUrlBase(e);
    this.manager.itemStart(e);
    const o = function(c) {
      r ? r(c) : console.error(c), s.manager.itemError(e), s.manager.itemEnd(e);
    }, l = new Bc(this.manager);
    l.setPath(this.path), l.setResponseType("arraybuffer"), l.setRequestHeader(this.requestHeader), l.setWithCredentials(this.withCredentials), l.load(e, function(c) {
      try {
        s.parse(c, a, function(u) {
          t(u), s.manager.itemEnd(e);
        }, o);
      } catch (u) {
        o(u);
      }
    }, n, o);
  }
  setDRACOLoader(e) {
    return this.dracoLoader = e, this;
  }
  setKTX2Loader(e) {
    return this.ktx2Loader = e, this;
  }
  setMeshoptDecoder(e) {
    return this.meshoptDecoder = e, this;
  }
  register(e) {
    return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
  }
  unregister(e) {
    return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
  }
  parse(e, t, n, r) {
    let s;
    const a = {}, o = {}, l = new TextDecoder();
    if (typeof e == "string")
      s = JSON.parse(e);
    else if (e instanceof ArrayBuffer)
      if (l.decode(new Uint8Array(e, 0, 4)) === op) {
        try {
          a[Qe.KHR_BINARY_GLTF] = new RA(e);
        } catch (h) {
          r && r(h);
          return;
        }
        s = JSON.parse(a[Qe.KHR_BINARY_GLTF].content);
      } else
        s = JSON.parse(l.decode(e));
    else
      s = e;
    if (s.asset === void 0 || s.asset.version[0] < 2) {
      r && r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
      return;
    }
    const c = new GA(s, {
      path: t || this.resourcePath || "",
      crossOrigin: this.crossOrigin,
      requestHeader: this.requestHeader,
      manager: this.manager,
      ktx2Loader: this.ktx2Loader,
      meshoptDecoder: this.meshoptDecoder
    });
    c.fileLoader.setRequestHeader(this.requestHeader);
    for (let u = 0; u < this.pluginCallbacks.length; u++) {
      const h = this.pluginCallbacks[u](c);
      h.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), o[h.name] = h, a[h.name] = !0;
    }
    if (s.extensionsUsed)
      for (let u = 0; u < s.extensionsUsed.length; ++u) {
        const h = s.extensionsUsed[u], d = s.extensionsRequired || [];
        switch (h) {
          case Qe.KHR_MATERIALS_UNLIT:
            a[h] = new fA();
            break;
          case Qe.KHR_DRACO_MESH_COMPRESSION:
            a[h] = new CA(s, this.dracoLoader);
            break;
          case Qe.KHR_TEXTURE_TRANSFORM:
            a[h] = new PA();
            break;
          case Qe.KHR_MESH_QUANTIZATION:
            a[h] = new LA();
            break;
          default:
            d.indexOf(h) >= 0 && o[h] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + h + '".');
        }
      }
    c.setExtensions(a), c.setPlugins(o), c.parse(n, r);
  }
  parseAsync(e, t) {
    const n = this;
    return new Promise(function(r, s) {
      n.parse(e, t, r, s);
    });
  }
}
function uA() {
  let i = {};
  return {
    get: function(e) {
      return i[e];
    },
    add: function(e, t) {
      i[e] = t;
    },
    remove: function(e) {
      delete i[e];
    },
    removeAll: function() {
      i = {};
    }
  };
}
const Qe = {
  KHR_BINARY_GLTF: "KHR_binary_glTF",
  KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
  KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
  KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
  KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
  KHR_MATERIALS_IOR: "KHR_materials_ior",
  KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
  KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
  KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
  KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
  KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
  KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
  KHR_MATERIALS_VOLUME: "KHR_materials_volume",
  KHR_TEXTURE_BASISU: "KHR_texture_basisu",
  KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
  KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
  KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
  EXT_MATERIALS_BUMP: "EXT_materials_bump",
  EXT_TEXTURE_WEBP: "EXT_texture_webp",
  EXT_TEXTURE_AVIF: "EXT_texture_avif",
  EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
  EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
};
class hA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
  }
  _markDefs() {
    const e = this.parser, t = this.parser.json.nodes || [];
    for (let n = 0, r = t.length; n < r; n++) {
      const s = t[n];
      s.extensions && s.extensions[this.name] && s.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, s.extensions[this.name].light);
    }
  }
  _loadLight(e) {
    const t = this.parser, n = "light:" + e;
    let r = t.cache.get(n);
    if (r) return r;
    const s = t.json, l = ((s.extensions && s.extensions[this.name] || {}).lights || [])[e];
    let c;
    const u = new Ue(16777215);
    l.color !== void 0 && u.setRGB(l.color[0], l.color[1], l.color[2], en);
    const h = l.range !== void 0 ? l.range : 0;
    switch (l.type) {
      case "directional":
        c = new sp(u), c.target.position.set(0, 0, -1), c.add(c.target);
        break;
      case "point":
        c = new TM(u), c.distance = h;
        break;
      case "spot":
        c = new MM(u), c.distance = h, l.spot = l.spot || {}, l.spot.innerConeAngle = l.spot.innerConeAngle !== void 0 ? l.spot.innerConeAngle : 0, l.spot.outerConeAngle = l.spot.outerConeAngle !== void 0 ? l.spot.outerConeAngle : Math.PI / 4, c.angle = l.spot.outerConeAngle, c.penumbra = 1 - l.spot.innerConeAngle / l.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
        break;
      default:
        throw new Error("THREE.GLTFLoader: Unexpected light type: " + l.type);
    }
    return c.position.set(0, 0, 0), c.decay = 2, Qn(c, l), l.intensity !== void 0 && (c.intensity = l.intensity), c.name = t.createUniqueName(l.name || "light_" + e), r = Promise.resolve(c), t.cache.add(n, r), r;
  }
  getDependency(e, t) {
    if (e === "light")
      return this._loadLight(t);
  }
  createNodeAttachment(e) {
    const t = this, n = this.parser, s = n.json.nodes[e], o = (s.extensions && s.extensions[this.name] || {}).light;
    return o === void 0 ? null : this._loadLight(o).then(function(l) {
      return n._getNodeRef(t.cache, o, l);
    });
  }
}
class fA {
  constructor() {
    this.name = Qe.KHR_MATERIALS_UNLIT;
  }
  getMaterialType() {
    return ki;
  }
  extendParams(e, t, n) {
    const r = [];
    e.color = new Ue(1, 1, 1), e.opacity = 1;
    const s = t.pbrMetallicRoughness;
    if (s) {
      if (Array.isArray(s.baseColorFactor)) {
        const a = s.baseColorFactor;
        e.color.setRGB(a[0], a[1], a[2], en), e.opacity = a[3];
      }
      s.baseColorTexture !== void 0 && r.push(n.assignTexture(e, "map", s.baseColorTexture, Ut));
    }
    return Promise.all(r);
  }
}
class dA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_EMISSIVE_STRENGTH;
  }
  extendMaterialParams(e, t) {
    const r = this.parser.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = r.extensions[this.name].emissiveStrength;
    return s !== void 0 && (t.emissiveIntensity = s), Promise.resolve();
  }
}
class pA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_CLEARCOAT;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const n = this.parser, r = n.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = [], a = r.extensions[this.name];
    if (a.clearcoatFactor !== void 0 && (t.clearcoat = a.clearcoatFactor), a.clearcoatTexture !== void 0 && s.push(n.assignTexture(t, "clearcoatMap", a.clearcoatTexture)), a.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = a.clearcoatRoughnessFactor), a.clearcoatRoughnessTexture !== void 0 && s.push(n.assignTexture(t, "clearcoatRoughnessMap", a.clearcoatRoughnessTexture)), a.clearcoatNormalTexture !== void 0 && (s.push(n.assignTexture(t, "clearcoatNormalMap", a.clearcoatNormalTexture)), a.clearcoatNormalTexture.scale !== void 0)) {
      const o = a.clearcoatNormalTexture.scale;
      t.clearcoatNormalScale = new ze(o, o);
    }
    return Promise.all(s);
  }
}
class mA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_DISPERSION;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const r = this.parser.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = r.extensions[this.name];
    return t.dispersion = s.dispersion !== void 0 ? s.dispersion : 0, Promise.resolve();
  }
}
class gA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_IRIDESCENCE;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const n = this.parser, r = n.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = [], a = r.extensions[this.name];
    return a.iridescenceFactor !== void 0 && (t.iridescence = a.iridescenceFactor), a.iridescenceTexture !== void 0 && s.push(n.assignTexture(t, "iridescenceMap", a.iridescenceTexture)), a.iridescenceIor !== void 0 && (t.iridescenceIOR = a.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), a.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = a.iridescenceThicknessMinimum), a.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = a.iridescenceThicknessMaximum), a.iridescenceThicknessTexture !== void 0 && s.push(n.assignTexture(t, "iridescenceThicknessMap", a.iridescenceThicknessTexture)), Promise.all(s);
  }
}
class _A {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_SHEEN;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const n = this.parser, r = n.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = [];
    t.sheenColor = new Ue(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
    const a = r.extensions[this.name];
    if (a.sheenColorFactor !== void 0) {
      const o = a.sheenColorFactor;
      t.sheenColor.setRGB(o[0], o[1], o[2], en);
    }
    return a.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = a.sheenRoughnessFactor), a.sheenColorTexture !== void 0 && s.push(n.assignTexture(t, "sheenColorMap", a.sheenColorTexture, Ut)), a.sheenRoughnessTexture !== void 0 && s.push(n.assignTexture(t, "sheenRoughnessMap", a.sheenRoughnessTexture)), Promise.all(s);
  }
}
class vA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_TRANSMISSION;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const n = this.parser, r = n.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = [], a = r.extensions[this.name];
    return a.transmissionFactor !== void 0 && (t.transmission = a.transmissionFactor), a.transmissionTexture !== void 0 && s.push(n.assignTexture(t, "transmissionMap", a.transmissionTexture)), Promise.all(s);
  }
}
class xA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_VOLUME;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const n = this.parser, r = n.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = [], a = r.extensions[this.name];
    t.thickness = a.thicknessFactor !== void 0 ? a.thicknessFactor : 0, a.thicknessTexture !== void 0 && s.push(n.assignTexture(t, "thicknessMap", a.thicknessTexture)), t.attenuationDistance = a.attenuationDistance || 1 / 0;
    const o = a.attenuationColor || [1, 1, 1];
    return t.attenuationColor = new Ue().setRGB(o[0], o[1], o[2], en), Promise.all(s);
  }
}
class bA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_IOR;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const r = this.parser.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = r.extensions[this.name];
    return t.ior = s.ior !== void 0 ? s.ior : 1.5, Promise.resolve();
  }
}
class EA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_SPECULAR;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const n = this.parser, r = n.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = [], a = r.extensions[this.name];
    t.specularIntensity = a.specularFactor !== void 0 ? a.specularFactor : 1, a.specularTexture !== void 0 && s.push(n.assignTexture(t, "specularIntensityMap", a.specularTexture));
    const o = a.specularColorFactor || [1, 1, 1];
    return t.specularColor = new Ue().setRGB(o[0], o[1], o[2], en), a.specularColorTexture !== void 0 && s.push(n.assignTexture(t, "specularColorMap", a.specularColorTexture, Ut)), Promise.all(s);
  }
}
class yA {
  constructor(e) {
    this.parser = e, this.name = Qe.EXT_MATERIALS_BUMP;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const n = this.parser, r = n.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = [], a = r.extensions[this.name];
    return t.bumpScale = a.bumpFactor !== void 0 ? a.bumpFactor : 1, a.bumpTexture !== void 0 && s.push(n.assignTexture(t, "bumpMap", a.bumpTexture)), Promise.all(s);
  }
}
class SA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_MATERIALS_ANISOTROPY;
  }
  getMaterialType(e) {
    const n = this.parser.json.materials[e];
    return !n.extensions || !n.extensions[this.name] ? null : Gn;
  }
  extendMaterialParams(e, t) {
    const n = this.parser, r = n.json.materials[e];
    if (!r.extensions || !r.extensions[this.name])
      return Promise.resolve();
    const s = [], a = r.extensions[this.name];
    return a.anisotropyStrength !== void 0 && (t.anisotropy = a.anisotropyStrength), a.anisotropyRotation !== void 0 && (t.anisotropyRotation = a.anisotropyRotation), a.anisotropyTexture !== void 0 && s.push(n.assignTexture(t, "anisotropyMap", a.anisotropyTexture)), Promise.all(s);
  }
}
class MA {
  constructor(e) {
    this.parser = e, this.name = Qe.KHR_TEXTURE_BASISU;
  }
  loadTexture(e) {
    const t = this.parser, n = t.json, r = n.textures[e];
    if (!r.extensions || !r.extensions[this.name])
      return null;
    const s = r.extensions[this.name], a = t.options.ktx2Loader;
    if (!a) {
      if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0)
        throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
      return null;
    }
    return t.loadTextureImage(e, s.source, a);
  }
}
class AA {
  constructor(e) {
    this.parser = e, this.name = Qe.EXT_TEXTURE_WEBP, this.isSupported = null;
  }
  loadTexture(e) {
    const t = this.name, n = this.parser, r = n.json, s = r.textures[e];
    if (!s.extensions || !s.extensions[t])
      return null;
    const a = s.extensions[t], o = r.images[a.source];
    let l = n.textureLoader;
    if (o.uri) {
      const c = n.options.manager.getHandler(o.uri);
      c !== null && (l = c);
    }
    return this.detectSupport().then(function(c) {
      if (c) return n.loadTextureImage(e, a.source, l);
      if (r.extensionsRequired && r.extensionsRequired.indexOf(t) >= 0)
        throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
      return n.loadTexture(e);
    });
  }
  detectSupport() {
    return this.isSupported || (this.isSupported = new Promise(function(e) {
      const t = new Image();
      t.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", t.onload = t.onerror = function() {
        e(t.height === 1);
      };
    })), this.isSupported;
  }
}
class TA {
  constructor(e) {
    this.parser = e, this.name = Qe.EXT_TEXTURE_AVIF, this.isSupported = null;
  }
  loadTexture(e) {
    const t = this.name, n = this.parser, r = n.json, s = r.textures[e];
    if (!s.extensions || !s.extensions[t])
      return null;
    const a = s.extensions[t], o = r.images[a.source];
    let l = n.textureLoader;
    if (o.uri) {
      const c = n.options.manager.getHandler(o.uri);
      c !== null && (l = c);
    }
    return this.detectSupport().then(function(c) {
      if (c) return n.loadTextureImage(e, a.source, l);
      if (r.extensionsRequired && r.extensionsRequired.indexOf(t) >= 0)
        throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");
      return n.loadTexture(e);
    });
  }
  detectSupport() {
    return this.isSupported || (this.isSupported = new Promise(function(e) {
      const t = new Image();
      t.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", t.onload = t.onerror = function() {
        e(t.height === 1);
      };
    })), this.isSupported;
  }
}
class wA {
  constructor(e) {
    this.name = Qe.EXT_MESHOPT_COMPRESSION, this.parser = e;
  }
  loadBufferView(e) {
    const t = this.parser.json, n = t.bufferViews[e];
    if (n.extensions && n.extensions[this.name]) {
      const r = n.extensions[this.name], s = this.parser.getDependency("buffer", r.buffer), a = this.parser.options.meshoptDecoder;
      if (!a || !a.supported) {
        if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
          throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
        return null;
      }
      return s.then(function(o) {
        const l = r.byteOffset || 0, c = r.byteLength || 0, u = r.count, h = r.byteStride, d = new Uint8Array(o, l, c);
        return a.decodeGltfBufferAsync ? a.decodeGltfBufferAsync(u, h, d, r.mode, r.filter).then(function(m) {
          return m.buffer;
        }) : a.ready.then(function() {
          const m = new ArrayBuffer(u * h);
          return a.decodeGltfBuffer(new Uint8Array(m), u, h, d, r.mode, r.filter), m;
        });
      });
    } else
      return null;
  }
}
class DA {
  constructor(e) {
    this.name = Qe.EXT_MESH_GPU_INSTANCING, this.parser = e;
  }
  createNodeMesh(e) {
    const t = this.parser.json, n = t.nodes[e];
    if (!n.extensions || !n.extensions[this.name] || n.mesh === void 0)
      return null;
    const r = t.meshes[n.mesh];
    for (const c of r.primitives)
      if (c.mode !== gn.TRIANGLES && c.mode !== gn.TRIANGLE_STRIP && c.mode !== gn.TRIANGLE_FAN && c.mode !== void 0)
        return null;
    const a = n.extensions[this.name].attributes, o = [], l = {};
    for (const c in a)
      o.push(this.parser.getDependency("accessor", a[c]).then((u) => (l[c] = u, l[c])));
    return o.length < 1 ? null : (o.push(this.parser.createNodeMesh(e)), Promise.all(o).then((c) => {
      const u = c.pop(), h = u.isGroup ? u.children : [u], d = c[0].count, m = [];
      for (const v of h) {
        const b = new Xe(), p = new L(), f = new kn(), x = new L(1, 1, 1), g = new aM(v.geometry, v.material, d);
        for (let _ = 0; _ < d; _++)
          l.TRANSLATION && p.fromBufferAttribute(l.TRANSLATION, _), l.ROTATION && f.fromBufferAttribute(l.ROTATION, _), l.SCALE && x.fromBufferAttribute(l.SCALE, _), g.setMatrixAt(_, b.compose(p, f, x));
        for (const _ in l)
          if (_ === "_COLOR_0") {
            const T = l[_];
            g.instanceColor = new tc(T.array, T.itemSize, T.normalized);
          } else _ !== "TRANSLATION" && _ !== "ROTATION" && _ !== "SCALE" && v.geometry.setAttribute(_, l[_]);
        Rt.prototype.copy.call(g, v), this.parser.assignFinalMaterial(g), m.push(g);
      }
      return u.isGroup ? (u.clear(), u.add(...m), u) : m[0];
    }));
  }
}
const op = "glTF", cs = 12, ff = { JSON: 1313821514, BIN: 5130562 };
class RA {
  constructor(e) {
    this.name = Qe.KHR_BINARY_GLTF, this.content = null, this.body = null;
    const t = new DataView(e, 0, cs), n = new TextDecoder();
    if (this.header = {
      magic: n.decode(new Uint8Array(e.slice(0, 4))),
      version: t.getUint32(4, !0),
      length: t.getUint32(8, !0)
    }, this.header.magic !== op)
      throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
    if (this.header.version < 2)
      throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
    const r = this.header.length - cs, s = new DataView(e, cs);
    let a = 0;
    for (; a < r; ) {
      const o = s.getUint32(a, !0);
      a += 4;
      const l = s.getUint32(a, !0);
      if (a += 4, l === ff.JSON) {
        const c = new Uint8Array(e, cs + a, o);
        this.content = n.decode(c);
      } else if (l === ff.BIN) {
        const c = cs + a;
        this.body = e.slice(c, c + o);
      }
      a += o;
    }
    if (this.content === null)
      throw new Error("THREE.GLTFLoader: JSON content not found.");
  }
}
class CA {
  constructor(e, t) {
    if (!t)
      throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
    this.name = Qe.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
  }
  decodePrimitive(e, t) {
    const n = this.json, r = this.dracoLoader, s = e.extensions[this.name].bufferView, a = e.extensions[this.name].attributes, o = {}, l = {}, c = {};
    for (const u in a) {
      const h = ic[u] || u.toLowerCase();
      o[h] = a[u];
    }
    for (const u in e.attributes) {
      const h = ic[u] || u.toLowerCase();
      if (a[u] !== void 0) {
        const d = n.accessors[e.attributes[u]], m = Sr[d.componentType];
        c[h] = m.name, l[h] = d.normalized === !0;
      }
    }
    return t.getDependency("bufferView", s).then(function(u) {
      return new Promise(function(h, d) {
        r.decodeDracoFile(u, function(m) {
          for (const v in m.attributes) {
            const b = m.attributes[v], p = l[v];
            p !== void 0 && (b.normalized = p);
          }
          h(m);
        }, o, c, en, d);
      });
    });
  }
}
class PA {
  constructor() {
    this.name = Qe.KHR_TEXTURE_TRANSFORM;
  }
  extendTexture(e, t) {
    return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;
  }
}
class LA {
  constructor() {
    this.name = Qe.KHR_MESH_QUANTIZATION;
  }
}
class lp extends Is {
  constructor(e, t, n, r) {
    super(e, t, n, r);
  }
  copySampleValue_(e) {
    const t = this.resultBuffer, n = this.sampleValues, r = this.valueSize, s = e * r * 3 + r;
    for (let a = 0; a !== r; a++)
      t[a] = n[s + a];
    return t;
  }
  interpolate_(e, t, n, r) {
    const s = this.resultBuffer, a = this.sampleValues, o = this.valueSize, l = o * 2, c = o * 3, u = r - t, h = (n - t) / u, d = h * h, m = d * h, v = e * c, b = v - c, p = -2 * m + 3 * d, f = m - d, x = 1 - p, g = f - d + h;
    for (let _ = 0; _ !== o; _++) {
      const T = a[b + _ + o], A = a[b + _ + l] * u, M = a[v + _ + o], C = a[v + _] * u;
      s[_] = x * T + g * A + p * M + f * C;
    }
    return s;
  }
}
const IA = new kn();
class FA extends lp {
  interpolate_(e, t, n, r) {
    const s = super.interpolate_(e, t, n, r);
    return IA.fromArray(s).normalize().toArray(s), s;
  }
}
const gn = {
  POINTS: 0,
  LINES: 1,
  LINE_LOOP: 2,
  LINE_STRIP: 3,
  TRIANGLES: 4,
  TRIANGLE_STRIP: 5,
  TRIANGLE_FAN: 6
}, Sr = {
  5120: Int8Array,
  5121: Uint8Array,
  5122: Int16Array,
  5123: Uint16Array,
  5125: Uint32Array,
  5126: Float32Array
}, df = {
  9728: Jt,
  9729: un,
  9984: Md,
  9985: xa,
  9986: fs,
  9987: ti
}, pf = {
  33071: bi,
  33648: La,
  10497: Pr
}, qo = {
  SCALAR: 1,
  VEC2: 2,
  VEC3: 3,
  VEC4: 4,
  MAT2: 4,
  MAT3: 9,
  MAT4: 16
}, ic = {
  POSITION: "position",
  NORMAL: "normal",
  TANGENT: "tangent",
  TEXCOORD_0: "uv",
  TEXCOORD_1: "uv1",
  TEXCOORD_2: "uv2",
  TEXCOORD_3: "uv3",
  COLOR_0: "color",
  WEIGHTS_0: "skinWeight",
  JOINTS_0: "skinIndex"
}, gi = {
  scale: "scale",
  translation: "position",
  rotation: "quaternion",
  weights: "morphTargetInfluences"
}, NA = {
  CUBICSPLINE: void 0,
  // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
  // keyframe track will be initialized with a default interpolation type, then modified.
  LINEAR: ys,
  STEP: Es
}, Yo = {
  OPAQUE: "OPAQUE",
  MASK: "MASK",
  BLEND: "BLEND"
};
function UA(i) {
  return i.DefaultMaterial === void 0 && (i.DefaultMaterial = new Oc({
    color: 16777215,
    emissive: 0,
    metalness: 1,
    roughness: 1,
    transparent: !1,
    depthTest: !0,
    side: si
  })), i.DefaultMaterial;
}
function Ii(i, e, t) {
  for (const n in t.extensions)
    i[n] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[n] = t.extensions[n]);
}
function Qn(i, e) {
  e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(i.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
}
function OA(i, e, t) {
  let n = !1, r = !1, s = !1;
  for (let c = 0, u = e.length; c < u; c++) {
    const h = e[c];
    if (h.POSITION !== void 0 && (n = !0), h.NORMAL !== void 0 && (r = !0), h.COLOR_0 !== void 0 && (s = !0), n && r && s) break;
  }
  if (!n && !r && !s) return Promise.resolve(i);
  const a = [], o = [], l = [];
  for (let c = 0, u = e.length; c < u; c++) {
    const h = e[c];
    if (n) {
      const d = h.POSITION !== void 0 ? t.getDependency("accessor", h.POSITION) : i.attributes.position;
      a.push(d);
    }
    if (r) {
      const d = h.NORMAL !== void 0 ? t.getDependency("accessor", h.NORMAL) : i.attributes.normal;
      o.push(d);
    }
    if (s) {
      const d = h.COLOR_0 !== void 0 ? t.getDependency("accessor", h.COLOR_0) : i.attributes.color;
      l.push(d);
    }
  }
  return Promise.all([
    Promise.all(a),
    Promise.all(o),
    Promise.all(l)
  ]).then(function(c) {
    const u = c[0], h = c[1], d = c[2];
    return n && (i.morphAttributes.position = u), r && (i.morphAttributes.normal = h), s && (i.morphAttributes.color = d), i.morphTargetsRelative = !0, i;
  });
}
function BA(i, e) {
  if (i.updateMorphTargets(), e.weights !== void 0)
    for (let t = 0, n = e.weights.length; t < n; t++)
      i.morphTargetInfluences[t] = e.weights[t];
  if (e.extras && Array.isArray(e.extras.targetNames)) {
    const t = e.extras.targetNames;
    if (i.morphTargetInfluences.length === t.length) {
      i.morphTargetDictionary = {};
      for (let n = 0, r = t.length; n < r; n++)
        i.morphTargetDictionary[t[n]] = n;
    } else
      console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
  }
}
function kA(i) {
  let e;
  const t = i.extensions && i.extensions[Qe.KHR_DRACO_MESH_COMPRESSION];
  if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + Zo(t.attributes) : e = i.indices + ":" + Zo(i.attributes) + ":" + i.mode, i.targets !== void 0)
    for (let n = 0, r = i.targets.length; n < r; n++)
      e += ":" + Zo(i.targets[n]);
  return e;
}
function Zo(i) {
  let e = "";
  const t = Object.keys(i).sort();
  for (let n = 0, r = t.length; n < r; n++)
    e += t[n] + ":" + i[t[n]] + ";";
  return e;
}
function rc(i) {
  switch (i) {
    case Int8Array:
      return 1 / 127;
    case Uint8Array:
      return 1 / 255;
    case Int16Array:
      return 1 / 32767;
    case Uint16Array:
      return 1 / 65535;
    default:
      throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
  }
}
function HA(i) {
  return i.search(/\.jpe?g($|\?)/i) > 0 || i.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : i.search(/\.webp($|\?)/i) > 0 || i.search(/^data\:image\/webp/) === 0 ? "image/webp" : i.search(/\.ktx2($|\?)/i) > 0 || i.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
}
const zA = new Xe();
class GA {
  constructor(e = {}, t = {}) {
    this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new uA(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
    let n = !1, r = -1, s = !1, a = -1;
    if (typeof navigator < "u") {
      const o = navigator.userAgent;
      n = /^((?!chrome|android).)*safari/i.test(o) === !0;
      const l = o.match(/Version\/(\d+)/);
      r = n && l ? parseInt(l[1], 10) : -1, s = o.indexOf("Firefox") > -1, a = s ? o.match(/Firefox\/([0-9]+)\./)[1] : -1;
    }
    typeof createImageBitmap > "u" || n && r < 17 || s && a < 98 ? this.textureLoader = new yM(this.options.manager) : this.textureLoader = new RM(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Bc(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
  }
  setExtensions(e) {
    this.extensions = e;
  }
  setPlugins(e) {
    this.plugins = e;
  }
  parse(e, t) {
    const n = this, r = this.json, s = this.extensions;
    this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(a) {
      return a._markDefs && a._markDefs();
    }), Promise.all(this._invokeAll(function(a) {
      return a.beforeRoot && a.beforeRoot();
    })).then(function() {
      return Promise.all([
        n.getDependencies("scene"),
        n.getDependencies("animation"),
        n.getDependencies("camera")
      ]);
    }).then(function(a) {
      const o = {
        scene: a[0][r.scene || 0],
        scenes: a[0],
        animations: a[1],
        cameras: a[2],
        asset: r.asset,
        parser: n,
        userData: {}
      };
      return Ii(s, o, r), Qn(o, r), Promise.all(n._invokeAll(function(l) {
        return l.afterRoot && l.afterRoot(o);
      })).then(function() {
        for (const l of o.scenes)
          l.updateMatrixWorld();
        e(o);
      });
    }).catch(t);
  }
  /**
   * Marks the special nodes/meshes in json for efficient parse.
   */
  _markDefs() {
    const e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || [];
    for (let r = 0, s = t.length; r < s; r++) {
      const a = t[r].joints;
      for (let o = 0, l = a.length; o < l; o++)
        e[a[o]].isBone = !0;
    }
    for (let r = 0, s = e.length; r < s; r++) {
      const a = e[r];
      a.mesh !== void 0 && (this._addNodeRef(this.meshCache, a.mesh), a.skin !== void 0 && (n[a.mesh].isSkinnedMesh = !0)), a.camera !== void 0 && this._addNodeRef(this.cameraCache, a.camera);
    }
  }
  /**
   * Counts references to shared node / Object3D resources. These resources
   * can be reused, or "instantiated", at multiple nodes in the scene
   * hierarchy. Mesh, Camera, and Light instances are instantiated and must
   * be marked. Non-scenegraph resources (like Materials, Geometries, and
   * Textures) can be reused directly and are not marked here.
   *
   * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
   */
  _addNodeRef(e, t) {
    t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
  }
  /** Returns a reference to a shared resource, cloning it if necessary. */
  _getNodeRef(e, t, n) {
    if (e.refs[t] <= 1) return n;
    const r = n.clone(), s = (a, o) => {
      const l = this.associations.get(a);
      l != null && this.associations.set(o, l);
      for (const [c, u] of a.children.entries())
        s(u, o.children[c]);
    };
    return s(n, r), r.name += "_instance_" + e.uses[t]++, r;
  }
  _invokeOne(e) {
    const t = Object.values(this.plugins);
    t.push(this);
    for (let n = 0; n < t.length; n++) {
      const r = e(t[n]);
      if (r) return r;
    }
    return null;
  }
  _invokeAll(e) {
    const t = Object.values(this.plugins);
    t.unshift(this);
    const n = [];
    for (let r = 0; r < t.length; r++) {
      const s = e(t[r]);
      s && n.push(s);
    }
    return n;
  }
  /**
   * Requests the specified dependency asynchronously, with caching.
   * @param {string} type
   * @param {number} index
   * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
   */
  getDependency(e, t) {
    const n = e + ":" + t;
    let r = this.cache.get(n);
    if (!r) {
      switch (e) {
        case "scene":
          r = this.loadScene(t);
          break;
        case "node":
          r = this._invokeOne(function(s) {
            return s.loadNode && s.loadNode(t);
          });
          break;
        case "mesh":
          r = this._invokeOne(function(s) {
            return s.loadMesh && s.loadMesh(t);
          });
          break;
        case "accessor":
          r = this.loadAccessor(t);
          break;
        case "bufferView":
          r = this._invokeOne(function(s) {
            return s.loadBufferView && s.loadBufferView(t);
          });
          break;
        case "buffer":
          r = this.loadBuffer(t);
          break;
        case "material":
          r = this._invokeOne(function(s) {
            return s.loadMaterial && s.loadMaterial(t);
          });
          break;
        case "texture":
          r = this._invokeOne(function(s) {
            return s.loadTexture && s.loadTexture(t);
          });
          break;
        case "skin":
          r = this.loadSkin(t);
          break;
        case "animation":
          r = this._invokeOne(function(s) {
            return s.loadAnimation && s.loadAnimation(t);
          });
          break;
        case "camera":
          r = this.loadCamera(t);
          break;
        default:
          if (r = this._invokeOne(function(s) {
            return s != this && s.getDependency && s.getDependency(e, t);
          }), !r)
            throw new Error("Unknown type: " + e);
          break;
      }
      this.cache.add(n, r);
    }
    return r;
  }
  /**
   * Requests all dependencies of the specified type asynchronously, with caching.
   * @param {string} type
   * @return {Promise<Array<Object>>}
   */
  getDependencies(e) {
    let t = this.cache.get(e);
    if (!t) {
      const n = this, r = this.json[e + (e === "mesh" ? "es" : "s")] || [];
      t = Promise.all(r.map(function(s, a) {
        return n.getDependency(e, a);
      })), this.cache.add(e, t);
    }
    return t;
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
   * @param {number} bufferIndex
   * @return {Promise<ArrayBuffer>}
   */
  loadBuffer(e) {
    const t = this.json.buffers[e], n = this.fileLoader;
    if (t.type && t.type !== "arraybuffer")
      throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
    if (t.uri === void 0 && e === 0)
      return Promise.resolve(this.extensions[Qe.KHR_BINARY_GLTF].body);
    const r = this.options;
    return new Promise(function(s, a) {
      n.load(vs.resolveURL(t.uri, r.path), s, void 0, function() {
        a(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
      });
    });
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
   * @param {number} bufferViewIndex
   * @return {Promise<ArrayBuffer>}
   */
  loadBufferView(e) {
    const t = this.json.bufferViews[e];
    return this.getDependency("buffer", t.buffer).then(function(n) {
      const r = t.byteLength || 0, s = t.byteOffset || 0;
      return n.slice(s, s + r);
    });
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
   * @param {number} accessorIndex
   * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
   */
  loadAccessor(e) {
    const t = this, n = this.json, r = this.json.accessors[e];
    if (r.bufferView === void 0 && r.sparse === void 0) {
      const a = qo[r.type], o = Sr[r.componentType], l = r.normalized === !0, c = new o(r.count * a);
      return Promise.resolve(new Qt(c, a, l));
    }
    const s = [];
    return r.bufferView !== void 0 ? s.push(this.getDependency("bufferView", r.bufferView)) : s.push(null), r.sparse !== void 0 && (s.push(this.getDependency("bufferView", r.sparse.indices.bufferView)), s.push(this.getDependency("bufferView", r.sparse.values.bufferView))), Promise.all(s).then(function(a) {
      const o = a[0], l = qo[r.type], c = Sr[r.componentType], u = c.BYTES_PER_ELEMENT, h = u * l, d = r.byteOffset || 0, m = r.bufferView !== void 0 ? n.bufferViews[r.bufferView].byteStride : void 0, v = r.normalized === !0;
      let b, p;
      if (m && m !== h) {
        const f = Math.floor(d / m), x = "InterleavedBuffer:" + r.bufferView + ":" + r.componentType + ":" + f + ":" + r.count;
        let g = t.cache.get(x);
        g || (b = new c(o, f * m, r.count * m / u), g = new tM(b, m / u), t.cache.add(x, g)), p = new Fc(g, l, d % m / u, v);
      } else
        o === null ? b = new c(r.count * l) : b = new c(o, d, r.count * l), p = new Qt(b, l, v);
      if (r.sparse !== void 0) {
        const f = qo.SCALAR, x = Sr[r.sparse.indices.componentType], g = r.sparse.indices.byteOffset || 0, _ = r.sparse.values.byteOffset || 0, T = new x(a[1], g, r.sparse.count * f), A = new c(a[2], _, r.sparse.count * l);
        o !== null && (p = new Qt(p.array.slice(), p.itemSize, p.normalized)), p.normalized = !1;
        for (let M = 0, C = T.length; M < C; M++) {
          const y = T[M];
          if (p.setX(y, A[M * l]), l >= 2 && p.setY(y, A[M * l + 1]), l >= 3 && p.setZ(y, A[M * l + 2]), l >= 4 && p.setW(y, A[M * l + 3]), l >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
        }
        p.normalized = v;
      }
      return p;
    });
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
   * @param {number} textureIndex
   * @return {Promise<THREE.Texture|null>}
   */
  loadTexture(e) {
    const t = this.json, n = this.options, s = t.textures[e].source, a = t.images[s];
    let o = this.textureLoader;
    if (a.uri) {
      const l = n.manager.getHandler(a.uri);
      l !== null && (o = l);
    }
    return this.loadTextureImage(e, s, o);
  }
  loadTextureImage(e, t, n) {
    const r = this, s = this.json, a = s.textures[e], o = s.images[t], l = (o.uri || o.bufferView) + ":" + a.sampler;
    if (this.textureCache[l])
      return this.textureCache[l];
    const c = this.loadImageSource(t, n).then(function(u) {
      u.flipY = !1, u.name = a.name || o.name || "", u.name === "" && typeof o.uri == "string" && o.uri.startsWith("data:image/") === !1 && (u.name = o.uri);
      const d = (s.samplers || {})[a.sampler] || {};
      return u.magFilter = df[d.magFilter] || un, u.minFilter = df[d.minFilter] || ti, u.wrapS = pf[d.wrapS] || Pr, u.wrapT = pf[d.wrapT] || Pr, u.generateMipmaps = !u.isCompressedTexture && u.minFilter !== Jt && u.minFilter !== un, r.associations.set(u, { textures: e }), u;
    }).catch(function() {
      return null;
    });
    return this.textureCache[l] = c, c;
  }
  loadImageSource(e, t) {
    const n = this, r = this.json, s = this.options;
    if (this.sourceCache[e] !== void 0)
      return this.sourceCache[e].then((h) => h.clone());
    const a = r.images[e], o = self.URL || self.webkitURL;
    let l = a.uri || "", c = !1;
    if (a.bufferView !== void 0)
      l = n.getDependency("bufferView", a.bufferView).then(function(h) {
        c = !0;
        const d = new Blob([h], { type: a.mimeType });
        return l = o.createObjectURL(d), l;
      });
    else if (a.uri === void 0)
      throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
    const u = Promise.resolve(l).then(function(h) {
      return new Promise(function(d, m) {
        let v = d;
        t.isImageBitmapLoader === !0 && (v = function(b) {
          const p = new zt(b);
          p.needsUpdate = !0, d(p);
        }), t.load(vs.resolveURL(h, s.path), v, void 0, m);
      });
    }).then(function(h) {
      return c === !0 && o.revokeObjectURL(l), Qn(h, a), h.userData.mimeType = a.mimeType || HA(a.uri), h;
    }).catch(function(h) {
      throw console.error("THREE.GLTFLoader: Couldn't load texture", l), h;
    });
    return this.sourceCache[e] = u, u;
  }
  /**
   * Asynchronously assigns a texture to the given material parameters.
   * @param {Object} materialParams
   * @param {string} mapName
   * @param {Object} mapDef
   * @return {Promise<Texture>}
   */
  assignTexture(e, t, n, r) {
    const s = this;
    return this.getDependency("texture", n.index).then(function(a) {
      if (!a) return null;
      if (n.texCoord !== void 0 && n.texCoord > 0 && (a = a.clone(), a.channel = n.texCoord), s.extensions[Qe.KHR_TEXTURE_TRANSFORM]) {
        const o = n.extensions !== void 0 ? n.extensions[Qe.KHR_TEXTURE_TRANSFORM] : void 0;
        if (o) {
          const l = s.associations.get(a);
          a = s.extensions[Qe.KHR_TEXTURE_TRANSFORM].extendTexture(a, o), s.associations.set(a, l);
        }
      }
      return r !== void 0 && (a.colorSpace = r), e[t] = a, a;
    });
  }
  /**
   * Assigns final material to a Mesh, Line, or Points instance. The instance
   * already has a material (generated from the glTF material options alone)
   * but reuse of the same glTF material may require multiple threejs materials
   * to accommodate different primitive types, defines, etc. New materials will
   * be created if necessary, and reused from a cache.
   * @param  {Object3D} mesh Mesh, Line, or Points instance.
   */
  assignFinalMaterial(e) {
    const t = e.geometry;
    let n = e.material;
    const r = t.attributes.tangent === void 0, s = t.attributes.color !== void 0, a = t.attributes.normal === void 0;
    if (e.isPoints) {
      const o = "PointsMaterial:" + n.uuid;
      let l = this.cache.get(o);
      l || (l = new Ms(), Bn.prototype.copy.call(l, n), l.color.copy(n.color), l.map = n.map, l.sizeAttenuation = !1, this.cache.add(o, l)), n = l;
    } else if (e.isLine) {
      const o = "LineBasicMaterial:" + n.uuid;
      let l = this.cache.get(o);
      l || (l = new np(), Bn.prototype.copy.call(l, n), l.color.copy(n.color), l.map = n.map, this.cache.add(o, l)), n = l;
    }
    if (r || s || a) {
      let o = "ClonedMaterial:" + n.uuid + ":";
      r && (o += "derivative-tangents:"), s && (o += "vertex-colors:"), a && (o += "flat-shading:");
      let l = this.cache.get(o);
      l || (l = n.clone(), s && (l.vertexColors = !0), a && (l.flatShading = !0), r && (l.normalScale && (l.normalScale.y *= -1), l.clearcoatNormalScale && (l.clearcoatNormalScale.y *= -1)), this.cache.add(o, l), this.associations.set(l, this.associations.get(n))), n = l;
    }
    e.material = n;
  }
  getMaterialType() {
    return Oc;
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
   * @param {number} materialIndex
   * @return {Promise<Material>}
   */
  loadMaterial(e) {
    const t = this, n = this.json, r = this.extensions, s = n.materials[e];
    let a;
    const o = {}, l = s.extensions || {}, c = [];
    if (l[Qe.KHR_MATERIALS_UNLIT]) {
      const h = r[Qe.KHR_MATERIALS_UNLIT];
      a = h.getMaterialType(), c.push(h.extendParams(o, s, t));
    } else {
      const h = s.pbrMetallicRoughness || {};
      if (o.color = new Ue(1, 1, 1), o.opacity = 1, Array.isArray(h.baseColorFactor)) {
        const d = h.baseColorFactor;
        o.color.setRGB(d[0], d[1], d[2], en), o.opacity = d[3];
      }
      h.baseColorTexture !== void 0 && c.push(t.assignTexture(o, "map", h.baseColorTexture, Ut)), o.metalness = h.metallicFactor !== void 0 ? h.metallicFactor : 1, o.roughness = h.roughnessFactor !== void 0 ? h.roughnessFactor : 1, h.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(o, "metalnessMap", h.metallicRoughnessTexture)), c.push(t.assignTexture(o, "roughnessMap", h.metallicRoughnessTexture))), a = this._invokeOne(function(d) {
        return d.getMaterialType && d.getMaterialType(e);
      }), c.push(Promise.all(this._invokeAll(function(d) {
        return d.extendMaterialParams && d.extendMaterialParams(e, o);
      })));
    }
    s.doubleSided === !0 && (o.side = Fn);
    const u = s.alphaMode || Yo.OPAQUE;
    if (u === Yo.BLEND ? (o.transparent = !0, o.depthWrite = !1) : (o.transparent = !1, u === Yo.MASK && (o.alphaTest = s.alphaCutoff !== void 0 ? s.alphaCutoff : 0.5)), s.normalTexture !== void 0 && a !== ki && (c.push(t.assignTexture(o, "normalMap", s.normalTexture)), o.normalScale = new ze(1, 1), s.normalTexture.scale !== void 0)) {
      const h = s.normalTexture.scale;
      o.normalScale.set(h, h);
    }
    if (s.occlusionTexture !== void 0 && a !== ki && (c.push(t.assignTexture(o, "aoMap", s.occlusionTexture)), s.occlusionTexture.strength !== void 0 && (o.aoMapIntensity = s.occlusionTexture.strength)), s.emissiveFactor !== void 0 && a !== ki) {
      const h = s.emissiveFactor;
      o.emissive = new Ue().setRGB(h[0], h[1], h[2], en);
    }
    return s.emissiveTexture !== void 0 && a !== ki && c.push(t.assignTexture(o, "emissiveMap", s.emissiveTexture, Ut)), Promise.all(c).then(function() {
      const h = new a(o);
      return s.name && (h.name = s.name), Qn(h, s), t.associations.set(h, { materials: e }), s.extensions && Ii(r, h, s), h;
    });
  }
  /** When Object3D instances are targeted by animation, they need unique names. */
  createUniqueName(e) {
    const t = dt.sanitizeNodeName(e || "");
    return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
   *
   * Creates BufferGeometries from primitives.
   *
   * @param {Array<GLTF.Primitive>} primitives
   * @return {Promise<Array<BufferGeometry>>}
   */
  loadGeometries(e) {
    const t = this, n = this.extensions, r = this.primitiveCache;
    function s(o) {
      return n[Qe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o, t).then(function(l) {
        return mf(l, o, t);
      });
    }
    const a = [];
    for (let o = 0, l = e.length; o < l; o++) {
      const c = e[o], u = kA(c), h = r[u];
      if (h)
        a.push(h.promise);
      else {
        let d;
        c.extensions && c.extensions[Qe.KHR_DRACO_MESH_COMPRESSION] ? d = s(c) : d = mf(new fn(), c, t), r[u] = { primitive: c, promise: d }, a.push(d);
      }
    }
    return Promise.all(a);
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
   * @param {number} meshIndex
   * @return {Promise<Group|Mesh|SkinnedMesh>}
   */
  loadMesh(e) {
    const t = this, n = this.json, r = this.extensions, s = n.meshes[e], a = s.primitives, o = [];
    for (let l = 0, c = a.length; l < c; l++) {
      const u = a[l].material === void 0 ? UA(this.cache) : this.getDependency("material", a[l].material);
      o.push(u);
    }
    return o.push(t.loadGeometries(a)), Promise.all(o).then(function(l) {
      const c = l.slice(0, l.length - 1), u = l[l.length - 1], h = [];
      for (let m = 0, v = u.length; m < v; m++) {
        const b = u[m], p = a[m];
        let f;
        const x = c[m];
        if (p.mode === gn.TRIANGLES || p.mode === gn.TRIANGLE_STRIP || p.mode === gn.TRIANGLE_FAN || p.mode === void 0)
          f = s.isSkinnedMesh === !0 ? new iM(b, x) : new hn(b, x), f.isSkinnedMesh === !0 && f.normalizeSkinWeights(), p.mode === gn.TRIANGLE_STRIP ? f.geometry = hf(f.geometry, Fd) : p.mode === gn.TRIANGLE_FAN && (f.geometry = hf(f.geometry, Jl));
        else if (p.mode === gn.LINES)
          f = new oM(b, x);
        else if (p.mode === gn.LINE_STRIP)
          f = new Uc(b, x);
        else if (p.mode === gn.LINE_LOOP)
          f = new lM(b, x);
        else if (p.mode === gn.POINTS)
          f = new Ua(b, x);
        else
          throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + p.mode);
        Object.keys(f.geometry.morphAttributes).length > 0 && BA(f, s), f.name = t.createUniqueName(s.name || "mesh_" + e), Qn(f, s), p.extensions && Ii(r, f, p), t.assignFinalMaterial(f), h.push(f);
      }
      for (let m = 0, v = h.length; m < v; m++)
        t.associations.set(h[m], {
          meshes: e,
          primitives: m
        });
      if (h.length === 1)
        return s.extensions && Ii(r, h[0], s), h[0];
      const d = new Hi();
      s.extensions && Ii(r, d, s), t.associations.set(d, { meshes: e });
      for (let m = 0, v = h.length; m < v; m++)
        d.add(h[m]);
      return d;
    });
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
   * @param {number} cameraIndex
   * @return {Promise<THREE.Camera>}
   */
  loadCamera(e) {
    let t;
    const n = this.json.cameras[e], r = n[n.type];
    if (!r) {
      console.warn("THREE.GLTFLoader: Missing camera parameters.");
      return;
    }
    return n.type === "perspective" ? t = new $t(Od.radToDeg(r.yfov), r.aspectRatio || 1, r.znear || 1, r.zfar || 2e6) : n.type === "orthographic" && (t = new Lc(-r.xmag, r.xmag, r.ymag, -r.ymag, r.znear, r.zfar)), n.name && (t.name = this.createUniqueName(n.name)), Qn(t, n), Promise.resolve(t);
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
   * @param {number} skinIndex
   * @return {Promise<Skeleton>}
   */
  loadSkin(e) {
    const t = this.json.skins[e], n = [];
    for (let r = 0, s = t.joints.length; r < s; r++)
      n.push(this._loadNodeShallow(t.joints[r]));
    return t.inverseBindMatrices !== void 0 ? n.push(this.getDependency("accessor", t.inverseBindMatrices)) : n.push(null), Promise.all(n).then(function(r) {
      const s = r.pop(), a = r, o = [], l = [];
      for (let c = 0, u = a.length; c < u; c++) {
        const h = a[c];
        if (h) {
          o.push(h);
          const d = new Xe();
          s !== null && d.fromArray(s.array, c * 16), l.push(d);
        } else
          console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[c]);
      }
      return new Nc(o, l);
    });
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
   * @param {number} animationIndex
   * @return {Promise<AnimationClip>}
   */
  loadAnimation(e) {
    const t = this.json, n = this, r = t.animations[e], s = r.name ? r.name : "animation_" + e, a = [], o = [], l = [], c = [], u = [];
    for (let h = 0, d = r.channels.length; h < d; h++) {
      const m = r.channels[h], v = r.samplers[m.sampler], b = m.target, p = b.node, f = r.parameters !== void 0 ? r.parameters[v.input] : v.input, x = r.parameters !== void 0 ? r.parameters[v.output] : v.output;
      b.node !== void 0 && (a.push(this.getDependency("node", p)), o.push(this.getDependency("accessor", f)), l.push(this.getDependency("accessor", x)), c.push(v), u.push(b));
    }
    return Promise.all([
      Promise.all(a),
      Promise.all(o),
      Promise.all(l),
      Promise.all(c),
      Promise.all(u)
    ]).then(function(h) {
      const d = h[0], m = h[1], v = h[2], b = h[3], p = h[4], f = [];
      for (let x = 0, g = d.length; x < g; x++) {
        const _ = d[x], T = m[x], A = v[x], M = b[x], C = p[x];
        if (_ === void 0) continue;
        _.updateMatrix && _.updateMatrix();
        const y = n._createAnimationTracks(_, T, A, M, C);
        if (y)
          for (let E = 0; E < y.length; E++)
            f.push(y[E]);
      }
      return new mM(s, void 0, f);
    });
  }
  createNodeMesh(e) {
    const t = this.json, n = this, r = t.nodes[e];
    return r.mesh === void 0 ? null : n.getDependency("mesh", r.mesh).then(function(s) {
      const a = n._getNodeRef(n.meshCache, r.mesh, s);
      return r.weights !== void 0 && a.traverse(function(o) {
        if (o.isMesh)
          for (let l = 0, c = r.weights.length; l < c; l++)
            o.morphTargetInfluences[l] = r.weights[l];
      }), a;
    });
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
   * @param {number} nodeIndex
   * @return {Promise<Object3D>}
   */
  loadNode(e) {
    const t = this.json, n = this, r = t.nodes[e], s = n._loadNodeShallow(e), a = [], o = r.children || [];
    for (let c = 0, u = o.length; c < u; c++)
      a.push(n.getDependency("node", o[c]));
    const l = r.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", r.skin);
    return Promise.all([
      s,
      Promise.all(a),
      l
    ]).then(function(c) {
      const u = c[0], h = c[1], d = c[2];
      d !== null && u.traverse(function(m) {
        m.isSkinnedMesh && m.bind(d, zA);
      });
      for (let m = 0, v = h.length; m < v; m++)
        u.add(h[m]);
      return u;
    });
  }
  // ._loadNodeShallow() parses a single node.
  // skin and child nodes are created and added in .loadNode() (no '_' prefix).
  _loadNodeShallow(e) {
    const t = this.json, n = this.extensions, r = this;
    if (this.nodeCache[e] !== void 0)
      return this.nodeCache[e];
    const s = t.nodes[e], a = s.name ? r.createUniqueName(s.name) : "", o = [], l = r._invokeOne(function(c) {
      return c.createNodeMesh && c.createNodeMesh(e);
    });
    return l && o.push(l), s.camera !== void 0 && o.push(r.getDependency("camera", s.camera).then(function(c) {
      return r._getNodeRef(r.cameraCache, s.camera, c);
    })), r._invokeAll(function(c) {
      return c.createNodeAttachment && c.createNodeAttachment(e);
    }).forEach(function(c) {
      o.push(c);
    }), this.nodeCache[e] = Promise.all(o).then(function(c) {
      let u;
      if (s.isBone === !0 ? u = new ep() : c.length > 1 ? u = new Hi() : c.length === 1 ? u = c[0] : u = new Rt(), u !== c[0])
        for (let h = 0, d = c.length; h < d; h++)
          u.add(c[h]);
      if (s.name && (u.userData.name = s.name, u.name = a), Qn(u, s), s.extensions && Ii(n, u, s), s.matrix !== void 0) {
        const h = new Xe();
        h.fromArray(s.matrix), u.applyMatrix4(h);
      } else
        s.translation !== void 0 && u.position.fromArray(s.translation), s.rotation !== void 0 && u.quaternion.fromArray(s.rotation), s.scale !== void 0 && u.scale.fromArray(s.scale);
      return r.associations.has(u) || r.associations.set(u, {}), r.associations.get(u).nodes = e, u;
    }), this.nodeCache[e];
  }
  /**
   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
   * @param {number} sceneIndex
   * @return {Promise<Group>}
   */
  loadScene(e) {
    const t = this.extensions, n = this.json.scenes[e], r = this, s = new Hi();
    n.name && (s.name = r.createUniqueName(n.name)), Qn(s, n), n.extensions && Ii(t, s, n);
    const a = n.nodes || [], o = [];
    for (let l = 0, c = a.length; l < c; l++)
      o.push(r.getDependency("node", a[l]));
    return Promise.all(o).then(function(l) {
      for (let u = 0, h = l.length; u < h; u++)
        s.add(l[u]);
      const c = (u) => {
        const h = /* @__PURE__ */ new Map();
        for (const [d, m] of r.associations)
          (d instanceof Bn || d instanceof zt) && h.set(d, m);
        return u.traverse((d) => {
          const m = r.associations.get(d);
          m != null && h.set(d, m);
        }), h;
      };
      return r.associations = c(s), s;
    });
  }
  _createAnimationTracks(e, t, n, r, s) {
    const a = [], o = e.name ? e.name : e.uuid, l = [];
    gi[s.path] === gi.weights ? e.traverse(function(d) {
      d.morphTargetInfluences && l.push(d.name ? d.name : d.uuid);
    }) : l.push(o);
    let c;
    switch (gi[s.path]) {
      case gi.weights:
        c = Ur;
        break;
      case gi.rotation:
        c = Or;
        break;
      case gi.position:
      case gi.scale:
        c = Br;
        break;
      default:
        n.itemSize === 1 ? c = Ur : c = Br;
        break;
    }
    const u = r.interpolation !== void 0 ? NA[r.interpolation] : ys, h = this._getArrayFromAccessor(n);
    for (let d = 0, m = l.length; d < m; d++) {
      const v = new c(
        l[d] + "." + gi[s.path],
        t.array,
        h,
        u
      );
      r.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(v), a.push(v);
    }
    return a;
  }
  _getArrayFromAccessor(e) {
    let t = e.array;
    if (e.normalized) {
      const n = rc(t.constructor), r = new Float32Array(t.length);
      for (let s = 0, a = t.length; s < a; s++)
        r[s] = t[s] * n;
      t = r;
    }
    return t;
  }
  _createCubicSplineTrackInterpolant(e) {
    e.createInterpolant = function(n) {
      const r = this instanceof Or ? FA : lp;
      return new r(this.times, this.values, this.getValueSize() / 3, n);
    }, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
  }
}
function VA(i, e, t) {
  const n = e.attributes, r = new vn();
  if (n.POSITION !== void 0) {
    const o = t.json.accessors[n.POSITION], l = o.min, c = o.max;
    if (l !== void 0 && c !== void 0) {
      if (r.set(
        new L(l[0], l[1], l[2]),
        new L(c[0], c[1], c[2])
      ), o.normalized) {
        const u = rc(Sr[o.componentType]);
        r.min.multiplyScalar(u), r.max.multiplyScalar(u);
      }
    } else {
      console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
      return;
    }
  } else
    return;
  const s = e.targets;
  if (s !== void 0) {
    const o = new L(), l = new L();
    for (let c = 0, u = s.length; c < u; c++) {
      const h = s[c];
      if (h.POSITION !== void 0) {
        const d = t.json.accessors[h.POSITION], m = d.min, v = d.max;
        if (m !== void 0 && v !== void 0) {
          if (l.setX(Math.max(Math.abs(m[0]), Math.abs(v[0]))), l.setY(Math.max(Math.abs(m[1]), Math.abs(v[1]))), l.setZ(Math.max(Math.abs(m[2]), Math.abs(v[2]))), d.normalized) {
            const b = rc(Sr[d.componentType]);
            l.multiplyScalar(b);
          }
          o.max(l);
        } else
          console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
      }
    }
    r.expandByVector(o);
  }
  i.boundingBox = r;
  const a = new zn();
  r.getCenter(a.center), a.radius = r.min.distanceTo(r.max) / 2, i.boundingSphere = a;
}
function mf(i, e, t) {
  const n = e.attributes, r = [];
  function s(a, o) {
    return t.getDependency("accessor", a).then(function(l) {
      i.setAttribute(o, l);
    });
  }
  for (const a in n) {
    const o = ic[a] || a.toLowerCase();
    o in i.attributes || r.push(s(n[a], o));
  }
  if (e.indices !== void 0 && !i.index) {
    const a = t.getDependency("accessor", e.indices).then(function(o) {
      i.setIndex(o);
    });
    r.push(a);
  }
  return nt.workingColorSpace !== en && "COLOR_0" in n && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${nt.workingColorSpace}" not supported.`), Qn(i, e), VA(i, e, t), Promise.all(r).then(function() {
    return e.targets !== void 0 ? OA(i, e.targets, t) : i;
  });
}
const WA = 1e5;
function XA(i, e = [180, 180, 180], t = WA) {
  const n = [], r = [], s = [], a = [];
  if (i.traverse((m) => {
    if (m.isMesh) {
      s.push(m);
      return;
    }
    m.isPoints && a.push(m);
  }), s.length === 0 && a.length === 0) {
    const m = new fn();
    return m.setAttribute("position", new Ot([], 3)), new Ua(m, new Ms({ size: 0.02 }));
  }
  const o = a.reduce(
    (m, v) => m + gf(v),
    0
  ), l = Math.min(t, o);
  for (let m = 0; m < a.length; m++) {
    const v = a[m], b = gf(v);
    if (b === 0) continue;
    const p = l >= o ? b : Math.max(1, Math.round(b / o * l));
    qA(v, p, n, r, e);
  }
  let c = 0;
  const u = [];
  for (const m of s) {
    const v = YA(m);
    u.push(v), c += v;
  }
  for (let m = 0; m < s.length; m++) {
    const v = s[m], b = c > 0 ? Math.max(1, Math.round(u[m] / c * t)) : Math.round(t / s.length);
    ZA(v, b, n, r, e);
  }
  const h = new fn();
  h.setAttribute("position", new Ot(n, 3)), h.setAttribute("color", new Ot(r, 3));
  const d = new Ms({
    size: 0.02,
    vertexColors: !0,
    sizeAttenuation: !0
  });
  return new Ua(h, d);
}
function gf(i) {
  return i.geometry?.attributes?.position?.count ?? 0;
}
function cp(i) {
  return new Ue(
    i[0] / 255,
    i[1] / 255,
    i[2] / 255
  );
}
function jA(i, e) {
  const t = Array.isArray(i) ? i[0] : i;
  return t && "color" in t && t.color instanceof Ue ? t.color.clone() : cp(e);
}
function qA(i, e, t, n, r) {
  const s = i.geometry, a = s.attributes.position;
  if (!a || a.count === 0) return;
  const o = !!s.attributes.color, l = s.attributes.color, c = jA(i.material, r), u = i.matrixWorld, h = new L(), d = new Ue(), m = a.count, v = e >= m ? 1 : m / e, b = e >= m ? m : e;
  for (let p = 0; p < b; p++) {
    const f = b === m ? p : Math.min(Math.floor(p * v), m - 1);
    h.fromBufferAttribute(a, f).applyMatrix4(u), t.push(h.x, h.y, h.z), o && l ? (d.fromBufferAttribute(l, f), n.push(d.r, d.g, d.b)) : n.push(c.r, c.g, c.b);
  }
}
function YA(i) {
  const e = i.geometry;
  if (!e) return 1;
  const t = e.attributes.position;
  if (!t) return 1;
  let n = 0;
  const r = new L(), s = new L(), a = new L(), o = new L();
  if (e.index) {
    const l = e.index;
    for (let c = 0; c < l.count; c += 3)
      r.fromBufferAttribute(t, l.getX(c)), s.fromBufferAttribute(t, l.getX(c + 1)), a.fromBufferAttribute(t, l.getX(c + 2)), o.crossVectors(s.clone().sub(r), a.clone().sub(r)), n += o.length() * 0.5;
  } else
    for (let l = 0; l < t.count; l += 3)
      r.fromBufferAttribute(t, l), s.fromBufferAttribute(t, l + 1), a.fromBufferAttribute(t, l + 2), o.crossVectors(s.clone().sub(r), a.clone().sub(r)), n += o.length() * 0.5;
  return n || 1;
}
function ZA(i, e, t, n, r) {
  const s = i.geometry, a = s.attributes.position;
  if (!a || a.count === 0) return;
  const o = !!s.attributes.color, l = s.attributes.color, u = i.material?.color ?? cp(r), h = i.matrixWorld, d = new L(), m = new L(), v = new L(), b = new L(), p = [];
  if (s.index) {
    const f = s.index;
    for (let x = 0; x < f.count; x += 3)
      p.push([f.getX(x), f.getX(x + 1), f.getX(x + 2)]);
  } else
    for (let f = 0; f < a.count; f += 3)
      p.push([f, f + 1, f + 2]);
  if (p.length !== 0)
    for (let f = 0; f < e; f++) {
      const x = Math.floor(Math.random() * p.length), [g, _, T] = p[x];
      d.fromBufferAttribute(a, g).applyMatrix4(h), m.fromBufferAttribute(a, _).applyMatrix4(h), v.fromBufferAttribute(a, T).applyMatrix4(h);
      let A = Math.random(), M = Math.random();
      A + M > 1 && (A = 1 - A, M = 1 - M);
      const C = 1 - A - M;
      if (b.set(
        A * d.x + M * m.x + C * v.x,
        A * d.y + M * m.y + C * v.y,
        A * d.z + M * m.z + C * v.z
      ), t.push(b.x, b.y, b.z), o) {
        const y = new Ue().fromBufferAttribute(l, g), E = new Ue().fromBufferAttribute(l, _), R = new Ue().fromBufferAttribute(l, T);
        n.push(
          A * y.r + M * E.r + C * R.r,
          A * y.g + M * E.g + C * R.g,
          A * y.b + M * E.b + C * R.b
        );
      } else
        n.push(u.r, u.g, u.b);
    }
}
async function KA(i, e, t) {
  const n = i.name ?? i.path.split("/").pop() ?? "Asset", r = i.color ? [i.color[0], i.color[1], i.color[2]] : [180, 180, 180], s = i.url ?? i.path;
  return i.type === "ply" ? $A(s, n, r, t) : JA(s, n, e, r, t);
}
async function $A(i, e, t, n) {
  const r = new oA(), s = await new Promise((u, h) => {
    r.load(i, u, void 0, h);
  });
  s.computeBoundingBox();
  const a = !!s.attributes.color, o = new Ms({
    size: n * 0.01,
    vertexColors: a,
    color: a ? void 0 : new Ue(
      t[0] / 255,
      t[1] / 255,
      t[2] / 255
    ),
    sizeAttenuation: !0
  }), l = new Ua(s, o), c = new vn().setFromObject(l);
  return {
    id: crypto.randomUUID(),
    name: e,
    type: "ply",
    object3d: l,
    bounds: c
  };
}
async function JA(i, e, t, n, r) {
  const s = new cA(), o = (await new Promise((u, h) => {
    s.load(i, u, void 0, h);
  })).scene;
  o.updateMatrixWorld(!0);
  let l;
  if (t === "native")
    l = o;
  else {
    const u = XA(o, n);
    u.material.size = r * 0.01, l = u;
  }
  const c = new vn().setFromObject(l);
  return {
    id: crypto.randomUUID(),
    name: e,
    type: "glb",
    object3d: l,
    bounds: c
  };
}
function QA(i) {
  const e = new L(), t = new L();
  i.getCenter(e), i.getSize(t);
  const r = (Math.max(t.x, t.y, t.z) || 1) * 2.5;
  return {
    position: {
      x: e.x + r * 0.5,
      y: e.y + r * 0.5,
      z: e.z + r
    },
    target: { x: e.x, y: e.y, z: e.z },
    zoom: 1,
    up: { x: 0, y: 1, z: 0 }
  };
}
function eT(i) {
  const e = new vn();
  for (const t of i)
    e.union(t);
  return e;
}
var tT = /* @__PURE__ */ Ct('<div class="sync3d-root svelte-ds98y4"><div class="toolbar svelte-ds98y4"><div class="toolbar-cluster svelte-ds98y4"><button class="toolbar-btn reset-btn svelte-ds98y4" title="Reset all cameras"><span class="reset-icon svelte-ds98y4">⟳</span> <span>Reset</span></button> <div class="toolbar-group svelte-ds98y4"><span class="toolbar-label svelte-ds98y4">Mode:</span> <div class="segmented-control svelte-ds98y4"><button>Points</button> <button>Native</button></div></div></div> <div class="toolbar-cluster controls-cluster svelte-ds98y4"><div class="toolbar-group slider-group svelte-ds98y4"><span class="toolbar-label svelte-ds98y4"> </span> <input type="range" step="0.5" class="toolbar-slider svelte-ds98y4"/></div> <div class="toolbar-group slider-group svelte-ds98y4"><span class="toolbar-label svelte-ds98y4"> </span> <input type="range" step="0.05" class="toolbar-slider svelte-ds98y4"/></div></div></div> <div class="viewports-grid svelte-ds98y4"></div> <input class="hidden-file-input svelte-ds98y4" type="file"/></div>');
function nT(i, e) {
  zr(e, !0);
  var t = this && this.__awaiter || function(H, X, ae, xe) {
    function Ne(Fe) {
      return Fe instanceof ae ? Fe : new ae(function(ke) {
        ke(Fe);
      });
    }
    return new (ae || (ae = Promise))(function(Fe, ke) {
      function it(xt) {
        try {
          It(xe.next(xt));
        } catch (Cn) {
          ke(Cn);
        }
      }
      function Et(xt) {
        try {
          It(xe.throw(xt));
        } catch (Cn) {
          ke(Cn);
        }
      }
      function It(xt) {
        xt.done ? Fe(xt.value) : Ne(xt.value).then(it, Et);
      }
      It((xe = xe.apply(H, X || [])).next());
    });
  }, n;
  const r = ".ply,.glb,model/gltf-binary", s = 0.5;
  let a = Ee(e, "render_mode", 3, "points"), o = Ee(e, "sync_camera", 3, !0), l = Ee(e, "point_size", 3, 2), c = Ee(e, "max_point_size", 3, 10), u = Ee(e, "height", 3, 500), h = Ee(e, "max_views", 3, 4), d = Ee(e, "default_zoom", 3, 1), m = Ee(e, "min_zoom", 3, 0.5), v = Ee(e, "max_zoom", 3, 16), b, p = wt(null), f = /* @__PURE__ */ new Set();
  function x(H, X, ae) {
    return Math.min(Math.max(H, X), ae);
  }
  function g(H, X) {
    const ae = Math.max(X, s);
    return Math.min(Math.max(H, s), ae);
  }
  function _(H) {
    return Object.assign(Object.assign({}, H), {
      color: H.color ? [...H.color] : void 0,
      metadata: H.metadata ? Object.assign({}, H.metadata) : void 0
    });
  }
  function T(H) {
    var X;
    const ae = new Set(((X = H?.assets) !== null && X !== void 0 ? X : []).map((xe) => xe.url).filter((xe) => typeof xe == "string" && xe.length > 0));
    for (const xe of Array.from(f))
      ae.has(xe) || (URL.revokeObjectURL(xe), f.delete(xe));
  }
  function A(H) {
    var X, ae, xe, Ne, Fe, ke, it, Et, It;
    const xt = Math.max((X = H?.min_zoom) !== null && X !== void 0 ? X : m(), 0.1), Cn = Math.max((ae = H?.max_zoom) !== null && ae !== void 0 ? ae : v(), xt), Fs = x((xe = H?.default_zoom) !== null && xe !== void 0 ? xe : d(), xt, Cn), Yr = Math.max((Ne = H?.max_point_size) !== null && Ne !== void 0 ? Ne : c(), s), Ki = g((Fe = H?.point_size) !== null && Fe !== void 0 ? Fe : l(), Yr);
    return {
      assets: ((ke = H?.assets) !== null && ke !== void 0 ? ke : []).map(_),
      render_mode: (it = H?.render_mode) !== null && it !== void 0 ? it : a(),
      sync_camera: (Et = H?.sync_camera) !== null && Et !== void 0 ? Et : o(),
      point_size: Ki,
      max_point_size: Yr,
      height: (It = H?.height) !== null && It !== void 0 ? It : u(),
      default_zoom: Fs,
      min_zoom: xt,
      max_zoom: Cn
    };
  }
  function M(H) {
    !H || !f.has(H) || (URL.revokeObjectURL(H), f.delete(H));
  }
  function C() {
    for (const H of f)
      URL.revokeObjectURL(H);
    f.clear();
  }
  function y(H = P(U), X = {}) {
    var ae, xe, Ne, Fe, ke, it, Et, It;
    const xt = Math.max((ae = X.max_point_size) !== null && ae !== void 0 ? ae : P(ne), s);
    return {
      assets: H.map(_),
      render_mode: (xe = X.render_mode) !== null && xe !== void 0 ? xe : P(he),
      sync_camera: (Ne = X.sync_camera) !== null && Ne !== void 0 ? Ne : P(Y),
      point_size: g((Fe = X.point_size) !== null && Fe !== void 0 ? Fe : P(re), xt),
      max_point_size: xt,
      height: (ke = X.height) !== null && ke !== void 0 ? ke : P(z),
      default_zoom: (it = X.default_zoom) !== null && it !== void 0 ? it : P(me),
      min_zoom: (Et = X.min_zoom) !== null && Et !== void 0 ? Et : P(ie),
      max_zoom: (It = X.max_zoom) !== null && It !== void 0 ? It : P(oe)
    };
  }
  function E(H = P(U), X = {}, ae = !0) {
    const xe = y(H, X);
    return Te(B, xe, !0), ae && (e.onchange === null || e.onchange === void 0 || e.onchange(xe)), xe;
  }
  function R(H) {
    const X = H.toLowerCase();
    return X.endsWith(".ply") ? "ply" : X.endsWith(".glb") ? "glb" : null;
  }
  function q(H) {
    const X = R(H.name);
    if (!X)
      return null;
    const ae = URL.createObjectURL(H);
    return f.add(ae), {
      name: H.name.replace(/\.[^/.]+$/, ""),
      path: H.name,
      url: ae,
      type: X,
      visible: !0
    };
  }
  function G(H, X, ae, xe) {
    const Ne = [...H];
    return ae !== null && Ne[ae] ? (M(Ne[ae].url), Ne[ae] = xe, Ne) : (Ne.splice(Math.min(X, Ne.length), 0, xe), Ne);
  }
  function V(H, X, ae) {
    return t(this, void 0, void 0, function* () {
      const xe = H[0];
      if (!xe) return;
      const Ne = q(xe);
      if (!Ne)
        return;
      const Fe = G(P(U), X, ae, Ne);
      E(Fe);
    });
  }
  let B = wt(Sn(A(e.value))), U = Mt(() => (n = P(B).assets) !== null && n !== void 0 ? n : []), Y = Mt(() => P(B).sync_camera), z = Mt(() => P(B).height), ie = Mt(() => P(B).min_zoom), oe = Mt(() => P(B).max_zoom), ce = Mt(() => Math.max(2, h())), ye = Mt(() => P(U).map((H, X) => ({ asset: H, index: X })).filter(({ asset: H }) => H.visible !== !1)), je = Mt(() => Math.min(Math.max(P(ye).length, 2), P(ce))), K = Mt(() => Math.min(P(je), 2)), Q = Mt(() => Array.from({ length: P(je) }, (H, X) => {
    var ae, xe;
    const Ne = P(ye)[X];
    return {
      slotIndex: X,
      descriptor: (ae = Ne?.asset) !== null && ae !== void 0 ? ae : null,
      sourceIndex: (xe = Ne?.index) !== null && xe !== void 0 ? xe : null
    };
  })), re = wt(Sn(P(B).point_size)), ne = wt(Sn(P(B).max_point_size)), he = wt(Sn(P(B).render_mode)), me = wt(Sn(P(B).default_zoom)), we = new aA(), qe = wt(Sn([])), Pe = wt(Sn([])), Je = wt(Sn([])), F = wt(null), Gt = 0;
  Nm(() => {
    C();
  }), Lt(() => {
    const H = e.value;
    T(H), Te(B, A(H), !0);
  }), Lt(() => {
    Te(he, P(B).render_mode, !0);
  }), Lt(() => {
    Te(re, P(B).point_size, !0);
  }), Lt(() => {
    Te(ne, Math.max(P(B).max_point_size, s), !0), Te(re, g(P(B).point_size, P(ne)), !0);
  }), Lt(() => {
    Te(me, x(P(B).default_zoom, P(ie), P(oe)), !0);
  }), Lt(() => {
    we.setEnabled(P(Y));
  }), Lt(() => {
    const H = P(U), X = P(he);
    H.length > 0 ? $e(H, X) : (Te(qe, [], !0), Te(Pe, [], !0), Te(Je, [], !0), Te(F, null), Te(me, x(P(B).default_zoom, P(ie), P(oe)), !0));
  });
  function $e() {
    return t(this, arguments, void 0, function* (H = P(U), X = P(he)) {
      const ae = ++Gt, xe = H.length, Ne = new Array(xe).fill(null), Fe = new Array(xe).fill(!0), ke = new Array(xe).fill(null);
      if (Te(qe, Ne, !0), Te(Pe, Fe, !0), Te(Je, ke, !0), yield Promise.allSettled(H.map((Et, It) => KA(Et, X, P(re)).then((xt) => (Ne[It] = xt, Fe[It] = !1, xt)).catch((xt) => {
        throw ke[It] = `Failed to load: ${Et.path.split("/").pop()}`, Fe[It] = !1, xt;
      }))), ae !== Gt)
        return;
      Te(qe, Ne, !0), Te(Pe, Fe, !0), Te(Je, ke, !0), Te(F, null), Te(me, x(P(B).default_zoom, P(ie), P(oe)), !0);
      const it = Ne.filter((Et) => Et !== null).map((Et) => Et.bounds);
      if (it.length > 0) {
        const Et = eT(it);
        Te(F, QA(Et), !0), P(F).zoom = x(P(B).default_zoom, P(ie), P(oe)), Te(me, P(F).zoom, !0), we.resetAll(P(F));
      }
    });
  }
  function Ze() {
    P(F) && (Te(me, x(P(F).zoom, P(ie), P(oe)), !0), we.resetAll(P(F)));
  }
  function Le(H) {
    Te(he, H, !0), E(P(U), { render_mode: H });
  }
  function ht() {
    Te(re, g(P(re), P(ne)), !0), E(P(U), { point_size: P(re) });
  }
  function Ie() {
    Te(me, x(P(me), P(ie), P(oe)), !0), we.setZoom(P(me)), E(P(U), { default_zoom: P(me) }, !1);
  }
  function D(H, X) {
    Te(p, { slotIndex: H, sourceIndex: X }, !0), b?.click();
  }
  function S(H) {
    return t(this, void 0, void 0, function* () {
      var X;
      const ae = H.currentTarget, xe = Array.from((X = ae.files) !== null && X !== void 0 ? X : []);
      if (!P(p) || xe.length === 0) {
        ae.value = "";
        return;
      }
      yield V(xe, P(p).slotIndex, P(p).sourceIndex), Te(p, null), ae.value = "";
    });
  }
  function k(H, X, ae) {
    return t(this, void 0, void 0, function* () {
      yield V(H, X, ae);
    });
  }
  var J = tT(), te = pt(J), $ = pt(te), be = pt($), fe = st(be, 2), ge = st(pt(fe), 2), He = pt(ge), se = st(He, 2), _e = st($, 2), Re = pt(_e), Ce = pt(Re), pe = pt(Ce), Be = st(Ce, 2);
  In(Be, "min", s);
  var Oe = st(Re, 2), et = pt(Oe), I = pt(et), ue = st(et, 2), Z = st(te, 2);
  tl(Z, 21, () => P(Q), (H) => H.slotIndex, (H, X) => {
    {
      let ae = Mt(() => P(X).sourceIndex === null ? null : P(qe)[P(X).sourceIndex] ?? null), xe = Mt(() => P(X).descriptor?.name ?? `View ${P(X).slotIndex + 1}`), Ne = Mt(() => P(X).sourceIndex === null ? !1 : P(Pe)[P(X).sourceIndex] ?? !0), Fe = Mt(() => P(X).sourceIndex === null ? null : P(Je)[P(X).sourceIndex] ?? null), ke = Mt(() => P(X).descriptor === null), it = Mt(() => P(X).descriptor === null);
      sA(H, {
        get asset() {
          return P(ae);
        },
        get label() {
          return P(xe);
        },
        get height() {
          return P(z);
        },
        get syncManager() {
          return we;
        },
        get initialCamera() {
          return P(F);
        },
        get pointSize() {
          return P(re);
        },
        get loading() {
          return P(Ne);
        },
        get error() {
          return P(Fe);
        },
        get placeholder() {
          return P(ke);
        },
        get uploadable() {
          return P(it);
        },
        request_upload: () => D(P(X).slotIndex, P(X).sourceIndex),
        drop_files: (Et) => k(Et, P(X).slotIndex, P(X).sourceIndex)
      });
    }
  });
  var ee = st(Z, 2);
  In(ee, "accept", r), Ha(ee, (H) => b = H, () => b), Dt(
    (H, X) => {
      ri(He, 1, `toolbar-btn mode-btn ${P(he) === "points" ? "active" : ""}`, "svelte-ds98y4"), ri(se, 1, `toolbar-btn mode-btn ${P(he) === "native" ? "active" : ""}`, "svelte-ds98y4"), Yt(pe, `Size: ${H ?? ""}`), In(Be, "max", P(ne)), Yt(I, `Zoom: ${X ?? ""}x`), In(ue, "min", P(ie)), In(ue, "max", P(oe)), Dn(Z, `--grid-columns: ${P(K) ?? ""};`);
    },
    [
      () => P(re).toFixed(1),
      () => P(me).toFixed(2)
    ]
  ), ei("click", be, Ze), ei("click", He, () => Le("points")), ei("click", se, () => Le("native")), ei("input", Be, ht), iu(Be, () => P(re), (H) => Te(re, H)), ei("input", ue, Ie), iu(ue, () => P(me), (H) => Te(me, H)), ei("change", ee, S), Ke(i, J), Hr();
}
kr(["click", "input", "change"]);
var iT = /* @__PURE__ */ Ct("<!> <!>", 1);
function sT(i, e) {
  zr(e, !0);
  const t = /* @__PURE__ */ Lm(e, ["$$slots", "$$events", "$$legacy"]), n = new v_(t);
  S_(i, {
    get visible() {
      return n.shared.visible;
    },
    get elem_id() {
      return n.shared.elem_id;
    },
    get elem_classes() {
      return n.shared.elem_classes;
    },
    container: !0,
    get scale() {
      return n.shared.scale;
    },
    get min_width() {
      return n.shared.min_width;
    },
    children: (r, s) => {
      var a = iT(), o = Kt(a);
      {
        var l = (u) => {
          N0(u, Fm(
            {
              get autoscroll() {
                return n.shared.autoscroll;
              },
              get i18n() {
                return n.i18n;
              }
            },
            () => n.shared.loading_status,
            {
              on_clear_status: () => n.dispatch("clear_status", n.shared.loading_status)
            }
          ));
        };
        At(o, (u) => {
          n.shared.loading_status && u(l);
        });
      }
      var c = st(o, 2);
      nT(c, {
        get value() {
          return n.props.value;
        },
        get render_mode() {
          return n.props.render_mode;
        },
        get sync_camera() {
          return n.props.sync_camera;
        },
        get point_size() {
          return n.props.point_size;
        },
        get max_point_size() {
          return n.props.max_point_size;
        },
        get height() {
          return n.props.height;
        },
        get max_views() {
          return n.props.max_views;
        },
        get default_zoom() {
          return n.props.default_zoom;
        },
        get min_zoom() {
          return n.props.min_zoom;
        },
        get max_zoom() {
          return n.props.max_zoom;
        },
        onchange: (u) => {
          n.props.value = u, n.dispatch("change", u);
        }
      }), Ke(r, a);
    },
    $$slots: { default: !0 }
  }), Hr();
}
export {
  sT as default
};
