var $A = Object.defineProperty;
var KA = (n, t, e) => t in n ? $A(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
var Nt = (n, t, e) => KA(n, typeof t != "symbol" ? t + "" : t, e);
function tM(n) {
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
}
var Kp = { exports: {} }, pe = {};
/**
 * @license React
 * react.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var zx;
function QA() {
  if (zx) return pe;
  zx = 1;
  var n = Symbol.for("react.transitional.element"), t = Symbol.for("react.portal"), e = Symbol.for("react.fragment"), r = Symbol.for("react.strict_mode"), a = Symbol.for("react.profiler"), o = Symbol.for("react.consumer"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), h = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), m = Symbol.for("react.activity"), g = Symbol.iterator;
  function _(F) {
    return F === null || typeof F != "object" ? null : (F = g && F[g] || F["@@iterator"], typeof F == "function" ? F : null);
  }
  var b = {
    isMounted: function() {
      return !1;
    },
    enqueueForceUpdate: function() {
    },
    enqueueReplaceState: function() {
    },
    enqueueSetState: function() {
    }
  }, E = Object.assign, S = {};
  function y(F, q, it) {
    this.props = F, this.context = q, this.refs = S, this.updater = it || b;
  }
  y.prototype.isReactComponent = {}, y.prototype.setState = function(F, q) {
    if (typeof F != "object" && typeof F != "function" && F != null)
      throw Error(
        "takes an object of state variables to update or a function which returns an object of state variables."
      );
    this.updater.enqueueSetState(this, F, q, "setState");
  }, y.prototype.forceUpdate = function(F) {
    this.updater.enqueueForceUpdate(this, F, "forceUpdate");
  };
  function A() {
  }
  A.prototype = y.prototype;
  function w(F, q, it) {
    this.props = F, this.context = q, this.refs = S, this.updater = it || b;
  }
  var M = w.prototype = new A();
  M.constructor = w, E(M, y.prototype), M.isPureReactComponent = !0;
  var O = Array.isArray;
  function L() {
  }
  var N = { H: null, A: null, T: null, S: null }, z = Object.prototype.hasOwnProperty;
  function R(F, q, it) {
    var G = it.ref;
    return {
      $$typeof: n,
      type: F,
      key: q,
      ref: G !== void 0 ? G : null,
      props: it
    };
  }
  function T(F, q) {
    return R(F.type, q, F.props);
  }
  function U(F) {
    return typeof F == "object" && F !== null && F.$$typeof === n;
  }
  function B(F) {
    var q = { "=": "=0", ":": "=2" };
    return "$" + F.replace(/[=:]/g, function(it) {
      return q[it];
    });
  }
  var I = /\/+/g;
  function C(F, q) {
    return typeof F == "object" && F !== null && F.key != null ? B("" + F.key) : q.toString(36);
  }
  function X(F) {
    switch (F.status) {
      case "fulfilled":
        return F.value;
      case "rejected":
        throw F.reason;
      default:
        switch (typeof F.status == "string" ? F.then(L, L) : (F.status = "pending", F.then(
          function(q) {
            F.status === "pending" && (F.status = "fulfilled", F.value = q);
          },
          function(q) {
            F.status === "pending" && (F.status = "rejected", F.reason = q);
          }
        )), F.status) {
          case "fulfilled":
            return F.value;
          case "rejected":
            throw F.reason;
        }
    }
    throw F;
  }
  function D(F, q, it, G, k) {
    var $ = typeof F;
    ($ === "undefined" || $ === "boolean") && (F = null);
    var Q = !1;
    if (F === null) Q = !0;
    else
      switch ($) {
        case "bigint":
        case "string":
        case "number":
          Q = !0;
          break;
        case "object":
          switch (F.$$typeof) {
            case n:
            case t:
              Q = !0;
              break;
            case p:
              return Q = F._init, D(
                Q(F._payload),
                q,
                it,
                G,
                k
              );
          }
      }
    if (Q)
      return k = k(F), Q = G === "" ? "." + C(F, 0) : G, O(k) ? (it = "", Q != null && (it = Q.replace(I, "$&/") + "/"), D(k, q, it, "", function(_t) {
        return _t;
      })) : k != null && (U(k) && (k = T(
        k,
        it + (k.key == null || F && F.key === k.key ? "" : ("" + k.key).replace(
          I,
          "$&/"
        ) + "/") + Q
      )), q.push(k)), 1;
    Q = 0;
    var et = G === "" ? "." : G + ":";
    if (O(F))
      for (var st = 0; st < F.length; st++)
        G = F[st], $ = et + C(G, st), Q += D(
          G,
          q,
          it,
          $,
          k
        );
    else if (st = _(F), typeof st == "function")
      for (F = st.call(F), st = 0; !(G = F.next()).done; )
        G = G.value, $ = et + C(G, st++), Q += D(
          G,
          q,
          it,
          $,
          k
        );
    else if ($ === "object") {
      if (typeof F.then == "function")
        return D(
          X(F),
          q,
          it,
          G,
          k
        );
      throw q = String(F), Error(
        "Objects are not valid as a React child (found: " + (q === "[object Object]" ? "object with keys {" + Object.keys(F).join(", ") + "}" : q) + "). If you meant to render a collection of children, use an array instead."
      );
    }
    return Q;
  }
  function V(F, q, it) {
    if (F == null) return F;
    var G = [], k = 0;
    return D(F, G, "", "", function($) {
      return q.call(it, $, k++);
    }), G;
  }
  function H(F) {
    if (F._status === -1) {
      var q = F._result;
      q = q(), q.then(
        function(it) {
          (F._status === 0 || F._status === -1) && (F._status = 1, F._result = it);
        },
        function(it) {
          (F._status === 0 || F._status === -1) && (F._status = 2, F._result = it);
        }
      ), F._status === -1 && (F._status = 0, F._result = q);
    }
    if (F._status === 1) return F._result.default;
    throw F._result;
  }
  var j = typeof reportError == "function" ? reportError : function(F) {
    if (typeof window == "object" && typeof window.ErrorEvent == "function") {
      var q = new window.ErrorEvent("error", {
        bubbles: !0,
        cancelable: !0,
        message: typeof F == "object" && F !== null && typeof F.message == "string" ? String(F.message) : String(F),
        error: F
      });
      if (!window.dispatchEvent(q)) return;
    } else if (typeof process == "object" && typeof process.emit == "function") {
      process.emit("uncaughtException", F);
      return;
    }
    console.error(F);
  }, K = {
    map: V,
    forEach: function(F, q, it) {
      V(
        F,
        function() {
          q.apply(this, arguments);
        },
        it
      );
    },
    count: function(F) {
      var q = 0;
      return V(F, function() {
        q++;
      }), q;
    },
    toArray: function(F) {
      return V(F, function(q) {
        return q;
      }) || [];
    },
    only: function(F) {
      if (!U(F))
        throw Error(
          "React.Children.only expected to receive a single React element child."
        );
      return F;
    }
  };
  return pe.Activity = m, pe.Children = K, pe.Component = y, pe.Fragment = e, pe.Profiler = a, pe.PureComponent = w, pe.StrictMode = r, pe.Suspense = d, pe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = N, pe.__COMPILER_RUNTIME = {
    __proto__: null,
    c: function(F) {
      return N.H.useMemoCache(F);
    }
  }, pe.cache = function(F) {
    return function() {
      return F.apply(null, arguments);
    };
  }, pe.cacheSignal = function() {
    return null;
  }, pe.cloneElement = function(F, q, it) {
    if (F == null)
      throw Error(
        "The argument must be a React element, but you passed " + F + "."
      );
    var G = E({}, F.props), k = F.key;
    if (q != null)
      for ($ in q.key !== void 0 && (k = "" + q.key), q)
        !z.call(q, $) || $ === "key" || $ === "__self" || $ === "__source" || $ === "ref" && q.ref === void 0 || (G[$] = q[$]);
    var $ = arguments.length - 2;
    if ($ === 1) G.children = it;
    else if (1 < $) {
      for (var Q = Array($), et = 0; et < $; et++)
        Q[et] = arguments[et + 2];
      G.children = Q;
    }
    return R(F.type, k, G);
  }, pe.createContext = function(F) {
    return F = {
      $$typeof: c,
      _currentValue: F,
      _currentValue2: F,
      _threadCount: 0,
      Provider: null,
      Consumer: null
    }, F.Provider = F, F.Consumer = {
      $$typeof: o,
      _context: F
    }, F;
  }, pe.createElement = function(F, q, it) {
    var G, k = {}, $ = null;
    if (q != null)
      for (G in q.key !== void 0 && ($ = "" + q.key), q)
        z.call(q, G) && G !== "key" && G !== "__self" && G !== "__source" && (k[G] = q[G]);
    var Q = arguments.length - 2;
    if (Q === 1) k.children = it;
    else if (1 < Q) {
      for (var et = Array(Q), st = 0; st < Q; st++)
        et[st] = arguments[st + 2];
      k.children = et;
    }
    if (F && F.defaultProps)
      for (G in Q = F.defaultProps, Q)
        k[G] === void 0 && (k[G] = Q[G]);
    return R(F, $, k);
  }, pe.createRef = function() {
    return { current: null };
  }, pe.forwardRef = function(F) {
    return { $$typeof: u, render: F };
  }, pe.isValidElement = U, pe.lazy = function(F) {
    return {
      $$typeof: p,
      _payload: { _status: -1, _result: F },
      _init: H
    };
  }, pe.memo = function(F, q) {
    return {
      $$typeof: h,
      type: F,
      compare: q === void 0 ? null : q
    };
  }, pe.startTransition = function(F) {
    var q = N.T, it = {};
    N.T = it;
    try {
      var G = F(), k = N.S;
      k !== null && k(it, G), typeof G == "object" && G !== null && typeof G.then == "function" && G.then(L, j);
    } catch ($) {
      j($);
    } finally {
      q !== null && it.types !== null && (q.types = it.types), N.T = q;
    }
  }, pe.unstable_useCacheRefresh = function() {
    return N.H.useCacheRefresh();
  }, pe.use = function(F) {
    return N.H.use(F);
  }, pe.useActionState = function(F, q, it) {
    return N.H.useActionState(F, q, it);
  }, pe.useCallback = function(F, q) {
    return N.H.useCallback(F, q);
  }, pe.useContext = function(F) {
    return N.H.useContext(F);
  }, pe.useDebugValue = function() {
  }, pe.useDeferredValue = function(F, q) {
    return N.H.useDeferredValue(F, q);
  }, pe.useEffect = function(F, q) {
    return N.H.useEffect(F, q);
  }, pe.useEffectEvent = function(F) {
    return N.H.useEffectEvent(F);
  }, pe.useId = function() {
    return N.H.useId();
  }, pe.useImperativeHandle = function(F, q, it) {
    return N.H.useImperativeHandle(F, q, it);
  }, pe.useInsertionEffect = function(F, q) {
    return N.H.useInsertionEffect(F, q);
  }, pe.useLayoutEffect = function(F, q) {
    return N.H.useLayoutEffect(F, q);
  }, pe.useMemo = function(F, q) {
    return N.H.useMemo(F, q);
  }, pe.useOptimistic = function(F, q) {
    return N.H.useOptimistic(F, q);
  }, pe.useReducer = function(F, q, it) {
    return N.H.useReducer(F, q, it);
  }, pe.useRef = function(F) {
    return N.H.useRef(F);
  }, pe.useState = function(F) {
    return N.H.useState(F);
  }, pe.useSyncExternalStore = function(F, q, it) {
    return N.H.useSyncExternalStore(
      F,
      q,
      it
    );
  }, pe.useTransition = function() {
    return N.H.useTransition();
  }, pe.version = "19.2.4", pe;
}
var Ix;
function Gc() {
  return Ix || (Ix = 1, Kp.exports = QA()), Kp.exports;
}
var ct = Gc();
const xc = /* @__PURE__ */ tM(ct);
var Qp = { exports: {} }, rc = {}, Jp = { exports: {} }, tm = {};
/**
 * @license React
 * scheduler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var Bx;
function JA() {
  return Bx || (Bx = 1, (function(n) {
    function t(D, V) {
      var H = D.length;
      D.push(V);
      t: for (; 0 < H; ) {
        var j = H - 1 >>> 1, K = D[j];
        if (0 < a(K, V))
          D[j] = V, D[H] = K, H = j;
        else break t;
      }
    }
    function e(D) {
      return D.length === 0 ? null : D[0];
    }
    function r(D) {
      if (D.length === 0) return null;
      var V = D[0], H = D.pop();
      if (H !== V) {
        D[0] = H;
        t: for (var j = 0, K = D.length, F = K >>> 1; j < F; ) {
          var q = 2 * (j + 1) - 1, it = D[q], G = q + 1, k = D[G];
          if (0 > a(it, H))
            G < K && 0 > a(k, it) ? (D[j] = k, D[G] = H, j = G) : (D[j] = it, D[q] = H, j = q);
          else if (G < K && 0 > a(k, H))
            D[j] = k, D[G] = H, j = G;
          else break t;
        }
      }
      return V;
    }
    function a(D, V) {
      var H = D.sortIndex - V.sortIndex;
      return H !== 0 ? H : D.id - V.id;
    }
    if (n.unstable_now = void 0, typeof performance == "object" && typeof performance.now == "function") {
      var o = performance;
      n.unstable_now = function() {
        return o.now();
      };
    } else {
      var c = Date, u = c.now();
      n.unstable_now = function() {
        return c.now() - u;
      };
    }
    var d = [], h = [], p = 1, m = null, g = 3, _ = !1, b = !1, E = !1, S = !1, y = typeof setTimeout == "function" ? setTimeout : null, A = typeof clearTimeout == "function" ? clearTimeout : null, w = typeof setImmediate < "u" ? setImmediate : null;
    function M(D) {
      for (var V = e(h); V !== null; ) {
        if (V.callback === null) r(h);
        else if (V.startTime <= D)
          r(h), V.sortIndex = V.expirationTime, t(d, V);
        else break;
        V = e(h);
      }
    }
    function O(D) {
      if (E = !1, M(D), !b)
        if (e(d) !== null)
          b = !0, L || (L = !0, B());
        else {
          var V = e(h);
          V !== null && X(O, V.startTime - D);
        }
    }
    var L = !1, N = -1, z = 5, R = -1;
    function T() {
      return S ? !0 : !(n.unstable_now() - R < z);
    }
    function U() {
      if (S = !1, L) {
        var D = n.unstable_now();
        R = D;
        var V = !0;
        try {
          t: {
            b = !1, E && (E = !1, A(N), N = -1), _ = !0;
            var H = g;
            try {
              e: {
                for (M(D), m = e(d); m !== null && !(m.expirationTime > D && T()); ) {
                  var j = m.callback;
                  if (typeof j == "function") {
                    m.callback = null, g = m.priorityLevel;
                    var K = j(
                      m.expirationTime <= D
                    );
                    if (D = n.unstable_now(), typeof K == "function") {
                      m.callback = K, M(D), V = !0;
                      break e;
                    }
                    m === e(d) && r(d), M(D);
                  } else r(d);
                  m = e(d);
                }
                if (m !== null) V = !0;
                else {
                  var F = e(h);
                  F !== null && X(
                    O,
                    F.startTime - D
                  ), V = !1;
                }
              }
              break t;
            } finally {
              m = null, g = H, _ = !1;
            }
            V = void 0;
          }
        } finally {
          V ? B() : L = !1;
        }
      }
    }
    var B;
    if (typeof w == "function")
      B = function() {
        w(U);
      };
    else if (typeof MessageChannel < "u") {
      var I = new MessageChannel(), C = I.port2;
      I.port1.onmessage = U, B = function() {
        C.postMessage(null);
      };
    } else
      B = function() {
        y(U, 0);
      };
    function X(D, V) {
      N = y(function() {
        D(n.unstable_now());
      }, V);
    }
    n.unstable_IdlePriority = 5, n.unstable_ImmediatePriority = 1, n.unstable_LowPriority = 4, n.unstable_NormalPriority = 3, n.unstable_Profiling = null, n.unstable_UserBlockingPriority = 2, n.unstable_cancelCallback = function(D) {
      D.callback = null;
    }, n.unstable_forceFrameRate = function(D) {
      0 > D || 125 < D ? console.error(
        "forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"
      ) : z = 0 < D ? Math.floor(1e3 / D) : 5;
    }, n.unstable_getCurrentPriorityLevel = function() {
      return g;
    }, n.unstable_next = function(D) {
      switch (g) {
        case 1:
        case 2:
        case 3:
          var V = 3;
          break;
        default:
          V = g;
      }
      var H = g;
      g = V;
      try {
        return D();
      } finally {
        g = H;
      }
    }, n.unstable_requestPaint = function() {
      S = !0;
    }, n.unstable_runWithPriority = function(D, V) {
      switch (D) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
          break;
        default:
          D = 3;
      }
      var H = g;
      g = D;
      try {
        return V();
      } finally {
        g = H;
      }
    }, n.unstable_scheduleCallback = function(D, V, H) {
      var j = n.unstable_now();
      switch (typeof H == "object" && H !== null ? (H = H.delay, H = typeof H == "number" && 0 < H ? j + H : j) : H = j, D) {
        case 1:
          var K = -1;
          break;
        case 2:
          K = 250;
          break;
        case 5:
          K = 1073741823;
          break;
        case 4:
          K = 1e4;
          break;
        default:
          K = 5e3;
      }
      return K = H + K, D = {
        id: p++,
        callback: V,
        priorityLevel: D,
        startTime: H,
        expirationTime: K,
        sortIndex: -1
      }, H > j ? (D.sortIndex = H, t(h, D), e(d) === null && D === e(h) && (E ? (A(N), N = -1) : E = !0, X(O, H - j))) : (D.sortIndex = K, t(d, D), b || _ || (b = !0, L || (L = !0, B()))), D;
    }, n.unstable_shouldYield = T, n.unstable_wrapCallback = function(D) {
      var V = g;
      return function() {
        var H = g;
        g = V;
        try {
          return D.apply(this, arguments);
        } finally {
          g = H;
        }
      };
    };
  })(tm)), tm;
}
var Fx;
function t2() {
  return Fx || (Fx = 1, Jp.exports = JA()), Jp.exports;
}
var em = { exports: {} }, $n = {};
/**
 * @license React
 * react-dom.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var Hx;
function e2() {
  if (Hx) return $n;
  Hx = 1;
  var n = Gc();
  function t(d) {
    var h = "https://react.dev/errors/" + d;
    if (1 < arguments.length) {
      h += "?args[]=" + encodeURIComponent(arguments[1]);
      for (var p = 2; p < arguments.length; p++)
        h += "&args[]=" + encodeURIComponent(arguments[p]);
    }
    return "Minified React error #" + d + "; visit " + h + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  function e() {
  }
  var r = {
    d: {
      f: e,
      r: function() {
        throw Error(t(522));
      },
      D: e,
      C: e,
      L: e,
      m: e,
      X: e,
      S: e,
      M: e
    },
    p: 0,
    findDOMNode: null
  }, a = Symbol.for("react.portal");
  function o(d, h, p) {
    var m = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
    return {
      $$typeof: a,
      key: m == null ? null : "" + m,
      children: d,
      containerInfo: h,
      implementation: p
    };
  }
  var c = n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
  function u(d, h) {
    if (d === "font") return "";
    if (typeof h == "string")
      return h === "use-credentials" ? h : "";
  }
  return $n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = r, $n.createPortal = function(d, h) {
    var p = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null;
    if (!h || h.nodeType !== 1 && h.nodeType !== 9 && h.nodeType !== 11)
      throw Error(t(299));
    return o(d, h, null, p);
  }, $n.flushSync = function(d) {
    var h = c.T, p = r.p;
    try {
      if (c.T = null, r.p = 2, d) return d();
    } finally {
      c.T = h, r.p = p, r.d.f();
    }
  }, $n.preconnect = function(d, h) {
    typeof d == "string" && (h ? (h = h.crossOrigin, h = typeof h == "string" ? h === "use-credentials" ? h : "" : void 0) : h = null, r.d.C(d, h));
  }, $n.prefetchDNS = function(d) {
    typeof d == "string" && r.d.D(d);
  }, $n.preinit = function(d, h) {
    if (typeof d == "string" && h && typeof h.as == "string") {
      var p = h.as, m = u(p, h.crossOrigin), g = typeof h.integrity == "string" ? h.integrity : void 0, _ = typeof h.fetchPriority == "string" ? h.fetchPriority : void 0;
      p === "style" ? r.d.S(
        d,
        typeof h.precedence == "string" ? h.precedence : void 0,
        {
          crossOrigin: m,
          integrity: g,
          fetchPriority: _
        }
      ) : p === "script" && r.d.X(d, {
        crossOrigin: m,
        integrity: g,
        fetchPriority: _,
        nonce: typeof h.nonce == "string" ? h.nonce : void 0
      });
    }
  }, $n.preinitModule = function(d, h) {
    if (typeof d == "string")
      if (typeof h == "object" && h !== null) {
        if (h.as == null || h.as === "script") {
          var p = u(
            h.as,
            h.crossOrigin
          );
          r.d.M(d, {
            crossOrigin: p,
            integrity: typeof h.integrity == "string" ? h.integrity : void 0,
            nonce: typeof h.nonce == "string" ? h.nonce : void 0
          });
        }
      } else h == null && r.d.M(d);
  }, $n.preload = function(d, h) {
    if (typeof d == "string" && typeof h == "object" && h !== null && typeof h.as == "string") {
      var p = h.as, m = u(p, h.crossOrigin);
      r.d.L(d, p, {
        crossOrigin: m,
        integrity: typeof h.integrity == "string" ? h.integrity : void 0,
        nonce: typeof h.nonce == "string" ? h.nonce : void 0,
        type: typeof h.type == "string" ? h.type : void 0,
        fetchPriority: typeof h.fetchPriority == "string" ? h.fetchPriority : void 0,
        referrerPolicy: typeof h.referrerPolicy == "string" ? h.referrerPolicy : void 0,
        imageSrcSet: typeof h.imageSrcSet == "string" ? h.imageSrcSet : void 0,
        imageSizes: typeof h.imageSizes == "string" ? h.imageSizes : void 0,
        media: typeof h.media == "string" ? h.media : void 0
      });
    }
  }, $n.preloadModule = function(d, h) {
    if (typeof d == "string")
      if (h) {
        var p = u(h.as, h.crossOrigin);
        r.d.m(d, {
          as: typeof h.as == "string" && h.as !== "script" ? h.as : void 0,
          crossOrigin: p,
          integrity: typeof h.integrity == "string" ? h.integrity : void 0
        });
      } else r.d.m(d);
  }, $n.requestFormReset = function(d) {
    r.d.r(d);
  }, $n.unstable_batchedUpdates = function(d, h) {
    return d(h);
  }, $n.useFormState = function(d, h, p) {
    return c.H.useFormState(d, h, p);
  }, $n.useFormStatus = function() {
    return c.H.useHostTransitionStatus();
  }, $n.version = "19.2.4", $n;
}
var Vx;
function eM() {
  if (Vx) return em.exports;
  Vx = 1;
  function n() {
    if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ > "u" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function"))
      try {
        __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n);
      } catch (t) {
        console.error(t);
      }
  }
  return n(), em.exports = e2(), em.exports;
}
/**
 * @license React
 * react-dom-client.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var kx;
function n2() {
  if (kx) return rc;
  kx = 1;
  var n = t2(), t = Gc(), e = eM();
  function r(i) {
    var s = "https://react.dev/errors/" + i;
    if (1 < arguments.length) {
      s += "?args[]=" + encodeURIComponent(arguments[1]);
      for (var l = 2; l < arguments.length; l++)
        s += "&args[]=" + encodeURIComponent(arguments[l]);
    }
    return "Minified React error #" + i + "; visit " + s + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  function a(i) {
    return !(!i || i.nodeType !== 1 && i.nodeType !== 9 && i.nodeType !== 11);
  }
  function o(i) {
    var s = i, l = i;
    if (i.alternate) for (; s.return; ) s = s.return;
    else {
      i = s;
      do
        s = i, (s.flags & 4098) !== 0 && (l = s.return), i = s.return;
      while (i);
    }
    return s.tag === 3 ? l : null;
  }
  function c(i) {
    if (i.tag === 13) {
      var s = i.memoizedState;
      if (s === null && (i = i.alternate, i !== null && (s = i.memoizedState)), s !== null) return s.dehydrated;
    }
    return null;
  }
  function u(i) {
    if (i.tag === 31) {
      var s = i.memoizedState;
      if (s === null && (i = i.alternate, i !== null && (s = i.memoizedState)), s !== null) return s.dehydrated;
    }
    return null;
  }
  function d(i) {
    if (o(i) !== i)
      throw Error(r(188));
  }
  function h(i) {
    var s = i.alternate;
    if (!s) {
      if (s = o(i), s === null) throw Error(r(188));
      return s !== i ? null : i;
    }
    for (var l = i, f = s; ; ) {
      var v = l.return;
      if (v === null) break;
      var x = v.alternate;
      if (x === null) {
        if (f = v.return, f !== null) {
          l = f;
          continue;
        }
        break;
      }
      if (v.child === x.child) {
        for (x = v.child; x; ) {
          if (x === l) return d(v), i;
          if (x === f) return d(v), s;
          x = x.sibling;
        }
        throw Error(r(188));
      }
      if (l.return !== f.return) l = v, f = x;
      else {
        for (var P = !1, Y = v.child; Y; ) {
          if (Y === l) {
            P = !0, l = v, f = x;
            break;
          }
          if (Y === f) {
            P = !0, f = v, l = x;
            break;
          }
          Y = Y.sibling;
        }
        if (!P) {
          for (Y = x.child; Y; ) {
            if (Y === l) {
              P = !0, l = x, f = v;
              break;
            }
            if (Y === f) {
              P = !0, f = x, l = v;
              break;
            }
            Y = Y.sibling;
          }
          if (!P) throw Error(r(189));
        }
      }
      if (l.alternate !== f) throw Error(r(190));
    }
    if (l.tag !== 3) throw Error(r(188));
    return l.stateNode.current === l ? i : s;
  }
  function p(i) {
    var s = i.tag;
    if (s === 5 || s === 26 || s === 27 || s === 6) return i;
    for (i = i.child; i !== null; ) {
      if (s = p(i), s !== null) return s;
      i = i.sibling;
    }
    return null;
  }
  var m = Object.assign, g = Symbol.for("react.element"), _ = Symbol.for("react.transitional.element"), b = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), w = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), L = Symbol.for("react.suspense_list"), N = Symbol.for("react.memo"), z = Symbol.for("react.lazy"), R = Symbol.for("react.activity"), T = Symbol.for("react.memo_cache_sentinel"), U = Symbol.iterator;
  function B(i) {
    return i === null || typeof i != "object" ? null : (i = U && i[U] || i["@@iterator"], typeof i == "function" ? i : null);
  }
  var I = Symbol.for("react.client.reference");
  function C(i) {
    if (i == null) return null;
    if (typeof i == "function")
      return i.$$typeof === I ? null : i.displayName || i.name || null;
    if (typeof i == "string") return i;
    switch (i) {
      case E:
        return "Fragment";
      case y:
        return "Profiler";
      case S:
        return "StrictMode";
      case O:
        return "Suspense";
      case L:
        return "SuspenseList";
      case R:
        return "Activity";
    }
    if (typeof i == "object")
      switch (i.$$typeof) {
        case b:
          return "Portal";
        case w:
          return i.displayName || "Context";
        case A:
          return (i._context.displayName || "Context") + ".Consumer";
        case M:
          var s = i.render;
          return i = i.displayName, i || (i = s.displayName || s.name || "", i = i !== "" ? "ForwardRef(" + i + ")" : "ForwardRef"), i;
        case N:
          return s = i.displayName || null, s !== null ? s : C(i.type) || "Memo";
        case z:
          s = i._payload, i = i._init;
          try {
            return C(i(s));
          } catch {
          }
      }
    return null;
  }
  var X = Array.isArray, D = t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, V = e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, H = {
    pending: !1,
    data: null,
    method: null,
    action: null
  }, j = [], K = -1;
  function F(i) {
    return { current: i };
  }
  function q(i) {
    0 > K || (i.current = j[K], j[K] = null, K--);
  }
  function it(i, s) {
    K++, j[K] = i.current, i.current = s;
  }
  var G = F(null), k = F(null), $ = F(null), Q = F(null);
  function et(i, s) {
    switch (it($, s), it(k, i), it(G, null), s.nodeType) {
      case 9:
      case 11:
        i = (i = s.documentElement) && (i = i.namespaceURI) ? sx(i) : 0;
        break;
      default:
        if (i = s.tagName, s = s.namespaceURI)
          s = sx(s), i = ax(s, i);
        else
          switch (i) {
            case "svg":
              i = 1;
              break;
            case "math":
              i = 2;
              break;
            default:
              i = 0;
          }
    }
    q(G), it(G, i);
  }
  function st() {
    q(G), q(k), q($);
  }
  function _t(i) {
    i.memoizedState !== null && it(Q, i);
    var s = G.current, l = ax(s, i.type);
    s !== l && (it(k, i), it(G, l));
  }
  function Mt(i) {
    k.current === i && (q(G), q(k)), Q.current === i && (q(Q), tc._currentValue = H);
  }
  var Rt, Ot;
  function nt(i) {
    if (Rt === void 0)
      try {
        throw Error();
      } catch (l) {
        var s = l.stack.trim().match(/\n( *(at )?)/);
        Rt = s && s[1] || "", Ot = -1 < l.stack.indexOf(`
    at`) ? " (<anonymous>)" : -1 < l.stack.indexOf("@") ? "@unknown:0:0" : "";
      }
    return `
` + Rt + i + Ot;
  }
  var Jt = !1;
  function Ft(i, s) {
    if (!i || Jt) return "";
    Jt = !0;
    var l = Error.prepareStackTrace;
    Error.prepareStackTrace = void 0;
    try {
      var f = {
        DetermineComponentFrameRoot: function() {
          try {
            if (s) {
              var At = function() {
                throw Error();
              };
              if (Object.defineProperty(At.prototype, "props", {
                set: function() {
                  throw Error();
                }
              }), typeof Reflect == "object" && Reflect.construct) {
                try {
                  Reflect.construct(At, []);
                } catch (xt) {
                  var vt = xt;
                }
                Reflect.construct(i, [], At);
              } else {
                try {
                  At.call();
                } catch (xt) {
                  vt = xt;
                }
                i.call(At.prototype);
              }
            } else {
              try {
                throw Error();
              } catch (xt) {
                vt = xt;
              }
              (At = i()) && typeof At.catch == "function" && At.catch(function() {
              });
            }
          } catch (xt) {
            if (xt && vt && typeof xt.stack == "string")
              return [xt.stack, vt.stack];
          }
          return [null, null];
        }
      };
      f.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
      var v = Object.getOwnPropertyDescriptor(
        f.DetermineComponentFrameRoot,
        "name"
      );
      v && v.configurable && Object.defineProperty(
        f.DetermineComponentFrameRoot,
        "name",
        { value: "DetermineComponentFrameRoot" }
      );
      var x = f.DetermineComponentFrameRoot(), P = x[0], Y = x[1];
      if (P && Y) {
        var rt = P.split(`
`), pt = Y.split(`
`);
        for (v = f = 0; f < rt.length && !rt[f].includes("DetermineComponentFrameRoot"); )
          f++;
        for (; v < pt.length && !pt[v].includes(
          "DetermineComponentFrameRoot"
        ); )
          v++;
        if (f === rt.length || v === pt.length)
          for (f = rt.length - 1, v = pt.length - 1; 1 <= f && 0 <= v && rt[f] !== pt[v]; )
            v--;
        for (; 1 <= f && 0 <= v; f--, v--)
          if (rt[f] !== pt[v]) {
            if (f !== 1 || v !== 1)
              do
                if (f--, v--, 0 > v || rt[f] !== pt[v]) {
                  var bt = `
` + rt[f].replace(" at new ", " at ");
                  return i.displayName && bt.includes("<anonymous>") && (bt = bt.replace("<anonymous>", i.displayName)), bt;
                }
              while (1 <= f && 0 <= v);
            break;
          }
      }
    } finally {
      Jt = !1, Error.prepareStackTrace = l;
    }
    return (l = i ? i.displayName || i.name : "") ? nt(l) : "";
  }
  function ne(i, s) {
    switch (i.tag) {
      case 26:
      case 27:
      case 5:
        return nt(i.type);
      case 16:
        return nt("Lazy");
      case 13:
        return i.child !== s && s !== null ? nt("Suspense Fallback") : nt("Suspense");
      case 19:
        return nt("SuspenseList");
      case 0:
      case 15:
        return Ft(i.type, !1);
      case 11:
        return Ft(i.type.render, !1);
      case 1:
        return Ft(i.type, !0);
      case 31:
        return nt("Activity");
      default:
        return "";
    }
  }
  function jt(i) {
    try {
      var s = "", l = null;
      do
        s += ne(i, l), l = i, i = i.return;
      while (i);
      return s;
    } catch (f) {
      return `
Error generating stack: ` + f.message + `
` + f.stack;
    }
  }
  var xe = Object.prototype.hasOwnProperty, qt = n.unstable_scheduleCallback, tt = n.unstable_cancelCallback, W = n.unstable_shouldYield, mt = n.unstable_requestPaint, Et = n.unstable_now, Dt = n.unstable_getCurrentPriorityLevel, wt = n.unstable_ImmediatePriority, Zt = n.unstable_UserBlockingPriority, Pt = n.unstable_NormalPriority, Wt = n.unstable_LowPriority, _e = n.unstable_IdlePriority, Ut = n.log, Yt = n.unstable_setDisableYieldValue, te = null, Kt = null;
  function Gt(i) {
    if (typeof Ut == "function" && Yt(i), Kt && typeof Kt.setStrictMode == "function")
      try {
        Kt.setStrictMode(te, i);
      } catch {
      }
  }
  var le = Math.clz32 ? Math.clz32 : ut, he = Math.log, Fe = Math.LN2;
  function ut(i) {
    return i >>>= 0, i === 0 ? 32 : 31 - (he(i) / Fe | 0) | 0;
  }
  var zt = 256, St = 262144, Ct = 4194304;
  function It(i) {
    var s = i & 42;
    if (s !== 0) return s;
    switch (i & -i) {
      case 1:
        return 1;
      case 2:
        return 2;
      case 4:
        return 4;
      case 8:
        return 8;
      case 16:
        return 16;
      case 32:
        return 32;
      case 64:
        return 64;
      case 128:
        return 128;
      case 256:
      case 512:
      case 1024:
      case 2048:
      case 4096:
      case 8192:
      case 16384:
      case 32768:
      case 65536:
      case 131072:
        return i & 261888;
      case 262144:
      case 524288:
      case 1048576:
      case 2097152:
        return i & 3932160;
      case 4194304:
      case 8388608:
      case 16777216:
      case 33554432:
        return i & 62914560;
      case 67108864:
        return 67108864;
      case 134217728:
        return 134217728;
      case 268435456:
        return 268435456;
      case 536870912:
        return 536870912;
      case 1073741824:
        return 0;
      default:
        return i;
    }
  }
  function Ht(i, s, l) {
    var f = i.pendingLanes;
    if (f === 0) return 0;
    var v = 0, x = i.suspendedLanes, P = i.pingedLanes;
    i = i.warmLanes;
    var Y = f & 134217727;
    return Y !== 0 ? (f = Y & ~x, f !== 0 ? v = It(f) : (P &= Y, P !== 0 ? v = It(P) : l || (l = Y & ~i, l !== 0 && (v = It(l))))) : (Y = f & ~x, Y !== 0 ? v = It(Y) : P !== 0 ? v = It(P) : l || (l = f & ~i, l !== 0 && (v = It(l)))), v === 0 ? 0 : s !== 0 && s !== v && (s & x) === 0 && (x = v & -v, l = s & -s, x >= l || x === 32 && (l & 4194048) !== 0) ? s : v;
  }
  function ue(i, s) {
    return (i.pendingLanes & ~(i.suspendedLanes & ~i.pingedLanes) & s) === 0;
  }
  function tn(i, s) {
    switch (i) {
      case 1:
      case 2:
      case 4:
      case 8:
      case 64:
        return s + 250;
      case 16:
      case 32:
      case 128:
      case 256:
      case 512:
      case 1024:
      case 2048:
      case 4096:
      case 8192:
      case 16384:
      case 32768:
      case 65536:
      case 131072:
      case 262144:
      case 524288:
      case 1048576:
      case 2097152:
        return s + 5e3;
      case 4194304:
      case 8388608:
      case 16777216:
      case 33554432:
        return -1;
      case 67108864:
      case 134217728:
      case 268435456:
      case 536870912:
      case 1073741824:
        return -1;
      default:
        return -1;
    }
  }
  function dn() {
    var i = Ct;
    return Ct <<= 1, (Ct & 62914560) === 0 && (Ct = 4194304), i;
  }
  function De(i) {
    for (var s = [], l = 0; 31 > l; l++) s.push(i);
    return s;
  }
  function wn(i, s) {
    i.pendingLanes |= s, s !== 268435456 && (i.suspendedLanes = 0, i.pingedLanes = 0, i.warmLanes = 0);
  }
  function mi(i, s, l, f, v, x) {
    var P = i.pendingLanes;
    i.pendingLanes = l, i.suspendedLanes = 0, i.pingedLanes = 0, i.warmLanes = 0, i.expiredLanes &= l, i.entangledLanes &= l, i.errorRecoveryDisabledLanes &= l, i.shellSuspendCounter = 0;
    var Y = i.entanglements, rt = i.expirationTimes, pt = i.hiddenUpdates;
    for (l = P & ~l; 0 < l; ) {
      var bt = 31 - le(l), At = 1 << bt;
      Y[bt] = 0, rt[bt] = -1;
      var vt = pt[bt];
      if (vt !== null)
        for (pt[bt] = null, bt = 0; bt < vt.length; bt++) {
          var xt = vt[bt];
          xt !== null && (xt.lane &= -536870913);
        }
      l &= ~At;
    }
    f !== 0 && Ys(i, f, 0), x !== 0 && v === 0 && i.tag !== 0 && (i.suspendedLanes |= x & ~(P & ~s));
  }
  function Ys(i, s, l) {
    i.pendingLanes |= s, i.suspendedLanes &= ~s;
    var f = 31 - le(s);
    i.entangledLanes |= s, i.entanglements[f] = i.entanglements[f] | 1073741824 | l & 261930;
  }
  function qs(i, s) {
    var l = i.entangledLanes |= s;
    for (i = i.entanglements; l; ) {
      var f = 31 - le(l), v = 1 << f;
      v & s | i[f] & s && (i[f] |= s), l &= ~v;
    }
  }
  function Di(i, s) {
    var l = s & -s;
    return l = (l & 42) !== 0 ? 1 : Sr(l), (l & (i.suspendedLanes | s)) !== 0 ? 0 : l;
  }
  function Sr(i) {
    switch (i) {
      case 2:
        i = 1;
        break;
      case 8:
        i = 4;
        break;
      case 32:
        i = 16;
        break;
      case 256:
      case 512:
      case 1024:
      case 2048:
      case 4096:
      case 8192:
      case 16384:
      case 32768:
      case 65536:
      case 131072:
      case 262144:
      case 524288:
      case 1048576:
      case 2097152:
      case 4194304:
      case 8388608:
      case 16777216:
      case 33554432:
        i = 128;
        break;
      case 268435456:
        i = 134217728;
        break;
      default:
        i = 0;
    }
    return i;
  }
  function rs(i) {
    return i &= -i, 2 < i ? 8 < i ? (i & 134217727) !== 0 ? 32 : 268435456 : 8 : 2;
  }
  function Zs() {
    var i = V.p;
    return i !== 0 ? i : (i = window.event, i === void 0 ? 32 : Rx(i.type));
  }
  function br(i, s) {
    var l = V.p;
    try {
      return V.p = i, s();
    } finally {
      V.p = l;
    }
  }
  var gi = Math.random().toString(36).slice(2), sn = "__reactFiber$" + gi, Tn = "__reactProps$" + gi, Ni = "__reactContainer$" + gi, ss = "__reactEvents$" + gi, Fa = "__reactListeners$" + gi, gl = "__reactHandles$" + gi, Ha = "__reactResources$" + gi, Mr = "__reactMarker$" + gi;
  function $s(i) {
    delete i[sn], delete i[Tn], delete i[ss], delete i[Fa], delete i[gl];
  }
  function Z(i) {
    var s = i[sn];
    if (s) return s;
    for (var l = i.parentNode; l; ) {
      if (s = l[Ni] || l[sn]) {
        if (l = s.alternate, s.child !== null || l !== null && l.child !== null)
          for (i = hx(i); i !== null; ) {
            if (l = i[sn]) return l;
            i = hx(i);
          }
        return s;
      }
      i = l, l = i.parentNode;
    }
    return null;
  }
  function ft(i) {
    if (i = i[sn] || i[Ni]) {
      var s = i.tag;
      if (s === 5 || s === 6 || s === 13 || s === 31 || s === 26 || s === 27 || s === 3)
        return i;
    }
    return null;
  }
  function gt(i) {
    var s = i.tag;
    if (s === 5 || s === 26 || s === 27 || s === 6) return i.stateNode;
    throw Error(r(33));
  }
  function yt(i) {
    var s = i[Ha];
    return s || (s = i[Ha] = { hoistableStyles: /* @__PURE__ */ new Map(), hoistableScripts: /* @__PURE__ */ new Map() }), s;
  }
  function lt(i) {
    i[Mr] = !0;
  }
  var Lt = /* @__PURE__ */ new Set(), Vt = {};
  function kt(i, s) {
    Xt(i, s), Xt(i + "Capture", s);
  }
  function Xt(i, s) {
    for (Vt[i] = s, i = 0; i < s.length; i++)
      Lt.add(s[i]);
  }
  var fe = RegExp(
    "^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"
  ), ce = {}, ee = {};
  function Ee(i) {
    return xe.call(ee, i) ? !0 : xe.call(ce, i) ? !1 : fe.test(i) ? ee[i] = !0 : (ce[i] = !0, !1);
  }
  function we(i, s, l) {
    if (Ee(s))
      if (l === null) i.removeAttribute(s);
      else {
        switch (typeof l) {
          case "undefined":
          case "function":
          case "symbol":
            i.removeAttribute(s);
            return;
          case "boolean":
            var f = s.toLowerCase().slice(0, 5);
            if (f !== "data-" && f !== "aria-") {
              i.removeAttribute(s);
              return;
            }
        }
        i.setAttribute(s, "" + l);
      }
  }
  function Qe(i, s, l) {
    if (l === null) i.removeAttribute(s);
    else {
      switch (typeof l) {
        case "undefined":
        case "function":
        case "symbol":
        case "boolean":
          i.removeAttribute(s);
          return;
      }
      i.setAttribute(s, "" + l);
    }
  }
  function Le(i, s, l, f) {
    if (f === null) i.removeAttribute(l);
    else {
      switch (typeof f) {
        case "undefined":
        case "function":
        case "symbol":
        case "boolean":
          i.removeAttribute(l);
          return;
      }
      i.setAttributeNS(s, l, "" + f);
    }
  }
  function de(i) {
    switch (typeof i) {
      case "bigint":
      case "boolean":
      case "number":
      case "string":
      case "undefined":
        return i;
      case "object":
        return i;
      default:
        return "";
    }
  }
  function ie(i) {
    var s = i.type;
    return (i = i.nodeName) && i.toLowerCase() === "input" && (s === "checkbox" || s === "radio");
  }
  function hn(i, s, l) {
    var f = Object.getOwnPropertyDescriptor(
      i.constructor.prototype,
      s
    );
    if (!i.hasOwnProperty(s) && typeof f < "u" && typeof f.get == "function" && typeof f.set == "function") {
      var v = f.get, x = f.set;
      return Object.defineProperty(i, s, {
        configurable: !0,
        get: function() {
          return v.call(this);
        },
        set: function(P) {
          l = "" + P, x.call(this, P);
        }
      }), Object.defineProperty(i, s, {
        enumerable: f.enumerable
      }), {
        getValue: function() {
          return l;
        },
        setValue: function(P) {
          l = "" + P;
        },
        stopTracking: function() {
          i._valueTracker = null, delete i[s];
        }
      };
    }
  }
  function Se(i) {
    if (!i._valueTracker) {
      var s = ie(i) ? "checked" : "value";
      i._valueTracker = hn(
        i,
        s,
        "" + i[s]
      );
    }
  }
  function Zn(i) {
    if (!i) return !1;
    var s = i._valueTracker;
    if (!s) return !0;
    var l = s.getValue(), f = "";
    return i && (f = ie(i) ? i.checked ? "true" : "false" : i.value), i = f, i !== l ? (s.setValue(i), !0) : !1;
  }
  function ii(i) {
    if (i = i || (typeof document < "u" ? document : void 0), typeof i > "u") return null;
    try {
      return i.activeElement || i.body;
    } catch {
      return i.body;
    }
  }
  var In = /[\n"\\]/g;
  function gn(i) {
    return i.replace(
      In,
      function(s) {
        return "\\" + s.charCodeAt(0).toString(16) + " ";
      }
    );
  }
  function Oe(i, s, l, f, v, x, P, Y) {
    i.name = "", P != null && typeof P != "function" && typeof P != "symbol" && typeof P != "boolean" ? i.type = P : i.removeAttribute("type"), s != null ? P === "number" ? (s === 0 && i.value === "" || i.value != s) && (i.value = "" + de(s)) : i.value !== "" + de(s) && (i.value = "" + de(s)) : P !== "submit" && P !== "reset" || i.removeAttribute("value"), s != null ? On(i, P, de(s)) : l != null ? On(i, P, de(l)) : f != null && i.removeAttribute("value"), v == null && x != null && (i.defaultChecked = !!x), v != null && (i.checked = v && typeof v != "function" && typeof v != "symbol"), Y != null && typeof Y != "function" && typeof Y != "symbol" && typeof Y != "boolean" ? i.name = "" + de(Y) : i.removeAttribute("name");
  }
  function Bn(i, s, l, f, v, x, P, Y) {
    if (x != null && typeof x != "function" && typeof x != "symbol" && typeof x != "boolean" && (i.type = x), s != null || l != null) {
      if (!(x !== "submit" && x !== "reset" || s != null)) {
        Se(i);
        return;
      }
      l = l != null ? "" + de(l) : "", s = s != null ? "" + de(s) : l, Y || s === i.value || (i.value = s), i.defaultValue = s;
    }
    f = f ?? v, f = typeof f != "function" && typeof f != "symbol" && !!f, i.checked = Y ? i.checked : !!f, i.defaultChecked = !!f, P != null && typeof P != "function" && typeof P != "symbol" && typeof P != "boolean" && (i.name = P), Se(i);
  }
  function On(i, s, l) {
    s === "number" && ii(i.ownerDocument) === i || i.defaultValue === "" + l || (i.defaultValue = "" + l);
  }
  function en(i, s, l, f) {
    if (i = i.options, s) {
      s = {};
      for (var v = 0; v < l.length; v++)
        s["$" + l[v]] = !0;
      for (l = 0; l < i.length; l++)
        v = s.hasOwnProperty("$" + i[l].value), i[l].selected !== v && (i[l].selected = v), v && f && (i[l].defaultSelected = !0);
    } else {
      for (l = "" + de(l), s = null, v = 0; v < i.length; v++) {
        if (i[v].value === l) {
          i[v].selected = !0, f && (i[v].defaultSelected = !0);
          return;
        }
        s !== null || i[v].disabled || (s = i[v]);
      }
      s !== null && (s.selected = !0);
    }
  }
  function Fn(i, s, l) {
    if (s != null && (s = "" + de(s), s !== i.value && (i.value = s), l == null)) {
      i.defaultValue !== s && (i.defaultValue = s);
      return;
    }
    i.defaultValue = l != null ? "" + de(l) : "";
  }
  function Va(i, s, l, f) {
    if (s == null) {
      if (f != null) {
        if (l != null) throw Error(r(92));
        if (X(f)) {
          if (1 < f.length) throw Error(r(93));
          f = f[0];
        }
        l = f;
      }
      l == null && (l = ""), s = l;
    }
    l = de(s), i.defaultValue = l, f = i.textContent, f === l && f !== "" && f !== null && (i.value = f), Se(i);
  }
  function ri(i, s) {
    if (s) {
      var l = i.firstChild;
      if (l && l === i.lastChild && l.nodeType === 3) {
        l.nodeValue = s;
        return;
      }
    }
    i.textContent = s;
  }
  var jw = new Set(
    "animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(
      " "
    )
  );
  function nv(i, s, l) {
    var f = s.indexOf("--") === 0;
    l == null || typeof l == "boolean" || l === "" ? f ? i.setProperty(s, "") : s === "float" ? i.cssFloat = "" : i[s] = "" : f ? i.setProperty(s, l) : typeof l != "number" || l === 0 || jw.has(s) ? s === "float" ? i.cssFloat = l : i[s] = ("" + l).trim() : i[s] = l + "px";
  }
  function iv(i, s, l) {
    if (s != null && typeof s != "object")
      throw Error(r(62));
    if (i = i.style, l != null) {
      for (var f in l)
        !l.hasOwnProperty(f) || s != null && s.hasOwnProperty(f) || (f.indexOf("--") === 0 ? i.setProperty(f, "") : f === "float" ? i.cssFloat = "" : i[f] = "");
      for (var v in s)
        f = s[v], s.hasOwnProperty(v) && l[v] !== f && nv(i, v, f);
    } else
      for (var x in s)
        s.hasOwnProperty(x) && nv(i, x, s[x]);
  }
  function Yd(i) {
    if (i.indexOf("-") === -1) return !1;
    switch (i) {
      case "annotation-xml":
      case "color-profile":
      case "font-face":
      case "font-face-src":
      case "font-face-uri":
      case "font-face-format":
      case "font-face-name":
      case "missing-glyph":
        return !1;
      default:
        return !0;
    }
  }
  var Ww = /* @__PURE__ */ new Map([
    ["acceptCharset", "accept-charset"],
    ["htmlFor", "for"],
    ["httpEquiv", "http-equiv"],
    ["crossOrigin", "crossorigin"],
    ["accentHeight", "accent-height"],
    ["alignmentBaseline", "alignment-baseline"],
    ["arabicForm", "arabic-form"],
    ["baselineShift", "baseline-shift"],
    ["capHeight", "cap-height"],
    ["clipPath", "clip-path"],
    ["clipRule", "clip-rule"],
    ["colorInterpolation", "color-interpolation"],
    ["colorInterpolationFilters", "color-interpolation-filters"],
    ["colorProfile", "color-profile"],
    ["colorRendering", "color-rendering"],
    ["dominantBaseline", "dominant-baseline"],
    ["enableBackground", "enable-background"],
    ["fillOpacity", "fill-opacity"],
    ["fillRule", "fill-rule"],
    ["floodColor", "flood-color"],
    ["floodOpacity", "flood-opacity"],
    ["fontFamily", "font-family"],
    ["fontSize", "font-size"],
    ["fontSizeAdjust", "font-size-adjust"],
    ["fontStretch", "font-stretch"],
    ["fontStyle", "font-style"],
    ["fontVariant", "font-variant"],
    ["fontWeight", "font-weight"],
    ["glyphName", "glyph-name"],
    ["glyphOrientationHorizontal", "glyph-orientation-horizontal"],
    ["glyphOrientationVertical", "glyph-orientation-vertical"],
    ["horizAdvX", "horiz-adv-x"],
    ["horizOriginX", "horiz-origin-x"],
    ["imageRendering", "image-rendering"],
    ["letterSpacing", "letter-spacing"],
    ["lightingColor", "lighting-color"],
    ["markerEnd", "marker-end"],
    ["markerMid", "marker-mid"],
    ["markerStart", "marker-start"],
    ["overlinePosition", "overline-position"],
    ["overlineThickness", "overline-thickness"],
    ["paintOrder", "paint-order"],
    ["panose-1", "panose-1"],
    ["pointerEvents", "pointer-events"],
    ["renderingIntent", "rendering-intent"],
    ["shapeRendering", "shape-rendering"],
    ["stopColor", "stop-color"],
    ["stopOpacity", "stop-opacity"],
    ["strikethroughPosition", "strikethrough-position"],
    ["strikethroughThickness", "strikethrough-thickness"],
    ["strokeDasharray", "stroke-dasharray"],
    ["strokeDashoffset", "stroke-dashoffset"],
    ["strokeLinecap", "stroke-linecap"],
    ["strokeLinejoin", "stroke-linejoin"],
    ["strokeMiterlimit", "stroke-miterlimit"],
    ["strokeOpacity", "stroke-opacity"],
    ["strokeWidth", "stroke-width"],
    ["textAnchor", "text-anchor"],
    ["textDecoration", "text-decoration"],
    ["textRendering", "text-rendering"],
    ["transformOrigin", "transform-origin"],
    ["underlinePosition", "underline-position"],
    ["underlineThickness", "underline-thickness"],
    ["unicodeBidi", "unicode-bidi"],
    ["unicodeRange", "unicode-range"],
    ["unitsPerEm", "units-per-em"],
    ["vAlphabetic", "v-alphabetic"],
    ["vHanging", "v-hanging"],
    ["vIdeographic", "v-ideographic"],
    ["vMathematical", "v-mathematical"],
    ["vectorEffect", "vector-effect"],
    ["vertAdvY", "vert-adv-y"],
    ["vertOriginX", "vert-origin-x"],
    ["vertOriginY", "vert-origin-y"],
    ["wordSpacing", "word-spacing"],
    ["writingMode", "writing-mode"],
    ["xmlnsXlink", "xmlns:xlink"],
    ["xHeight", "x-height"]
  ]), Yw = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;
  function Jc(i) {
    return Yw.test("" + i) ? "javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')" : i;
  }
  function Er() {
  }
  var qd = null;
  function Zd(i) {
    return i = i.target || i.srcElement || window, i.correspondingUseElement && (i = i.correspondingUseElement), i.nodeType === 3 ? i.parentNode : i;
  }
  var ka = null, Ga = null;
  function rv(i) {
    var s = ft(i);
    if (s && (i = s.stateNode)) {
      var l = i[Tn] || null;
      t: switch (i = s.stateNode, s.type) {
        case "input":
          if (Oe(
            i,
            l.value,
            l.defaultValue,
            l.defaultValue,
            l.checked,
            l.defaultChecked,
            l.type,
            l.name
          ), s = l.name, l.type === "radio" && s != null) {
            for (l = i; l.parentNode; ) l = l.parentNode;
            for (l = l.querySelectorAll(
              'input[name="' + gn(
                "" + s
              ) + '"][type="radio"]'
            ), s = 0; s < l.length; s++) {
              var f = l[s];
              if (f !== i && f.form === i.form) {
                var v = f[Tn] || null;
                if (!v) throw Error(r(90));
                Oe(
                  f,
                  v.value,
                  v.defaultValue,
                  v.defaultValue,
                  v.checked,
                  v.defaultChecked,
                  v.type,
                  v.name
                );
              }
            }
            for (s = 0; s < l.length; s++)
              f = l[s], f.form === i.form && Zn(f);
          }
          break t;
        case "textarea":
          Fn(i, l.value, l.defaultValue);
          break t;
        case "select":
          s = l.value, s != null && en(i, !!l.multiple, s, !1);
      }
    }
  }
  var $d = !1;
  function sv(i, s, l) {
    if ($d) return i(s, l);
    $d = !0;
    try {
      var f = i(s);
      return f;
    } finally {
      if ($d = !1, (ka !== null || Ga !== null) && (Hu(), ka && (s = ka, i = Ga, Ga = ka = null, rv(s), i)))
        for (s = 0; s < i.length; s++) rv(i[s]);
    }
  }
  function vl(i, s) {
    var l = i.stateNode;
    if (l === null) return null;
    var f = l[Tn] || null;
    if (f === null) return null;
    l = f[s];
    t: switch (s) {
      case "onClick":
      case "onClickCapture":
      case "onDoubleClick":
      case "onDoubleClickCapture":
      case "onMouseDown":
      case "onMouseDownCapture":
      case "onMouseMove":
      case "onMouseMoveCapture":
      case "onMouseUp":
      case "onMouseUpCapture":
      case "onMouseEnter":
        (f = !f.disabled) || (i = i.type, f = !(i === "button" || i === "input" || i === "select" || i === "textarea")), i = !f;
        break t;
      default:
        i = !1;
    }
    if (i) return null;
    if (l && typeof l != "function")
      throw Error(
        r(231, s, typeof l)
      );
    return l;
  }
  var wr = !(typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u"), Kd = !1;
  if (wr)
    try {
      var _l = {};
      Object.defineProperty(_l, "passive", {
        get: function() {
          Kd = !0;
        }
      }), window.addEventListener("test", _l, _l), window.removeEventListener("test", _l, _l);
    } catch {
      Kd = !1;
    }
  var as = null, Qd = null, tu = null;
  function av() {
    if (tu) return tu;
    var i, s = Qd, l = s.length, f, v = "value" in as ? as.value : as.textContent, x = v.length;
    for (i = 0; i < l && s[i] === v[i]; i++) ;
    var P = l - i;
    for (f = 1; f <= P && s[l - f] === v[x - f]; f++) ;
    return tu = v.slice(i, 1 < f ? 1 - f : void 0);
  }
  function eu(i) {
    var s = i.keyCode;
    return "charCode" in i ? (i = i.charCode, i === 0 && s === 13 && (i = 13)) : i = s, i === 10 && (i = 13), 32 <= i || i === 13 ? i : 0;
  }
  function nu() {
    return !0;
  }
  function ov() {
    return !1;
  }
  function si(i) {
    function s(l, f, v, x, P) {
      this._reactName = l, this._targetInst = v, this.type = f, this.nativeEvent = x, this.target = P, this.currentTarget = null;
      for (var Y in i)
        i.hasOwnProperty(Y) && (l = i[Y], this[Y] = l ? l(x) : x[Y]);
      return this.isDefaultPrevented = (x.defaultPrevented != null ? x.defaultPrevented : x.returnValue === !1) ? nu : ov, this.isPropagationStopped = ov, this;
    }
    return m(s.prototype, {
      preventDefault: function() {
        this.defaultPrevented = !0;
        var l = this.nativeEvent;
        l && (l.preventDefault ? l.preventDefault() : typeof l.returnValue != "unknown" && (l.returnValue = !1), this.isDefaultPrevented = nu);
      },
      stopPropagation: function() {
        var l = this.nativeEvent;
        l && (l.stopPropagation ? l.stopPropagation() : typeof l.cancelBubble != "unknown" && (l.cancelBubble = !0), this.isPropagationStopped = nu);
      },
      persist: function() {
      },
      isPersistent: nu
    }), s;
  }
  var Ks = {
    eventPhase: 0,
    bubbles: 0,
    cancelable: 0,
    timeStamp: function(i) {
      return i.timeStamp || Date.now();
    },
    defaultPrevented: 0,
    isTrusted: 0
  }, iu = si(Ks), yl = m({}, Ks, { view: 0, detail: 0 }), qw = si(yl), Jd, th, xl, ru = m({}, yl, {
    screenX: 0,
    screenY: 0,
    clientX: 0,
    clientY: 0,
    pageX: 0,
    pageY: 0,
    ctrlKey: 0,
    shiftKey: 0,
    altKey: 0,
    metaKey: 0,
    getModifierState: nh,
    button: 0,
    buttons: 0,
    relatedTarget: function(i) {
      return i.relatedTarget === void 0 ? i.fromElement === i.srcElement ? i.toElement : i.fromElement : i.relatedTarget;
    },
    movementX: function(i) {
      return "movementX" in i ? i.movementX : (i !== xl && (xl && i.type === "mousemove" ? (Jd = i.screenX - xl.screenX, th = i.screenY - xl.screenY) : th = Jd = 0, xl = i), Jd);
    },
    movementY: function(i) {
      return "movementY" in i ? i.movementY : th;
    }
  }), lv = si(ru), Zw = m({}, ru, { dataTransfer: 0 }), $w = si(Zw), Kw = m({}, yl, { relatedTarget: 0 }), eh = si(Kw), Qw = m({}, Ks, {
    animationName: 0,
    elapsedTime: 0,
    pseudoElement: 0
  }), Jw = si(Qw), tT = m({}, Ks, {
    clipboardData: function(i) {
      return "clipboardData" in i ? i.clipboardData : window.clipboardData;
    }
  }), eT = si(tT), nT = m({}, Ks, { data: 0 }), cv = si(nT), iT = {
    Esc: "Escape",
    Spacebar: " ",
    Left: "ArrowLeft",
    Up: "ArrowUp",
    Right: "ArrowRight",
    Down: "ArrowDown",
    Del: "Delete",
    Win: "OS",
    Menu: "ContextMenu",
    Apps: "ContextMenu",
    Scroll: "ScrollLock",
    MozPrintableKey: "Unidentified"
  }, rT = {
    8: "Backspace",
    9: "Tab",
    12: "Clear",
    13: "Enter",
    16: "Shift",
    17: "Control",
    18: "Alt",
    19: "Pause",
    20: "CapsLock",
    27: "Escape",
    32: " ",
    33: "PageUp",
    34: "PageDown",
    35: "End",
    36: "Home",
    37: "ArrowLeft",
    38: "ArrowUp",
    39: "ArrowRight",
    40: "ArrowDown",
    45: "Insert",
    46: "Delete",
    112: "F1",
    113: "F2",
    114: "F3",
    115: "F4",
    116: "F5",
    117: "F6",
    118: "F7",
    119: "F8",
    120: "F9",
    121: "F10",
    122: "F11",
    123: "F12",
    144: "NumLock",
    145: "ScrollLock",
    224: "Meta"
  }, sT = {
    Alt: "altKey",
    Control: "ctrlKey",
    Meta: "metaKey",
    Shift: "shiftKey"
  };
  function aT(i) {
    var s = this.nativeEvent;
    return s.getModifierState ? s.getModifierState(i) : (i = sT[i]) ? !!s[i] : !1;
  }
  function nh() {
    return aT;
  }
  var oT = m({}, yl, {
    key: function(i) {
      if (i.key) {
        var s = iT[i.key] || i.key;
        if (s !== "Unidentified") return s;
      }
      return i.type === "keypress" ? (i = eu(i), i === 13 ? "Enter" : String.fromCharCode(i)) : i.type === "keydown" || i.type === "keyup" ? rT[i.keyCode] || "Unidentified" : "";
    },
    code: 0,
    location: 0,
    ctrlKey: 0,
    shiftKey: 0,
    altKey: 0,
    metaKey: 0,
    repeat: 0,
    locale: 0,
    getModifierState: nh,
    charCode: function(i) {
      return i.type === "keypress" ? eu(i) : 0;
    },
    keyCode: function(i) {
      return i.type === "keydown" || i.type === "keyup" ? i.keyCode : 0;
    },
    which: function(i) {
      return i.type === "keypress" ? eu(i) : i.type === "keydown" || i.type === "keyup" ? i.keyCode : 0;
    }
  }), lT = si(oT), cT = m({}, ru, {
    pointerId: 0,
    width: 0,
    height: 0,
    pressure: 0,
    tangentialPressure: 0,
    tiltX: 0,
    tiltY: 0,
    twist: 0,
    pointerType: 0,
    isPrimary: 0
  }), uv = si(cT), uT = m({}, yl, {
    touches: 0,
    targetTouches: 0,
    changedTouches: 0,
    altKey: 0,
    metaKey: 0,
    ctrlKey: 0,
    shiftKey: 0,
    getModifierState: nh
  }), fT = si(uT), dT = m({}, Ks, {
    propertyName: 0,
    elapsedTime: 0,
    pseudoElement: 0
  }), hT = si(dT), pT = m({}, ru, {
    deltaX: function(i) {
      return "deltaX" in i ? i.deltaX : "wheelDeltaX" in i ? -i.wheelDeltaX : 0;
    },
    deltaY: function(i) {
      return "deltaY" in i ? i.deltaY : "wheelDeltaY" in i ? -i.wheelDeltaY : "wheelDelta" in i ? -i.wheelDelta : 0;
    },
    deltaZ: 0,
    deltaMode: 0
  }), mT = si(pT), gT = m({}, Ks, {
    newState: 0,
    oldState: 0
  }), vT = si(gT), _T = [9, 13, 27, 32], ih = wr && "CompositionEvent" in window, Sl = null;
  wr && "documentMode" in document && (Sl = document.documentMode);
  var yT = wr && "TextEvent" in window && !Sl, fv = wr && (!ih || Sl && 8 < Sl && 11 >= Sl), dv = " ", hv = !1;
  function pv(i, s) {
    switch (i) {
      case "keyup":
        return _T.indexOf(s.keyCode) !== -1;
      case "keydown":
        return s.keyCode !== 229;
      case "keypress":
      case "mousedown":
      case "focusout":
        return !0;
      default:
        return !1;
    }
  }
  function mv(i) {
    return i = i.detail, typeof i == "object" && "data" in i ? i.data : null;
  }
  var Xa = !1;
  function xT(i, s) {
    switch (i) {
      case "compositionend":
        return mv(s);
      case "keypress":
        return s.which !== 32 ? null : (hv = !0, dv);
      case "textInput":
        return i = s.data, i === dv && hv ? null : i;
      default:
        return null;
    }
  }
  function ST(i, s) {
    if (Xa)
      return i === "compositionend" || !ih && pv(i, s) ? (i = av(), tu = Qd = as = null, Xa = !1, i) : null;
    switch (i) {
      case "paste":
        return null;
      case "keypress":
        if (!(s.ctrlKey || s.altKey || s.metaKey) || s.ctrlKey && s.altKey) {
          if (s.char && 1 < s.char.length)
            return s.char;
          if (s.which) return String.fromCharCode(s.which);
        }
        return null;
      case "compositionend":
        return fv && s.locale !== "ko" ? null : s.data;
      default:
        return null;
    }
  }
  var bT = {
    color: !0,
    date: !0,
    datetime: !0,
    "datetime-local": !0,
    email: !0,
    month: !0,
    number: !0,
    password: !0,
    range: !0,
    search: !0,
    tel: !0,
    text: !0,
    time: !0,
    url: !0,
    week: !0
  };
  function gv(i) {
    var s = i && i.nodeName && i.nodeName.toLowerCase();
    return s === "input" ? !!bT[i.type] : s === "textarea";
  }
  function vv(i, s, l, f) {
    ka ? Ga ? Ga.push(f) : Ga = [f] : ka = f, s = Yu(s, "onChange"), 0 < s.length && (l = new iu(
      "onChange",
      "change",
      null,
      l,
      f
    ), i.push({ event: l, listeners: s }));
  }
  var bl = null, Ml = null;
  function MT(i) {
    Jy(i, 0);
  }
  function su(i) {
    var s = gt(i);
    if (Zn(s)) return i;
  }
  function _v(i, s) {
    if (i === "change") return s;
  }
  var yv = !1;
  if (wr) {
    var rh;
    if (wr) {
      var sh = "oninput" in document;
      if (!sh) {
        var xv = document.createElement("div");
        xv.setAttribute("oninput", "return;"), sh = typeof xv.oninput == "function";
      }
      rh = sh;
    } else rh = !1;
    yv = rh && (!document.documentMode || 9 < document.documentMode);
  }
  function Sv() {
    bl && (bl.detachEvent("onpropertychange", bv), Ml = bl = null);
  }
  function bv(i) {
    if (i.propertyName === "value" && su(Ml)) {
      var s = [];
      vv(
        s,
        Ml,
        i,
        Zd(i)
      ), sv(MT, s);
    }
  }
  function ET(i, s, l) {
    i === "focusin" ? (Sv(), bl = s, Ml = l, bl.attachEvent("onpropertychange", bv)) : i === "focusout" && Sv();
  }
  function wT(i) {
    if (i === "selectionchange" || i === "keyup" || i === "keydown")
      return su(Ml);
  }
  function TT(i, s) {
    if (i === "click") return su(s);
  }
  function AT(i, s) {
    if (i === "input" || i === "change")
      return su(s);
  }
  function CT(i, s) {
    return i === s && (i !== 0 || 1 / i === 1 / s) || i !== i && s !== s;
  }
  var vi = typeof Object.is == "function" ? Object.is : CT;
  function El(i, s) {
    if (vi(i, s)) return !0;
    if (typeof i != "object" || i === null || typeof s != "object" || s === null)
      return !1;
    var l = Object.keys(i), f = Object.keys(s);
    if (l.length !== f.length) return !1;
    for (f = 0; f < l.length; f++) {
      var v = l[f];
      if (!xe.call(s, v) || !vi(i[v], s[v]))
        return !1;
    }
    return !0;
  }
  function Mv(i) {
    for (; i && i.firstChild; ) i = i.firstChild;
    return i;
  }
  function Ev(i, s) {
    var l = Mv(i);
    i = 0;
    for (var f; l; ) {
      if (l.nodeType === 3) {
        if (f = i + l.textContent.length, i <= s && f >= s)
          return { node: l, offset: s - i };
        i = f;
      }
      t: {
        for (; l; ) {
          if (l.nextSibling) {
            l = l.nextSibling;
            break t;
          }
          l = l.parentNode;
        }
        l = void 0;
      }
      l = Mv(l);
    }
  }
  function wv(i, s) {
    return i && s ? i === s ? !0 : i && i.nodeType === 3 ? !1 : s && s.nodeType === 3 ? wv(i, s.parentNode) : "contains" in i ? i.contains(s) : i.compareDocumentPosition ? !!(i.compareDocumentPosition(s) & 16) : !1 : !1;
  }
  function Tv(i) {
    i = i != null && i.ownerDocument != null && i.ownerDocument.defaultView != null ? i.ownerDocument.defaultView : window;
    for (var s = ii(i.document); s instanceof i.HTMLIFrameElement; ) {
      try {
        var l = typeof s.contentWindow.location.href == "string";
      } catch {
        l = !1;
      }
      if (l) i = s.contentWindow;
      else break;
      s = ii(i.document);
    }
    return s;
  }
  function ah(i) {
    var s = i && i.nodeName && i.nodeName.toLowerCase();
    return s && (s === "input" && (i.type === "text" || i.type === "search" || i.type === "tel" || i.type === "url" || i.type === "password") || s === "textarea" || i.contentEditable === "true");
  }
  var RT = wr && "documentMode" in document && 11 >= document.documentMode, ja = null, oh = null, wl = null, lh = !1;
  function Av(i, s, l) {
    var f = l.window === l ? l.document : l.nodeType === 9 ? l : l.ownerDocument;
    lh || ja == null || ja !== ii(f) || (f = ja, "selectionStart" in f && ah(f) ? f = { start: f.selectionStart, end: f.selectionEnd } : (f = (f.ownerDocument && f.ownerDocument.defaultView || window).getSelection(), f = {
      anchorNode: f.anchorNode,
      anchorOffset: f.anchorOffset,
      focusNode: f.focusNode,
      focusOffset: f.focusOffset
    }), wl && El(wl, f) || (wl = f, f = Yu(oh, "onSelect"), 0 < f.length && (s = new iu(
      "onSelect",
      "select",
      null,
      s,
      l
    ), i.push({ event: s, listeners: f }), s.target = ja)));
  }
  function Qs(i, s) {
    var l = {};
    return l[i.toLowerCase()] = s.toLowerCase(), l["Webkit" + i] = "webkit" + s, l["Moz" + i] = "moz" + s, l;
  }
  var Wa = {
    animationend: Qs("Animation", "AnimationEnd"),
    animationiteration: Qs("Animation", "AnimationIteration"),
    animationstart: Qs("Animation", "AnimationStart"),
    transitionrun: Qs("Transition", "TransitionRun"),
    transitionstart: Qs("Transition", "TransitionStart"),
    transitioncancel: Qs("Transition", "TransitionCancel"),
    transitionend: Qs("Transition", "TransitionEnd")
  }, ch = {}, Cv = {};
  wr && (Cv = document.createElement("div").style, "AnimationEvent" in window || (delete Wa.animationend.animation, delete Wa.animationiteration.animation, delete Wa.animationstart.animation), "TransitionEvent" in window || delete Wa.transitionend.transition);
  function Js(i) {
    if (ch[i]) return ch[i];
    if (!Wa[i]) return i;
    var s = Wa[i], l;
    for (l in s)
      if (s.hasOwnProperty(l) && l in Cv)
        return ch[i] = s[l];
    return i;
  }
  var Rv = Js("animationend"), Dv = Js("animationiteration"), Nv = Js("animationstart"), DT = Js("transitionrun"), NT = Js("transitionstart"), LT = Js("transitioncancel"), Lv = Js("transitionend"), Uv = /* @__PURE__ */ new Map(), uh = "abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(
    " "
  );
  uh.push("scrollEnd");
  function Xi(i, s) {
    Uv.set(i, s), kt(s, [i]);
  }
  var au = typeof reportError == "function" ? reportError : function(i) {
    if (typeof window == "object" && typeof window.ErrorEvent == "function") {
      var s = new window.ErrorEvent("error", {
        bubbles: !0,
        cancelable: !0,
        message: typeof i == "object" && i !== null && typeof i.message == "string" ? String(i.message) : String(i),
        error: i
      });
      if (!window.dispatchEvent(s)) return;
    } else if (typeof process == "object" && typeof process.emit == "function") {
      process.emit("uncaughtException", i);
      return;
    }
    console.error(i);
  }, Li = [], Ya = 0, fh = 0;
  function ou() {
    for (var i = Ya, s = fh = Ya = 0; s < i; ) {
      var l = Li[s];
      Li[s++] = null;
      var f = Li[s];
      Li[s++] = null;
      var v = Li[s];
      Li[s++] = null;
      var x = Li[s];
      if (Li[s++] = null, f !== null && v !== null) {
        var P = f.pending;
        P === null ? v.next = v : (v.next = P.next, P.next = v), f.pending = v;
      }
      x !== 0 && Ov(l, v, x);
    }
  }
  function lu(i, s, l, f) {
    Li[Ya++] = i, Li[Ya++] = s, Li[Ya++] = l, Li[Ya++] = f, fh |= f, i.lanes |= f, i = i.alternate, i !== null && (i.lanes |= f);
  }
  function dh(i, s, l, f) {
    return lu(i, s, l, f), cu(i);
  }
  function ta(i, s) {
    return lu(i, null, null, s), cu(i);
  }
  function Ov(i, s, l) {
    i.lanes |= l;
    var f = i.alternate;
    f !== null && (f.lanes |= l);
    for (var v = !1, x = i.return; x !== null; )
      x.childLanes |= l, f = x.alternate, f !== null && (f.childLanes |= l), x.tag === 22 && (i = x.stateNode, i === null || i._visibility & 1 || (v = !0)), i = x, x = x.return;
    return i.tag === 3 ? (x = i.stateNode, v && s !== null && (v = 31 - le(l), i = x.hiddenUpdates, f = i[v], f === null ? i[v] = [s] : f.push(s), s.lane = l | 536870912), x) : null;
  }
  function cu(i) {
    if (50 < Yl)
      throw Yl = 0, Sp = null, Error(r(185));
    for (var s = i.return; s !== null; )
      i = s, s = i.return;
    return i.tag === 3 ? i.stateNode : null;
  }
  var qa = {};
  function UT(i, s, l, f) {
    this.tag = i, this.key = l, this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null, this.index = 0, this.refCleanup = this.ref = null, this.pendingProps = s, this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null, this.mode = f, this.subtreeFlags = this.flags = 0, this.deletions = null, this.childLanes = this.lanes = 0, this.alternate = null;
  }
  function _i(i, s, l, f) {
    return new UT(i, s, l, f);
  }
  function hh(i) {
    return i = i.prototype, !(!i || !i.isReactComponent);
  }
  function Tr(i, s) {
    var l = i.alternate;
    return l === null ? (l = _i(
      i.tag,
      s,
      i.key,
      i.mode
    ), l.elementType = i.elementType, l.type = i.type, l.stateNode = i.stateNode, l.alternate = i, i.alternate = l) : (l.pendingProps = s, l.type = i.type, l.flags = 0, l.subtreeFlags = 0, l.deletions = null), l.flags = i.flags & 65011712, l.childLanes = i.childLanes, l.lanes = i.lanes, l.child = i.child, l.memoizedProps = i.memoizedProps, l.memoizedState = i.memoizedState, l.updateQueue = i.updateQueue, s = i.dependencies, l.dependencies = s === null ? null : { lanes: s.lanes, firstContext: s.firstContext }, l.sibling = i.sibling, l.index = i.index, l.ref = i.ref, l.refCleanup = i.refCleanup, l;
  }
  function Pv(i, s) {
    i.flags &= 65011714;
    var l = i.alternate;
    return l === null ? (i.childLanes = 0, i.lanes = s, i.child = null, i.subtreeFlags = 0, i.memoizedProps = null, i.memoizedState = null, i.updateQueue = null, i.dependencies = null, i.stateNode = null) : (i.childLanes = l.childLanes, i.lanes = l.lanes, i.child = l.child, i.subtreeFlags = 0, i.deletions = null, i.memoizedProps = l.memoizedProps, i.memoizedState = l.memoizedState, i.updateQueue = l.updateQueue, i.type = l.type, s = l.dependencies, i.dependencies = s === null ? null : {
      lanes: s.lanes,
      firstContext: s.firstContext
    }), i;
  }
  function uu(i, s, l, f, v, x) {
    var P = 0;
    if (f = i, typeof i == "function") hh(i) && (P = 1);
    else if (typeof i == "string")
      P = BA(
        i,
        l,
        G.current
      ) ? 26 : i === "html" || i === "head" || i === "body" ? 27 : 5;
    else
      t: switch (i) {
        case R:
          return i = _i(31, l, s, v), i.elementType = R, i.lanes = x, i;
        case E:
          return ea(l.children, v, x, s);
        case S:
          P = 8, v |= 24;
          break;
        case y:
          return i = _i(12, l, s, v | 2), i.elementType = y, i.lanes = x, i;
        case O:
          return i = _i(13, l, s, v), i.elementType = O, i.lanes = x, i;
        case L:
          return i = _i(19, l, s, v), i.elementType = L, i.lanes = x, i;
        default:
          if (typeof i == "object" && i !== null)
            switch (i.$$typeof) {
              case w:
                P = 10;
                break t;
              case A:
                P = 9;
                break t;
              case M:
                P = 11;
                break t;
              case N:
                P = 14;
                break t;
              case z:
                P = 16, f = null;
                break t;
            }
          P = 29, l = Error(
            r(130, i === null ? "null" : typeof i, "")
          ), f = null;
      }
    return s = _i(P, l, s, v), s.elementType = i, s.type = f, s.lanes = x, s;
  }
  function ea(i, s, l, f) {
    return i = _i(7, i, f, s), i.lanes = l, i;
  }
  function ph(i, s, l) {
    return i = _i(6, i, null, s), i.lanes = l, i;
  }
  function zv(i) {
    var s = _i(18, null, null, 0);
    return s.stateNode = i, s;
  }
  function mh(i, s, l) {
    return s = _i(
      4,
      i.children !== null ? i.children : [],
      i.key,
      s
    ), s.lanes = l, s.stateNode = {
      containerInfo: i.containerInfo,
      pendingChildren: null,
      implementation: i.implementation
    }, s;
  }
  var Iv = /* @__PURE__ */ new WeakMap();
  function Ui(i, s) {
    if (typeof i == "object" && i !== null) {
      var l = Iv.get(i);
      return l !== void 0 ? l : (s = {
        value: i,
        source: s,
        stack: jt(s)
      }, Iv.set(i, s), s);
    }
    return {
      value: i,
      source: s,
      stack: jt(s)
    };
  }
  var Za = [], $a = 0, fu = null, Tl = 0, Oi = [], Pi = 0, os = null, ir = 1, rr = "";
  function Ar(i, s) {
    Za[$a++] = Tl, Za[$a++] = fu, fu = i, Tl = s;
  }
  function Bv(i, s, l) {
    Oi[Pi++] = ir, Oi[Pi++] = rr, Oi[Pi++] = os, os = i;
    var f = ir;
    i = rr;
    var v = 32 - le(f) - 1;
    f &= ~(1 << v), l += 1;
    var x = 32 - le(s) + v;
    if (30 < x) {
      var P = v - v % 5;
      x = (f & (1 << P) - 1).toString(32), f >>= P, v -= P, ir = 1 << 32 - le(s) + v | l << v | f, rr = x + i;
    } else
      ir = 1 << x | l << v | f, rr = i;
  }
  function gh(i) {
    i.return !== null && (Ar(i, 1), Bv(i, 1, 0));
  }
  function vh(i) {
    for (; i === fu; )
      fu = Za[--$a], Za[$a] = null, Tl = Za[--$a], Za[$a] = null;
    for (; i === os; )
      os = Oi[--Pi], Oi[Pi] = null, rr = Oi[--Pi], Oi[Pi] = null, ir = Oi[--Pi], Oi[Pi] = null;
  }
  function Fv(i, s) {
    Oi[Pi++] = ir, Oi[Pi++] = rr, Oi[Pi++] = os, ir = s.id, rr = s.overflow, os = i;
  }
  var Hn = null, nn = null, Ne = !1, ls = null, zi = !1, _h = Error(r(519));
  function cs(i) {
    var s = Error(
      r(
        418,
        1 < arguments.length && arguments[1] !== void 0 && arguments[1] ? "text" : "HTML",
        ""
      )
    );
    throw Al(Ui(s, i)), _h;
  }
  function Hv(i) {
    var s = i.stateNode, l = i.type, f = i.memoizedProps;
    switch (s[sn] = i, s[Tn] = f, l) {
      case "dialog":
        Ae("cancel", s), Ae("close", s);
        break;
      case "iframe":
      case "object":
      case "embed":
        Ae("load", s);
        break;
      case "video":
      case "audio":
        for (l = 0; l < Zl.length; l++)
          Ae(Zl[l], s);
        break;
      case "source":
        Ae("error", s);
        break;
      case "img":
      case "image":
      case "link":
        Ae("error", s), Ae("load", s);
        break;
      case "details":
        Ae("toggle", s);
        break;
      case "input":
        Ae("invalid", s), Bn(
          s,
          f.value,
          f.defaultValue,
          f.checked,
          f.defaultChecked,
          f.type,
          f.name,
          !0
        );
        break;
      case "select":
        Ae("invalid", s);
        break;
      case "textarea":
        Ae("invalid", s), Va(s, f.value, f.defaultValue, f.children);
    }
    l = f.children, typeof l != "string" && typeof l != "number" && typeof l != "bigint" || s.textContent === "" + l || f.suppressHydrationWarning === !0 || ix(s.textContent, l) ? (f.popover != null && (Ae("beforetoggle", s), Ae("toggle", s)), f.onScroll != null && Ae("scroll", s), f.onScrollEnd != null && Ae("scrollend", s), f.onClick != null && (s.onclick = Er), s = !0) : s = !1, s || cs(i, !0);
  }
  function Vv(i) {
    for (Hn = i.return; Hn; )
      switch (Hn.tag) {
        case 5:
        case 31:
        case 13:
          zi = !1;
          return;
        case 27:
        case 3:
          zi = !0;
          return;
        default:
          Hn = Hn.return;
      }
  }
  function Ka(i) {
    if (i !== Hn) return !1;
    if (!Ne) return Vv(i), Ne = !0, !1;
    var s = i.tag, l;
    if ((l = s !== 3 && s !== 27) && ((l = s === 5) && (l = i.type, l = !(l !== "form" && l !== "button") || zp(i.type, i.memoizedProps)), l = !l), l && nn && cs(i), Vv(i), s === 13) {
      if (i = i.memoizedState, i = i !== null ? i.dehydrated : null, !i) throw Error(r(317));
      nn = dx(i);
    } else if (s === 31) {
      if (i = i.memoizedState, i = i !== null ? i.dehydrated : null, !i) throw Error(r(317));
      nn = dx(i);
    } else
      s === 27 ? (s = nn, Ms(i.type) ? (i = Vp, Vp = null, nn = i) : nn = s) : nn = Hn ? Bi(i.stateNode.nextSibling) : null;
    return !0;
  }
  function na() {
    nn = Hn = null, Ne = !1;
  }
  function yh() {
    var i = ls;
    return i !== null && (ci === null ? ci = i : ci.push.apply(
      ci,
      i
    ), ls = null), i;
  }
  function Al(i) {
    ls === null ? ls = [i] : ls.push(i);
  }
  var xh = F(null), ia = null, Cr = null;
  function us(i, s, l) {
    it(xh, s._currentValue), s._currentValue = l;
  }
  function Rr(i) {
    i._currentValue = xh.current, q(xh);
  }
  function Sh(i, s, l) {
    for (; i !== null; ) {
      var f = i.alternate;
      if ((i.childLanes & s) !== s ? (i.childLanes |= s, f !== null && (f.childLanes |= s)) : f !== null && (f.childLanes & s) !== s && (f.childLanes |= s), i === l) break;
      i = i.return;
    }
  }
  function bh(i, s, l, f) {
    var v = i.child;
    for (v !== null && (v.return = i); v !== null; ) {
      var x = v.dependencies;
      if (x !== null) {
        var P = v.child;
        x = x.firstContext;
        t: for (; x !== null; ) {
          var Y = x;
          x = v;
          for (var rt = 0; rt < s.length; rt++)
            if (Y.context === s[rt]) {
              x.lanes |= l, Y = x.alternate, Y !== null && (Y.lanes |= l), Sh(
                x.return,
                l,
                i
              ), f || (P = null);
              break t;
            }
          x = Y.next;
        }
      } else if (v.tag === 18) {
        if (P = v.return, P === null) throw Error(r(341));
        P.lanes |= l, x = P.alternate, x !== null && (x.lanes |= l), Sh(P, l, i), P = null;
      } else P = v.child;
      if (P !== null) P.return = v;
      else
        for (P = v; P !== null; ) {
          if (P === i) {
            P = null;
            break;
          }
          if (v = P.sibling, v !== null) {
            v.return = P.return, P = v;
            break;
          }
          P = P.return;
        }
      v = P;
    }
  }
  function Qa(i, s, l, f) {
    i = null;
    for (var v = s, x = !1; v !== null; ) {
      if (!x) {
        if ((v.flags & 524288) !== 0) x = !0;
        else if ((v.flags & 262144) !== 0) break;
      }
      if (v.tag === 10) {
        var P = v.alternate;
        if (P === null) throw Error(r(387));
        if (P = P.memoizedProps, P !== null) {
          var Y = v.type;
          vi(v.pendingProps.value, P.value) || (i !== null ? i.push(Y) : i = [Y]);
        }
      } else if (v === Q.current) {
        if (P = v.alternate, P === null) throw Error(r(387));
        P.memoizedState.memoizedState !== v.memoizedState.memoizedState && (i !== null ? i.push(tc) : i = [tc]);
      }
      v = v.return;
    }
    i !== null && bh(
      s,
      i,
      l,
      f
    ), s.flags |= 262144;
  }
  function du(i) {
    for (i = i.firstContext; i !== null; ) {
      if (!vi(
        i.context._currentValue,
        i.memoizedValue
      ))
        return !0;
      i = i.next;
    }
    return !1;
  }
  function ra(i) {
    ia = i, Cr = null, i = i.dependencies, i !== null && (i.firstContext = null);
  }
  function Vn(i) {
    return kv(ia, i);
  }
  function hu(i, s) {
    return ia === null && ra(i), kv(i, s);
  }
  function kv(i, s) {
    var l = s._currentValue;
    if (s = { context: s, memoizedValue: l, next: null }, Cr === null) {
      if (i === null) throw Error(r(308));
      Cr = s, i.dependencies = { lanes: 0, firstContext: s }, i.flags |= 524288;
    } else Cr = Cr.next = s;
    return l;
  }
  var OT = typeof AbortController < "u" ? AbortController : function() {
    var i = [], s = this.signal = {
      aborted: !1,
      addEventListener: function(l, f) {
        i.push(f);
      }
    };
    this.abort = function() {
      s.aborted = !0, i.forEach(function(l) {
        return l();
      });
    };
  }, PT = n.unstable_scheduleCallback, zT = n.unstable_NormalPriority, vn = {
    $$typeof: w,
    Consumer: null,
    Provider: null,
    _currentValue: null,
    _currentValue2: null,
    _threadCount: 0
  };
  function Mh() {
    return {
      controller: new OT(),
      data: /* @__PURE__ */ new Map(),
      refCount: 0
    };
  }
  function Cl(i) {
    i.refCount--, i.refCount === 0 && PT(zT, function() {
      i.controller.abort();
    });
  }
  var Rl = null, Eh = 0, Ja = 0, to = null;
  function IT(i, s) {
    if (Rl === null) {
      var l = Rl = [];
      Eh = 0, Ja = Ap(), to = {
        status: "pending",
        value: void 0,
        then: function(f) {
          l.push(f);
        }
      };
    }
    return Eh++, s.then(Gv, Gv), s;
  }
  function Gv() {
    if (--Eh === 0 && Rl !== null) {
      to !== null && (to.status = "fulfilled");
      var i = Rl;
      Rl = null, Ja = 0, to = null;
      for (var s = 0; s < i.length; s++) (0, i[s])();
    }
  }
  function BT(i, s) {
    var l = [], f = {
      status: "pending",
      value: null,
      reason: null,
      then: function(v) {
        l.push(v);
      }
    };
    return i.then(
      function() {
        f.status = "fulfilled", f.value = s;
        for (var v = 0; v < l.length; v++) (0, l[v])(s);
      },
      function(v) {
        for (f.status = "rejected", f.reason = v, v = 0; v < l.length; v++)
          (0, l[v])(void 0);
      }
    ), f;
  }
  var Xv = D.S;
  D.S = function(i, s) {
    Ay = Et(), typeof s == "object" && s !== null && typeof s.then == "function" && IT(i, s), Xv !== null && Xv(i, s);
  };
  var sa = F(null);
  function wh() {
    var i = sa.current;
    return i !== null ? i : Je.pooledCache;
  }
  function pu(i, s) {
    s === null ? it(sa, sa.current) : it(sa, s.pool);
  }
  function jv() {
    var i = wh();
    return i === null ? null : { parent: vn._currentValue, pool: i };
  }
  var eo = Error(r(460)), Th = Error(r(474)), mu = Error(r(542)), gu = { then: function() {
  } };
  function Wv(i) {
    return i = i.status, i === "fulfilled" || i === "rejected";
  }
  function Yv(i, s, l) {
    switch (l = i[l], l === void 0 ? i.push(s) : l !== s && (s.then(Er, Er), s = l), s.status) {
      case "fulfilled":
        return s.value;
      case "rejected":
        throw i = s.reason, Zv(i), i;
      default:
        if (typeof s.status == "string") s.then(Er, Er);
        else {
          if (i = Je, i !== null && 100 < i.shellSuspendCounter)
            throw Error(r(482));
          i = s, i.status = "pending", i.then(
            function(f) {
              if (s.status === "pending") {
                var v = s;
                v.status = "fulfilled", v.value = f;
              }
            },
            function(f) {
              if (s.status === "pending") {
                var v = s;
                v.status = "rejected", v.reason = f;
              }
            }
          );
        }
        switch (s.status) {
          case "fulfilled":
            return s.value;
          case "rejected":
            throw i = s.reason, Zv(i), i;
        }
        throw oa = s, eo;
    }
  }
  function aa(i) {
    try {
      var s = i._init;
      return s(i._payload);
    } catch (l) {
      throw l !== null && typeof l == "object" && typeof l.then == "function" ? (oa = l, eo) : l;
    }
  }
  var oa = null;
  function qv() {
    if (oa === null) throw Error(r(459));
    var i = oa;
    return oa = null, i;
  }
  function Zv(i) {
    if (i === eo || i === mu)
      throw Error(r(483));
  }
  var no = null, Dl = 0;
  function vu(i) {
    var s = Dl;
    return Dl += 1, no === null && (no = []), Yv(no, i, s);
  }
  function Nl(i, s) {
    s = s.props.ref, i.ref = s !== void 0 ? s : null;
  }
  function _u(i, s) {
    throw s.$$typeof === g ? Error(r(525)) : (i = Object.prototype.toString.call(s), Error(
      r(
        31,
        i === "[object Object]" ? "object with keys {" + Object.keys(s).join(", ") + "}" : i
      )
    ));
  }
  function $v(i) {
    function s(dt, at) {
      if (i) {
        var ht = dt.deletions;
        ht === null ? (dt.deletions = [at], dt.flags |= 16) : ht.push(at);
      }
    }
    function l(dt, at) {
      if (!i) return null;
      for (; at !== null; )
        s(dt, at), at = at.sibling;
      return null;
    }
    function f(dt) {
      for (var at = /* @__PURE__ */ new Map(); dt !== null; )
        dt.key !== null ? at.set(dt.key, dt) : at.set(dt.index, dt), dt = dt.sibling;
      return at;
    }
    function v(dt, at) {
      return dt = Tr(dt, at), dt.index = 0, dt.sibling = null, dt;
    }
    function x(dt, at, ht) {
      return dt.index = ht, i ? (ht = dt.alternate, ht !== null ? (ht = ht.index, ht < at ? (dt.flags |= 67108866, at) : ht) : (dt.flags |= 67108866, at)) : (dt.flags |= 1048576, at);
    }
    function P(dt) {
      return i && dt.alternate === null && (dt.flags |= 67108866), dt;
    }
    function Y(dt, at, ht, Tt) {
      return at === null || at.tag !== 6 ? (at = ph(ht, dt.mode, Tt), at.return = dt, at) : (at = v(at, ht), at.return = dt, at);
    }
    function rt(dt, at, ht, Tt) {
      var se = ht.type;
      return se === E ? bt(
        dt,
        at,
        ht.props.children,
        Tt,
        ht.key
      ) : at !== null && (at.elementType === se || typeof se == "object" && se !== null && se.$$typeof === z && aa(se) === at.type) ? (at = v(at, ht.props), Nl(at, ht), at.return = dt, at) : (at = uu(
        ht.type,
        ht.key,
        ht.props,
        null,
        dt.mode,
        Tt
      ), Nl(at, ht), at.return = dt, at);
    }
    function pt(dt, at, ht, Tt) {
      return at === null || at.tag !== 4 || at.stateNode.containerInfo !== ht.containerInfo || at.stateNode.implementation !== ht.implementation ? (at = mh(ht, dt.mode, Tt), at.return = dt, at) : (at = v(at, ht.children || []), at.return = dt, at);
    }
    function bt(dt, at, ht, Tt, se) {
      return at === null || at.tag !== 7 ? (at = ea(
        ht,
        dt.mode,
        Tt,
        se
      ), at.return = dt, at) : (at = v(at, ht), at.return = dt, at);
    }
    function At(dt, at, ht) {
      if (typeof at == "string" && at !== "" || typeof at == "number" || typeof at == "bigint")
        return at = ph(
          "" + at,
          dt.mode,
          ht
        ), at.return = dt, at;
      if (typeof at == "object" && at !== null) {
        switch (at.$$typeof) {
          case _:
            return ht = uu(
              at.type,
              at.key,
              at.props,
              null,
              dt.mode,
              ht
            ), Nl(ht, at), ht.return = dt, ht;
          case b:
            return at = mh(
              at,
              dt.mode,
              ht
            ), at.return = dt, at;
          case z:
            return at = aa(at), At(dt, at, ht);
        }
        if (X(at) || B(at))
          return at = ea(
            at,
            dt.mode,
            ht,
            null
          ), at.return = dt, at;
        if (typeof at.then == "function")
          return At(dt, vu(at), ht);
        if (at.$$typeof === w)
          return At(
            dt,
            hu(dt, at),
            ht
          );
        _u(dt, at);
      }
      return null;
    }
    function vt(dt, at, ht, Tt) {
      var se = at !== null ? at.key : null;
      if (typeof ht == "string" && ht !== "" || typeof ht == "number" || typeof ht == "bigint")
        return se !== null ? null : Y(dt, at, "" + ht, Tt);
      if (typeof ht == "object" && ht !== null) {
        switch (ht.$$typeof) {
          case _:
            return ht.key === se ? rt(dt, at, ht, Tt) : null;
          case b:
            return ht.key === se ? pt(dt, at, ht, Tt) : null;
          case z:
            return ht = aa(ht), vt(dt, at, ht, Tt);
        }
        if (X(ht) || B(ht))
          return se !== null ? null : bt(dt, at, ht, Tt, null);
        if (typeof ht.then == "function")
          return vt(
            dt,
            at,
            vu(ht),
            Tt
          );
        if (ht.$$typeof === w)
          return vt(
            dt,
            at,
            hu(dt, ht),
            Tt
          );
        _u(dt, ht);
      }
      return null;
    }
    function xt(dt, at, ht, Tt, se) {
      if (typeof Tt == "string" && Tt !== "" || typeof Tt == "number" || typeof Tt == "bigint")
        return dt = dt.get(ht) || null, Y(at, dt, "" + Tt, se);
      if (typeof Tt == "object" && Tt !== null) {
        switch (Tt.$$typeof) {
          case _:
            return dt = dt.get(
              Tt.key === null ? ht : Tt.key
            ) || null, rt(at, dt, Tt, se);
          case b:
            return dt = dt.get(
              Tt.key === null ? ht : Tt.key
            ) || null, pt(at, dt, Tt, se);
          case z:
            return Tt = aa(Tt), xt(
              dt,
              at,
              ht,
              Tt,
              se
            );
        }
        if (X(Tt) || B(Tt))
          return dt = dt.get(ht) || null, bt(at, dt, Tt, se, null);
        if (typeof Tt.then == "function")
          return xt(
            dt,
            at,
            ht,
            vu(Tt),
            se
          );
        if (Tt.$$typeof === w)
          return xt(
            dt,
            at,
            ht,
            hu(at, Tt),
            se
          );
        _u(at, Tt);
      }
      return null;
    }
    function $t(dt, at, ht, Tt) {
      for (var se = null, Pe = null, Qt = at, ge = at = 0, Re = null; Qt !== null && ge < ht.length; ge++) {
        Qt.index > ge ? (Re = Qt, Qt = null) : Re = Qt.sibling;
        var ze = vt(
          dt,
          Qt,
          ht[ge],
          Tt
        );
        if (ze === null) {
          Qt === null && (Qt = Re);
          break;
        }
        i && Qt && ze.alternate === null && s(dt, Qt), at = x(ze, at, ge), Pe === null ? se = ze : Pe.sibling = ze, Pe = ze, Qt = Re;
      }
      if (ge === ht.length)
        return l(dt, Qt), Ne && Ar(dt, ge), se;
      if (Qt === null) {
        for (; ge < ht.length; ge++)
          Qt = At(dt, ht[ge], Tt), Qt !== null && (at = x(
            Qt,
            at,
            ge
          ), Pe === null ? se = Qt : Pe.sibling = Qt, Pe = Qt);
        return Ne && Ar(dt, ge), se;
      }
      for (Qt = f(Qt); ge < ht.length; ge++)
        Re = xt(
          Qt,
          dt,
          ge,
          ht[ge],
          Tt
        ), Re !== null && (i && Re.alternate !== null && Qt.delete(
          Re.key === null ? ge : Re.key
        ), at = x(
          Re,
          at,
          ge
        ), Pe === null ? se = Re : Pe.sibling = Re, Pe = Re);
      return i && Qt.forEach(function(Cs) {
        return s(dt, Cs);
      }), Ne && Ar(dt, ge), se;
    }
    function ae(dt, at, ht, Tt) {
      if (ht == null) throw Error(r(151));
      for (var se = null, Pe = null, Qt = at, ge = at = 0, Re = null, ze = ht.next(); Qt !== null && !ze.done; ge++, ze = ht.next()) {
        Qt.index > ge ? (Re = Qt, Qt = null) : Re = Qt.sibling;
        var Cs = vt(dt, Qt, ze.value, Tt);
        if (Cs === null) {
          Qt === null && (Qt = Re);
          break;
        }
        i && Qt && Cs.alternate === null && s(dt, Qt), at = x(Cs, at, ge), Pe === null ? se = Cs : Pe.sibling = Cs, Pe = Cs, Qt = Re;
      }
      if (ze.done)
        return l(dt, Qt), Ne && Ar(dt, ge), se;
      if (Qt === null) {
        for (; !ze.done; ge++, ze = ht.next())
          ze = At(dt, ze.value, Tt), ze !== null && (at = x(ze, at, ge), Pe === null ? se = ze : Pe.sibling = ze, Pe = ze);
        return Ne && Ar(dt, ge), se;
      }
      for (Qt = f(Qt); !ze.done; ge++, ze = ht.next())
        ze = xt(Qt, dt, ge, ze.value, Tt), ze !== null && (i && ze.alternate !== null && Qt.delete(ze.key === null ? ge : ze.key), at = x(ze, at, ge), Pe === null ? se = ze : Pe.sibling = ze, Pe = ze);
      return i && Qt.forEach(function(ZA) {
        return s(dt, ZA);
      }), Ne && Ar(dt, ge), se;
    }
    function Ye(dt, at, ht, Tt) {
      if (typeof ht == "object" && ht !== null && ht.type === E && ht.key === null && (ht = ht.props.children), typeof ht == "object" && ht !== null) {
        switch (ht.$$typeof) {
          case _:
            t: {
              for (var se = ht.key; at !== null; ) {
                if (at.key === se) {
                  if (se = ht.type, se === E) {
                    if (at.tag === 7) {
                      l(
                        dt,
                        at.sibling
                      ), Tt = v(
                        at,
                        ht.props.children
                      ), Tt.return = dt, dt = Tt;
                      break t;
                    }
                  } else if (at.elementType === se || typeof se == "object" && se !== null && se.$$typeof === z && aa(se) === at.type) {
                    l(
                      dt,
                      at.sibling
                    ), Tt = v(at, ht.props), Nl(Tt, ht), Tt.return = dt, dt = Tt;
                    break t;
                  }
                  l(dt, at);
                  break;
                } else s(dt, at);
                at = at.sibling;
              }
              ht.type === E ? (Tt = ea(
                ht.props.children,
                dt.mode,
                Tt,
                ht.key
              ), Tt.return = dt, dt = Tt) : (Tt = uu(
                ht.type,
                ht.key,
                ht.props,
                null,
                dt.mode,
                Tt
              ), Nl(Tt, ht), Tt.return = dt, dt = Tt);
            }
            return P(dt);
          case b:
            t: {
              for (se = ht.key; at !== null; ) {
                if (at.key === se)
                  if (at.tag === 4 && at.stateNode.containerInfo === ht.containerInfo && at.stateNode.implementation === ht.implementation) {
                    l(
                      dt,
                      at.sibling
                    ), Tt = v(at, ht.children || []), Tt.return = dt, dt = Tt;
                    break t;
                  } else {
                    l(dt, at);
                    break;
                  }
                else s(dt, at);
                at = at.sibling;
              }
              Tt = mh(ht, dt.mode, Tt), Tt.return = dt, dt = Tt;
            }
            return P(dt);
          case z:
            return ht = aa(ht), Ye(
              dt,
              at,
              ht,
              Tt
            );
        }
        if (X(ht))
          return $t(
            dt,
            at,
            ht,
            Tt
          );
        if (B(ht)) {
          if (se = B(ht), typeof se != "function") throw Error(r(150));
          return ht = se.call(ht), ae(
            dt,
            at,
            ht,
            Tt
          );
        }
        if (typeof ht.then == "function")
          return Ye(
            dt,
            at,
            vu(ht),
            Tt
          );
        if (ht.$$typeof === w)
          return Ye(
            dt,
            at,
            hu(dt, ht),
            Tt
          );
        _u(dt, ht);
      }
      return typeof ht == "string" && ht !== "" || typeof ht == "number" || typeof ht == "bigint" ? (ht = "" + ht, at !== null && at.tag === 6 ? (l(dt, at.sibling), Tt = v(at, ht), Tt.return = dt, dt = Tt) : (l(dt, at), Tt = ph(ht, dt.mode, Tt), Tt.return = dt, dt = Tt), P(dt)) : l(dt, at);
    }
    return function(dt, at, ht, Tt) {
      try {
        Dl = 0;
        var se = Ye(
          dt,
          at,
          ht,
          Tt
        );
        return no = null, se;
      } catch (Qt) {
        if (Qt === eo || Qt === mu) throw Qt;
        var Pe = _i(29, Qt, null, dt.mode);
        return Pe.lanes = Tt, Pe.return = dt, Pe;
      } finally {
      }
    };
  }
  var la = $v(!0), Kv = $v(!1), fs = !1;
  function Ah(i) {
    i.updateQueue = {
      baseState: i.memoizedState,
      firstBaseUpdate: null,
      lastBaseUpdate: null,
      shared: { pending: null, lanes: 0, hiddenCallbacks: null },
      callbacks: null
    };
  }
  function Ch(i, s) {
    i = i.updateQueue, s.updateQueue === i && (s.updateQueue = {
      baseState: i.baseState,
      firstBaseUpdate: i.firstBaseUpdate,
      lastBaseUpdate: i.lastBaseUpdate,
      shared: i.shared,
      callbacks: null
    });
  }
  function ds(i) {
    return { lane: i, tag: 0, payload: null, callback: null, next: null };
  }
  function hs(i, s, l) {
    var f = i.updateQueue;
    if (f === null) return null;
    if (f = f.shared, (Be & 2) !== 0) {
      var v = f.pending;
      return v === null ? s.next = s : (s.next = v.next, v.next = s), f.pending = s, s = cu(i), Ov(i, null, l), s;
    }
    return lu(i, f, s, l), cu(i);
  }
  function Ll(i, s, l) {
    if (s = s.updateQueue, s !== null && (s = s.shared, (l & 4194048) !== 0)) {
      var f = s.lanes;
      f &= i.pendingLanes, l |= f, s.lanes = l, qs(i, l);
    }
  }
  function Rh(i, s) {
    var l = i.updateQueue, f = i.alternate;
    if (f !== null && (f = f.updateQueue, l === f)) {
      var v = null, x = null;
      if (l = l.firstBaseUpdate, l !== null) {
        do {
          var P = {
            lane: l.lane,
            tag: l.tag,
            payload: l.payload,
            callback: null,
            next: null
          };
          x === null ? v = x = P : x = x.next = P, l = l.next;
        } while (l !== null);
        x === null ? v = x = s : x = x.next = s;
      } else v = x = s;
      l = {
        baseState: f.baseState,
        firstBaseUpdate: v,
        lastBaseUpdate: x,
        shared: f.shared,
        callbacks: f.callbacks
      }, i.updateQueue = l;
      return;
    }
    i = l.lastBaseUpdate, i === null ? l.firstBaseUpdate = s : i.next = s, l.lastBaseUpdate = s;
  }
  var Dh = !1;
  function Ul() {
    if (Dh) {
      var i = to;
      if (i !== null) throw i;
    }
  }
  function Ol(i, s, l, f) {
    Dh = !1;
    var v = i.updateQueue;
    fs = !1;
    var x = v.firstBaseUpdate, P = v.lastBaseUpdate, Y = v.shared.pending;
    if (Y !== null) {
      v.shared.pending = null;
      var rt = Y, pt = rt.next;
      rt.next = null, P === null ? x = pt : P.next = pt, P = rt;
      var bt = i.alternate;
      bt !== null && (bt = bt.updateQueue, Y = bt.lastBaseUpdate, Y !== P && (Y === null ? bt.firstBaseUpdate = pt : Y.next = pt, bt.lastBaseUpdate = rt));
    }
    if (x !== null) {
      var At = v.baseState;
      P = 0, bt = pt = rt = null, Y = x;
      do {
        var vt = Y.lane & -536870913, xt = vt !== Y.lane;
        if (xt ? (Ce & vt) === vt : (f & vt) === vt) {
          vt !== 0 && vt === Ja && (Dh = !0), bt !== null && (bt = bt.next = {
            lane: 0,
            tag: Y.tag,
            payload: Y.payload,
            callback: null,
            next: null
          });
          t: {
            var $t = i, ae = Y;
            vt = s;
            var Ye = l;
            switch (ae.tag) {
              case 1:
                if ($t = ae.payload, typeof $t == "function") {
                  At = $t.call(Ye, At, vt);
                  break t;
                }
                At = $t;
                break t;
              case 3:
                $t.flags = $t.flags & -65537 | 128;
              case 0:
                if ($t = ae.payload, vt = typeof $t == "function" ? $t.call(Ye, At, vt) : $t, vt == null) break t;
                At = m({}, At, vt);
                break t;
              case 2:
                fs = !0;
            }
          }
          vt = Y.callback, vt !== null && (i.flags |= 64, xt && (i.flags |= 8192), xt = v.callbacks, xt === null ? v.callbacks = [vt] : xt.push(vt));
        } else
          xt = {
            lane: vt,
            tag: Y.tag,
            payload: Y.payload,
            callback: Y.callback,
            next: null
          }, bt === null ? (pt = bt = xt, rt = At) : bt = bt.next = xt, P |= vt;
        if (Y = Y.next, Y === null) {
          if (Y = v.shared.pending, Y === null)
            break;
          xt = Y, Y = xt.next, xt.next = null, v.lastBaseUpdate = xt, v.shared.pending = null;
        }
      } while (!0);
      bt === null && (rt = At), v.baseState = rt, v.firstBaseUpdate = pt, v.lastBaseUpdate = bt, x === null && (v.shared.lanes = 0), _s |= P, i.lanes = P, i.memoizedState = At;
    }
  }
  function Qv(i, s) {
    if (typeof i != "function")
      throw Error(r(191, i));
    i.call(s);
  }
  function Jv(i, s) {
    var l = i.callbacks;
    if (l !== null)
      for (i.callbacks = null, i = 0; i < l.length; i++)
        Qv(l[i], s);
  }
  var io = F(null), yu = F(0);
  function t_(i, s) {
    i = Br, it(yu, i), it(io, s), Br = i | s.baseLanes;
  }
  function Nh() {
    it(yu, Br), it(io, io.current);
  }
  function Lh() {
    Br = yu.current, q(io), q(yu);
  }
  var yi = F(null), Ii = null;
  function ps(i) {
    var s = i.alternate;
    it(pn, pn.current & 1), it(yi, i), Ii === null && (s === null || io.current !== null || s.memoizedState !== null) && (Ii = i);
  }
  function Uh(i) {
    it(pn, pn.current), it(yi, i), Ii === null && (Ii = i);
  }
  function e_(i) {
    i.tag === 22 ? (it(pn, pn.current), it(yi, i), Ii === null && (Ii = i)) : ms();
  }
  function ms() {
    it(pn, pn.current), it(yi, yi.current);
  }
  function xi(i) {
    q(yi), Ii === i && (Ii = null), q(pn);
  }
  var pn = F(0);
  function xu(i) {
    for (var s = i; s !== null; ) {
      if (s.tag === 13) {
        var l = s.memoizedState;
        if (l !== null && (l = l.dehydrated, l === null || Fp(l) || Hp(l)))
          return s;
      } else if (s.tag === 19 && (s.memoizedProps.revealOrder === "forwards" || s.memoizedProps.revealOrder === "backwards" || s.memoizedProps.revealOrder === "unstable_legacy-backwards" || s.memoizedProps.revealOrder === "together")) {
        if ((s.flags & 128) !== 0) return s;
      } else if (s.child !== null) {
        s.child.return = s, s = s.child;
        continue;
      }
      if (s === i) break;
      for (; s.sibling === null; ) {
        if (s.return === null || s.return === i) return null;
        s = s.return;
      }
      s.sibling.return = s.return, s = s.sibling;
    }
    return null;
  }
  var Dr = 0, me = null, je = null, _n = null, Su = !1, ro = !1, ca = !1, bu = 0, Pl = 0, so = null, FT = 0;
  function cn() {
    throw Error(r(321));
  }
  function Oh(i, s) {
    if (s === null) return !1;
    for (var l = 0; l < s.length && l < i.length; l++)
      if (!vi(i[l], s[l])) return !1;
    return !0;
  }
  function Ph(i, s, l, f, v, x) {
    return Dr = x, me = s, s.memoizedState = null, s.updateQueue = null, s.lanes = 0, D.H = i === null || i.memoizedState === null ? B_ : $h, ca = !1, x = l(f, v), ca = !1, ro && (x = i_(
      s,
      l,
      f,
      v
    )), n_(i), x;
  }
  function n_(i) {
    D.H = Bl;
    var s = je !== null && je.next !== null;
    if (Dr = 0, _n = je = me = null, Su = !1, Pl = 0, so = null, s) throw Error(r(300));
    i === null || yn || (i = i.dependencies, i !== null && du(i) && (yn = !0));
  }
  function i_(i, s, l, f) {
    me = i;
    var v = 0;
    do {
      if (ro && (so = null), Pl = 0, ro = !1, 25 <= v) throw Error(r(301));
      if (v += 1, _n = je = null, i.updateQueue != null) {
        var x = i.updateQueue;
        x.lastEffect = null, x.events = null, x.stores = null, x.memoCache != null && (x.memoCache.index = 0);
      }
      D.H = F_, x = s(l, f);
    } while (ro);
    return x;
  }
  function HT() {
    var i = D.H, s = i.useState()[0];
    return s = typeof s.then == "function" ? zl(s) : s, i = i.useState()[0], (je !== null ? je.memoizedState : null) !== i && (me.flags |= 1024), s;
  }
  function zh() {
    var i = bu !== 0;
    return bu = 0, i;
  }
  function Ih(i, s, l) {
    s.updateQueue = i.updateQueue, s.flags &= -2053, i.lanes &= ~l;
  }
  function Bh(i) {
    if (Su) {
      for (i = i.memoizedState; i !== null; ) {
        var s = i.queue;
        s !== null && (s.pending = null), i = i.next;
      }
      Su = !1;
    }
    Dr = 0, _n = je = me = null, ro = !1, Pl = bu = 0, so = null;
  }
  function ti() {
    var i = {
      memoizedState: null,
      baseState: null,
      baseQueue: null,
      queue: null,
      next: null
    };
    return _n === null ? me.memoizedState = _n = i : _n = _n.next = i, _n;
  }
  function mn() {
    if (je === null) {
      var i = me.alternate;
      i = i !== null ? i.memoizedState : null;
    } else i = je.next;
    var s = _n === null ? me.memoizedState : _n.next;
    if (s !== null)
      _n = s, je = i;
    else {
      if (i === null)
        throw me.alternate === null ? Error(r(467)) : Error(r(310));
      je = i, i = {
        memoizedState: je.memoizedState,
        baseState: je.baseState,
        baseQueue: je.baseQueue,
        queue: je.queue,
        next: null
      }, _n === null ? me.memoizedState = _n = i : _n = _n.next = i;
    }
    return _n;
  }
  function Mu() {
    return { lastEffect: null, events: null, stores: null, memoCache: null };
  }
  function zl(i) {
    var s = Pl;
    return Pl += 1, so === null && (so = []), i = Yv(so, i, s), s = me, (_n === null ? s.memoizedState : _n.next) === null && (s = s.alternate, D.H = s === null || s.memoizedState === null ? B_ : $h), i;
  }
  function Eu(i) {
    if (i !== null && typeof i == "object") {
      if (typeof i.then == "function") return zl(i);
      if (i.$$typeof === w) return Vn(i);
    }
    throw Error(r(438, String(i)));
  }
  function Fh(i) {
    var s = null, l = me.updateQueue;
    if (l !== null && (s = l.memoCache), s == null) {
      var f = me.alternate;
      f !== null && (f = f.updateQueue, f !== null && (f = f.memoCache, f != null && (s = {
        data: f.data.map(function(v) {
          return v.slice();
        }),
        index: 0
      })));
    }
    if (s == null && (s = { data: [], index: 0 }), l === null && (l = Mu(), me.updateQueue = l), l.memoCache = s, l = s.data[s.index], l === void 0)
      for (l = s.data[s.index] = Array(i), f = 0; f < i; f++)
        l[f] = T;
    return s.index++, l;
  }
  function Nr(i, s) {
    return typeof s == "function" ? s(i) : s;
  }
  function wu(i) {
    var s = mn();
    return Hh(s, je, i);
  }
  function Hh(i, s, l) {
    var f = i.queue;
    if (f === null) throw Error(r(311));
    f.lastRenderedReducer = l;
    var v = i.baseQueue, x = f.pending;
    if (x !== null) {
      if (v !== null) {
        var P = v.next;
        v.next = x.next, x.next = P;
      }
      s.baseQueue = v = x, f.pending = null;
    }
    if (x = i.baseState, v === null) i.memoizedState = x;
    else {
      s = v.next;
      var Y = P = null, rt = null, pt = s, bt = !1;
      do {
        var At = pt.lane & -536870913;
        if (At !== pt.lane ? (Ce & At) === At : (Dr & At) === At) {
          var vt = pt.revertLane;
          if (vt === 0)
            rt !== null && (rt = rt.next = {
              lane: 0,
              revertLane: 0,
              gesture: null,
              action: pt.action,
              hasEagerState: pt.hasEagerState,
              eagerState: pt.eagerState,
              next: null
            }), At === Ja && (bt = !0);
          else if ((Dr & vt) === vt) {
            pt = pt.next, vt === Ja && (bt = !0);
            continue;
          } else
            At = {
              lane: 0,
              revertLane: pt.revertLane,
              gesture: null,
              action: pt.action,
              hasEagerState: pt.hasEagerState,
              eagerState: pt.eagerState,
              next: null
            }, rt === null ? (Y = rt = At, P = x) : rt = rt.next = At, me.lanes |= vt, _s |= vt;
          At = pt.action, ca && l(x, At), x = pt.hasEagerState ? pt.eagerState : l(x, At);
        } else
          vt = {
            lane: At,
            revertLane: pt.revertLane,
            gesture: pt.gesture,
            action: pt.action,
            hasEagerState: pt.hasEagerState,
            eagerState: pt.eagerState,
            next: null
          }, rt === null ? (Y = rt = vt, P = x) : rt = rt.next = vt, me.lanes |= At, _s |= At;
        pt = pt.next;
      } while (pt !== null && pt !== s);
      if (rt === null ? P = x : rt.next = Y, !vi(x, i.memoizedState) && (yn = !0, bt && (l = to, l !== null)))
        throw l;
      i.memoizedState = x, i.baseState = P, i.baseQueue = rt, f.lastRenderedState = x;
    }
    return v === null && (f.lanes = 0), [i.memoizedState, f.dispatch];
  }
  function Vh(i) {
    var s = mn(), l = s.queue;
    if (l === null) throw Error(r(311));
    l.lastRenderedReducer = i;
    var f = l.dispatch, v = l.pending, x = s.memoizedState;
    if (v !== null) {
      l.pending = null;
      var P = v = v.next;
      do
        x = i(x, P.action), P = P.next;
      while (P !== v);
      vi(x, s.memoizedState) || (yn = !0), s.memoizedState = x, s.baseQueue === null && (s.baseState = x), l.lastRenderedState = x;
    }
    return [x, f];
  }
  function r_(i, s, l) {
    var f = me, v = mn(), x = Ne;
    if (x) {
      if (l === void 0) throw Error(r(407));
      l = l();
    } else l = s();
    var P = !vi(
      (je || v).memoizedState,
      l
    );
    if (P && (v.memoizedState = l, yn = !0), v = v.queue, Xh(o_.bind(null, f, v, i), [
      i
    ]), v.getSnapshot !== s || P || _n !== null && _n.memoizedState.tag & 1) {
      if (f.flags |= 2048, ao(
        9,
        { destroy: void 0 },
        a_.bind(
          null,
          f,
          v,
          l,
          s
        ),
        null
      ), Je === null) throw Error(r(349));
      x || (Dr & 127) !== 0 || s_(f, s, l);
    }
    return l;
  }
  function s_(i, s, l) {
    i.flags |= 16384, i = { getSnapshot: s, value: l }, s = me.updateQueue, s === null ? (s = Mu(), me.updateQueue = s, s.stores = [i]) : (l = s.stores, l === null ? s.stores = [i] : l.push(i));
  }
  function a_(i, s, l, f) {
    s.value = l, s.getSnapshot = f, l_(s) && c_(i);
  }
  function o_(i, s, l) {
    return l(function() {
      l_(s) && c_(i);
    });
  }
  function l_(i) {
    var s = i.getSnapshot;
    i = i.value;
    try {
      var l = s();
      return !vi(i, l);
    } catch {
      return !0;
    }
  }
  function c_(i) {
    var s = ta(i, 2);
    s !== null && ui(s, i, 2);
  }
  function kh(i) {
    var s = ti();
    if (typeof i == "function") {
      var l = i;
      if (i = l(), ca) {
        Gt(!0);
        try {
          l();
        } finally {
          Gt(!1);
        }
      }
    }
    return s.memoizedState = s.baseState = i, s.queue = {
      pending: null,
      lanes: 0,
      dispatch: null,
      lastRenderedReducer: Nr,
      lastRenderedState: i
    }, s;
  }
  function u_(i, s, l, f) {
    return i.baseState = l, Hh(
      i,
      je,
      typeof f == "function" ? f : Nr
    );
  }
  function VT(i, s, l, f, v) {
    if (Cu(i)) throw Error(r(485));
    if (i = s.action, i !== null) {
      var x = {
        payload: v,
        action: i,
        next: null,
        isTransition: !0,
        status: "pending",
        value: null,
        reason: null,
        listeners: [],
        then: function(P) {
          x.listeners.push(P);
        }
      };
      D.T !== null ? l(!0) : x.isTransition = !1, f(x), l = s.pending, l === null ? (x.next = s.pending = x, f_(s, x)) : (x.next = l.next, s.pending = l.next = x);
    }
  }
  function f_(i, s) {
    var l = s.action, f = s.payload, v = i.state;
    if (s.isTransition) {
      var x = D.T, P = {};
      D.T = P;
      try {
        var Y = l(v, f), rt = D.S;
        rt !== null && rt(P, Y), d_(i, s, Y);
      } catch (pt) {
        Gh(i, s, pt);
      } finally {
        x !== null && P.types !== null && (x.types = P.types), D.T = x;
      }
    } else
      try {
        x = l(v, f), d_(i, s, x);
      } catch (pt) {
        Gh(i, s, pt);
      }
  }
  function d_(i, s, l) {
    l !== null && typeof l == "object" && typeof l.then == "function" ? l.then(
      function(f) {
        h_(i, s, f);
      },
      function(f) {
        return Gh(i, s, f);
      }
    ) : h_(i, s, l);
  }
  function h_(i, s, l) {
    s.status = "fulfilled", s.value = l, p_(s), i.state = l, s = i.pending, s !== null && (l = s.next, l === s ? i.pending = null : (l = l.next, s.next = l, f_(i, l)));
  }
  function Gh(i, s, l) {
    var f = i.pending;
    if (i.pending = null, f !== null) {
      f = f.next;
      do
        s.status = "rejected", s.reason = l, p_(s), s = s.next;
      while (s !== f);
    }
    i.action = null;
  }
  function p_(i) {
    i = i.listeners;
    for (var s = 0; s < i.length; s++) (0, i[s])();
  }
  function m_(i, s) {
    return s;
  }
  function g_(i, s) {
    if (Ne) {
      var l = Je.formState;
      if (l !== null) {
        t: {
          var f = me;
          if (Ne) {
            if (nn) {
              e: {
                for (var v = nn, x = zi; v.nodeType !== 8; ) {
                  if (!x) {
                    v = null;
                    break e;
                  }
                  if (v = Bi(
                    v.nextSibling
                  ), v === null) {
                    v = null;
                    break e;
                  }
                }
                x = v.data, v = x === "F!" || x === "F" ? v : null;
              }
              if (v) {
                nn = Bi(
                  v.nextSibling
                ), f = v.data === "F!";
                break t;
              }
            }
            cs(f);
          }
          f = !1;
        }
        f && (s = l[0]);
      }
    }
    return l = ti(), l.memoizedState = l.baseState = s, f = {
      pending: null,
      lanes: 0,
      dispatch: null,
      lastRenderedReducer: m_,
      lastRenderedState: s
    }, l.queue = f, l = P_.bind(
      null,
      me,
      f
    ), f.dispatch = l, f = kh(!1), x = Zh.bind(
      null,
      me,
      !1,
      f.queue
    ), f = ti(), v = {
      state: s,
      dispatch: null,
      action: i,
      pending: null
    }, f.queue = v, l = VT.bind(
      null,
      me,
      v,
      x,
      l
    ), v.dispatch = l, f.memoizedState = i, [s, l, !1];
  }
  function v_(i) {
    var s = mn();
    return __(s, je, i);
  }
  function __(i, s, l) {
    if (s = Hh(
      i,
      s,
      m_
    )[0], i = wu(Nr)[0], typeof s == "object" && s !== null && typeof s.then == "function")
      try {
        var f = zl(s);
      } catch (P) {
        throw P === eo ? mu : P;
      }
    else f = s;
    s = mn();
    var v = s.queue, x = v.dispatch;
    return l !== s.memoizedState && (me.flags |= 2048, ao(
      9,
      { destroy: void 0 },
      kT.bind(null, v, l),
      null
    )), [f, x, i];
  }
  function kT(i, s) {
    i.action = s;
  }
  function y_(i) {
    var s = mn(), l = je;
    if (l !== null)
      return __(s, l, i);
    mn(), s = s.memoizedState, l = mn();
    var f = l.queue.dispatch;
    return l.memoizedState = i, [s, f, !1];
  }
  function ao(i, s, l, f) {
    return i = { tag: i, create: l, deps: f, inst: s, next: null }, s = me.updateQueue, s === null && (s = Mu(), me.updateQueue = s), l = s.lastEffect, l === null ? s.lastEffect = i.next = i : (f = l.next, l.next = i, i.next = f, s.lastEffect = i), i;
  }
  function x_() {
    return mn().memoizedState;
  }
  function Tu(i, s, l, f) {
    var v = ti();
    me.flags |= i, v.memoizedState = ao(
      1 | s,
      { destroy: void 0 },
      l,
      f === void 0 ? null : f
    );
  }
  function Au(i, s, l, f) {
    var v = mn();
    f = f === void 0 ? null : f;
    var x = v.memoizedState.inst;
    je !== null && f !== null && Oh(f, je.memoizedState.deps) ? v.memoizedState = ao(s, x, l, f) : (me.flags |= i, v.memoizedState = ao(
      1 | s,
      x,
      l,
      f
    ));
  }
  function S_(i, s) {
    Tu(8390656, 8, i, s);
  }
  function Xh(i, s) {
    Au(2048, 8, i, s);
  }
  function GT(i) {
    me.flags |= 4;
    var s = me.updateQueue;
    if (s === null)
      s = Mu(), me.updateQueue = s, s.events = [i];
    else {
      var l = s.events;
      l === null ? s.events = [i] : l.push(i);
    }
  }
  function b_(i) {
    var s = mn().memoizedState;
    return GT({ ref: s, nextImpl: i }), function() {
      if ((Be & 2) !== 0) throw Error(r(440));
      return s.impl.apply(void 0, arguments);
    };
  }
  function M_(i, s) {
    return Au(4, 2, i, s);
  }
  function E_(i, s) {
    return Au(4, 4, i, s);
  }
  function w_(i, s) {
    if (typeof s == "function") {
      i = i();
      var l = s(i);
      return function() {
        typeof l == "function" ? l() : s(null);
      };
    }
    if (s != null)
      return i = i(), s.current = i, function() {
        s.current = null;
      };
  }
  function T_(i, s, l) {
    l = l != null ? l.concat([i]) : null, Au(4, 4, w_.bind(null, s, i), l);
  }
  function jh() {
  }
  function A_(i, s) {
    var l = mn();
    s = s === void 0 ? null : s;
    var f = l.memoizedState;
    return s !== null && Oh(s, f[1]) ? f[0] : (l.memoizedState = [i, s], i);
  }
  function C_(i, s) {
    var l = mn();
    s = s === void 0 ? null : s;
    var f = l.memoizedState;
    if (s !== null && Oh(s, f[1]))
      return f[0];
    if (f = i(), ca) {
      Gt(!0);
      try {
        i();
      } finally {
        Gt(!1);
      }
    }
    return l.memoizedState = [f, s], f;
  }
  function Wh(i, s, l) {
    return l === void 0 || (Dr & 1073741824) !== 0 && (Ce & 261930) === 0 ? i.memoizedState = s : (i.memoizedState = l, i = Ry(), me.lanes |= i, _s |= i, l);
  }
  function R_(i, s, l, f) {
    return vi(l, s) ? l : io.current !== null ? (i = Wh(i, l, f), vi(i, s) || (yn = !0), i) : (Dr & 42) === 0 || (Dr & 1073741824) !== 0 && (Ce & 261930) === 0 ? (yn = !0, i.memoizedState = l) : (i = Ry(), me.lanes |= i, _s |= i, s);
  }
  function D_(i, s, l, f, v) {
    var x = V.p;
    V.p = x !== 0 && 8 > x ? x : 8;
    var P = D.T, Y = {};
    D.T = Y, Zh(i, !1, s, l);
    try {
      var rt = v(), pt = D.S;
      if (pt !== null && pt(Y, rt), rt !== null && typeof rt == "object" && typeof rt.then == "function") {
        var bt = BT(
          rt,
          f
        );
        Il(
          i,
          s,
          bt,
          Mi(i)
        );
      } else
        Il(
          i,
          s,
          f,
          Mi(i)
        );
    } catch (At) {
      Il(
        i,
        s,
        { then: function() {
        }, status: "rejected", reason: At },
        Mi()
      );
    } finally {
      V.p = x, P !== null && Y.types !== null && (P.types = Y.types), D.T = P;
    }
  }
  function XT() {
  }
  function Yh(i, s, l, f) {
    if (i.tag !== 5) throw Error(r(476));
    var v = N_(i).queue;
    D_(
      i,
      v,
      s,
      H,
      l === null ? XT : function() {
        return L_(i), l(f);
      }
    );
  }
  function N_(i) {
    var s = i.memoizedState;
    if (s !== null) return s;
    s = {
      memoizedState: H,
      baseState: H,
      baseQueue: null,
      queue: {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: Nr,
        lastRenderedState: H
      },
      next: null
    };
    var l = {};
    return s.next = {
      memoizedState: l,
      baseState: l,
      baseQueue: null,
      queue: {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: Nr,
        lastRenderedState: l
      },
      next: null
    }, i.memoizedState = s, i = i.alternate, i !== null && (i.memoizedState = s), s;
  }
  function L_(i) {
    var s = N_(i);
    s.next === null && (s = i.alternate.memoizedState), Il(
      i,
      s.next.queue,
      {},
      Mi()
    );
  }
  function qh() {
    return Vn(tc);
  }
  function U_() {
    return mn().memoizedState;
  }
  function O_() {
    return mn().memoizedState;
  }
  function jT(i) {
    for (var s = i.return; s !== null; ) {
      switch (s.tag) {
        case 24:
        case 3:
          var l = Mi();
          i = ds(l);
          var f = hs(s, i, l);
          f !== null && (ui(f, s, l), Ll(f, s, l)), s = { cache: Mh() }, i.payload = s;
          return;
      }
      s = s.return;
    }
  }
  function WT(i, s, l) {
    var f = Mi();
    l = {
      lane: f,
      revertLane: 0,
      gesture: null,
      action: l,
      hasEagerState: !1,
      eagerState: null,
      next: null
    }, Cu(i) ? z_(s, l) : (l = dh(i, s, l, f), l !== null && (ui(l, i, f), I_(l, s, f)));
  }
  function P_(i, s, l) {
    var f = Mi();
    Il(i, s, l, f);
  }
  function Il(i, s, l, f) {
    var v = {
      lane: f,
      revertLane: 0,
      gesture: null,
      action: l,
      hasEagerState: !1,
      eagerState: null,
      next: null
    };
    if (Cu(i)) z_(s, v);
    else {
      var x = i.alternate;
      if (i.lanes === 0 && (x === null || x.lanes === 0) && (x = s.lastRenderedReducer, x !== null))
        try {
          var P = s.lastRenderedState, Y = x(P, l);
          if (v.hasEagerState = !0, v.eagerState = Y, vi(Y, P))
            return lu(i, s, v, 0), Je === null && ou(), !1;
        } catch {
        } finally {
        }
      if (l = dh(i, s, v, f), l !== null)
        return ui(l, i, f), I_(l, s, f), !0;
    }
    return !1;
  }
  function Zh(i, s, l, f) {
    if (f = {
      lane: 2,
      revertLane: Ap(),
      gesture: null,
      action: f,
      hasEagerState: !1,
      eagerState: null,
      next: null
    }, Cu(i)) {
      if (s) throw Error(r(479));
    } else
      s = dh(
        i,
        l,
        f,
        2
      ), s !== null && ui(s, i, 2);
  }
  function Cu(i) {
    var s = i.alternate;
    return i === me || s !== null && s === me;
  }
  function z_(i, s) {
    ro = Su = !0;
    var l = i.pending;
    l === null ? s.next = s : (s.next = l.next, l.next = s), i.pending = s;
  }
  function I_(i, s, l) {
    if ((l & 4194048) !== 0) {
      var f = s.lanes;
      f &= i.pendingLanes, l |= f, s.lanes = l, qs(i, l);
    }
  }
  var Bl = {
    readContext: Vn,
    use: Eu,
    useCallback: cn,
    useContext: cn,
    useEffect: cn,
    useImperativeHandle: cn,
    useLayoutEffect: cn,
    useInsertionEffect: cn,
    useMemo: cn,
    useReducer: cn,
    useRef: cn,
    useState: cn,
    useDebugValue: cn,
    useDeferredValue: cn,
    useTransition: cn,
    useSyncExternalStore: cn,
    useId: cn,
    useHostTransitionStatus: cn,
    useFormState: cn,
    useActionState: cn,
    useOptimistic: cn,
    useMemoCache: cn,
    useCacheRefresh: cn
  };
  Bl.useEffectEvent = cn;
  var B_ = {
    readContext: Vn,
    use: Eu,
    useCallback: function(i, s) {
      return ti().memoizedState = [
        i,
        s === void 0 ? null : s
      ], i;
    },
    useContext: Vn,
    useEffect: S_,
    useImperativeHandle: function(i, s, l) {
      l = l != null ? l.concat([i]) : null, Tu(
        4194308,
        4,
        w_.bind(null, s, i),
        l
      );
    },
    useLayoutEffect: function(i, s) {
      return Tu(4194308, 4, i, s);
    },
    useInsertionEffect: function(i, s) {
      Tu(4, 2, i, s);
    },
    useMemo: function(i, s) {
      var l = ti();
      s = s === void 0 ? null : s;
      var f = i();
      if (ca) {
        Gt(!0);
        try {
          i();
        } finally {
          Gt(!1);
        }
      }
      return l.memoizedState = [f, s], f;
    },
    useReducer: function(i, s, l) {
      var f = ti();
      if (l !== void 0) {
        var v = l(s);
        if (ca) {
          Gt(!0);
          try {
            l(s);
          } finally {
            Gt(!1);
          }
        }
      } else v = s;
      return f.memoizedState = f.baseState = v, i = {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: i,
        lastRenderedState: v
      }, f.queue = i, i = i.dispatch = WT.bind(
        null,
        me,
        i
      ), [f.memoizedState, i];
    },
    useRef: function(i) {
      var s = ti();
      return i = { current: i }, s.memoizedState = i;
    },
    useState: function(i) {
      i = kh(i);
      var s = i.queue, l = P_.bind(null, me, s);
      return s.dispatch = l, [i.memoizedState, l];
    },
    useDebugValue: jh,
    useDeferredValue: function(i, s) {
      var l = ti();
      return Wh(l, i, s);
    },
    useTransition: function() {
      var i = kh(!1);
      return i = D_.bind(
        null,
        me,
        i.queue,
        !0,
        !1
      ), ti().memoizedState = i, [!1, i];
    },
    useSyncExternalStore: function(i, s, l) {
      var f = me, v = ti();
      if (Ne) {
        if (l === void 0)
          throw Error(r(407));
        l = l();
      } else {
        if (l = s(), Je === null)
          throw Error(r(349));
        (Ce & 127) !== 0 || s_(f, s, l);
      }
      v.memoizedState = l;
      var x = { value: l, getSnapshot: s };
      return v.queue = x, S_(o_.bind(null, f, x, i), [
        i
      ]), f.flags |= 2048, ao(
        9,
        { destroy: void 0 },
        a_.bind(
          null,
          f,
          x,
          l,
          s
        ),
        null
      ), l;
    },
    useId: function() {
      var i = ti(), s = Je.identifierPrefix;
      if (Ne) {
        var l = rr, f = ir;
        l = (f & ~(1 << 32 - le(f) - 1)).toString(32) + l, s = "_" + s + "R_" + l, l = bu++, 0 < l && (s += "H" + l.toString(32)), s += "_";
      } else
        l = FT++, s = "_" + s + "r_" + l.toString(32) + "_";
      return i.memoizedState = s;
    },
    useHostTransitionStatus: qh,
    useFormState: g_,
    useActionState: g_,
    useOptimistic: function(i) {
      var s = ti();
      s.memoizedState = s.baseState = i;
      var l = {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: null,
        lastRenderedState: null
      };
      return s.queue = l, s = Zh.bind(
        null,
        me,
        !0,
        l
      ), l.dispatch = s, [i, s];
    },
    useMemoCache: Fh,
    useCacheRefresh: function() {
      return ti().memoizedState = jT.bind(
        null,
        me
      );
    },
    useEffectEvent: function(i) {
      var s = ti(), l = { impl: i };
      return s.memoizedState = l, function() {
        if ((Be & 2) !== 0)
          throw Error(r(440));
        return l.impl.apply(void 0, arguments);
      };
    }
  }, $h = {
    readContext: Vn,
    use: Eu,
    useCallback: A_,
    useContext: Vn,
    useEffect: Xh,
    useImperativeHandle: T_,
    useInsertionEffect: M_,
    useLayoutEffect: E_,
    useMemo: C_,
    useReducer: wu,
    useRef: x_,
    useState: function() {
      return wu(Nr);
    },
    useDebugValue: jh,
    useDeferredValue: function(i, s) {
      var l = mn();
      return R_(
        l,
        je.memoizedState,
        i,
        s
      );
    },
    useTransition: function() {
      var i = wu(Nr)[0], s = mn().memoizedState;
      return [
        typeof i == "boolean" ? i : zl(i),
        s
      ];
    },
    useSyncExternalStore: r_,
    useId: U_,
    useHostTransitionStatus: qh,
    useFormState: v_,
    useActionState: v_,
    useOptimistic: function(i, s) {
      var l = mn();
      return u_(l, je, i, s);
    },
    useMemoCache: Fh,
    useCacheRefresh: O_
  };
  $h.useEffectEvent = b_;
  var F_ = {
    readContext: Vn,
    use: Eu,
    useCallback: A_,
    useContext: Vn,
    useEffect: Xh,
    useImperativeHandle: T_,
    useInsertionEffect: M_,
    useLayoutEffect: E_,
    useMemo: C_,
    useReducer: Vh,
    useRef: x_,
    useState: function() {
      return Vh(Nr);
    },
    useDebugValue: jh,
    useDeferredValue: function(i, s) {
      var l = mn();
      return je === null ? Wh(l, i, s) : R_(
        l,
        je.memoizedState,
        i,
        s
      );
    },
    useTransition: function() {
      var i = Vh(Nr)[0], s = mn().memoizedState;
      return [
        typeof i == "boolean" ? i : zl(i),
        s
      ];
    },
    useSyncExternalStore: r_,
    useId: U_,
    useHostTransitionStatus: qh,
    useFormState: y_,
    useActionState: y_,
    useOptimistic: function(i, s) {
      var l = mn();
      return je !== null ? u_(l, je, i, s) : (l.baseState = i, [i, l.queue.dispatch]);
    },
    useMemoCache: Fh,
    useCacheRefresh: O_
  };
  F_.useEffectEvent = b_;
  function Kh(i, s, l, f) {
    s = i.memoizedState, l = l(f, s), l = l == null ? s : m({}, s, l), i.memoizedState = l, i.lanes === 0 && (i.updateQueue.baseState = l);
  }
  var Qh = {
    enqueueSetState: function(i, s, l) {
      i = i._reactInternals;
      var f = Mi(), v = ds(f);
      v.payload = s, l != null && (v.callback = l), s = hs(i, v, f), s !== null && (ui(s, i, f), Ll(s, i, f));
    },
    enqueueReplaceState: function(i, s, l) {
      i = i._reactInternals;
      var f = Mi(), v = ds(f);
      v.tag = 1, v.payload = s, l != null && (v.callback = l), s = hs(i, v, f), s !== null && (ui(s, i, f), Ll(s, i, f));
    },
    enqueueForceUpdate: function(i, s) {
      i = i._reactInternals;
      var l = Mi(), f = ds(l);
      f.tag = 2, s != null && (f.callback = s), s = hs(i, f, l), s !== null && (ui(s, i, l), Ll(s, i, l));
    }
  };
  function H_(i, s, l, f, v, x, P) {
    return i = i.stateNode, typeof i.shouldComponentUpdate == "function" ? i.shouldComponentUpdate(f, x, P) : s.prototype && s.prototype.isPureReactComponent ? !El(l, f) || !El(v, x) : !0;
  }
  function V_(i, s, l, f) {
    i = s.state, typeof s.componentWillReceiveProps == "function" && s.componentWillReceiveProps(l, f), typeof s.UNSAFE_componentWillReceiveProps == "function" && s.UNSAFE_componentWillReceiveProps(l, f), s.state !== i && Qh.enqueueReplaceState(s, s.state, null);
  }
  function ua(i, s) {
    var l = s;
    if ("ref" in s) {
      l = {};
      for (var f in s)
        f !== "ref" && (l[f] = s[f]);
    }
    if (i = i.defaultProps) {
      l === s && (l = m({}, l));
      for (var v in i)
        l[v] === void 0 && (l[v] = i[v]);
    }
    return l;
  }
  function k_(i) {
    au(i);
  }
  function G_(i) {
    console.error(i);
  }
  function X_(i) {
    au(i);
  }
  function Ru(i, s) {
    try {
      var l = i.onUncaughtError;
      l(s.value, { componentStack: s.stack });
    } catch (f) {
      setTimeout(function() {
        throw f;
      });
    }
  }
  function j_(i, s, l) {
    try {
      var f = i.onCaughtError;
      f(l.value, {
        componentStack: l.stack,
        errorBoundary: s.tag === 1 ? s.stateNode : null
      });
    } catch (v) {
      setTimeout(function() {
        throw v;
      });
    }
  }
  function Jh(i, s, l) {
    return l = ds(l), l.tag = 3, l.payload = { element: null }, l.callback = function() {
      Ru(i, s);
    }, l;
  }
  function W_(i) {
    return i = ds(i), i.tag = 3, i;
  }
  function Y_(i, s, l, f) {
    var v = l.type.getDerivedStateFromError;
    if (typeof v == "function") {
      var x = f.value;
      i.payload = function() {
        return v(x);
      }, i.callback = function() {
        j_(s, l, f);
      };
    }
    var P = l.stateNode;
    P !== null && typeof P.componentDidCatch == "function" && (i.callback = function() {
      j_(s, l, f), typeof v != "function" && (ys === null ? ys = /* @__PURE__ */ new Set([this]) : ys.add(this));
      var Y = f.stack;
      this.componentDidCatch(f.value, {
        componentStack: Y !== null ? Y : ""
      });
    });
  }
  function YT(i, s, l, f, v) {
    if (l.flags |= 32768, f !== null && typeof f == "object" && typeof f.then == "function") {
      if (s = l.alternate, s !== null && Qa(
        s,
        l,
        v,
        !0
      ), l = yi.current, l !== null) {
        switch (l.tag) {
          case 31:
          case 13:
            return Ii === null ? Vu() : l.alternate === null && un === 0 && (un = 3), l.flags &= -257, l.flags |= 65536, l.lanes = v, f === gu ? l.flags |= 16384 : (s = l.updateQueue, s === null ? l.updateQueue = /* @__PURE__ */ new Set([f]) : s.add(f), Ep(i, f, v)), !1;
          case 22:
            return l.flags |= 65536, f === gu ? l.flags |= 16384 : (s = l.updateQueue, s === null ? (s = {
              transitions: null,
              markerInstances: null,
              retryQueue: /* @__PURE__ */ new Set([f])
            }, l.updateQueue = s) : (l = s.retryQueue, l === null ? s.retryQueue = /* @__PURE__ */ new Set([f]) : l.add(f)), Ep(i, f, v)), !1;
        }
        throw Error(r(435, l.tag));
      }
      return Ep(i, f, v), Vu(), !1;
    }
    if (Ne)
      return s = yi.current, s !== null ? ((s.flags & 65536) === 0 && (s.flags |= 256), s.flags |= 65536, s.lanes = v, f !== _h && (i = Error(r(422), { cause: f }), Al(Ui(i, l)))) : (f !== _h && (s = Error(r(423), {
        cause: f
      }), Al(
        Ui(s, l)
      )), i = i.current.alternate, i.flags |= 65536, v &= -v, i.lanes |= v, f = Ui(f, l), v = Jh(
        i.stateNode,
        f,
        v
      ), Rh(i, v), un !== 4 && (un = 2)), !1;
    var x = Error(r(520), { cause: f });
    if (x = Ui(x, l), Wl === null ? Wl = [x] : Wl.push(x), un !== 4 && (un = 2), s === null) return !0;
    f = Ui(f, l), l = s;
    do {
      switch (l.tag) {
        case 3:
          return l.flags |= 65536, i = v & -v, l.lanes |= i, i = Jh(l.stateNode, f, i), Rh(l, i), !1;
        case 1:
          if (s = l.type, x = l.stateNode, (l.flags & 128) === 0 && (typeof s.getDerivedStateFromError == "function" || x !== null && typeof x.componentDidCatch == "function" && (ys === null || !ys.has(x))))
            return l.flags |= 65536, v &= -v, l.lanes |= v, v = W_(v), Y_(
              v,
              i,
              l,
              f
            ), Rh(l, v), !1;
      }
      l = l.return;
    } while (l !== null);
    return !1;
  }
  var tp = Error(r(461)), yn = !1;
  function kn(i, s, l, f) {
    s.child = i === null ? Kv(s, null, l, f) : la(
      s,
      i.child,
      l,
      f
    );
  }
  function q_(i, s, l, f, v) {
    l = l.render;
    var x = s.ref;
    if ("ref" in f) {
      var P = {};
      for (var Y in f)
        Y !== "ref" && (P[Y] = f[Y]);
    } else P = f;
    return ra(s), f = Ph(
      i,
      s,
      l,
      P,
      x,
      v
    ), Y = zh(), i !== null && !yn ? (Ih(i, s, v), Lr(i, s, v)) : (Ne && Y && gh(s), s.flags |= 1, kn(i, s, f, v), s.child);
  }
  function Z_(i, s, l, f, v) {
    if (i === null) {
      var x = l.type;
      return typeof x == "function" && !hh(x) && x.defaultProps === void 0 && l.compare === null ? (s.tag = 15, s.type = x, $_(
        i,
        s,
        x,
        f,
        v
      )) : (i = uu(
        l.type,
        null,
        f,
        s,
        s.mode,
        v
      ), i.ref = s.ref, i.return = s, s.child = i);
    }
    if (x = i.child, !lp(i, v)) {
      var P = x.memoizedProps;
      if (l = l.compare, l = l !== null ? l : El, l(P, f) && i.ref === s.ref)
        return Lr(i, s, v);
    }
    return s.flags |= 1, i = Tr(x, f), i.ref = s.ref, i.return = s, s.child = i;
  }
  function $_(i, s, l, f, v) {
    if (i !== null) {
      var x = i.memoizedProps;
      if (El(x, f) && i.ref === s.ref)
        if (yn = !1, s.pendingProps = f = x, lp(i, v))
          (i.flags & 131072) !== 0 && (yn = !0);
        else
          return s.lanes = i.lanes, Lr(i, s, v);
    }
    return ep(
      i,
      s,
      l,
      f,
      v
    );
  }
  function K_(i, s, l, f) {
    var v = f.children, x = i !== null ? i.memoizedState : null;
    if (i === null && s.stateNode === null && (s.stateNode = {
      _visibility: 1,
      _pendingMarkers: null,
      _retryCache: null,
      _transitions: null
    }), f.mode === "hidden") {
      if ((s.flags & 128) !== 0) {
        if (x = x !== null ? x.baseLanes | l : l, i !== null) {
          for (f = s.child = i.child, v = 0; f !== null; )
            v = v | f.lanes | f.childLanes, f = f.sibling;
          f = v & ~x;
        } else f = 0, s.child = null;
        return Q_(
          i,
          s,
          x,
          l,
          f
        );
      }
      if ((l & 536870912) !== 0)
        s.memoizedState = { baseLanes: 0, cachePool: null }, i !== null && pu(
          s,
          x !== null ? x.cachePool : null
        ), x !== null ? t_(s, x) : Nh(), e_(s);
      else
        return f = s.lanes = 536870912, Q_(
          i,
          s,
          x !== null ? x.baseLanes | l : l,
          l,
          f
        );
    } else
      x !== null ? (pu(s, x.cachePool), t_(s, x), ms(), s.memoizedState = null) : (i !== null && pu(s, null), Nh(), ms());
    return kn(i, s, v, l), s.child;
  }
  function Fl(i, s) {
    return i !== null && i.tag === 22 || s.stateNode !== null || (s.stateNode = {
      _visibility: 1,
      _pendingMarkers: null,
      _retryCache: null,
      _transitions: null
    }), s.sibling;
  }
  function Q_(i, s, l, f, v) {
    var x = wh();
    return x = x === null ? null : { parent: vn._currentValue, pool: x }, s.memoizedState = {
      baseLanes: l,
      cachePool: x
    }, i !== null && pu(s, null), Nh(), e_(s), i !== null && Qa(i, s, f, !0), s.childLanes = v, null;
  }
  function Du(i, s) {
    return s = Lu(
      { mode: s.mode, children: s.children },
      i.mode
    ), s.ref = i.ref, i.child = s, s.return = i, s;
  }
  function J_(i, s, l) {
    return la(s, i.child, null, l), i = Du(s, s.pendingProps), i.flags |= 2, xi(s), s.memoizedState = null, i;
  }
  function qT(i, s, l) {
    var f = s.pendingProps, v = (s.flags & 128) !== 0;
    if (s.flags &= -129, i === null) {
      if (Ne) {
        if (f.mode === "hidden")
          return i = Du(s, f), s.lanes = 536870912, Fl(null, i);
        if (Uh(s), (i = nn) ? (i = fx(
          i,
          zi
        ), i = i !== null && i.data === "&" ? i : null, i !== null && (s.memoizedState = {
          dehydrated: i,
          treeContext: os !== null ? { id: ir, overflow: rr } : null,
          retryLane: 536870912,
          hydrationErrors: null
        }, l = zv(i), l.return = s, s.child = l, Hn = s, nn = null)) : i = null, i === null) throw cs(s);
        return s.lanes = 536870912, null;
      }
      return Du(s, f);
    }
    var x = i.memoizedState;
    if (x !== null) {
      var P = x.dehydrated;
      if (Uh(s), v)
        if (s.flags & 256)
          s.flags &= -257, s = J_(
            i,
            s,
            l
          );
        else if (s.memoizedState !== null)
          s.child = i.child, s.flags |= 128, s = null;
        else throw Error(r(558));
      else if (yn || Qa(i, s, l, !1), v = (l & i.childLanes) !== 0, yn || v) {
        if (f = Je, f !== null && (P = Di(f, l), P !== 0 && P !== x.retryLane))
          throw x.retryLane = P, ta(i, P), ui(f, i, P), tp;
        Vu(), s = J_(
          i,
          s,
          l
        );
      } else
        i = x.treeContext, nn = Bi(P.nextSibling), Hn = s, Ne = !0, ls = null, zi = !1, i !== null && Fv(s, i), s = Du(s, f), s.flags |= 4096;
      return s;
    }
    return i = Tr(i.child, {
      mode: f.mode,
      children: f.children
    }), i.ref = s.ref, s.child = i, i.return = s, i;
  }
  function Nu(i, s) {
    var l = s.ref;
    if (l === null)
      i !== null && i.ref !== null && (s.flags |= 4194816);
    else {
      if (typeof l != "function" && typeof l != "object")
        throw Error(r(284));
      (i === null || i.ref !== l) && (s.flags |= 4194816);
    }
  }
  function ep(i, s, l, f, v) {
    return ra(s), l = Ph(
      i,
      s,
      l,
      f,
      void 0,
      v
    ), f = zh(), i !== null && !yn ? (Ih(i, s, v), Lr(i, s, v)) : (Ne && f && gh(s), s.flags |= 1, kn(i, s, l, v), s.child);
  }
  function ty(i, s, l, f, v, x) {
    return ra(s), s.updateQueue = null, l = i_(
      s,
      f,
      l,
      v
    ), n_(i), f = zh(), i !== null && !yn ? (Ih(i, s, x), Lr(i, s, x)) : (Ne && f && gh(s), s.flags |= 1, kn(i, s, l, x), s.child);
  }
  function ey(i, s, l, f, v) {
    if (ra(s), s.stateNode === null) {
      var x = qa, P = l.contextType;
      typeof P == "object" && P !== null && (x = Vn(P)), x = new l(f, x), s.memoizedState = x.state !== null && x.state !== void 0 ? x.state : null, x.updater = Qh, s.stateNode = x, x._reactInternals = s, x = s.stateNode, x.props = f, x.state = s.memoizedState, x.refs = {}, Ah(s), P = l.contextType, x.context = typeof P == "object" && P !== null ? Vn(P) : qa, x.state = s.memoizedState, P = l.getDerivedStateFromProps, typeof P == "function" && (Kh(
        s,
        l,
        P,
        f
      ), x.state = s.memoizedState), typeof l.getDerivedStateFromProps == "function" || typeof x.getSnapshotBeforeUpdate == "function" || typeof x.UNSAFE_componentWillMount != "function" && typeof x.componentWillMount != "function" || (P = x.state, typeof x.componentWillMount == "function" && x.componentWillMount(), typeof x.UNSAFE_componentWillMount == "function" && x.UNSAFE_componentWillMount(), P !== x.state && Qh.enqueueReplaceState(x, x.state, null), Ol(s, f, x, v), Ul(), x.state = s.memoizedState), typeof x.componentDidMount == "function" && (s.flags |= 4194308), f = !0;
    } else if (i === null) {
      x = s.stateNode;
      var Y = s.memoizedProps, rt = ua(l, Y);
      x.props = rt;
      var pt = x.context, bt = l.contextType;
      P = qa, typeof bt == "object" && bt !== null && (P = Vn(bt));
      var At = l.getDerivedStateFromProps;
      bt = typeof At == "function" || typeof x.getSnapshotBeforeUpdate == "function", Y = s.pendingProps !== Y, bt || typeof x.UNSAFE_componentWillReceiveProps != "function" && typeof x.componentWillReceiveProps != "function" || (Y || pt !== P) && V_(
        s,
        x,
        f,
        P
      ), fs = !1;
      var vt = s.memoizedState;
      x.state = vt, Ol(s, f, x, v), Ul(), pt = s.memoizedState, Y || vt !== pt || fs ? (typeof At == "function" && (Kh(
        s,
        l,
        At,
        f
      ), pt = s.memoizedState), (rt = fs || H_(
        s,
        l,
        rt,
        f,
        vt,
        pt,
        P
      )) ? (bt || typeof x.UNSAFE_componentWillMount != "function" && typeof x.componentWillMount != "function" || (typeof x.componentWillMount == "function" && x.componentWillMount(), typeof x.UNSAFE_componentWillMount == "function" && x.UNSAFE_componentWillMount()), typeof x.componentDidMount == "function" && (s.flags |= 4194308)) : (typeof x.componentDidMount == "function" && (s.flags |= 4194308), s.memoizedProps = f, s.memoizedState = pt), x.props = f, x.state = pt, x.context = P, f = rt) : (typeof x.componentDidMount == "function" && (s.flags |= 4194308), f = !1);
    } else {
      x = s.stateNode, Ch(i, s), P = s.memoizedProps, bt = ua(l, P), x.props = bt, At = s.pendingProps, vt = x.context, pt = l.contextType, rt = qa, typeof pt == "object" && pt !== null && (rt = Vn(pt)), Y = l.getDerivedStateFromProps, (pt = typeof Y == "function" || typeof x.getSnapshotBeforeUpdate == "function") || typeof x.UNSAFE_componentWillReceiveProps != "function" && typeof x.componentWillReceiveProps != "function" || (P !== At || vt !== rt) && V_(
        s,
        x,
        f,
        rt
      ), fs = !1, vt = s.memoizedState, x.state = vt, Ol(s, f, x, v), Ul();
      var xt = s.memoizedState;
      P !== At || vt !== xt || fs || i !== null && i.dependencies !== null && du(i.dependencies) ? (typeof Y == "function" && (Kh(
        s,
        l,
        Y,
        f
      ), xt = s.memoizedState), (bt = fs || H_(
        s,
        l,
        bt,
        f,
        vt,
        xt,
        rt
      ) || i !== null && i.dependencies !== null && du(i.dependencies)) ? (pt || typeof x.UNSAFE_componentWillUpdate != "function" && typeof x.componentWillUpdate != "function" || (typeof x.componentWillUpdate == "function" && x.componentWillUpdate(f, xt, rt), typeof x.UNSAFE_componentWillUpdate == "function" && x.UNSAFE_componentWillUpdate(
        f,
        xt,
        rt
      )), typeof x.componentDidUpdate == "function" && (s.flags |= 4), typeof x.getSnapshotBeforeUpdate == "function" && (s.flags |= 1024)) : (typeof x.componentDidUpdate != "function" || P === i.memoizedProps && vt === i.memoizedState || (s.flags |= 4), typeof x.getSnapshotBeforeUpdate != "function" || P === i.memoizedProps && vt === i.memoizedState || (s.flags |= 1024), s.memoizedProps = f, s.memoizedState = xt), x.props = f, x.state = xt, x.context = rt, f = bt) : (typeof x.componentDidUpdate != "function" || P === i.memoizedProps && vt === i.memoizedState || (s.flags |= 4), typeof x.getSnapshotBeforeUpdate != "function" || P === i.memoizedProps && vt === i.memoizedState || (s.flags |= 1024), f = !1);
    }
    return x = f, Nu(i, s), f = (s.flags & 128) !== 0, x || f ? (x = s.stateNode, l = f && typeof l.getDerivedStateFromError != "function" ? null : x.render(), s.flags |= 1, i !== null && f ? (s.child = la(
      s,
      i.child,
      null,
      v
    ), s.child = la(
      s,
      null,
      l,
      v
    )) : kn(i, s, l, v), s.memoizedState = x.state, i = s.child) : i = Lr(
      i,
      s,
      v
    ), i;
  }
  function ny(i, s, l, f) {
    return na(), s.flags |= 256, kn(i, s, l, f), s.child;
  }
  var np = {
    dehydrated: null,
    treeContext: null,
    retryLane: 0,
    hydrationErrors: null
  };
  function ip(i) {
    return { baseLanes: i, cachePool: jv() };
  }
  function rp(i, s, l) {
    return i = i !== null ? i.childLanes & ~l : 0, s && (i |= bi), i;
  }
  function iy(i, s, l) {
    var f = s.pendingProps, v = !1, x = (s.flags & 128) !== 0, P;
    if ((P = x) || (P = i !== null && i.memoizedState === null ? !1 : (pn.current & 2) !== 0), P && (v = !0, s.flags &= -129), P = (s.flags & 32) !== 0, s.flags &= -33, i === null) {
      if (Ne) {
        if (v ? ps(s) : ms(), (i = nn) ? (i = fx(
          i,
          zi
        ), i = i !== null && i.data !== "&" ? i : null, i !== null && (s.memoizedState = {
          dehydrated: i,
          treeContext: os !== null ? { id: ir, overflow: rr } : null,
          retryLane: 536870912,
          hydrationErrors: null
        }, l = zv(i), l.return = s, s.child = l, Hn = s, nn = null)) : i = null, i === null) throw cs(s);
        return Hp(i) ? s.lanes = 32 : s.lanes = 536870912, null;
      }
      var Y = f.children;
      return f = f.fallback, v ? (ms(), v = s.mode, Y = Lu(
        { mode: "hidden", children: Y },
        v
      ), f = ea(
        f,
        v,
        l,
        null
      ), Y.return = s, f.return = s, Y.sibling = f, s.child = Y, f = s.child, f.memoizedState = ip(l), f.childLanes = rp(
        i,
        P,
        l
      ), s.memoizedState = np, Fl(null, f)) : (ps(s), sp(s, Y));
    }
    var rt = i.memoizedState;
    if (rt !== null && (Y = rt.dehydrated, Y !== null)) {
      if (x)
        s.flags & 256 ? (ps(s), s.flags &= -257, s = ap(
          i,
          s,
          l
        )) : s.memoizedState !== null ? (ms(), s.child = i.child, s.flags |= 128, s = null) : (ms(), Y = f.fallback, v = s.mode, f = Lu(
          { mode: "visible", children: f.children },
          v
        ), Y = ea(
          Y,
          v,
          l,
          null
        ), Y.flags |= 2, f.return = s, Y.return = s, f.sibling = Y, s.child = f, la(
          s,
          i.child,
          null,
          l
        ), f = s.child, f.memoizedState = ip(l), f.childLanes = rp(
          i,
          P,
          l
        ), s.memoizedState = np, s = Fl(null, f));
      else if (ps(s), Hp(Y)) {
        if (P = Y.nextSibling && Y.nextSibling.dataset, P) var pt = P.dgst;
        P = pt, f = Error(r(419)), f.stack = "", f.digest = P, Al({ value: f, source: null, stack: null }), s = ap(
          i,
          s,
          l
        );
      } else if (yn || Qa(i, s, l, !1), P = (l & i.childLanes) !== 0, yn || P) {
        if (P = Je, P !== null && (f = Di(P, l), f !== 0 && f !== rt.retryLane))
          throw rt.retryLane = f, ta(i, f), ui(P, i, f), tp;
        Fp(Y) || Vu(), s = ap(
          i,
          s,
          l
        );
      } else
        Fp(Y) ? (s.flags |= 192, s.child = i.child, s = null) : (i = rt.treeContext, nn = Bi(
          Y.nextSibling
        ), Hn = s, Ne = !0, ls = null, zi = !1, i !== null && Fv(s, i), s = sp(
          s,
          f.children
        ), s.flags |= 4096);
      return s;
    }
    return v ? (ms(), Y = f.fallback, v = s.mode, rt = i.child, pt = rt.sibling, f = Tr(rt, {
      mode: "hidden",
      children: f.children
    }), f.subtreeFlags = rt.subtreeFlags & 65011712, pt !== null ? Y = Tr(
      pt,
      Y
    ) : (Y = ea(
      Y,
      v,
      l,
      null
    ), Y.flags |= 2), Y.return = s, f.return = s, f.sibling = Y, s.child = f, Fl(null, f), f = s.child, Y = i.child.memoizedState, Y === null ? Y = ip(l) : (v = Y.cachePool, v !== null ? (rt = vn._currentValue, v = v.parent !== rt ? { parent: rt, pool: rt } : v) : v = jv(), Y = {
      baseLanes: Y.baseLanes | l,
      cachePool: v
    }), f.memoizedState = Y, f.childLanes = rp(
      i,
      P,
      l
    ), s.memoizedState = np, Fl(i.child, f)) : (ps(s), l = i.child, i = l.sibling, l = Tr(l, {
      mode: "visible",
      children: f.children
    }), l.return = s, l.sibling = null, i !== null && (P = s.deletions, P === null ? (s.deletions = [i], s.flags |= 16) : P.push(i)), s.child = l, s.memoizedState = null, l);
  }
  function sp(i, s) {
    return s = Lu(
      { mode: "visible", children: s },
      i.mode
    ), s.return = i, i.child = s;
  }
  function Lu(i, s) {
    return i = _i(22, i, null, s), i.lanes = 0, i;
  }
  function ap(i, s, l) {
    return la(s, i.child, null, l), i = sp(
      s,
      s.pendingProps.children
    ), i.flags |= 2, s.memoizedState = null, i;
  }
  function ry(i, s, l) {
    i.lanes |= s;
    var f = i.alternate;
    f !== null && (f.lanes |= s), Sh(i.return, s, l);
  }
  function op(i, s, l, f, v, x) {
    var P = i.memoizedState;
    P === null ? i.memoizedState = {
      isBackwards: s,
      rendering: null,
      renderingStartTime: 0,
      last: f,
      tail: l,
      tailMode: v,
      treeForkCount: x
    } : (P.isBackwards = s, P.rendering = null, P.renderingStartTime = 0, P.last = f, P.tail = l, P.tailMode = v, P.treeForkCount = x);
  }
  function sy(i, s, l) {
    var f = s.pendingProps, v = f.revealOrder, x = f.tail;
    f = f.children;
    var P = pn.current, Y = (P & 2) !== 0;
    if (Y ? (P = P & 1 | 2, s.flags |= 128) : P &= 1, it(pn, P), kn(i, s, f, l), f = Ne ? Tl : 0, !Y && i !== null && (i.flags & 128) !== 0)
      t: for (i = s.child; i !== null; ) {
        if (i.tag === 13)
          i.memoizedState !== null && ry(i, l, s);
        else if (i.tag === 19)
          ry(i, l, s);
        else if (i.child !== null) {
          i.child.return = i, i = i.child;
          continue;
        }
        if (i === s) break t;
        for (; i.sibling === null; ) {
          if (i.return === null || i.return === s)
            break t;
          i = i.return;
        }
        i.sibling.return = i.return, i = i.sibling;
      }
    switch (v) {
      case "forwards":
        for (l = s.child, v = null; l !== null; )
          i = l.alternate, i !== null && xu(i) === null && (v = l), l = l.sibling;
        l = v, l === null ? (v = s.child, s.child = null) : (v = l.sibling, l.sibling = null), op(
          s,
          !1,
          v,
          l,
          x,
          f
        );
        break;
      case "backwards":
      case "unstable_legacy-backwards":
        for (l = null, v = s.child, s.child = null; v !== null; ) {
          if (i = v.alternate, i !== null && xu(i) === null) {
            s.child = v;
            break;
          }
          i = v.sibling, v.sibling = l, l = v, v = i;
        }
        op(
          s,
          !0,
          l,
          null,
          x,
          f
        );
        break;
      case "together":
        op(
          s,
          !1,
          null,
          null,
          void 0,
          f
        );
        break;
      default:
        s.memoizedState = null;
    }
    return s.child;
  }
  function Lr(i, s, l) {
    if (i !== null && (s.dependencies = i.dependencies), _s |= s.lanes, (l & s.childLanes) === 0)
      if (i !== null) {
        if (Qa(
          i,
          s,
          l,
          !1
        ), (l & s.childLanes) === 0)
          return null;
      } else return null;
    if (i !== null && s.child !== i.child)
      throw Error(r(153));
    if (s.child !== null) {
      for (i = s.child, l = Tr(i, i.pendingProps), s.child = l, l.return = s; i.sibling !== null; )
        i = i.sibling, l = l.sibling = Tr(i, i.pendingProps), l.return = s;
      l.sibling = null;
    }
    return s.child;
  }
  function lp(i, s) {
    return (i.lanes & s) !== 0 ? !0 : (i = i.dependencies, !!(i !== null && du(i)));
  }
  function ZT(i, s, l) {
    switch (s.tag) {
      case 3:
        et(s, s.stateNode.containerInfo), us(s, vn, i.memoizedState.cache), na();
        break;
      case 27:
      case 5:
        _t(s);
        break;
      case 4:
        et(s, s.stateNode.containerInfo);
        break;
      case 10:
        us(
          s,
          s.type,
          s.memoizedProps.value
        );
        break;
      case 31:
        if (s.memoizedState !== null)
          return s.flags |= 128, Uh(s), null;
        break;
      case 13:
        var f = s.memoizedState;
        if (f !== null)
          return f.dehydrated !== null ? (ps(s), s.flags |= 128, null) : (l & s.child.childLanes) !== 0 ? iy(i, s, l) : (ps(s), i = Lr(
            i,
            s,
            l
          ), i !== null ? i.sibling : null);
        ps(s);
        break;
      case 19:
        var v = (i.flags & 128) !== 0;
        if (f = (l & s.childLanes) !== 0, f || (Qa(
          i,
          s,
          l,
          !1
        ), f = (l & s.childLanes) !== 0), v) {
          if (f)
            return sy(
              i,
              s,
              l
            );
          s.flags |= 128;
        }
        if (v = s.memoizedState, v !== null && (v.rendering = null, v.tail = null, v.lastEffect = null), it(pn, pn.current), f) break;
        return null;
      case 22:
        return s.lanes = 0, K_(
          i,
          s,
          l,
          s.pendingProps
        );
      case 24:
        us(s, vn, i.memoizedState.cache);
    }
    return Lr(i, s, l);
  }
  function ay(i, s, l) {
    if (i !== null)
      if (i.memoizedProps !== s.pendingProps)
        yn = !0;
      else {
        if (!lp(i, l) && (s.flags & 128) === 0)
          return yn = !1, ZT(
            i,
            s,
            l
          );
        yn = (i.flags & 131072) !== 0;
      }
    else
      yn = !1, Ne && (s.flags & 1048576) !== 0 && Bv(s, Tl, s.index);
    switch (s.lanes = 0, s.tag) {
      case 16:
        t: {
          var f = s.pendingProps;
          if (i = aa(s.elementType), s.type = i, typeof i == "function")
            hh(i) ? (f = ua(i, f), s.tag = 1, s = ey(
              null,
              s,
              i,
              f,
              l
            )) : (s.tag = 0, s = ep(
              null,
              s,
              i,
              f,
              l
            ));
          else {
            if (i != null) {
              var v = i.$$typeof;
              if (v === M) {
                s.tag = 11, s = q_(
                  null,
                  s,
                  i,
                  f,
                  l
                );
                break t;
              } else if (v === N) {
                s.tag = 14, s = Z_(
                  null,
                  s,
                  i,
                  f,
                  l
                );
                break t;
              }
            }
            throw s = C(i) || i, Error(r(306, s, ""));
          }
        }
        return s;
      case 0:
        return ep(
          i,
          s,
          s.type,
          s.pendingProps,
          l
        );
      case 1:
        return f = s.type, v = ua(
          f,
          s.pendingProps
        ), ey(
          i,
          s,
          f,
          v,
          l
        );
      case 3:
        t: {
          if (et(
            s,
            s.stateNode.containerInfo
          ), i === null) throw Error(r(387));
          f = s.pendingProps;
          var x = s.memoizedState;
          v = x.element, Ch(i, s), Ol(s, f, null, l);
          var P = s.memoizedState;
          if (f = P.cache, us(s, vn, f), f !== x.cache && bh(
            s,
            [vn],
            l,
            !0
          ), Ul(), f = P.element, x.isDehydrated)
            if (x = {
              element: f,
              isDehydrated: !1,
              cache: P.cache
            }, s.updateQueue.baseState = x, s.memoizedState = x, s.flags & 256) {
              s = ny(
                i,
                s,
                f,
                l
              );
              break t;
            } else if (f !== v) {
              v = Ui(
                Error(r(424)),
                s
              ), Al(v), s = ny(
                i,
                s,
                f,
                l
              );
              break t;
            } else {
              switch (i = s.stateNode.containerInfo, i.nodeType) {
                case 9:
                  i = i.body;
                  break;
                default:
                  i = i.nodeName === "HTML" ? i.ownerDocument.body : i;
              }
              for (nn = Bi(i.firstChild), Hn = s, Ne = !0, ls = null, zi = !0, l = Kv(
                s,
                null,
                f,
                l
              ), s.child = l; l; )
                l.flags = l.flags & -3 | 4096, l = l.sibling;
            }
          else {
            if (na(), f === v) {
              s = Lr(
                i,
                s,
                l
              );
              break t;
            }
            kn(i, s, f, l);
          }
          s = s.child;
        }
        return s;
      case 26:
        return Nu(i, s), i === null ? (l = vx(
          s.type,
          null,
          s.pendingProps,
          null
        )) ? s.memoizedState = l : Ne || (l = s.type, i = s.pendingProps, f = qu(
          $.current
        ).createElement(l), f[sn] = s, f[Tn] = i, Gn(f, l, i), lt(f), s.stateNode = f) : s.memoizedState = vx(
          s.type,
          i.memoizedProps,
          s.pendingProps,
          i.memoizedState
        ), null;
      case 27:
        return _t(s), i === null && Ne && (f = s.stateNode = px(
          s.type,
          s.pendingProps,
          $.current
        ), Hn = s, zi = !0, v = nn, Ms(s.type) ? (Vp = v, nn = Bi(f.firstChild)) : nn = v), kn(
          i,
          s,
          s.pendingProps.children,
          l
        ), Nu(i, s), i === null && (s.flags |= 4194304), s.child;
      case 5:
        return i === null && Ne && ((v = f = nn) && (f = wA(
          f,
          s.type,
          s.pendingProps,
          zi
        ), f !== null ? (s.stateNode = f, Hn = s, nn = Bi(f.firstChild), zi = !1, v = !0) : v = !1), v || cs(s)), _t(s), v = s.type, x = s.pendingProps, P = i !== null ? i.memoizedProps : null, f = x.children, zp(v, x) ? f = null : P !== null && zp(v, P) && (s.flags |= 32), s.memoizedState !== null && (v = Ph(
          i,
          s,
          HT,
          null,
          null,
          l
        ), tc._currentValue = v), Nu(i, s), kn(i, s, f, l), s.child;
      case 6:
        return i === null && Ne && ((i = l = nn) && (l = TA(
          l,
          s.pendingProps,
          zi
        ), l !== null ? (s.stateNode = l, Hn = s, nn = null, i = !0) : i = !1), i || cs(s)), null;
      case 13:
        return iy(i, s, l);
      case 4:
        return et(
          s,
          s.stateNode.containerInfo
        ), f = s.pendingProps, i === null ? s.child = la(
          s,
          null,
          f,
          l
        ) : kn(i, s, f, l), s.child;
      case 11:
        return q_(
          i,
          s,
          s.type,
          s.pendingProps,
          l
        );
      case 7:
        return kn(
          i,
          s,
          s.pendingProps,
          l
        ), s.child;
      case 8:
        return kn(
          i,
          s,
          s.pendingProps.children,
          l
        ), s.child;
      case 12:
        return kn(
          i,
          s,
          s.pendingProps.children,
          l
        ), s.child;
      case 10:
        return f = s.pendingProps, us(s, s.type, f.value), kn(i, s, f.children, l), s.child;
      case 9:
        return v = s.type._context, f = s.pendingProps.children, ra(s), v = Vn(v), f = f(v), s.flags |= 1, kn(i, s, f, l), s.child;
      case 14:
        return Z_(
          i,
          s,
          s.type,
          s.pendingProps,
          l
        );
      case 15:
        return $_(
          i,
          s,
          s.type,
          s.pendingProps,
          l
        );
      case 19:
        return sy(i, s, l);
      case 31:
        return qT(i, s, l);
      case 22:
        return K_(
          i,
          s,
          l,
          s.pendingProps
        );
      case 24:
        return ra(s), f = Vn(vn), i === null ? (v = wh(), v === null && (v = Je, x = Mh(), v.pooledCache = x, x.refCount++, x !== null && (v.pooledCacheLanes |= l), v = x), s.memoizedState = { parent: f, cache: v }, Ah(s), us(s, vn, v)) : ((i.lanes & l) !== 0 && (Ch(i, s), Ol(s, null, null, l), Ul()), v = i.memoizedState, x = s.memoizedState, v.parent !== f ? (v = { parent: f, cache: f }, s.memoizedState = v, s.lanes === 0 && (s.memoizedState = s.updateQueue.baseState = v), us(s, vn, f)) : (f = x.cache, us(s, vn, f), f !== v.cache && bh(
          s,
          [vn],
          l,
          !0
        ))), kn(
          i,
          s,
          s.pendingProps.children,
          l
        ), s.child;
      case 29:
        throw s.pendingProps;
    }
    throw Error(r(156, s.tag));
  }
  function Ur(i) {
    i.flags |= 4;
  }
  function cp(i, s, l, f, v) {
    if ((s = (i.mode & 32) !== 0) && (s = !1), s) {
      if (i.flags |= 16777216, (v & 335544128) === v)
        if (i.stateNode.complete) i.flags |= 8192;
        else if (Uy()) i.flags |= 8192;
        else
          throw oa = gu, Th;
    } else i.flags &= -16777217;
  }
  function oy(i, s) {
    if (s.type !== "stylesheet" || (s.state.loading & 4) !== 0)
      i.flags &= -16777217;
    else if (i.flags |= 16777216, !bx(s))
      if (Uy()) i.flags |= 8192;
      else
        throw oa = gu, Th;
  }
  function Uu(i, s) {
    s !== null && (i.flags |= 4), i.flags & 16384 && (s = i.tag !== 22 ? dn() : 536870912, i.lanes |= s, uo |= s);
  }
  function Hl(i, s) {
    if (!Ne)
      switch (i.tailMode) {
        case "hidden":
          s = i.tail;
          for (var l = null; s !== null; )
            s.alternate !== null && (l = s), s = s.sibling;
          l === null ? i.tail = null : l.sibling = null;
          break;
        case "collapsed":
          l = i.tail;
          for (var f = null; l !== null; )
            l.alternate !== null && (f = l), l = l.sibling;
          f === null ? s || i.tail === null ? i.tail = null : i.tail.sibling = null : f.sibling = null;
      }
  }
  function rn(i) {
    var s = i.alternate !== null && i.alternate.child === i.child, l = 0, f = 0;
    if (s)
      for (var v = i.child; v !== null; )
        l |= v.lanes | v.childLanes, f |= v.subtreeFlags & 65011712, f |= v.flags & 65011712, v.return = i, v = v.sibling;
    else
      for (v = i.child; v !== null; )
        l |= v.lanes | v.childLanes, f |= v.subtreeFlags, f |= v.flags, v.return = i, v = v.sibling;
    return i.subtreeFlags |= f, i.childLanes = l, s;
  }
  function $T(i, s, l) {
    var f = s.pendingProps;
    switch (vh(s), s.tag) {
      case 16:
      case 15:
      case 0:
      case 11:
      case 7:
      case 8:
      case 12:
      case 9:
      case 14:
        return rn(s), null;
      case 1:
        return rn(s), null;
      case 3:
        return l = s.stateNode, f = null, i !== null && (f = i.memoizedState.cache), s.memoizedState.cache !== f && (s.flags |= 2048), Rr(vn), st(), l.pendingContext && (l.context = l.pendingContext, l.pendingContext = null), (i === null || i.child === null) && (Ka(s) ? Ur(s) : i === null || i.memoizedState.isDehydrated && (s.flags & 256) === 0 || (s.flags |= 1024, yh())), rn(s), null;
      case 26:
        var v = s.type, x = s.memoizedState;
        return i === null ? (Ur(s), x !== null ? (rn(s), oy(s, x)) : (rn(s), cp(
          s,
          v,
          null,
          f,
          l
        ))) : x ? x !== i.memoizedState ? (Ur(s), rn(s), oy(s, x)) : (rn(s), s.flags &= -16777217) : (i = i.memoizedProps, i !== f && Ur(s), rn(s), cp(
          s,
          v,
          i,
          f,
          l
        )), null;
      case 27:
        if (Mt(s), l = $.current, v = s.type, i !== null && s.stateNode != null)
          i.memoizedProps !== f && Ur(s);
        else {
          if (!f) {
            if (s.stateNode === null)
              throw Error(r(166));
            return rn(s), null;
          }
          i = G.current, Ka(s) ? Hv(s) : (i = px(v, f, l), s.stateNode = i, Ur(s));
        }
        return rn(s), null;
      case 5:
        if (Mt(s), v = s.type, i !== null && s.stateNode != null)
          i.memoizedProps !== f && Ur(s);
        else {
          if (!f) {
            if (s.stateNode === null)
              throw Error(r(166));
            return rn(s), null;
          }
          if (x = G.current, Ka(s))
            Hv(s);
          else {
            var P = qu(
              $.current
            );
            switch (x) {
              case 1:
                x = P.createElementNS(
                  "http://www.w3.org/2000/svg",
                  v
                );
                break;
              case 2:
                x = P.createElementNS(
                  "http://www.w3.org/1998/Math/MathML",
                  v
                );
                break;
              default:
                switch (v) {
                  case "svg":
                    x = P.createElementNS(
                      "http://www.w3.org/2000/svg",
                      v
                    );
                    break;
                  case "math":
                    x = P.createElementNS(
                      "http://www.w3.org/1998/Math/MathML",
                      v
                    );
                    break;
                  case "script":
                    x = P.createElement("div"), x.innerHTML = "<script><\/script>", x = x.removeChild(
                      x.firstChild
                    );
                    break;
                  case "select":
                    x = typeof f.is == "string" ? P.createElement("select", {
                      is: f.is
                    }) : P.createElement("select"), f.multiple ? x.multiple = !0 : f.size && (x.size = f.size);
                    break;
                  default:
                    x = typeof f.is == "string" ? P.createElement(v, { is: f.is }) : P.createElement(v);
                }
            }
            x[sn] = s, x[Tn] = f;
            t: for (P = s.child; P !== null; ) {
              if (P.tag === 5 || P.tag === 6)
                x.appendChild(P.stateNode);
              else if (P.tag !== 4 && P.tag !== 27 && P.child !== null) {
                P.child.return = P, P = P.child;
                continue;
              }
              if (P === s) break t;
              for (; P.sibling === null; ) {
                if (P.return === null || P.return === s)
                  break t;
                P = P.return;
              }
              P.sibling.return = P.return, P = P.sibling;
            }
            s.stateNode = x;
            t: switch (Gn(x, v, f), v) {
              case "button":
              case "input":
              case "select":
              case "textarea":
                f = !!f.autoFocus;
                break t;
              case "img":
                f = !0;
                break t;
              default:
                f = !1;
            }
            f && Ur(s);
          }
        }
        return rn(s), cp(
          s,
          s.type,
          i === null ? null : i.memoizedProps,
          s.pendingProps,
          l
        ), null;
      case 6:
        if (i && s.stateNode != null)
          i.memoizedProps !== f && Ur(s);
        else {
          if (typeof f != "string" && s.stateNode === null)
            throw Error(r(166));
          if (i = $.current, Ka(s)) {
            if (i = s.stateNode, l = s.memoizedProps, f = null, v = Hn, v !== null)
              switch (v.tag) {
                case 27:
                case 5:
                  f = v.memoizedProps;
              }
            i[sn] = s, i = !!(i.nodeValue === l || f !== null && f.suppressHydrationWarning === !0 || ix(i.nodeValue, l)), i || cs(s, !0);
          } else
            i = qu(i).createTextNode(
              f
            ), i[sn] = s, s.stateNode = i;
        }
        return rn(s), null;
      case 31:
        if (l = s.memoizedState, i === null || i.memoizedState !== null) {
          if (f = Ka(s), l !== null) {
            if (i === null) {
              if (!f) throw Error(r(318));
              if (i = s.memoizedState, i = i !== null ? i.dehydrated : null, !i) throw Error(r(557));
              i[sn] = s;
            } else
              na(), (s.flags & 128) === 0 && (s.memoizedState = null), s.flags |= 4;
            rn(s), i = !1;
          } else
            l = yh(), i !== null && i.memoizedState !== null && (i.memoizedState.hydrationErrors = l), i = !0;
          if (!i)
            return s.flags & 256 ? (xi(s), s) : (xi(s), null);
          if ((s.flags & 128) !== 0)
            throw Error(r(558));
        }
        return rn(s), null;
      case 13:
        if (f = s.memoizedState, i === null || i.memoizedState !== null && i.memoizedState.dehydrated !== null) {
          if (v = Ka(s), f !== null && f.dehydrated !== null) {
            if (i === null) {
              if (!v) throw Error(r(318));
              if (v = s.memoizedState, v = v !== null ? v.dehydrated : null, !v) throw Error(r(317));
              v[sn] = s;
            } else
              na(), (s.flags & 128) === 0 && (s.memoizedState = null), s.flags |= 4;
            rn(s), v = !1;
          } else
            v = yh(), i !== null && i.memoizedState !== null && (i.memoizedState.hydrationErrors = v), v = !0;
          if (!v)
            return s.flags & 256 ? (xi(s), s) : (xi(s), null);
        }
        return xi(s), (s.flags & 128) !== 0 ? (s.lanes = l, s) : (l = f !== null, i = i !== null && i.memoizedState !== null, l && (f = s.child, v = null, f.alternate !== null && f.alternate.memoizedState !== null && f.alternate.memoizedState.cachePool !== null && (v = f.alternate.memoizedState.cachePool.pool), x = null, f.memoizedState !== null && f.memoizedState.cachePool !== null && (x = f.memoizedState.cachePool.pool), x !== v && (f.flags |= 2048)), l !== i && l && (s.child.flags |= 8192), Uu(s, s.updateQueue), rn(s), null);
      case 4:
        return st(), i === null && Np(s.stateNode.containerInfo), rn(s), null;
      case 10:
        return Rr(s.type), rn(s), null;
      case 19:
        if (q(pn), f = s.memoizedState, f === null) return rn(s), null;
        if (v = (s.flags & 128) !== 0, x = f.rendering, x === null)
          if (v) Hl(f, !1);
          else {
            if (un !== 0 || i !== null && (i.flags & 128) !== 0)
              for (i = s.child; i !== null; ) {
                if (x = xu(i), x !== null) {
                  for (s.flags |= 128, Hl(f, !1), i = x.updateQueue, s.updateQueue = i, Uu(s, i), s.subtreeFlags = 0, i = l, l = s.child; l !== null; )
                    Pv(l, i), l = l.sibling;
                  return it(
                    pn,
                    pn.current & 1 | 2
                  ), Ne && Ar(s, f.treeForkCount), s.child;
                }
                i = i.sibling;
              }
            f.tail !== null && Et() > Bu && (s.flags |= 128, v = !0, Hl(f, !1), s.lanes = 4194304);
          }
        else {
          if (!v)
            if (i = xu(x), i !== null) {
              if (s.flags |= 128, v = !0, i = i.updateQueue, s.updateQueue = i, Uu(s, i), Hl(f, !0), f.tail === null && f.tailMode === "hidden" && !x.alternate && !Ne)
                return rn(s), null;
            } else
              2 * Et() - f.renderingStartTime > Bu && l !== 536870912 && (s.flags |= 128, v = !0, Hl(f, !1), s.lanes = 4194304);
          f.isBackwards ? (x.sibling = s.child, s.child = x) : (i = f.last, i !== null ? i.sibling = x : s.child = x, f.last = x);
        }
        return f.tail !== null ? (i = f.tail, f.rendering = i, f.tail = i.sibling, f.renderingStartTime = Et(), i.sibling = null, l = pn.current, it(
          pn,
          v ? l & 1 | 2 : l & 1
        ), Ne && Ar(s, f.treeForkCount), i) : (rn(s), null);
      case 22:
      case 23:
        return xi(s), Lh(), f = s.memoizedState !== null, i !== null ? i.memoizedState !== null !== f && (s.flags |= 8192) : f && (s.flags |= 8192), f ? (l & 536870912) !== 0 && (s.flags & 128) === 0 && (rn(s), s.subtreeFlags & 6 && (s.flags |= 8192)) : rn(s), l = s.updateQueue, l !== null && Uu(s, l.retryQueue), l = null, i !== null && i.memoizedState !== null && i.memoizedState.cachePool !== null && (l = i.memoizedState.cachePool.pool), f = null, s.memoizedState !== null && s.memoizedState.cachePool !== null && (f = s.memoizedState.cachePool.pool), f !== l && (s.flags |= 2048), i !== null && q(sa), null;
      case 24:
        return l = null, i !== null && (l = i.memoizedState.cache), s.memoizedState.cache !== l && (s.flags |= 2048), Rr(vn), rn(s), null;
      case 25:
        return null;
      case 30:
        return null;
    }
    throw Error(r(156, s.tag));
  }
  function KT(i, s) {
    switch (vh(s), s.tag) {
      case 1:
        return i = s.flags, i & 65536 ? (s.flags = i & -65537 | 128, s) : null;
      case 3:
        return Rr(vn), st(), i = s.flags, (i & 65536) !== 0 && (i & 128) === 0 ? (s.flags = i & -65537 | 128, s) : null;
      case 26:
      case 27:
      case 5:
        return Mt(s), null;
      case 31:
        if (s.memoizedState !== null) {
          if (xi(s), s.alternate === null)
            throw Error(r(340));
          na();
        }
        return i = s.flags, i & 65536 ? (s.flags = i & -65537 | 128, s) : null;
      case 13:
        if (xi(s), i = s.memoizedState, i !== null && i.dehydrated !== null) {
          if (s.alternate === null)
            throw Error(r(340));
          na();
        }
        return i = s.flags, i & 65536 ? (s.flags = i & -65537 | 128, s) : null;
      case 19:
        return q(pn), null;
      case 4:
        return st(), null;
      case 10:
        return Rr(s.type), null;
      case 22:
      case 23:
        return xi(s), Lh(), i !== null && q(sa), i = s.flags, i & 65536 ? (s.flags = i & -65537 | 128, s) : null;
      case 24:
        return Rr(vn), null;
      case 25:
        return null;
      default:
        return null;
    }
  }
  function ly(i, s) {
    switch (vh(s), s.tag) {
      case 3:
        Rr(vn), st();
        break;
      case 26:
      case 27:
      case 5:
        Mt(s);
        break;
      case 4:
        st();
        break;
      case 31:
        s.memoizedState !== null && xi(s);
        break;
      case 13:
        xi(s);
        break;
      case 19:
        q(pn);
        break;
      case 10:
        Rr(s.type);
        break;
      case 22:
      case 23:
        xi(s), Lh(), i !== null && q(sa);
        break;
      case 24:
        Rr(vn);
    }
  }
  function Vl(i, s) {
    try {
      var l = s.updateQueue, f = l !== null ? l.lastEffect : null;
      if (f !== null) {
        var v = f.next;
        l = v;
        do {
          if ((l.tag & i) === i) {
            f = void 0;
            var x = l.create, P = l.inst;
            f = x(), P.destroy = f;
          }
          l = l.next;
        } while (l !== v);
      }
    } catch (Y) {
      Ve(s, s.return, Y);
    }
  }
  function gs(i, s, l) {
    try {
      var f = s.updateQueue, v = f !== null ? f.lastEffect : null;
      if (v !== null) {
        var x = v.next;
        f = x;
        do {
          if ((f.tag & i) === i) {
            var P = f.inst, Y = P.destroy;
            if (Y !== void 0) {
              P.destroy = void 0, v = s;
              var rt = l, pt = Y;
              try {
                pt();
              } catch (bt) {
                Ve(
                  v,
                  rt,
                  bt
                );
              }
            }
          }
          f = f.next;
        } while (f !== x);
      }
    } catch (bt) {
      Ve(s, s.return, bt);
    }
  }
  function cy(i) {
    var s = i.updateQueue;
    if (s !== null) {
      var l = i.stateNode;
      try {
        Jv(s, l);
      } catch (f) {
        Ve(i, i.return, f);
      }
    }
  }
  function uy(i, s, l) {
    l.props = ua(
      i.type,
      i.memoizedProps
    ), l.state = i.memoizedState;
    try {
      l.componentWillUnmount();
    } catch (f) {
      Ve(i, s, f);
    }
  }
  function kl(i, s) {
    try {
      var l = i.ref;
      if (l !== null) {
        switch (i.tag) {
          case 26:
          case 27:
          case 5:
            var f = i.stateNode;
            break;
          case 30:
            f = i.stateNode;
            break;
          default:
            f = i.stateNode;
        }
        typeof l == "function" ? i.refCleanup = l(f) : l.current = f;
      }
    } catch (v) {
      Ve(i, s, v);
    }
  }
  function sr(i, s) {
    var l = i.ref, f = i.refCleanup;
    if (l !== null)
      if (typeof f == "function")
        try {
          f();
        } catch (v) {
          Ve(i, s, v);
        } finally {
          i.refCleanup = null, i = i.alternate, i != null && (i.refCleanup = null);
        }
      else if (typeof l == "function")
        try {
          l(null);
        } catch (v) {
          Ve(i, s, v);
        }
      else l.current = null;
  }
  function fy(i) {
    var s = i.type, l = i.memoizedProps, f = i.stateNode;
    try {
      t: switch (s) {
        case "button":
        case "input":
        case "select":
        case "textarea":
          l.autoFocus && f.focus();
          break t;
        case "img":
          l.src ? f.src = l.src : l.srcSet && (f.srcset = l.srcSet);
      }
    } catch (v) {
      Ve(i, i.return, v);
    }
  }
  function up(i, s, l) {
    try {
      var f = i.stateNode;
      yA(f, i.type, l, s), f[Tn] = s;
    } catch (v) {
      Ve(i, i.return, v);
    }
  }
  function dy(i) {
    return i.tag === 5 || i.tag === 3 || i.tag === 26 || i.tag === 27 && Ms(i.type) || i.tag === 4;
  }
  function fp(i) {
    t: for (; ; ) {
      for (; i.sibling === null; ) {
        if (i.return === null || dy(i.return)) return null;
        i = i.return;
      }
      for (i.sibling.return = i.return, i = i.sibling; i.tag !== 5 && i.tag !== 6 && i.tag !== 18; ) {
        if (i.tag === 27 && Ms(i.type) || i.flags & 2 || i.child === null || i.tag === 4) continue t;
        i.child.return = i, i = i.child;
      }
      if (!(i.flags & 2)) return i.stateNode;
    }
  }
  function dp(i, s, l) {
    var f = i.tag;
    if (f === 5 || f === 6)
      i = i.stateNode, s ? (l.nodeType === 9 ? l.body : l.nodeName === "HTML" ? l.ownerDocument.body : l).insertBefore(i, s) : (s = l.nodeType === 9 ? l.body : l.nodeName === "HTML" ? l.ownerDocument.body : l, s.appendChild(i), l = l._reactRootContainer, l != null || s.onclick !== null || (s.onclick = Er));
    else if (f !== 4 && (f === 27 && Ms(i.type) && (l = i.stateNode, s = null), i = i.child, i !== null))
      for (dp(i, s, l), i = i.sibling; i !== null; )
        dp(i, s, l), i = i.sibling;
  }
  function Ou(i, s, l) {
    var f = i.tag;
    if (f === 5 || f === 6)
      i = i.stateNode, s ? l.insertBefore(i, s) : l.appendChild(i);
    else if (f !== 4 && (f === 27 && Ms(i.type) && (l = i.stateNode), i = i.child, i !== null))
      for (Ou(i, s, l), i = i.sibling; i !== null; )
        Ou(i, s, l), i = i.sibling;
  }
  function hy(i) {
    var s = i.stateNode, l = i.memoizedProps;
    try {
      for (var f = i.type, v = s.attributes; v.length; )
        s.removeAttributeNode(v[0]);
      Gn(s, f, l), s[sn] = i, s[Tn] = l;
    } catch (x) {
      Ve(i, i.return, x);
    }
  }
  var Or = !1, xn = !1, hp = !1, py = typeof WeakSet == "function" ? WeakSet : Set, Pn = null;
  function QT(i, s) {
    if (i = i.containerInfo, Op = ef, i = Tv(i), ah(i)) {
      if ("selectionStart" in i)
        var l = {
          start: i.selectionStart,
          end: i.selectionEnd
        };
      else
        t: {
          l = (l = i.ownerDocument) && l.defaultView || window;
          var f = l.getSelection && l.getSelection();
          if (f && f.rangeCount !== 0) {
            l = f.anchorNode;
            var v = f.anchorOffset, x = f.focusNode;
            f = f.focusOffset;
            try {
              l.nodeType, x.nodeType;
            } catch {
              l = null;
              break t;
            }
            var P = 0, Y = -1, rt = -1, pt = 0, bt = 0, At = i, vt = null;
            e: for (; ; ) {
              for (var xt; At !== l || v !== 0 && At.nodeType !== 3 || (Y = P + v), At !== x || f !== 0 && At.nodeType !== 3 || (rt = P + f), At.nodeType === 3 && (P += At.nodeValue.length), (xt = At.firstChild) !== null; )
                vt = At, At = xt;
              for (; ; ) {
                if (At === i) break e;
                if (vt === l && ++pt === v && (Y = P), vt === x && ++bt === f && (rt = P), (xt = At.nextSibling) !== null) break;
                At = vt, vt = At.parentNode;
              }
              At = xt;
            }
            l = Y === -1 || rt === -1 ? null : { start: Y, end: rt };
          } else l = null;
        }
      l = l || { start: 0, end: 0 };
    } else l = null;
    for (Pp = { focusedElem: i, selectionRange: l }, ef = !1, Pn = s; Pn !== null; )
      if (s = Pn, i = s.child, (s.subtreeFlags & 1028) !== 0 && i !== null)
        i.return = s, Pn = i;
      else
        for (; Pn !== null; ) {
          switch (s = Pn, x = s.alternate, i = s.flags, s.tag) {
            case 0:
              if ((i & 4) !== 0 && (i = s.updateQueue, i = i !== null ? i.events : null, i !== null))
                for (l = 0; l < i.length; l++)
                  v = i[l], v.ref.impl = v.nextImpl;
              break;
            case 11:
            case 15:
              break;
            case 1:
              if ((i & 1024) !== 0 && x !== null) {
                i = void 0, l = s, v = x.memoizedProps, x = x.memoizedState, f = l.stateNode;
                try {
                  var $t = ua(
                    l.type,
                    v
                  );
                  i = f.getSnapshotBeforeUpdate(
                    $t,
                    x
                  ), f.__reactInternalSnapshotBeforeUpdate = i;
                } catch (ae) {
                  Ve(
                    l,
                    l.return,
                    ae
                  );
                }
              }
              break;
            case 3:
              if ((i & 1024) !== 0) {
                if (i = s.stateNode.containerInfo, l = i.nodeType, l === 9)
                  Bp(i);
                else if (l === 1)
                  switch (i.nodeName) {
                    case "HEAD":
                    case "HTML":
                    case "BODY":
                      Bp(i);
                      break;
                    default:
                      i.textContent = "";
                  }
              }
              break;
            case 5:
            case 26:
            case 27:
            case 6:
            case 4:
            case 17:
              break;
            default:
              if ((i & 1024) !== 0) throw Error(r(163));
          }
          if (i = s.sibling, i !== null) {
            i.return = s.return, Pn = i;
            break;
          }
          Pn = s.return;
        }
  }
  function my(i, s, l) {
    var f = l.flags;
    switch (l.tag) {
      case 0:
      case 11:
      case 15:
        zr(i, l), f & 4 && Vl(5, l);
        break;
      case 1:
        if (zr(i, l), f & 4)
          if (i = l.stateNode, s === null)
            try {
              i.componentDidMount();
            } catch (P) {
              Ve(l, l.return, P);
            }
          else {
            var v = ua(
              l.type,
              s.memoizedProps
            );
            s = s.memoizedState;
            try {
              i.componentDidUpdate(
                v,
                s,
                i.__reactInternalSnapshotBeforeUpdate
              );
            } catch (P) {
              Ve(
                l,
                l.return,
                P
              );
            }
          }
        f & 64 && cy(l), f & 512 && kl(l, l.return);
        break;
      case 3:
        if (zr(i, l), f & 64 && (i = l.updateQueue, i !== null)) {
          if (s = null, l.child !== null)
            switch (l.child.tag) {
              case 27:
              case 5:
                s = l.child.stateNode;
                break;
              case 1:
                s = l.child.stateNode;
            }
          try {
            Jv(i, s);
          } catch (P) {
            Ve(l, l.return, P);
          }
        }
        break;
      case 27:
        s === null && f & 4 && hy(l);
      case 26:
      case 5:
        zr(i, l), s === null && f & 4 && fy(l), f & 512 && kl(l, l.return);
        break;
      case 12:
        zr(i, l);
        break;
      case 31:
        zr(i, l), f & 4 && _y(i, l);
        break;
      case 13:
        zr(i, l), f & 4 && yy(i, l), f & 64 && (i = l.memoizedState, i !== null && (i = i.dehydrated, i !== null && (l = oA.bind(
          null,
          l
        ), AA(i, l))));
        break;
      case 22:
        if (f = l.memoizedState !== null || Or, !f) {
          s = s !== null && s.memoizedState !== null || xn, v = Or;
          var x = xn;
          Or = f, (xn = s) && !x ? Ir(
            i,
            l,
            (l.subtreeFlags & 8772) !== 0
          ) : zr(i, l), Or = v, xn = x;
        }
        break;
      case 30:
        break;
      default:
        zr(i, l);
    }
  }
  function gy(i) {
    var s = i.alternate;
    s !== null && (i.alternate = null, gy(s)), i.child = null, i.deletions = null, i.sibling = null, i.tag === 5 && (s = i.stateNode, s !== null && $s(s)), i.stateNode = null, i.return = null, i.dependencies = null, i.memoizedProps = null, i.memoizedState = null, i.pendingProps = null, i.stateNode = null, i.updateQueue = null;
  }
  var an = null, ai = !1;
  function Pr(i, s, l) {
    for (l = l.child; l !== null; )
      vy(i, s, l), l = l.sibling;
  }
  function vy(i, s, l) {
    if (Kt && typeof Kt.onCommitFiberUnmount == "function")
      try {
        Kt.onCommitFiberUnmount(te, l);
      } catch {
      }
    switch (l.tag) {
      case 26:
        xn || sr(l, s), Pr(
          i,
          s,
          l
        ), l.memoizedState ? l.memoizedState.count-- : l.stateNode && (l = l.stateNode, l.parentNode.removeChild(l));
        break;
      case 27:
        xn || sr(l, s);
        var f = an, v = ai;
        Ms(l.type) && (an = l.stateNode, ai = !1), Pr(
          i,
          s,
          l
        ), Kl(l.stateNode), an = f, ai = v;
        break;
      case 5:
        xn || sr(l, s);
      case 6:
        if (f = an, v = ai, an = null, Pr(
          i,
          s,
          l
        ), an = f, ai = v, an !== null)
          if (ai)
            try {
              (an.nodeType === 9 ? an.body : an.nodeName === "HTML" ? an.ownerDocument.body : an).removeChild(l.stateNode);
            } catch (x) {
              Ve(
                l,
                s,
                x
              );
            }
          else
            try {
              an.removeChild(l.stateNode);
            } catch (x) {
              Ve(
                l,
                s,
                x
              );
            }
        break;
      case 18:
        an !== null && (ai ? (i = an, cx(
          i.nodeType === 9 ? i.body : i.nodeName === "HTML" ? i.ownerDocument.body : i,
          l.stateNode
        ), yo(i)) : cx(an, l.stateNode));
        break;
      case 4:
        f = an, v = ai, an = l.stateNode.containerInfo, ai = !0, Pr(
          i,
          s,
          l
        ), an = f, ai = v;
        break;
      case 0:
      case 11:
      case 14:
      case 15:
        gs(2, l, s), xn || gs(4, l, s), Pr(
          i,
          s,
          l
        );
        break;
      case 1:
        xn || (sr(l, s), f = l.stateNode, typeof f.componentWillUnmount == "function" && uy(
          l,
          s,
          f
        )), Pr(
          i,
          s,
          l
        );
        break;
      case 21:
        Pr(
          i,
          s,
          l
        );
        break;
      case 22:
        xn = (f = xn) || l.memoizedState !== null, Pr(
          i,
          s,
          l
        ), xn = f;
        break;
      default:
        Pr(
          i,
          s,
          l
        );
    }
  }
  function _y(i, s) {
    if (s.memoizedState === null && (i = s.alternate, i !== null && (i = i.memoizedState, i !== null))) {
      i = i.dehydrated;
      try {
        yo(i);
      } catch (l) {
        Ve(s, s.return, l);
      }
    }
  }
  function yy(i, s) {
    if (s.memoizedState === null && (i = s.alternate, i !== null && (i = i.memoizedState, i !== null && (i = i.dehydrated, i !== null))))
      try {
        yo(i);
      } catch (l) {
        Ve(s, s.return, l);
      }
  }
  function JT(i) {
    switch (i.tag) {
      case 31:
      case 13:
      case 19:
        var s = i.stateNode;
        return s === null && (s = i.stateNode = new py()), s;
      case 22:
        return i = i.stateNode, s = i._retryCache, s === null && (s = i._retryCache = new py()), s;
      default:
        throw Error(r(435, i.tag));
    }
  }
  function Pu(i, s) {
    var l = JT(i);
    s.forEach(function(f) {
      if (!l.has(f)) {
        l.add(f);
        var v = lA.bind(null, i, f);
        f.then(v, v);
      }
    });
  }
  function oi(i, s) {
    var l = s.deletions;
    if (l !== null)
      for (var f = 0; f < l.length; f++) {
        var v = l[f], x = i, P = s, Y = P;
        t: for (; Y !== null; ) {
          switch (Y.tag) {
            case 27:
              if (Ms(Y.type)) {
                an = Y.stateNode, ai = !1;
                break t;
              }
              break;
            case 5:
              an = Y.stateNode, ai = !1;
              break t;
            case 3:
            case 4:
              an = Y.stateNode.containerInfo, ai = !0;
              break t;
          }
          Y = Y.return;
        }
        if (an === null) throw Error(r(160));
        vy(x, P, v), an = null, ai = !1, x = v.alternate, x !== null && (x.return = null), v.return = null;
      }
    if (s.subtreeFlags & 13886)
      for (s = s.child; s !== null; )
        xy(s, i), s = s.sibling;
  }
  var ji = null;
  function xy(i, s) {
    var l = i.alternate, f = i.flags;
    switch (i.tag) {
      case 0:
      case 11:
      case 14:
      case 15:
        oi(s, i), li(i), f & 4 && (gs(3, i, i.return), Vl(3, i), gs(5, i, i.return));
        break;
      case 1:
        oi(s, i), li(i), f & 512 && (xn || l === null || sr(l, l.return)), f & 64 && Or && (i = i.updateQueue, i !== null && (f = i.callbacks, f !== null && (l = i.shared.hiddenCallbacks, i.shared.hiddenCallbacks = l === null ? f : l.concat(f))));
        break;
      case 26:
        var v = ji;
        if (oi(s, i), li(i), f & 512 && (xn || l === null || sr(l, l.return)), f & 4) {
          var x = l !== null ? l.memoizedState : null;
          if (f = i.memoizedState, l === null)
            if (f === null)
              if (i.stateNode === null) {
                t: {
                  f = i.type, l = i.memoizedProps, v = v.ownerDocument || v;
                  e: switch (f) {
                    case "title":
                      x = v.getElementsByTagName("title")[0], (!x || x[Mr] || x[sn] || x.namespaceURI === "http://www.w3.org/2000/svg" || x.hasAttribute("itemprop")) && (x = v.createElement(f), v.head.insertBefore(
                        x,
                        v.querySelector("head > title")
                      )), Gn(x, f, l), x[sn] = i, lt(x), f = x;
                      break t;
                    case "link":
                      var P = xx(
                        "link",
                        "href",
                        v
                      ).get(f + (l.href || ""));
                      if (P) {
                        for (var Y = 0; Y < P.length; Y++)
                          if (x = P[Y], x.getAttribute("href") === (l.href == null || l.href === "" ? null : l.href) && x.getAttribute("rel") === (l.rel == null ? null : l.rel) && x.getAttribute("title") === (l.title == null ? null : l.title) && x.getAttribute("crossorigin") === (l.crossOrigin == null ? null : l.crossOrigin)) {
                            P.splice(Y, 1);
                            break e;
                          }
                      }
                      x = v.createElement(f), Gn(x, f, l), v.head.appendChild(x);
                      break;
                    case "meta":
                      if (P = xx(
                        "meta",
                        "content",
                        v
                      ).get(f + (l.content || ""))) {
                        for (Y = 0; Y < P.length; Y++)
                          if (x = P[Y], x.getAttribute("content") === (l.content == null ? null : "" + l.content) && x.getAttribute("name") === (l.name == null ? null : l.name) && x.getAttribute("property") === (l.property == null ? null : l.property) && x.getAttribute("http-equiv") === (l.httpEquiv == null ? null : l.httpEquiv) && x.getAttribute("charset") === (l.charSet == null ? null : l.charSet)) {
                            P.splice(Y, 1);
                            break e;
                          }
                      }
                      x = v.createElement(f), Gn(x, f, l), v.head.appendChild(x);
                      break;
                    default:
                      throw Error(r(468, f));
                  }
                  x[sn] = i, lt(x), f = x;
                }
                i.stateNode = f;
              } else
                Sx(
                  v,
                  i.type,
                  i.stateNode
                );
            else
              i.stateNode = yx(
                v,
                f,
                i.memoizedProps
              );
          else
            x !== f ? (x === null ? l.stateNode !== null && (l = l.stateNode, l.parentNode.removeChild(l)) : x.count--, f === null ? Sx(
              v,
              i.type,
              i.stateNode
            ) : yx(
              v,
              f,
              i.memoizedProps
            )) : f === null && i.stateNode !== null && up(
              i,
              i.memoizedProps,
              l.memoizedProps
            );
        }
        break;
      case 27:
        oi(s, i), li(i), f & 512 && (xn || l === null || sr(l, l.return)), l !== null && f & 4 && up(
          i,
          i.memoizedProps,
          l.memoizedProps
        );
        break;
      case 5:
        if (oi(s, i), li(i), f & 512 && (xn || l === null || sr(l, l.return)), i.flags & 32) {
          v = i.stateNode;
          try {
            ri(v, "");
          } catch ($t) {
            Ve(i, i.return, $t);
          }
        }
        f & 4 && i.stateNode != null && (v = i.memoizedProps, up(
          i,
          v,
          l !== null ? l.memoizedProps : v
        )), f & 1024 && (hp = !0);
        break;
      case 6:
        if (oi(s, i), li(i), f & 4) {
          if (i.stateNode === null)
            throw Error(r(162));
          f = i.memoizedProps, l = i.stateNode;
          try {
            l.nodeValue = f;
          } catch ($t) {
            Ve(i, i.return, $t);
          }
        }
        break;
      case 3:
        if (Ku = null, v = ji, ji = Zu(s.containerInfo), oi(s, i), ji = v, li(i), f & 4 && l !== null && l.memoizedState.isDehydrated)
          try {
            yo(s.containerInfo);
          } catch ($t) {
            Ve(i, i.return, $t);
          }
        hp && (hp = !1, Sy(i));
        break;
      case 4:
        f = ji, ji = Zu(
          i.stateNode.containerInfo
        ), oi(s, i), li(i), ji = f;
        break;
      case 12:
        oi(s, i), li(i);
        break;
      case 31:
        oi(s, i), li(i), f & 4 && (f = i.updateQueue, f !== null && (i.updateQueue = null, Pu(i, f)));
        break;
      case 13:
        oi(s, i), li(i), i.child.flags & 8192 && i.memoizedState !== null != (l !== null && l.memoizedState !== null) && (Iu = Et()), f & 4 && (f = i.updateQueue, f !== null && (i.updateQueue = null, Pu(i, f)));
        break;
      case 22:
        v = i.memoizedState !== null;
        var rt = l !== null && l.memoizedState !== null, pt = Or, bt = xn;
        if (Or = pt || v, xn = bt || rt, oi(s, i), xn = bt, Or = pt, li(i), f & 8192)
          t: for (s = i.stateNode, s._visibility = v ? s._visibility & -2 : s._visibility | 1, v && (l === null || rt || Or || xn || fa(i)), l = null, s = i; ; ) {
            if (s.tag === 5 || s.tag === 26) {
              if (l === null) {
                rt = l = s;
                try {
                  if (x = rt.stateNode, v)
                    P = x.style, typeof P.setProperty == "function" ? P.setProperty("display", "none", "important") : P.display = "none";
                  else {
                    Y = rt.stateNode;
                    var At = rt.memoizedProps.style, vt = At != null && At.hasOwnProperty("display") ? At.display : null;
                    Y.style.display = vt == null || typeof vt == "boolean" ? "" : ("" + vt).trim();
                  }
                } catch ($t) {
                  Ve(rt, rt.return, $t);
                }
              }
            } else if (s.tag === 6) {
              if (l === null) {
                rt = s;
                try {
                  rt.stateNode.nodeValue = v ? "" : rt.memoizedProps;
                } catch ($t) {
                  Ve(rt, rt.return, $t);
                }
              }
            } else if (s.tag === 18) {
              if (l === null) {
                rt = s;
                try {
                  var xt = rt.stateNode;
                  v ? ux(xt, !0) : ux(rt.stateNode, !1);
                } catch ($t) {
                  Ve(rt, rt.return, $t);
                }
              }
            } else if ((s.tag !== 22 && s.tag !== 23 || s.memoizedState === null || s === i) && s.child !== null) {
              s.child.return = s, s = s.child;
              continue;
            }
            if (s === i) break t;
            for (; s.sibling === null; ) {
              if (s.return === null || s.return === i) break t;
              l === s && (l = null), s = s.return;
            }
            l === s && (l = null), s.sibling.return = s.return, s = s.sibling;
          }
        f & 4 && (f = i.updateQueue, f !== null && (l = f.retryQueue, l !== null && (f.retryQueue = null, Pu(i, l))));
        break;
      case 19:
        oi(s, i), li(i), f & 4 && (f = i.updateQueue, f !== null && (i.updateQueue = null, Pu(i, f)));
        break;
      case 30:
        break;
      case 21:
        break;
      default:
        oi(s, i), li(i);
    }
  }
  function li(i) {
    var s = i.flags;
    if (s & 2) {
      try {
        for (var l, f = i.return; f !== null; ) {
          if (dy(f)) {
            l = f;
            break;
          }
          f = f.return;
        }
        if (l == null) throw Error(r(160));
        switch (l.tag) {
          case 27:
            var v = l.stateNode, x = fp(i);
            Ou(i, x, v);
            break;
          case 5:
            var P = l.stateNode;
            l.flags & 32 && (ri(P, ""), l.flags &= -33);
            var Y = fp(i);
            Ou(i, Y, P);
            break;
          case 3:
          case 4:
            var rt = l.stateNode.containerInfo, pt = fp(i);
            dp(
              i,
              pt,
              rt
            );
            break;
          default:
            throw Error(r(161));
        }
      } catch (bt) {
        Ve(i, i.return, bt);
      }
      i.flags &= -3;
    }
    s & 4096 && (i.flags &= -4097);
  }
  function Sy(i) {
    if (i.subtreeFlags & 1024)
      for (i = i.child; i !== null; ) {
        var s = i;
        Sy(s), s.tag === 5 && s.flags & 1024 && s.stateNode.reset(), i = i.sibling;
      }
  }
  function zr(i, s) {
    if (s.subtreeFlags & 8772)
      for (s = s.child; s !== null; )
        my(i, s.alternate, s), s = s.sibling;
  }
  function fa(i) {
    for (i = i.child; i !== null; ) {
      var s = i;
      switch (s.tag) {
        case 0:
        case 11:
        case 14:
        case 15:
          gs(4, s, s.return), fa(s);
          break;
        case 1:
          sr(s, s.return);
          var l = s.stateNode;
          typeof l.componentWillUnmount == "function" && uy(
            s,
            s.return,
            l
          ), fa(s);
          break;
        case 27:
          Kl(s.stateNode);
        case 26:
        case 5:
          sr(s, s.return), fa(s);
          break;
        case 22:
          s.memoizedState === null && fa(s);
          break;
        case 30:
          fa(s);
          break;
        default:
          fa(s);
      }
      i = i.sibling;
    }
  }
  function Ir(i, s, l) {
    for (l = l && (s.subtreeFlags & 8772) !== 0, s = s.child; s !== null; ) {
      var f = s.alternate, v = i, x = s, P = x.flags;
      switch (x.tag) {
        case 0:
        case 11:
        case 15:
          Ir(
            v,
            x,
            l
          ), Vl(4, x);
          break;
        case 1:
          if (Ir(
            v,
            x,
            l
          ), f = x, v = f.stateNode, typeof v.componentDidMount == "function")
            try {
              v.componentDidMount();
            } catch (pt) {
              Ve(f, f.return, pt);
            }
          if (f = x, v = f.updateQueue, v !== null) {
            var Y = f.stateNode;
            try {
              var rt = v.shared.hiddenCallbacks;
              if (rt !== null)
                for (v.shared.hiddenCallbacks = null, v = 0; v < rt.length; v++)
                  Qv(rt[v], Y);
            } catch (pt) {
              Ve(f, f.return, pt);
            }
          }
          l && P & 64 && cy(x), kl(x, x.return);
          break;
        case 27:
          hy(x);
        case 26:
        case 5:
          Ir(
            v,
            x,
            l
          ), l && f === null && P & 4 && fy(x), kl(x, x.return);
          break;
        case 12:
          Ir(
            v,
            x,
            l
          );
          break;
        case 31:
          Ir(
            v,
            x,
            l
          ), l && P & 4 && _y(v, x);
          break;
        case 13:
          Ir(
            v,
            x,
            l
          ), l && P & 4 && yy(v, x);
          break;
        case 22:
          x.memoizedState === null && Ir(
            v,
            x,
            l
          ), kl(x, x.return);
          break;
        case 30:
          break;
        default:
          Ir(
            v,
            x,
            l
          );
      }
      s = s.sibling;
    }
  }
  function pp(i, s) {
    var l = null;
    i !== null && i.memoizedState !== null && i.memoizedState.cachePool !== null && (l = i.memoizedState.cachePool.pool), i = null, s.memoizedState !== null && s.memoizedState.cachePool !== null && (i = s.memoizedState.cachePool.pool), i !== l && (i != null && i.refCount++, l != null && Cl(l));
  }
  function mp(i, s) {
    i = null, s.alternate !== null && (i = s.alternate.memoizedState.cache), s = s.memoizedState.cache, s !== i && (s.refCount++, i != null && Cl(i));
  }
  function Wi(i, s, l, f) {
    if (s.subtreeFlags & 10256)
      for (s = s.child; s !== null; )
        by(
          i,
          s,
          l,
          f
        ), s = s.sibling;
  }
  function by(i, s, l, f) {
    var v = s.flags;
    switch (s.tag) {
      case 0:
      case 11:
      case 15:
        Wi(
          i,
          s,
          l,
          f
        ), v & 2048 && Vl(9, s);
        break;
      case 1:
        Wi(
          i,
          s,
          l,
          f
        );
        break;
      case 3:
        Wi(
          i,
          s,
          l,
          f
        ), v & 2048 && (i = null, s.alternate !== null && (i = s.alternate.memoizedState.cache), s = s.memoizedState.cache, s !== i && (s.refCount++, i != null && Cl(i)));
        break;
      case 12:
        if (v & 2048) {
          Wi(
            i,
            s,
            l,
            f
          ), i = s.stateNode;
          try {
            var x = s.memoizedProps, P = x.id, Y = x.onPostCommit;
            typeof Y == "function" && Y(
              P,
              s.alternate === null ? "mount" : "update",
              i.passiveEffectDuration,
              -0
            );
          } catch (rt) {
            Ve(s, s.return, rt);
          }
        } else
          Wi(
            i,
            s,
            l,
            f
          );
        break;
      case 31:
        Wi(
          i,
          s,
          l,
          f
        );
        break;
      case 13:
        Wi(
          i,
          s,
          l,
          f
        );
        break;
      case 23:
        break;
      case 22:
        x = s.stateNode, P = s.alternate, s.memoizedState !== null ? x._visibility & 2 ? Wi(
          i,
          s,
          l,
          f
        ) : Gl(i, s) : x._visibility & 2 ? Wi(
          i,
          s,
          l,
          f
        ) : (x._visibility |= 2, oo(
          i,
          s,
          l,
          f,
          (s.subtreeFlags & 10256) !== 0 || !1
        )), v & 2048 && pp(P, s);
        break;
      case 24:
        Wi(
          i,
          s,
          l,
          f
        ), v & 2048 && mp(s.alternate, s);
        break;
      default:
        Wi(
          i,
          s,
          l,
          f
        );
    }
  }
  function oo(i, s, l, f, v) {
    for (v = v && ((s.subtreeFlags & 10256) !== 0 || !1), s = s.child; s !== null; ) {
      var x = i, P = s, Y = l, rt = f, pt = P.flags;
      switch (P.tag) {
        case 0:
        case 11:
        case 15:
          oo(
            x,
            P,
            Y,
            rt,
            v
          ), Vl(8, P);
          break;
        case 23:
          break;
        case 22:
          var bt = P.stateNode;
          P.memoizedState !== null ? bt._visibility & 2 ? oo(
            x,
            P,
            Y,
            rt,
            v
          ) : Gl(
            x,
            P
          ) : (bt._visibility |= 2, oo(
            x,
            P,
            Y,
            rt,
            v
          )), v && pt & 2048 && pp(
            P.alternate,
            P
          );
          break;
        case 24:
          oo(
            x,
            P,
            Y,
            rt,
            v
          ), v && pt & 2048 && mp(P.alternate, P);
          break;
        default:
          oo(
            x,
            P,
            Y,
            rt,
            v
          );
      }
      s = s.sibling;
    }
  }
  function Gl(i, s) {
    if (s.subtreeFlags & 10256)
      for (s = s.child; s !== null; ) {
        var l = i, f = s, v = f.flags;
        switch (f.tag) {
          case 22:
            Gl(l, f), v & 2048 && pp(
              f.alternate,
              f
            );
            break;
          case 24:
            Gl(l, f), v & 2048 && mp(f.alternate, f);
            break;
          default:
            Gl(l, f);
        }
        s = s.sibling;
      }
  }
  var Xl = 8192;
  function lo(i, s, l) {
    if (i.subtreeFlags & Xl)
      for (i = i.child; i !== null; )
        My(
          i,
          s,
          l
        ), i = i.sibling;
  }
  function My(i, s, l) {
    switch (i.tag) {
      case 26:
        lo(
          i,
          s,
          l
        ), i.flags & Xl && i.memoizedState !== null && FA(
          l,
          ji,
          i.memoizedState,
          i.memoizedProps
        );
        break;
      case 5:
        lo(
          i,
          s,
          l
        );
        break;
      case 3:
      case 4:
        var f = ji;
        ji = Zu(i.stateNode.containerInfo), lo(
          i,
          s,
          l
        ), ji = f;
        break;
      case 22:
        i.memoizedState === null && (f = i.alternate, f !== null && f.memoizedState !== null ? (f = Xl, Xl = 16777216, lo(
          i,
          s,
          l
        ), Xl = f) : lo(
          i,
          s,
          l
        ));
        break;
      default:
        lo(
          i,
          s,
          l
        );
    }
  }
  function Ey(i) {
    var s = i.alternate;
    if (s !== null && (i = s.child, i !== null)) {
      s.child = null;
      do
        s = i.sibling, i.sibling = null, i = s;
      while (i !== null);
    }
  }
  function jl(i) {
    var s = i.deletions;
    if ((i.flags & 16) !== 0) {
      if (s !== null)
        for (var l = 0; l < s.length; l++) {
          var f = s[l];
          Pn = f, Ty(
            f,
            i
          );
        }
      Ey(i);
    }
    if (i.subtreeFlags & 10256)
      for (i = i.child; i !== null; )
        wy(i), i = i.sibling;
  }
  function wy(i) {
    switch (i.tag) {
      case 0:
      case 11:
      case 15:
        jl(i), i.flags & 2048 && gs(9, i, i.return);
        break;
      case 3:
        jl(i);
        break;
      case 12:
        jl(i);
        break;
      case 22:
        var s = i.stateNode;
        i.memoizedState !== null && s._visibility & 2 && (i.return === null || i.return.tag !== 13) ? (s._visibility &= -3, zu(i)) : jl(i);
        break;
      default:
        jl(i);
    }
  }
  function zu(i) {
    var s = i.deletions;
    if ((i.flags & 16) !== 0) {
      if (s !== null)
        for (var l = 0; l < s.length; l++) {
          var f = s[l];
          Pn = f, Ty(
            f,
            i
          );
        }
      Ey(i);
    }
    for (i = i.child; i !== null; ) {
      switch (s = i, s.tag) {
        case 0:
        case 11:
        case 15:
          gs(8, s, s.return), zu(s);
          break;
        case 22:
          l = s.stateNode, l._visibility & 2 && (l._visibility &= -3, zu(s));
          break;
        default:
          zu(s);
      }
      i = i.sibling;
    }
  }
  function Ty(i, s) {
    for (; Pn !== null; ) {
      var l = Pn;
      switch (l.tag) {
        case 0:
        case 11:
        case 15:
          gs(8, l, s);
          break;
        case 23:
        case 22:
          if (l.memoizedState !== null && l.memoizedState.cachePool !== null) {
            var f = l.memoizedState.cachePool.pool;
            f != null && f.refCount++;
          }
          break;
        case 24:
          Cl(l.memoizedState.cache);
      }
      if (f = l.child, f !== null) f.return = l, Pn = f;
      else
        t: for (l = i; Pn !== null; ) {
          f = Pn;
          var v = f.sibling, x = f.return;
          if (gy(f), f === l) {
            Pn = null;
            break t;
          }
          if (v !== null) {
            v.return = x, Pn = v;
            break t;
          }
          Pn = x;
        }
    }
  }
  var tA = {
    getCacheForType: function(i) {
      var s = Vn(vn), l = s.data.get(i);
      return l === void 0 && (l = i(), s.data.set(i, l)), l;
    },
    cacheSignal: function() {
      return Vn(vn).controller.signal;
    }
  }, eA = typeof WeakMap == "function" ? WeakMap : Map, Be = 0, Je = null, Te = null, Ce = 0, He = 0, Si = null, vs = !1, co = !1, gp = !1, Br = 0, un = 0, _s = 0, da = 0, vp = 0, bi = 0, uo = 0, Wl = null, ci = null, _p = !1, Iu = 0, Ay = 0, Bu = 1 / 0, Fu = null, ys = null, An = 0, xs = null, fo = null, Fr = 0, yp = 0, xp = null, Cy = null, Yl = 0, Sp = null;
  function Mi() {
    return (Be & 2) !== 0 && Ce !== 0 ? Ce & -Ce : D.T !== null ? Ap() : Zs();
  }
  function Ry() {
    if (bi === 0)
      if ((Ce & 536870912) === 0 || Ne) {
        var i = St;
        St <<= 1, (St & 3932160) === 0 && (St = 262144), bi = i;
      } else bi = 536870912;
    return i = yi.current, i !== null && (i.flags |= 32), bi;
  }
  function ui(i, s, l) {
    (i === Je && (He === 2 || He === 9) || i.cancelPendingCommit !== null) && (ho(i, 0), Ss(
      i,
      Ce,
      bi,
      !1
    )), wn(i, l), ((Be & 2) === 0 || i !== Je) && (i === Je && ((Be & 2) === 0 && (da |= l), un === 4 && Ss(
      i,
      Ce,
      bi,
      !1
    )), ar(i));
  }
  function Dy(i, s, l) {
    if ((Be & 6) !== 0) throw Error(r(327));
    var f = !l && (s & 127) === 0 && (s & i.expiredLanes) === 0 || ue(i, s), v = f ? rA(i, s) : Mp(i, s, !0), x = f;
    do {
      if (v === 0) {
        co && !f && Ss(i, s, 0, !1);
        break;
      } else {
        if (l = i.current.alternate, x && !nA(l)) {
          v = Mp(i, s, !1), x = !1;
          continue;
        }
        if (v === 2) {
          if (x = s, i.errorRecoveryDisabledLanes & x)
            var P = 0;
          else
            P = i.pendingLanes & -536870913, P = P !== 0 ? P : P & 536870912 ? 536870912 : 0;
          if (P !== 0) {
            s = P;
            t: {
              var Y = i;
              v = Wl;
              var rt = Y.current.memoizedState.isDehydrated;
              if (rt && (ho(Y, P).flags |= 256), P = Mp(
                Y,
                P,
                !1
              ), P !== 2) {
                if (gp && !rt) {
                  Y.errorRecoveryDisabledLanes |= x, da |= x, v = 4;
                  break t;
                }
                x = ci, ci = v, x !== null && (ci === null ? ci = x : ci.push.apply(
                  ci,
                  x
                ));
              }
              v = P;
            }
            if (x = !1, v !== 2) continue;
          }
        }
        if (v === 1) {
          ho(i, 0), Ss(i, s, 0, !0);
          break;
        }
        t: {
          switch (f = i, x = v, x) {
            case 0:
            case 1:
              throw Error(r(345));
            case 4:
              if ((s & 4194048) !== s) break;
            case 6:
              Ss(
                f,
                s,
                bi,
                !vs
              );
              break t;
            case 2:
              ci = null;
              break;
            case 3:
            case 5:
              break;
            default:
              throw Error(r(329));
          }
          if ((s & 62914560) === s && (v = Iu + 300 - Et(), 10 < v)) {
            if (Ss(
              f,
              s,
              bi,
              !vs
            ), Ht(f, 0, !0) !== 0) break t;
            Fr = s, f.timeoutHandle = ox(
              Ny.bind(
                null,
                f,
                l,
                ci,
                Fu,
                _p,
                s,
                bi,
                da,
                uo,
                vs,
                x,
                "Throttled",
                -0,
                0
              ),
              v
            );
            break t;
          }
          Ny(
            f,
            l,
            ci,
            Fu,
            _p,
            s,
            bi,
            da,
            uo,
            vs,
            x,
            null,
            -0,
            0
          );
        }
      }
      break;
    } while (!0);
    ar(i);
  }
  function Ny(i, s, l, f, v, x, P, Y, rt, pt, bt, At, vt, xt) {
    if (i.timeoutHandle = -1, At = s.subtreeFlags, At & 8192 || (At & 16785408) === 16785408) {
      At = {
        stylesheets: null,
        count: 0,
        imgCount: 0,
        imgBytes: 0,
        suspenseyImages: [],
        waitingForImages: !0,
        waitingForViewTransition: !1,
        unsuspend: Er
      }, My(
        s,
        x,
        At
      );
      var $t = (x & 62914560) === x ? Iu - Et() : (x & 4194048) === x ? Ay - Et() : 0;
      if ($t = HA(
        At,
        $t
      ), $t !== null) {
        Fr = x, i.cancelPendingCommit = $t(
          Fy.bind(
            null,
            i,
            s,
            x,
            l,
            f,
            v,
            P,
            Y,
            rt,
            bt,
            At,
            null,
            vt,
            xt
          )
        ), Ss(i, x, P, !pt);
        return;
      }
    }
    Fy(
      i,
      s,
      x,
      l,
      f,
      v,
      P,
      Y,
      rt
    );
  }
  function nA(i) {
    for (var s = i; ; ) {
      var l = s.tag;
      if ((l === 0 || l === 11 || l === 15) && s.flags & 16384 && (l = s.updateQueue, l !== null && (l = l.stores, l !== null)))
        for (var f = 0; f < l.length; f++) {
          var v = l[f], x = v.getSnapshot;
          v = v.value;
          try {
            if (!vi(x(), v)) return !1;
          } catch {
            return !1;
          }
        }
      if (l = s.child, s.subtreeFlags & 16384 && l !== null)
        l.return = s, s = l;
      else {
        if (s === i) break;
        for (; s.sibling === null; ) {
          if (s.return === null || s.return === i) return !0;
          s = s.return;
        }
        s.sibling.return = s.return, s = s.sibling;
      }
    }
    return !0;
  }
  function Ss(i, s, l, f) {
    s &= ~vp, s &= ~da, i.suspendedLanes |= s, i.pingedLanes &= ~s, f && (i.warmLanes |= s), f = i.expirationTimes;
    for (var v = s; 0 < v; ) {
      var x = 31 - le(v), P = 1 << x;
      f[x] = -1, v &= ~P;
    }
    l !== 0 && Ys(i, l, s);
  }
  function Hu() {
    return (Be & 6) === 0 ? (ql(0), !1) : !0;
  }
  function bp() {
    if (Te !== null) {
      if (He === 0)
        var i = Te.return;
      else
        i = Te, Cr = ia = null, Bh(i), no = null, Dl = 0, i = Te;
      for (; i !== null; )
        ly(i.alternate, i), i = i.return;
      Te = null;
    }
  }
  function ho(i, s) {
    var l = i.timeoutHandle;
    l !== -1 && (i.timeoutHandle = -1, bA(l)), l = i.cancelPendingCommit, l !== null && (i.cancelPendingCommit = null, l()), Fr = 0, bp(), Je = i, Te = l = Tr(i.current, null), Ce = s, He = 0, Si = null, vs = !1, co = ue(i, s), gp = !1, uo = bi = vp = da = _s = un = 0, ci = Wl = null, _p = !1, (s & 8) !== 0 && (s |= s & 32);
    var f = i.entangledLanes;
    if (f !== 0)
      for (i = i.entanglements, f &= s; 0 < f; ) {
        var v = 31 - le(f), x = 1 << v;
        s |= i[v], f &= ~x;
      }
    return Br = s, ou(), l;
  }
  function Ly(i, s) {
    me = null, D.H = Bl, s === eo || s === mu ? (s = qv(), He = 3) : s === Th ? (s = qv(), He = 4) : He = s === tp ? 8 : s !== null && typeof s == "object" && typeof s.then == "function" ? 6 : 1, Si = s, Te === null && (un = 1, Ru(
      i,
      Ui(s, i.current)
    ));
  }
  function Uy() {
    var i = yi.current;
    return i === null ? !0 : (Ce & 4194048) === Ce ? Ii === null : (Ce & 62914560) === Ce || (Ce & 536870912) !== 0 ? i === Ii : !1;
  }
  function Oy() {
    var i = D.H;
    return D.H = Bl, i === null ? Bl : i;
  }
  function Py() {
    var i = D.A;
    return D.A = tA, i;
  }
  function Vu() {
    un = 4, vs || (Ce & 4194048) !== Ce && yi.current !== null || (co = !0), (_s & 134217727) === 0 && (da & 134217727) === 0 || Je === null || Ss(
      Je,
      Ce,
      bi,
      !1
    );
  }
  function Mp(i, s, l) {
    var f = Be;
    Be |= 2;
    var v = Oy(), x = Py();
    (Je !== i || Ce !== s) && (Fu = null, ho(i, s)), s = !1;
    var P = un;
    t: do
      try {
        if (He !== 0 && Te !== null) {
          var Y = Te, rt = Si;
          switch (He) {
            case 8:
              bp(), P = 6;
              break t;
            case 3:
            case 2:
            case 9:
            case 6:
              yi.current === null && (s = !0);
              var pt = He;
              if (He = 0, Si = null, po(i, Y, rt, pt), l && co) {
                P = 0;
                break t;
              }
              break;
            default:
              pt = He, He = 0, Si = null, po(i, Y, rt, pt);
          }
        }
        iA(), P = un;
        break;
      } catch (bt) {
        Ly(i, bt);
      }
    while (!0);
    return s && i.shellSuspendCounter++, Cr = ia = null, Be = f, D.H = v, D.A = x, Te === null && (Je = null, Ce = 0, ou()), P;
  }
  function iA() {
    for (; Te !== null; ) zy(Te);
  }
  function rA(i, s) {
    var l = Be;
    Be |= 2;
    var f = Oy(), v = Py();
    Je !== i || Ce !== s ? (Fu = null, Bu = Et() + 500, ho(i, s)) : co = ue(
      i,
      s
    );
    t: do
      try {
        if (He !== 0 && Te !== null) {
          s = Te;
          var x = Si;
          e: switch (He) {
            case 1:
              He = 0, Si = null, po(i, s, x, 1);
              break;
            case 2:
            case 9:
              if (Wv(x)) {
                He = 0, Si = null, Iy(s);
                break;
              }
              s = function() {
                He !== 2 && He !== 9 || Je !== i || (He = 7), ar(i);
              }, x.then(s, s);
              break t;
            case 3:
              He = 7;
              break t;
            case 4:
              He = 5;
              break t;
            case 7:
              Wv(x) ? (He = 0, Si = null, Iy(s)) : (He = 0, Si = null, po(i, s, x, 7));
              break;
            case 5:
              var P = null;
              switch (Te.tag) {
                case 26:
                  P = Te.memoizedState;
                case 5:
                case 27:
                  var Y = Te;
                  if (P ? bx(P) : Y.stateNode.complete) {
                    He = 0, Si = null;
                    var rt = Y.sibling;
                    if (rt !== null) Te = rt;
                    else {
                      var pt = Y.return;
                      pt !== null ? (Te = pt, ku(pt)) : Te = null;
                    }
                    break e;
                  }
              }
              He = 0, Si = null, po(i, s, x, 5);
              break;
            case 6:
              He = 0, Si = null, po(i, s, x, 6);
              break;
            case 8:
              bp(), un = 6;
              break t;
            default:
              throw Error(r(462));
          }
        }
        sA();
        break;
      } catch (bt) {
        Ly(i, bt);
      }
    while (!0);
    return Cr = ia = null, D.H = f, D.A = v, Be = l, Te !== null ? 0 : (Je = null, Ce = 0, ou(), un);
  }
  function sA() {
    for (; Te !== null && !W(); )
      zy(Te);
  }
  function zy(i) {
    var s = ay(i.alternate, i, Br);
    i.memoizedProps = i.pendingProps, s === null ? ku(i) : Te = s;
  }
  function Iy(i) {
    var s = i, l = s.alternate;
    switch (s.tag) {
      case 15:
      case 0:
        s = ty(
          l,
          s,
          s.pendingProps,
          s.type,
          void 0,
          Ce
        );
        break;
      case 11:
        s = ty(
          l,
          s,
          s.pendingProps,
          s.type.render,
          s.ref,
          Ce
        );
        break;
      case 5:
        Bh(s);
      default:
        ly(l, s), s = Te = Pv(s, Br), s = ay(l, s, Br);
    }
    i.memoizedProps = i.pendingProps, s === null ? ku(i) : Te = s;
  }
  function po(i, s, l, f) {
    Cr = ia = null, Bh(s), no = null, Dl = 0;
    var v = s.return;
    try {
      if (YT(
        i,
        v,
        s,
        l,
        Ce
      )) {
        un = 1, Ru(
          i,
          Ui(l, i.current)
        ), Te = null;
        return;
      }
    } catch (x) {
      if (v !== null) throw Te = v, x;
      un = 1, Ru(
        i,
        Ui(l, i.current)
      ), Te = null;
      return;
    }
    s.flags & 32768 ? (Ne || f === 1 ? i = !0 : co || (Ce & 536870912) !== 0 ? i = !1 : (vs = i = !0, (f === 2 || f === 9 || f === 3 || f === 6) && (f = yi.current, f !== null && f.tag === 13 && (f.flags |= 16384))), By(s, i)) : ku(s);
  }
  function ku(i) {
    var s = i;
    do {
      if ((s.flags & 32768) !== 0) {
        By(
          s,
          vs
        );
        return;
      }
      i = s.return;
      var l = $T(
        s.alternate,
        s,
        Br
      );
      if (l !== null) {
        Te = l;
        return;
      }
      if (s = s.sibling, s !== null) {
        Te = s;
        return;
      }
      Te = s = i;
    } while (s !== null);
    un === 0 && (un = 5);
  }
  function By(i, s) {
    do {
      var l = KT(i.alternate, i);
      if (l !== null) {
        l.flags &= 32767, Te = l;
        return;
      }
      if (l = i.return, l !== null && (l.flags |= 32768, l.subtreeFlags = 0, l.deletions = null), !s && (i = i.sibling, i !== null)) {
        Te = i;
        return;
      }
      Te = i = l;
    } while (i !== null);
    un = 6, Te = null;
  }
  function Fy(i, s, l, f, v, x, P, Y, rt) {
    i.cancelPendingCommit = null;
    do
      Gu();
    while (An !== 0);
    if ((Be & 6) !== 0) throw Error(r(327));
    if (s !== null) {
      if (s === i.current) throw Error(r(177));
      if (x = s.lanes | s.childLanes, x |= fh, mi(
        i,
        l,
        x,
        P,
        Y,
        rt
      ), i === Je && (Te = Je = null, Ce = 0), fo = s, xs = i, Fr = l, yp = x, xp = v, Cy = f, (s.subtreeFlags & 10256) !== 0 || (s.flags & 10256) !== 0 ? (i.callbackNode = null, i.callbackPriority = 0, cA(Pt, function() {
        return Xy(), null;
      })) : (i.callbackNode = null, i.callbackPriority = 0), f = (s.flags & 13878) !== 0, (s.subtreeFlags & 13878) !== 0 || f) {
        f = D.T, D.T = null, v = V.p, V.p = 2, P = Be, Be |= 4;
        try {
          QT(i, s, l);
        } finally {
          Be = P, V.p = v, D.T = f;
        }
      }
      An = 1, Hy(), Vy(), ky();
    }
  }
  function Hy() {
    if (An === 1) {
      An = 0;
      var i = xs, s = fo, l = (s.flags & 13878) !== 0;
      if ((s.subtreeFlags & 13878) !== 0 || l) {
        l = D.T, D.T = null;
        var f = V.p;
        V.p = 2;
        var v = Be;
        Be |= 4;
        try {
          xy(s, i);
          var x = Pp, P = Tv(i.containerInfo), Y = x.focusedElem, rt = x.selectionRange;
          if (P !== Y && Y && Y.ownerDocument && wv(
            Y.ownerDocument.documentElement,
            Y
          )) {
            if (rt !== null && ah(Y)) {
              var pt = rt.start, bt = rt.end;
              if (bt === void 0 && (bt = pt), "selectionStart" in Y)
                Y.selectionStart = pt, Y.selectionEnd = Math.min(
                  bt,
                  Y.value.length
                );
              else {
                var At = Y.ownerDocument || document, vt = At && At.defaultView || window;
                if (vt.getSelection) {
                  var xt = vt.getSelection(), $t = Y.textContent.length, ae = Math.min(rt.start, $t), Ye = rt.end === void 0 ? ae : Math.min(rt.end, $t);
                  !xt.extend && ae > Ye && (P = Ye, Ye = ae, ae = P);
                  var dt = Ev(
                    Y,
                    ae
                  ), at = Ev(
                    Y,
                    Ye
                  );
                  if (dt && at && (xt.rangeCount !== 1 || xt.anchorNode !== dt.node || xt.anchorOffset !== dt.offset || xt.focusNode !== at.node || xt.focusOffset !== at.offset)) {
                    var ht = At.createRange();
                    ht.setStart(dt.node, dt.offset), xt.removeAllRanges(), ae > Ye ? (xt.addRange(ht), xt.extend(at.node, at.offset)) : (ht.setEnd(at.node, at.offset), xt.addRange(ht));
                  }
                }
              }
            }
            for (At = [], xt = Y; xt = xt.parentNode; )
              xt.nodeType === 1 && At.push({
                element: xt,
                left: xt.scrollLeft,
                top: xt.scrollTop
              });
            for (typeof Y.focus == "function" && Y.focus(), Y = 0; Y < At.length; Y++) {
              var Tt = At[Y];
              Tt.element.scrollLeft = Tt.left, Tt.element.scrollTop = Tt.top;
            }
          }
          ef = !!Op, Pp = Op = null;
        } finally {
          Be = v, V.p = f, D.T = l;
        }
      }
      i.current = s, An = 2;
    }
  }
  function Vy() {
    if (An === 2) {
      An = 0;
      var i = xs, s = fo, l = (s.flags & 8772) !== 0;
      if ((s.subtreeFlags & 8772) !== 0 || l) {
        l = D.T, D.T = null;
        var f = V.p;
        V.p = 2;
        var v = Be;
        Be |= 4;
        try {
          my(i, s.alternate, s);
        } finally {
          Be = v, V.p = f, D.T = l;
        }
      }
      An = 3;
    }
  }
  function ky() {
    if (An === 4 || An === 3) {
      An = 0, mt();
      var i = xs, s = fo, l = Fr, f = Cy;
      (s.subtreeFlags & 10256) !== 0 || (s.flags & 10256) !== 0 ? An = 5 : (An = 0, fo = xs = null, Gy(i, i.pendingLanes));
      var v = i.pendingLanes;
      if (v === 0 && (ys = null), rs(l), s = s.stateNode, Kt && typeof Kt.onCommitFiberRoot == "function")
        try {
          Kt.onCommitFiberRoot(
            te,
            s,
            void 0,
            (s.current.flags & 128) === 128
          );
        } catch {
        }
      if (f !== null) {
        s = D.T, v = V.p, V.p = 2, D.T = null;
        try {
          for (var x = i.onRecoverableError, P = 0; P < f.length; P++) {
            var Y = f[P];
            x(Y.value, {
              componentStack: Y.stack
            });
          }
        } finally {
          D.T = s, V.p = v;
        }
      }
      (Fr & 3) !== 0 && Gu(), ar(i), v = i.pendingLanes, (l & 261930) !== 0 && (v & 42) !== 0 ? i === Sp ? Yl++ : (Yl = 0, Sp = i) : Yl = 0, ql(0);
    }
  }
  function Gy(i, s) {
    (i.pooledCacheLanes &= s) === 0 && (s = i.pooledCache, s != null && (i.pooledCache = null, Cl(s)));
  }
  function Gu() {
    return Hy(), Vy(), ky(), Xy();
  }
  function Xy() {
    if (An !== 5) return !1;
    var i = xs, s = yp;
    yp = 0;
    var l = rs(Fr), f = D.T, v = V.p;
    try {
      V.p = 32 > l ? 32 : l, D.T = null, l = xp, xp = null;
      var x = xs, P = Fr;
      if (An = 0, fo = xs = null, Fr = 0, (Be & 6) !== 0) throw Error(r(331));
      var Y = Be;
      if (Be |= 4, wy(x.current), by(
        x,
        x.current,
        P,
        l
      ), Be = Y, ql(0, !1), Kt && typeof Kt.onPostCommitFiberRoot == "function")
        try {
          Kt.onPostCommitFiberRoot(te, x);
        } catch {
        }
      return !0;
    } finally {
      V.p = v, D.T = f, Gy(i, s);
    }
  }
  function jy(i, s, l) {
    s = Ui(l, s), s = Jh(i.stateNode, s, 2), i = hs(i, s, 2), i !== null && (wn(i, 2), ar(i));
  }
  function Ve(i, s, l) {
    if (i.tag === 3)
      jy(i, i, l);
    else
      for (; s !== null; ) {
        if (s.tag === 3) {
          jy(
            s,
            i,
            l
          );
          break;
        } else if (s.tag === 1) {
          var f = s.stateNode;
          if (typeof s.type.getDerivedStateFromError == "function" || typeof f.componentDidCatch == "function" && (ys === null || !ys.has(f))) {
            i = Ui(l, i), l = W_(2), f = hs(s, l, 2), f !== null && (Y_(
              l,
              f,
              s,
              i
            ), wn(f, 2), ar(f));
            break;
          }
        }
        s = s.return;
      }
  }
  function Ep(i, s, l) {
    var f = i.pingCache;
    if (f === null) {
      f = i.pingCache = new eA();
      var v = /* @__PURE__ */ new Set();
      f.set(s, v);
    } else
      v = f.get(s), v === void 0 && (v = /* @__PURE__ */ new Set(), f.set(s, v));
    v.has(l) || (gp = !0, v.add(l), i = aA.bind(null, i, s, l), s.then(i, i));
  }
  function aA(i, s, l) {
    var f = i.pingCache;
    f !== null && f.delete(s), i.pingedLanes |= i.suspendedLanes & l, i.warmLanes &= ~l, Je === i && (Ce & l) === l && (un === 4 || un === 3 && (Ce & 62914560) === Ce && 300 > Et() - Iu ? (Be & 2) === 0 && ho(i, 0) : vp |= l, uo === Ce && (uo = 0)), ar(i);
  }
  function Wy(i, s) {
    s === 0 && (s = dn()), i = ta(i, s), i !== null && (wn(i, s), ar(i));
  }
  function oA(i) {
    var s = i.memoizedState, l = 0;
    s !== null && (l = s.retryLane), Wy(i, l);
  }
  function lA(i, s) {
    var l = 0;
    switch (i.tag) {
      case 31:
      case 13:
        var f = i.stateNode, v = i.memoizedState;
        v !== null && (l = v.retryLane);
        break;
      case 19:
        f = i.stateNode;
        break;
      case 22:
        f = i.stateNode._retryCache;
        break;
      default:
        throw Error(r(314));
    }
    f !== null && f.delete(s), Wy(i, l);
  }
  function cA(i, s) {
    return qt(i, s);
  }
  var Xu = null, mo = null, wp = !1, ju = !1, Tp = !1, bs = 0;
  function ar(i) {
    i !== mo && i.next === null && (mo === null ? Xu = mo = i : mo = mo.next = i), ju = !0, wp || (wp = !0, fA());
  }
  function ql(i, s) {
    if (!Tp && ju) {
      Tp = !0;
      do
        for (var l = !1, f = Xu; f !== null; ) {
          if (i !== 0) {
            var v = f.pendingLanes;
            if (v === 0) var x = 0;
            else {
              var P = f.suspendedLanes, Y = f.pingedLanes;
              x = (1 << 31 - le(42 | i) + 1) - 1, x &= v & ~(P & ~Y), x = x & 201326741 ? x & 201326741 | 1 : x ? x | 2 : 0;
            }
            x !== 0 && (l = !0, $y(f, x));
          } else
            x = Ce, x = Ht(
              f,
              f === Je ? x : 0,
              f.cancelPendingCommit !== null || f.timeoutHandle !== -1
            ), (x & 3) === 0 || ue(f, x) || (l = !0, $y(f, x));
          f = f.next;
        }
      while (l);
      Tp = !1;
    }
  }
  function uA() {
    Yy();
  }
  function Yy() {
    ju = wp = !1;
    var i = 0;
    bs !== 0 && SA() && (i = bs);
    for (var s = Et(), l = null, f = Xu; f !== null; ) {
      var v = f.next, x = qy(f, s);
      x === 0 ? (f.next = null, l === null ? Xu = v : l.next = v, v === null && (mo = l)) : (l = f, (i !== 0 || (x & 3) !== 0) && (ju = !0)), f = v;
    }
    An !== 0 && An !== 5 || ql(i), bs !== 0 && (bs = 0);
  }
  function qy(i, s) {
    for (var l = i.suspendedLanes, f = i.pingedLanes, v = i.expirationTimes, x = i.pendingLanes & -62914561; 0 < x; ) {
      var P = 31 - le(x), Y = 1 << P, rt = v[P];
      rt === -1 ? ((Y & l) === 0 || (Y & f) !== 0) && (v[P] = tn(Y, s)) : rt <= s && (i.expiredLanes |= Y), x &= ~Y;
    }
    if (s = Je, l = Ce, l = Ht(
      i,
      i === s ? l : 0,
      i.cancelPendingCommit !== null || i.timeoutHandle !== -1
    ), f = i.callbackNode, l === 0 || i === s && (He === 2 || He === 9) || i.cancelPendingCommit !== null)
      return f !== null && f !== null && tt(f), i.callbackNode = null, i.callbackPriority = 0;
    if ((l & 3) === 0 || ue(i, l)) {
      if (s = l & -l, s === i.callbackPriority) return s;
      switch (f !== null && tt(f), rs(l)) {
        case 2:
        case 8:
          l = Zt;
          break;
        case 32:
          l = Pt;
          break;
        case 268435456:
          l = _e;
          break;
        default:
          l = Pt;
      }
      return f = Zy.bind(null, i), l = qt(l, f), i.callbackPriority = s, i.callbackNode = l, s;
    }
    return f !== null && f !== null && tt(f), i.callbackPriority = 2, i.callbackNode = null, 2;
  }
  function Zy(i, s) {
    if (An !== 0 && An !== 5)
      return i.callbackNode = null, i.callbackPriority = 0, null;
    var l = i.callbackNode;
    if (Gu() && i.callbackNode !== l)
      return null;
    var f = Ce;
    return f = Ht(
      i,
      i === Je ? f : 0,
      i.cancelPendingCommit !== null || i.timeoutHandle !== -1
    ), f === 0 ? null : (Dy(i, f, s), qy(i, Et()), i.callbackNode != null && i.callbackNode === l ? Zy.bind(null, i) : null);
  }
  function $y(i, s) {
    if (Gu()) return null;
    Dy(i, s, !0);
  }
  function fA() {
    MA(function() {
      (Be & 6) !== 0 ? qt(
        wt,
        uA
      ) : Yy();
    });
  }
  function Ap() {
    if (bs === 0) {
      var i = Ja;
      i === 0 && (i = zt, zt <<= 1, (zt & 261888) === 0 && (zt = 256)), bs = i;
    }
    return bs;
  }
  function Ky(i) {
    return i == null || typeof i == "symbol" || typeof i == "boolean" ? null : typeof i == "function" ? i : Jc("" + i);
  }
  function Qy(i, s) {
    var l = s.ownerDocument.createElement("input");
    return l.name = s.name, l.value = s.value, i.id && l.setAttribute("form", i.id), s.parentNode.insertBefore(l, s), i = new FormData(i), l.parentNode.removeChild(l), i;
  }
  function dA(i, s, l, f, v) {
    if (s === "submit" && l && l.stateNode === v) {
      var x = Ky(
        (v[Tn] || null).action
      ), P = f.submitter;
      P && (s = (s = P[Tn] || null) ? Ky(s.formAction) : P.getAttribute("formAction"), s !== null && (x = s, P = null));
      var Y = new iu(
        "action",
        "action",
        null,
        f,
        v
      );
      i.push({
        event: Y,
        listeners: [
          {
            instance: null,
            listener: function() {
              if (f.defaultPrevented) {
                if (bs !== 0) {
                  var rt = P ? Qy(v, P) : new FormData(v);
                  Yh(
                    l,
                    {
                      pending: !0,
                      data: rt,
                      method: v.method,
                      action: x
                    },
                    null,
                    rt
                  );
                }
              } else
                typeof x == "function" && (Y.preventDefault(), rt = P ? Qy(v, P) : new FormData(v), Yh(
                  l,
                  {
                    pending: !0,
                    data: rt,
                    method: v.method,
                    action: x
                  },
                  x,
                  rt
                ));
            },
            currentTarget: v
          }
        ]
      });
    }
  }
  for (var Cp = 0; Cp < uh.length; Cp++) {
    var Rp = uh[Cp], hA = Rp.toLowerCase(), pA = Rp[0].toUpperCase() + Rp.slice(1);
    Xi(
      hA,
      "on" + pA
    );
  }
  Xi(Rv, "onAnimationEnd"), Xi(Dv, "onAnimationIteration"), Xi(Nv, "onAnimationStart"), Xi("dblclick", "onDoubleClick"), Xi("focusin", "onFocus"), Xi("focusout", "onBlur"), Xi(DT, "onTransitionRun"), Xi(NT, "onTransitionStart"), Xi(LT, "onTransitionCancel"), Xi(Lv, "onTransitionEnd"), Xt("onMouseEnter", ["mouseout", "mouseover"]), Xt("onMouseLeave", ["mouseout", "mouseover"]), Xt("onPointerEnter", ["pointerout", "pointerover"]), Xt("onPointerLeave", ["pointerout", "pointerover"]), kt(
    "onChange",
    "change click focusin focusout input keydown keyup selectionchange".split(" ")
  ), kt(
    "onSelect",
    "focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(
      " "
    )
  ), kt("onBeforeInput", [
    "compositionend",
    "keypress",
    "textInput",
    "paste"
  ]), kt(
    "onCompositionEnd",
    "compositionend focusout keydown keypress keyup mousedown".split(" ")
  ), kt(
    "onCompositionStart",
    "compositionstart focusout keydown keypress keyup mousedown".split(" ")
  ), kt(
    "onCompositionUpdate",
    "compositionupdate focusout keydown keypress keyup mousedown".split(" ")
  );
  var Zl = "abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(
    " "
  ), mA = new Set(
    "beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Zl)
  );
  function Jy(i, s) {
    s = (s & 4) !== 0;
    for (var l = 0; l < i.length; l++) {
      var f = i[l], v = f.event;
      f = f.listeners;
      t: {
        var x = void 0;
        if (s)
          for (var P = f.length - 1; 0 <= P; P--) {
            var Y = f[P], rt = Y.instance, pt = Y.currentTarget;
            if (Y = Y.listener, rt !== x && v.isPropagationStopped())
              break t;
            x = Y, v.currentTarget = pt;
            try {
              x(v);
            } catch (bt) {
              au(bt);
            }
            v.currentTarget = null, x = rt;
          }
        else
          for (P = 0; P < f.length; P++) {
            if (Y = f[P], rt = Y.instance, pt = Y.currentTarget, Y = Y.listener, rt !== x && v.isPropagationStopped())
              break t;
            x = Y, v.currentTarget = pt;
            try {
              x(v);
            } catch (bt) {
              au(bt);
            }
            v.currentTarget = null, x = rt;
          }
      }
    }
  }
  function Ae(i, s) {
    var l = s[ss];
    l === void 0 && (l = s[ss] = /* @__PURE__ */ new Set());
    var f = i + "__bubble";
    l.has(f) || (tx(s, i, 2, !1), l.add(f));
  }
  function Dp(i, s, l) {
    var f = 0;
    s && (f |= 4), tx(
      l,
      i,
      f,
      s
    );
  }
  var Wu = "_reactListening" + Math.random().toString(36).slice(2);
  function Np(i) {
    if (!i[Wu]) {
      i[Wu] = !0, Lt.forEach(function(l) {
        l !== "selectionchange" && (mA.has(l) || Dp(l, !1, i), Dp(l, !0, i));
      });
      var s = i.nodeType === 9 ? i : i.ownerDocument;
      s === null || s[Wu] || (s[Wu] = !0, Dp("selectionchange", !1, s));
    }
  }
  function tx(i, s, l, f) {
    switch (Rx(s)) {
      case 2:
        var v = GA;
        break;
      case 8:
        v = XA;
        break;
      default:
        v = Wp;
    }
    l = v.bind(
      null,
      s,
      l,
      i
    ), v = void 0, !Kd || s !== "touchstart" && s !== "touchmove" && s !== "wheel" || (v = !0), f ? v !== void 0 ? i.addEventListener(s, l, {
      capture: !0,
      passive: v
    }) : i.addEventListener(s, l, !0) : v !== void 0 ? i.addEventListener(s, l, {
      passive: v
    }) : i.addEventListener(s, l, !1);
  }
  function Lp(i, s, l, f, v) {
    var x = f;
    if ((s & 1) === 0 && (s & 2) === 0 && f !== null)
      t: for (; ; ) {
        if (f === null) return;
        var P = f.tag;
        if (P === 3 || P === 4) {
          var Y = f.stateNode.containerInfo;
          if (Y === v) break;
          if (P === 4)
            for (P = f.return; P !== null; ) {
              var rt = P.tag;
              if ((rt === 3 || rt === 4) && P.stateNode.containerInfo === v)
                return;
              P = P.return;
            }
          for (; Y !== null; ) {
            if (P = Z(Y), P === null) return;
            if (rt = P.tag, rt === 5 || rt === 6 || rt === 26 || rt === 27) {
              f = x = P;
              continue t;
            }
            Y = Y.parentNode;
          }
        }
        f = f.return;
      }
    sv(function() {
      var pt = x, bt = Zd(l), At = [];
      t: {
        var vt = Uv.get(i);
        if (vt !== void 0) {
          var xt = iu, $t = i;
          switch (i) {
            case "keypress":
              if (eu(l) === 0) break t;
            case "keydown":
            case "keyup":
              xt = lT;
              break;
            case "focusin":
              $t = "focus", xt = eh;
              break;
            case "focusout":
              $t = "blur", xt = eh;
              break;
            case "beforeblur":
            case "afterblur":
              xt = eh;
              break;
            case "click":
              if (l.button === 2) break t;
            case "auxclick":
            case "dblclick":
            case "mousedown":
            case "mousemove":
            case "mouseup":
            case "mouseout":
            case "mouseover":
            case "contextmenu":
              xt = lv;
              break;
            case "drag":
            case "dragend":
            case "dragenter":
            case "dragexit":
            case "dragleave":
            case "dragover":
            case "dragstart":
            case "drop":
              xt = $w;
              break;
            case "touchcancel":
            case "touchend":
            case "touchmove":
            case "touchstart":
              xt = fT;
              break;
            case Rv:
            case Dv:
            case Nv:
              xt = Jw;
              break;
            case Lv:
              xt = hT;
              break;
            case "scroll":
            case "scrollend":
              xt = qw;
              break;
            case "wheel":
              xt = mT;
              break;
            case "copy":
            case "cut":
            case "paste":
              xt = eT;
              break;
            case "gotpointercapture":
            case "lostpointercapture":
            case "pointercancel":
            case "pointerdown":
            case "pointermove":
            case "pointerout":
            case "pointerover":
            case "pointerup":
              xt = uv;
              break;
            case "toggle":
            case "beforetoggle":
              xt = vT;
          }
          var ae = (s & 4) !== 0, Ye = !ae && (i === "scroll" || i === "scrollend"), dt = ae ? vt !== null ? vt + "Capture" : null : vt;
          ae = [];
          for (var at = pt, ht; at !== null; ) {
            var Tt = at;
            if (ht = Tt.stateNode, Tt = Tt.tag, Tt !== 5 && Tt !== 26 && Tt !== 27 || ht === null || dt === null || (Tt = vl(at, dt), Tt != null && ae.push(
              $l(at, Tt, ht)
            )), Ye) break;
            at = at.return;
          }
          0 < ae.length && (vt = new xt(
            vt,
            $t,
            null,
            l,
            bt
          ), At.push({ event: vt, listeners: ae }));
        }
      }
      if ((s & 7) === 0) {
        t: {
          if (vt = i === "mouseover" || i === "pointerover", xt = i === "mouseout" || i === "pointerout", vt && l !== qd && ($t = l.relatedTarget || l.fromElement) && (Z($t) || $t[Ni]))
            break t;
          if ((xt || vt) && (vt = bt.window === bt ? bt : (vt = bt.ownerDocument) ? vt.defaultView || vt.parentWindow : window, xt ? ($t = l.relatedTarget || l.toElement, xt = pt, $t = $t ? Z($t) : null, $t !== null && (Ye = o($t), ae = $t.tag, $t !== Ye || ae !== 5 && ae !== 27 && ae !== 6) && ($t = null)) : (xt = null, $t = pt), xt !== $t)) {
            if (ae = lv, Tt = "onMouseLeave", dt = "onMouseEnter", at = "mouse", (i === "pointerout" || i === "pointerover") && (ae = uv, Tt = "onPointerLeave", dt = "onPointerEnter", at = "pointer"), Ye = xt == null ? vt : gt(xt), ht = $t == null ? vt : gt($t), vt = new ae(
              Tt,
              at + "leave",
              xt,
              l,
              bt
            ), vt.target = Ye, vt.relatedTarget = ht, Tt = null, Z(bt) === pt && (ae = new ae(
              dt,
              at + "enter",
              $t,
              l,
              bt
            ), ae.target = ht, ae.relatedTarget = Ye, Tt = ae), Ye = Tt, xt && $t)
              e: {
                for (ae = gA, dt = xt, at = $t, ht = 0, Tt = dt; Tt; Tt = ae(Tt))
                  ht++;
                Tt = 0;
                for (var se = at; se; se = ae(se))
                  Tt++;
                for (; 0 < ht - Tt; )
                  dt = ae(dt), ht--;
                for (; 0 < Tt - ht; )
                  at = ae(at), Tt--;
                for (; ht--; ) {
                  if (dt === at || at !== null && dt === at.alternate) {
                    ae = dt;
                    break e;
                  }
                  dt = ae(dt), at = ae(at);
                }
                ae = null;
              }
            else ae = null;
            xt !== null && ex(
              At,
              vt,
              xt,
              ae,
              !1
            ), $t !== null && Ye !== null && ex(
              At,
              Ye,
              $t,
              ae,
              !0
            );
          }
        }
        t: {
          if (vt = pt ? gt(pt) : window, xt = vt.nodeName && vt.nodeName.toLowerCase(), xt === "select" || xt === "input" && vt.type === "file")
            var Pe = _v;
          else if (gv(vt))
            if (yv)
              Pe = AT;
            else {
              Pe = wT;
              var Qt = ET;
            }
          else
            xt = vt.nodeName, !xt || xt.toLowerCase() !== "input" || vt.type !== "checkbox" && vt.type !== "radio" ? pt && Yd(pt.elementType) && (Pe = _v) : Pe = TT;
          if (Pe && (Pe = Pe(i, pt))) {
            vv(
              At,
              Pe,
              l,
              bt
            );
            break t;
          }
          Qt && Qt(i, vt, pt), i === "focusout" && pt && vt.type === "number" && pt.memoizedProps.value != null && On(vt, "number", vt.value);
        }
        switch (Qt = pt ? gt(pt) : window, i) {
          case "focusin":
            (gv(Qt) || Qt.contentEditable === "true") && (ja = Qt, oh = pt, wl = null);
            break;
          case "focusout":
            wl = oh = ja = null;
            break;
          case "mousedown":
            lh = !0;
            break;
          case "contextmenu":
          case "mouseup":
          case "dragend":
            lh = !1, Av(At, l, bt);
            break;
          case "selectionchange":
            if (RT) break;
          case "keydown":
          case "keyup":
            Av(At, l, bt);
        }
        var ge;
        if (ih)
          t: {
            switch (i) {
              case "compositionstart":
                var Re = "onCompositionStart";
                break t;
              case "compositionend":
                Re = "onCompositionEnd";
                break t;
              case "compositionupdate":
                Re = "onCompositionUpdate";
                break t;
            }
            Re = void 0;
          }
        else
          Xa ? pv(i, l) && (Re = "onCompositionEnd") : i === "keydown" && l.keyCode === 229 && (Re = "onCompositionStart");
        Re && (fv && l.locale !== "ko" && (Xa || Re !== "onCompositionStart" ? Re === "onCompositionEnd" && Xa && (ge = av()) : (as = bt, Qd = "value" in as ? as.value : as.textContent, Xa = !0)), Qt = Yu(pt, Re), 0 < Qt.length && (Re = new cv(
          Re,
          i,
          null,
          l,
          bt
        ), At.push({ event: Re, listeners: Qt }), ge ? Re.data = ge : (ge = mv(l), ge !== null && (Re.data = ge)))), (ge = yT ? xT(i, l) : ST(i, l)) && (Re = Yu(pt, "onBeforeInput"), 0 < Re.length && (Qt = new cv(
          "onBeforeInput",
          "beforeinput",
          null,
          l,
          bt
        ), At.push({
          event: Qt,
          listeners: Re
        }), Qt.data = ge)), dA(
          At,
          i,
          pt,
          l,
          bt
        );
      }
      Jy(At, s);
    });
  }
  function $l(i, s, l) {
    return {
      instance: i,
      listener: s,
      currentTarget: l
    };
  }
  function Yu(i, s) {
    for (var l = s + "Capture", f = []; i !== null; ) {
      var v = i, x = v.stateNode;
      if (v = v.tag, v !== 5 && v !== 26 && v !== 27 || x === null || (v = vl(i, l), v != null && f.unshift(
        $l(i, v, x)
      ), v = vl(i, s), v != null && f.push(
        $l(i, v, x)
      )), i.tag === 3) return f;
      i = i.return;
    }
    return [];
  }
  function gA(i) {
    if (i === null) return null;
    do
      i = i.return;
    while (i && i.tag !== 5 && i.tag !== 27);
    return i || null;
  }
  function ex(i, s, l, f, v) {
    for (var x = s._reactName, P = []; l !== null && l !== f; ) {
      var Y = l, rt = Y.alternate, pt = Y.stateNode;
      if (Y = Y.tag, rt !== null && rt === f) break;
      Y !== 5 && Y !== 26 && Y !== 27 || pt === null || (rt = pt, v ? (pt = vl(l, x), pt != null && P.unshift(
        $l(l, pt, rt)
      )) : v || (pt = vl(l, x), pt != null && P.push(
        $l(l, pt, rt)
      ))), l = l.return;
    }
    P.length !== 0 && i.push({ event: s, listeners: P });
  }
  var vA = /\r\n?/g, _A = /\u0000|\uFFFD/g;
  function nx(i) {
    return (typeof i == "string" ? i : "" + i).replace(vA, `
`).replace(_A, "");
  }
  function ix(i, s) {
    return s = nx(s), nx(i) === s;
  }
  function We(i, s, l, f, v, x) {
    switch (l) {
      case "children":
        typeof f == "string" ? s === "body" || s === "textarea" && f === "" || ri(i, f) : (typeof f == "number" || typeof f == "bigint") && s !== "body" && ri(i, "" + f);
        break;
      case "className":
        Qe(i, "class", f);
        break;
      case "tabIndex":
        Qe(i, "tabindex", f);
        break;
      case "dir":
      case "role":
      case "viewBox":
      case "width":
      case "height":
        Qe(i, l, f);
        break;
      case "style":
        iv(i, f, x);
        break;
      case "data":
        if (s !== "object") {
          Qe(i, "data", f);
          break;
        }
      case "src":
      case "href":
        if (f === "" && (s !== "a" || l !== "href")) {
          i.removeAttribute(l);
          break;
        }
        if (f == null || typeof f == "function" || typeof f == "symbol" || typeof f == "boolean") {
          i.removeAttribute(l);
          break;
        }
        f = Jc("" + f), i.setAttribute(l, f);
        break;
      case "action":
      case "formAction":
        if (typeof f == "function") {
          i.setAttribute(
            l,
            "javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
          );
          break;
        } else
          typeof x == "function" && (l === "formAction" ? (s !== "input" && We(i, s, "name", v.name, v, null), We(
            i,
            s,
            "formEncType",
            v.formEncType,
            v,
            null
          ), We(
            i,
            s,
            "formMethod",
            v.formMethod,
            v,
            null
          ), We(
            i,
            s,
            "formTarget",
            v.formTarget,
            v,
            null
          )) : (We(i, s, "encType", v.encType, v, null), We(i, s, "method", v.method, v, null), We(i, s, "target", v.target, v, null)));
        if (f == null || typeof f == "symbol" || typeof f == "boolean") {
          i.removeAttribute(l);
          break;
        }
        f = Jc("" + f), i.setAttribute(l, f);
        break;
      case "onClick":
        f != null && (i.onclick = Er);
        break;
      case "onScroll":
        f != null && Ae("scroll", i);
        break;
      case "onScrollEnd":
        f != null && Ae("scrollend", i);
        break;
      case "dangerouslySetInnerHTML":
        if (f != null) {
          if (typeof f != "object" || !("__html" in f))
            throw Error(r(61));
          if (l = f.__html, l != null) {
            if (v.children != null) throw Error(r(60));
            i.innerHTML = l;
          }
        }
        break;
      case "multiple":
        i.multiple = f && typeof f != "function" && typeof f != "symbol";
        break;
      case "muted":
        i.muted = f && typeof f != "function" && typeof f != "symbol";
        break;
      case "suppressContentEditableWarning":
      case "suppressHydrationWarning":
      case "defaultValue":
      case "defaultChecked":
      case "innerHTML":
      case "ref":
        break;
      case "autoFocus":
        break;
      case "xlinkHref":
        if (f == null || typeof f == "function" || typeof f == "boolean" || typeof f == "symbol") {
          i.removeAttribute("xlink:href");
          break;
        }
        l = Jc("" + f), i.setAttributeNS(
          "http://www.w3.org/1999/xlink",
          "xlink:href",
          l
        );
        break;
      case "contentEditable":
      case "spellCheck":
      case "draggable":
      case "value":
      case "autoReverse":
      case "externalResourcesRequired":
      case "focusable":
      case "preserveAlpha":
        f != null && typeof f != "function" && typeof f != "symbol" ? i.setAttribute(l, "" + f) : i.removeAttribute(l);
        break;
      case "inert":
      case "allowFullScreen":
      case "async":
      case "autoPlay":
      case "controls":
      case "default":
      case "defer":
      case "disabled":
      case "disablePictureInPicture":
      case "disableRemotePlayback":
      case "formNoValidate":
      case "hidden":
      case "loop":
      case "noModule":
      case "noValidate":
      case "open":
      case "playsInline":
      case "readOnly":
      case "required":
      case "reversed":
      case "scoped":
      case "seamless":
      case "itemScope":
        f && typeof f != "function" && typeof f != "symbol" ? i.setAttribute(l, "") : i.removeAttribute(l);
        break;
      case "capture":
      case "download":
        f === !0 ? i.setAttribute(l, "") : f !== !1 && f != null && typeof f != "function" && typeof f != "symbol" ? i.setAttribute(l, f) : i.removeAttribute(l);
        break;
      case "cols":
      case "rows":
      case "size":
      case "span":
        f != null && typeof f != "function" && typeof f != "symbol" && !isNaN(f) && 1 <= f ? i.setAttribute(l, f) : i.removeAttribute(l);
        break;
      case "rowSpan":
      case "start":
        f == null || typeof f == "function" || typeof f == "symbol" || isNaN(f) ? i.removeAttribute(l) : i.setAttribute(l, f);
        break;
      case "popover":
        Ae("beforetoggle", i), Ae("toggle", i), we(i, "popover", f);
        break;
      case "xlinkActuate":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:actuate",
          f
        );
        break;
      case "xlinkArcrole":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:arcrole",
          f
        );
        break;
      case "xlinkRole":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:role",
          f
        );
        break;
      case "xlinkShow":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:show",
          f
        );
        break;
      case "xlinkTitle":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:title",
          f
        );
        break;
      case "xlinkType":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:type",
          f
        );
        break;
      case "xmlBase":
        Le(
          i,
          "http://www.w3.org/XML/1998/namespace",
          "xml:base",
          f
        );
        break;
      case "xmlLang":
        Le(
          i,
          "http://www.w3.org/XML/1998/namespace",
          "xml:lang",
          f
        );
        break;
      case "xmlSpace":
        Le(
          i,
          "http://www.w3.org/XML/1998/namespace",
          "xml:space",
          f
        );
        break;
      case "is":
        we(i, "is", f);
        break;
      case "innerText":
      case "textContent":
        break;
      default:
        (!(2 < l.length) || l[0] !== "o" && l[0] !== "O" || l[1] !== "n" && l[1] !== "N") && (l = Ww.get(l) || l, we(i, l, f));
    }
  }
  function Up(i, s, l, f, v, x) {
    switch (l) {
      case "style":
        iv(i, f, x);
        break;
      case "dangerouslySetInnerHTML":
        if (f != null) {
          if (typeof f != "object" || !("__html" in f))
            throw Error(r(61));
          if (l = f.__html, l != null) {
            if (v.children != null) throw Error(r(60));
            i.innerHTML = l;
          }
        }
        break;
      case "children":
        typeof f == "string" ? ri(i, f) : (typeof f == "number" || typeof f == "bigint") && ri(i, "" + f);
        break;
      case "onScroll":
        f != null && Ae("scroll", i);
        break;
      case "onScrollEnd":
        f != null && Ae("scrollend", i);
        break;
      case "onClick":
        f != null && (i.onclick = Er);
        break;
      case "suppressContentEditableWarning":
      case "suppressHydrationWarning":
      case "innerHTML":
      case "ref":
        break;
      case "innerText":
      case "textContent":
        break;
      default:
        if (!Vt.hasOwnProperty(l))
          t: {
            if (l[0] === "o" && l[1] === "n" && (v = l.endsWith("Capture"), s = l.slice(2, v ? l.length - 7 : void 0), x = i[Tn] || null, x = x != null ? x[l] : null, typeof x == "function" && i.removeEventListener(s, x, v), typeof f == "function")) {
              typeof x != "function" && x !== null && (l in i ? i[l] = null : i.hasAttribute(l) && i.removeAttribute(l)), i.addEventListener(s, f, v);
              break t;
            }
            l in i ? i[l] = f : f === !0 ? i.setAttribute(l, "") : we(i, l, f);
          }
    }
  }
  function Gn(i, s, l) {
    switch (s) {
      case "div":
      case "span":
      case "svg":
      case "path":
      case "a":
      case "g":
      case "p":
      case "li":
        break;
      case "img":
        Ae("error", i), Ae("load", i);
        var f = !1, v = !1, x;
        for (x in l)
          if (l.hasOwnProperty(x)) {
            var P = l[x];
            if (P != null)
              switch (x) {
                case "src":
                  f = !0;
                  break;
                case "srcSet":
                  v = !0;
                  break;
                case "children":
                case "dangerouslySetInnerHTML":
                  throw Error(r(137, s));
                default:
                  We(i, s, x, P, l, null);
              }
          }
        v && We(i, s, "srcSet", l.srcSet, l, null), f && We(i, s, "src", l.src, l, null);
        return;
      case "input":
        Ae("invalid", i);
        var Y = x = P = v = null, rt = null, pt = null;
        for (f in l)
          if (l.hasOwnProperty(f)) {
            var bt = l[f];
            if (bt != null)
              switch (f) {
                case "name":
                  v = bt;
                  break;
                case "type":
                  P = bt;
                  break;
                case "checked":
                  rt = bt;
                  break;
                case "defaultChecked":
                  pt = bt;
                  break;
                case "value":
                  x = bt;
                  break;
                case "defaultValue":
                  Y = bt;
                  break;
                case "children":
                case "dangerouslySetInnerHTML":
                  if (bt != null)
                    throw Error(r(137, s));
                  break;
                default:
                  We(i, s, f, bt, l, null);
              }
          }
        Bn(
          i,
          x,
          Y,
          rt,
          pt,
          P,
          v,
          !1
        );
        return;
      case "select":
        Ae("invalid", i), f = P = x = null;
        for (v in l)
          if (l.hasOwnProperty(v) && (Y = l[v], Y != null))
            switch (v) {
              case "value":
                x = Y;
                break;
              case "defaultValue":
                P = Y;
                break;
              case "multiple":
                f = Y;
              default:
                We(i, s, v, Y, l, null);
            }
        s = x, l = P, i.multiple = !!f, s != null ? en(i, !!f, s, !1) : l != null && en(i, !!f, l, !0);
        return;
      case "textarea":
        Ae("invalid", i), x = v = f = null;
        for (P in l)
          if (l.hasOwnProperty(P) && (Y = l[P], Y != null))
            switch (P) {
              case "value":
                f = Y;
                break;
              case "defaultValue":
                v = Y;
                break;
              case "children":
                x = Y;
                break;
              case "dangerouslySetInnerHTML":
                if (Y != null) throw Error(r(91));
                break;
              default:
                We(i, s, P, Y, l, null);
            }
        Va(i, f, v, x);
        return;
      case "option":
        for (rt in l)
          if (l.hasOwnProperty(rt) && (f = l[rt], f != null))
            switch (rt) {
              case "selected":
                i.selected = f && typeof f != "function" && typeof f != "symbol";
                break;
              default:
                We(i, s, rt, f, l, null);
            }
        return;
      case "dialog":
        Ae("beforetoggle", i), Ae("toggle", i), Ae("cancel", i), Ae("close", i);
        break;
      case "iframe":
      case "object":
        Ae("load", i);
        break;
      case "video":
      case "audio":
        for (f = 0; f < Zl.length; f++)
          Ae(Zl[f], i);
        break;
      case "image":
        Ae("error", i), Ae("load", i);
        break;
      case "details":
        Ae("toggle", i);
        break;
      case "embed":
      case "source":
      case "link":
        Ae("error", i), Ae("load", i);
      case "area":
      case "base":
      case "br":
      case "col":
      case "hr":
      case "keygen":
      case "meta":
      case "param":
      case "track":
      case "wbr":
      case "menuitem":
        for (pt in l)
          if (l.hasOwnProperty(pt) && (f = l[pt], f != null))
            switch (pt) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(r(137, s));
              default:
                We(i, s, pt, f, l, null);
            }
        return;
      default:
        if (Yd(s)) {
          for (bt in l)
            l.hasOwnProperty(bt) && (f = l[bt], f !== void 0 && Up(
              i,
              s,
              bt,
              f,
              l,
              void 0
            ));
          return;
        }
    }
    for (Y in l)
      l.hasOwnProperty(Y) && (f = l[Y], f != null && We(i, s, Y, f, l, null));
  }
  function yA(i, s, l, f) {
    switch (s) {
      case "div":
      case "span":
      case "svg":
      case "path":
      case "a":
      case "g":
      case "p":
      case "li":
        break;
      case "input":
        var v = null, x = null, P = null, Y = null, rt = null, pt = null, bt = null;
        for (xt in l) {
          var At = l[xt];
          if (l.hasOwnProperty(xt) && At != null)
            switch (xt) {
              case "checked":
                break;
              case "value":
                break;
              case "defaultValue":
                rt = At;
              default:
                f.hasOwnProperty(xt) || We(i, s, xt, null, f, At);
            }
        }
        for (var vt in f) {
          var xt = f[vt];
          if (At = l[vt], f.hasOwnProperty(vt) && (xt != null || At != null))
            switch (vt) {
              case "type":
                x = xt;
                break;
              case "name":
                v = xt;
                break;
              case "checked":
                pt = xt;
                break;
              case "defaultChecked":
                bt = xt;
                break;
              case "value":
                P = xt;
                break;
              case "defaultValue":
                Y = xt;
                break;
              case "children":
              case "dangerouslySetInnerHTML":
                if (xt != null)
                  throw Error(r(137, s));
                break;
              default:
                xt !== At && We(
                  i,
                  s,
                  vt,
                  xt,
                  f,
                  At
                );
            }
        }
        Oe(
          i,
          P,
          Y,
          rt,
          pt,
          bt,
          x,
          v
        );
        return;
      case "select":
        xt = P = Y = vt = null;
        for (x in l)
          if (rt = l[x], l.hasOwnProperty(x) && rt != null)
            switch (x) {
              case "value":
                break;
              case "multiple":
                xt = rt;
              default:
                f.hasOwnProperty(x) || We(
                  i,
                  s,
                  x,
                  null,
                  f,
                  rt
                );
            }
        for (v in f)
          if (x = f[v], rt = l[v], f.hasOwnProperty(v) && (x != null || rt != null))
            switch (v) {
              case "value":
                vt = x;
                break;
              case "defaultValue":
                Y = x;
                break;
              case "multiple":
                P = x;
              default:
                x !== rt && We(
                  i,
                  s,
                  v,
                  x,
                  f,
                  rt
                );
            }
        s = Y, l = P, f = xt, vt != null ? en(i, !!l, vt, !1) : !!f != !!l && (s != null ? en(i, !!l, s, !0) : en(i, !!l, l ? [] : "", !1));
        return;
      case "textarea":
        xt = vt = null;
        for (Y in l)
          if (v = l[Y], l.hasOwnProperty(Y) && v != null && !f.hasOwnProperty(Y))
            switch (Y) {
              case "value":
                break;
              case "children":
                break;
              default:
                We(i, s, Y, null, f, v);
            }
        for (P in f)
          if (v = f[P], x = l[P], f.hasOwnProperty(P) && (v != null || x != null))
            switch (P) {
              case "value":
                vt = v;
                break;
              case "defaultValue":
                xt = v;
                break;
              case "children":
                break;
              case "dangerouslySetInnerHTML":
                if (v != null) throw Error(r(91));
                break;
              default:
                v !== x && We(i, s, P, v, f, x);
            }
        Fn(i, vt, xt);
        return;
      case "option":
        for (var $t in l)
          if (vt = l[$t], l.hasOwnProperty($t) && vt != null && !f.hasOwnProperty($t))
            switch ($t) {
              case "selected":
                i.selected = !1;
                break;
              default:
                We(
                  i,
                  s,
                  $t,
                  null,
                  f,
                  vt
                );
            }
        for (rt in f)
          if (vt = f[rt], xt = l[rt], f.hasOwnProperty(rt) && vt !== xt && (vt != null || xt != null))
            switch (rt) {
              case "selected":
                i.selected = vt && typeof vt != "function" && typeof vt != "symbol";
                break;
              default:
                We(
                  i,
                  s,
                  rt,
                  vt,
                  f,
                  xt
                );
            }
        return;
      case "img":
      case "link":
      case "area":
      case "base":
      case "br":
      case "col":
      case "embed":
      case "hr":
      case "keygen":
      case "meta":
      case "param":
      case "source":
      case "track":
      case "wbr":
      case "menuitem":
        for (var ae in l)
          vt = l[ae], l.hasOwnProperty(ae) && vt != null && !f.hasOwnProperty(ae) && We(i, s, ae, null, f, vt);
        for (pt in f)
          if (vt = f[pt], xt = l[pt], f.hasOwnProperty(pt) && vt !== xt && (vt != null || xt != null))
            switch (pt) {
              case "children":
              case "dangerouslySetInnerHTML":
                if (vt != null)
                  throw Error(r(137, s));
                break;
              default:
                We(
                  i,
                  s,
                  pt,
                  vt,
                  f,
                  xt
                );
            }
        return;
      default:
        if (Yd(s)) {
          for (var Ye in l)
            vt = l[Ye], l.hasOwnProperty(Ye) && vt !== void 0 && !f.hasOwnProperty(Ye) && Up(
              i,
              s,
              Ye,
              void 0,
              f,
              vt
            );
          for (bt in f)
            vt = f[bt], xt = l[bt], !f.hasOwnProperty(bt) || vt === xt || vt === void 0 && xt === void 0 || Up(
              i,
              s,
              bt,
              vt,
              f,
              xt
            );
          return;
        }
    }
    for (var dt in l)
      vt = l[dt], l.hasOwnProperty(dt) && vt != null && !f.hasOwnProperty(dt) && We(i, s, dt, null, f, vt);
    for (At in f)
      vt = f[At], xt = l[At], !f.hasOwnProperty(At) || vt === xt || vt == null && xt == null || We(i, s, At, vt, f, xt);
  }
  function rx(i) {
    switch (i) {
      case "css":
      case "script":
      case "font":
      case "img":
      case "image":
      case "input":
      case "link":
        return !0;
      default:
        return !1;
    }
  }
  function xA() {
    if (typeof performance.getEntriesByType == "function") {
      for (var i = 0, s = 0, l = performance.getEntriesByType("resource"), f = 0; f < l.length; f++) {
        var v = l[f], x = v.transferSize, P = v.initiatorType, Y = v.duration;
        if (x && Y && rx(P)) {
          for (P = 0, Y = v.responseEnd, f += 1; f < l.length; f++) {
            var rt = l[f], pt = rt.startTime;
            if (pt > Y) break;
            var bt = rt.transferSize, At = rt.initiatorType;
            bt && rx(At) && (rt = rt.responseEnd, P += bt * (rt < Y ? 1 : (Y - pt) / (rt - pt)));
          }
          if (--f, s += 8 * (x + P) / (v.duration / 1e3), i++, 10 < i) break;
        }
      }
      if (0 < i) return s / i / 1e6;
    }
    return navigator.connection && (i = navigator.connection.downlink, typeof i == "number") ? i : 5;
  }
  var Op = null, Pp = null;
  function qu(i) {
    return i.nodeType === 9 ? i : i.ownerDocument;
  }
  function sx(i) {
    switch (i) {
      case "http://www.w3.org/2000/svg":
        return 1;
      case "http://www.w3.org/1998/Math/MathML":
        return 2;
      default:
        return 0;
    }
  }
  function ax(i, s) {
    if (i === 0)
      switch (s) {
        case "svg":
          return 1;
        case "math":
          return 2;
        default:
          return 0;
      }
    return i === 1 && s === "foreignObject" ? 0 : i;
  }
  function zp(i, s) {
    return i === "textarea" || i === "noscript" || typeof s.children == "string" || typeof s.children == "number" || typeof s.children == "bigint" || typeof s.dangerouslySetInnerHTML == "object" && s.dangerouslySetInnerHTML !== null && s.dangerouslySetInnerHTML.__html != null;
  }
  var Ip = null;
  function SA() {
    var i = window.event;
    return i && i.type === "popstate" ? i === Ip ? !1 : (Ip = i, !0) : (Ip = null, !1);
  }
  var ox = typeof setTimeout == "function" ? setTimeout : void 0, bA = typeof clearTimeout == "function" ? clearTimeout : void 0, lx = typeof Promise == "function" ? Promise : void 0, MA = typeof queueMicrotask == "function" ? queueMicrotask : typeof lx < "u" ? function(i) {
    return lx.resolve(null).then(i).catch(EA);
  } : ox;
  function EA(i) {
    setTimeout(function() {
      throw i;
    });
  }
  function Ms(i) {
    return i === "head";
  }
  function cx(i, s) {
    var l = s, f = 0;
    do {
      var v = l.nextSibling;
      if (i.removeChild(l), v && v.nodeType === 8)
        if (l = v.data, l === "/$" || l === "/&") {
          if (f === 0) {
            i.removeChild(v), yo(s);
            return;
          }
          f--;
        } else if (l === "$" || l === "$?" || l === "$~" || l === "$!" || l === "&")
          f++;
        else if (l === "html")
          Kl(i.ownerDocument.documentElement);
        else if (l === "head") {
          l = i.ownerDocument.head, Kl(l);
          for (var x = l.firstChild; x; ) {
            var P = x.nextSibling, Y = x.nodeName;
            x[Mr] || Y === "SCRIPT" || Y === "STYLE" || Y === "LINK" && x.rel.toLowerCase() === "stylesheet" || l.removeChild(x), x = P;
          }
        } else
          l === "body" && Kl(i.ownerDocument.body);
      l = v;
    } while (l);
    yo(s);
  }
  function ux(i, s) {
    var l = i;
    i = 0;
    do {
      var f = l.nextSibling;
      if (l.nodeType === 1 ? s ? (l._stashedDisplay = l.style.display, l.style.display = "none") : (l.style.display = l._stashedDisplay || "", l.getAttribute("style") === "" && l.removeAttribute("style")) : l.nodeType === 3 && (s ? (l._stashedText = l.nodeValue, l.nodeValue = "") : l.nodeValue = l._stashedText || ""), f && f.nodeType === 8)
        if (l = f.data, l === "/$") {
          if (i === 0) break;
          i--;
        } else
          l !== "$" && l !== "$?" && l !== "$~" && l !== "$!" || i++;
      l = f;
    } while (l);
  }
  function Bp(i) {
    var s = i.firstChild;
    for (s && s.nodeType === 10 && (s = s.nextSibling); s; ) {
      var l = s;
      switch (s = s.nextSibling, l.nodeName) {
        case "HTML":
        case "HEAD":
        case "BODY":
          Bp(l), $s(l);
          continue;
        case "SCRIPT":
        case "STYLE":
          continue;
        case "LINK":
          if (l.rel.toLowerCase() === "stylesheet") continue;
      }
      i.removeChild(l);
    }
  }
  function wA(i, s, l, f) {
    for (; i.nodeType === 1; ) {
      var v = l;
      if (i.nodeName.toLowerCase() !== s.toLowerCase()) {
        if (!f && (i.nodeName !== "INPUT" || i.type !== "hidden"))
          break;
      } else if (f) {
        if (!i[Mr])
          switch (s) {
            case "meta":
              if (!i.hasAttribute("itemprop")) break;
              return i;
            case "link":
              if (x = i.getAttribute("rel"), x === "stylesheet" && i.hasAttribute("data-precedence"))
                break;
              if (x !== v.rel || i.getAttribute("href") !== (v.href == null || v.href === "" ? null : v.href) || i.getAttribute("crossorigin") !== (v.crossOrigin == null ? null : v.crossOrigin) || i.getAttribute("title") !== (v.title == null ? null : v.title))
                break;
              return i;
            case "style":
              if (i.hasAttribute("data-precedence")) break;
              return i;
            case "script":
              if (x = i.getAttribute("src"), (x !== (v.src == null ? null : v.src) || i.getAttribute("type") !== (v.type == null ? null : v.type) || i.getAttribute("crossorigin") !== (v.crossOrigin == null ? null : v.crossOrigin)) && x && i.hasAttribute("async") && !i.hasAttribute("itemprop"))
                break;
              return i;
            default:
              return i;
          }
      } else if (s === "input" && i.type === "hidden") {
        var x = v.name == null ? null : "" + v.name;
        if (v.type === "hidden" && i.getAttribute("name") === x)
          return i;
      } else return i;
      if (i = Bi(i.nextSibling), i === null) break;
    }
    return null;
  }
  function TA(i, s, l) {
    if (s === "") return null;
    for (; i.nodeType !== 3; )
      if ((i.nodeType !== 1 || i.nodeName !== "INPUT" || i.type !== "hidden") && !l || (i = Bi(i.nextSibling), i === null)) return null;
    return i;
  }
  function fx(i, s) {
    for (; i.nodeType !== 8; )
      if ((i.nodeType !== 1 || i.nodeName !== "INPUT" || i.type !== "hidden") && !s || (i = Bi(i.nextSibling), i === null)) return null;
    return i;
  }
  function Fp(i) {
    return i.data === "$?" || i.data === "$~";
  }
  function Hp(i) {
    return i.data === "$!" || i.data === "$?" && i.ownerDocument.readyState !== "loading";
  }
  function AA(i, s) {
    var l = i.ownerDocument;
    if (i.data === "$~") i._reactRetry = s;
    else if (i.data !== "$?" || l.readyState !== "loading")
      s();
    else {
      var f = function() {
        s(), l.removeEventListener("DOMContentLoaded", f);
      };
      l.addEventListener("DOMContentLoaded", f), i._reactRetry = f;
    }
  }
  function Bi(i) {
    for (; i != null; i = i.nextSibling) {
      var s = i.nodeType;
      if (s === 1 || s === 3) break;
      if (s === 8) {
        if (s = i.data, s === "$" || s === "$!" || s === "$?" || s === "$~" || s === "&" || s === "F!" || s === "F")
          break;
        if (s === "/$" || s === "/&") return null;
      }
    }
    return i;
  }
  var Vp = null;
  function dx(i) {
    i = i.nextSibling;
    for (var s = 0; i; ) {
      if (i.nodeType === 8) {
        var l = i.data;
        if (l === "/$" || l === "/&") {
          if (s === 0)
            return Bi(i.nextSibling);
          s--;
        } else
          l !== "$" && l !== "$!" && l !== "$?" && l !== "$~" && l !== "&" || s++;
      }
      i = i.nextSibling;
    }
    return null;
  }
  function hx(i) {
    i = i.previousSibling;
    for (var s = 0; i; ) {
      if (i.nodeType === 8) {
        var l = i.data;
        if (l === "$" || l === "$!" || l === "$?" || l === "$~" || l === "&") {
          if (s === 0) return i;
          s--;
        } else l !== "/$" && l !== "/&" || s++;
      }
      i = i.previousSibling;
    }
    return null;
  }
  function px(i, s, l) {
    switch (s = qu(l), i) {
      case "html":
        if (i = s.documentElement, !i) throw Error(r(452));
        return i;
      case "head":
        if (i = s.head, !i) throw Error(r(453));
        return i;
      case "body":
        if (i = s.body, !i) throw Error(r(454));
        return i;
      default:
        throw Error(r(451));
    }
  }
  function Kl(i) {
    for (var s = i.attributes; s.length; )
      i.removeAttributeNode(s[0]);
    $s(i);
  }
  var Fi = /* @__PURE__ */ new Map(), mx = /* @__PURE__ */ new Set();
  function Zu(i) {
    return typeof i.getRootNode == "function" ? i.getRootNode() : i.nodeType === 9 ? i : i.ownerDocument;
  }
  var Hr = V.d;
  V.d = {
    f: CA,
    r: RA,
    D: DA,
    C: NA,
    L: LA,
    m: UA,
    X: PA,
    S: OA,
    M: zA
  };
  function CA() {
    var i = Hr.f(), s = Hu();
    return i || s;
  }
  function RA(i) {
    var s = ft(i);
    s !== null && s.tag === 5 && s.type === "form" ? L_(s) : Hr.r(i);
  }
  var go = typeof document > "u" ? null : document;
  function gx(i, s, l) {
    var f = go;
    if (f && typeof s == "string" && s) {
      var v = gn(s);
      v = 'link[rel="' + i + '"][href="' + v + '"]', typeof l == "string" && (v += '[crossorigin="' + l + '"]'), mx.has(v) || (mx.add(v), i = { rel: i, crossOrigin: l, href: s }, f.querySelector(v) === null && (s = f.createElement("link"), Gn(s, "link", i), lt(s), f.head.appendChild(s)));
    }
  }
  function DA(i) {
    Hr.D(i), gx("dns-prefetch", i, null);
  }
  function NA(i, s) {
    Hr.C(i, s), gx("preconnect", i, s);
  }
  function LA(i, s, l) {
    Hr.L(i, s, l);
    var f = go;
    if (f && i && s) {
      var v = 'link[rel="preload"][as="' + gn(s) + '"]';
      s === "image" && l && l.imageSrcSet ? (v += '[imagesrcset="' + gn(
        l.imageSrcSet
      ) + '"]', typeof l.imageSizes == "string" && (v += '[imagesizes="' + gn(
        l.imageSizes
      ) + '"]')) : v += '[href="' + gn(i) + '"]';
      var x = v;
      switch (s) {
        case "style":
          x = vo(i);
          break;
        case "script":
          x = _o(i);
      }
      Fi.has(x) || (i = m(
        {
          rel: "preload",
          href: s === "image" && l && l.imageSrcSet ? void 0 : i,
          as: s
        },
        l
      ), Fi.set(x, i), f.querySelector(v) !== null || s === "style" && f.querySelector(Ql(x)) || s === "script" && f.querySelector(Jl(x)) || (s = f.createElement("link"), Gn(s, "link", i), lt(s), f.head.appendChild(s)));
    }
  }
  function UA(i, s) {
    Hr.m(i, s);
    var l = go;
    if (l && i) {
      var f = s && typeof s.as == "string" ? s.as : "script", v = 'link[rel="modulepreload"][as="' + gn(f) + '"][href="' + gn(i) + '"]', x = v;
      switch (f) {
        case "audioworklet":
        case "paintworklet":
        case "serviceworker":
        case "sharedworker":
        case "worker":
        case "script":
          x = _o(i);
      }
      if (!Fi.has(x) && (i = m({ rel: "modulepreload", href: i }, s), Fi.set(x, i), l.querySelector(v) === null)) {
        switch (f) {
          case "audioworklet":
          case "paintworklet":
          case "serviceworker":
          case "sharedworker":
          case "worker":
          case "script":
            if (l.querySelector(Jl(x)))
              return;
        }
        f = l.createElement("link"), Gn(f, "link", i), lt(f), l.head.appendChild(f);
      }
    }
  }
  function OA(i, s, l) {
    Hr.S(i, s, l);
    var f = go;
    if (f && i) {
      var v = yt(f).hoistableStyles, x = vo(i);
      s = s || "default";
      var P = v.get(x);
      if (!P) {
        var Y = { loading: 0, preload: null };
        if (P = f.querySelector(
          Ql(x)
        ))
          Y.loading = 5;
        else {
          i = m(
            { rel: "stylesheet", href: i, "data-precedence": s },
            l
          ), (l = Fi.get(x)) && kp(i, l);
          var rt = P = f.createElement("link");
          lt(rt), Gn(rt, "link", i), rt._p = new Promise(function(pt, bt) {
            rt.onload = pt, rt.onerror = bt;
          }), rt.addEventListener("load", function() {
            Y.loading |= 1;
          }), rt.addEventListener("error", function() {
            Y.loading |= 2;
          }), Y.loading |= 4, $u(P, s, f);
        }
        P = {
          type: "stylesheet",
          instance: P,
          count: 1,
          state: Y
        }, v.set(x, P);
      }
    }
  }
  function PA(i, s) {
    Hr.X(i, s);
    var l = go;
    if (l && i) {
      var f = yt(l).hoistableScripts, v = _o(i), x = f.get(v);
      x || (x = l.querySelector(Jl(v)), x || (i = m({ src: i, async: !0 }, s), (s = Fi.get(v)) && Gp(i, s), x = l.createElement("script"), lt(x), Gn(x, "link", i), l.head.appendChild(x)), x = {
        type: "script",
        instance: x,
        count: 1,
        state: null
      }, f.set(v, x));
    }
  }
  function zA(i, s) {
    Hr.M(i, s);
    var l = go;
    if (l && i) {
      var f = yt(l).hoistableScripts, v = _o(i), x = f.get(v);
      x || (x = l.querySelector(Jl(v)), x || (i = m({ src: i, async: !0, type: "module" }, s), (s = Fi.get(v)) && Gp(i, s), x = l.createElement("script"), lt(x), Gn(x, "link", i), l.head.appendChild(x)), x = {
        type: "script",
        instance: x,
        count: 1,
        state: null
      }, f.set(v, x));
    }
  }
  function vx(i, s, l, f) {
    var v = (v = $.current) ? Zu(v) : null;
    if (!v) throw Error(r(446));
    switch (i) {
      case "meta":
      case "title":
        return null;
      case "style":
        return typeof l.precedence == "string" && typeof l.href == "string" ? (s = vo(l.href), l = yt(
          v
        ).hoistableStyles, f = l.get(s), f || (f = {
          type: "style",
          instance: null,
          count: 0,
          state: null
        }, l.set(s, f)), f) : { type: "void", instance: null, count: 0, state: null };
      case "link":
        if (l.rel === "stylesheet" && typeof l.href == "string" && typeof l.precedence == "string") {
          i = vo(l.href);
          var x = yt(
            v
          ).hoistableStyles, P = x.get(i);
          if (P || (v = v.ownerDocument || v, P = {
            type: "stylesheet",
            instance: null,
            count: 0,
            state: { loading: 0, preload: null }
          }, x.set(i, P), (x = v.querySelector(
            Ql(i)
          )) && !x._p && (P.instance = x, P.state.loading = 5), Fi.has(i) || (l = {
            rel: "preload",
            as: "style",
            href: l.href,
            crossOrigin: l.crossOrigin,
            integrity: l.integrity,
            media: l.media,
            hrefLang: l.hrefLang,
            referrerPolicy: l.referrerPolicy
          }, Fi.set(i, l), x || IA(
            v,
            i,
            l,
            P.state
          ))), s && f === null)
            throw Error(r(528, ""));
          return P;
        }
        if (s && f !== null)
          throw Error(r(529, ""));
        return null;
      case "script":
        return s = l.async, l = l.src, typeof l == "string" && s && typeof s != "function" && typeof s != "symbol" ? (s = _o(l), l = yt(
          v
        ).hoistableScripts, f = l.get(s), f || (f = {
          type: "script",
          instance: null,
          count: 0,
          state: null
        }, l.set(s, f)), f) : { type: "void", instance: null, count: 0, state: null };
      default:
        throw Error(r(444, i));
    }
  }
  function vo(i) {
    return 'href="' + gn(i) + '"';
  }
  function Ql(i) {
    return 'link[rel="stylesheet"][' + i + "]";
  }
  function _x(i) {
    return m({}, i, {
      "data-precedence": i.precedence,
      precedence: null
    });
  }
  function IA(i, s, l, f) {
    i.querySelector('link[rel="preload"][as="style"][' + s + "]") ? f.loading = 1 : (s = i.createElement("link"), f.preload = s, s.addEventListener("load", function() {
      return f.loading |= 1;
    }), s.addEventListener("error", function() {
      return f.loading |= 2;
    }), Gn(s, "link", l), lt(s), i.head.appendChild(s));
  }
  function _o(i) {
    return '[src="' + gn(i) + '"]';
  }
  function Jl(i) {
    return "script[async]" + i;
  }
  function yx(i, s, l) {
    if (s.count++, s.instance === null)
      switch (s.type) {
        case "style":
          var f = i.querySelector(
            'style[data-href~="' + gn(l.href) + '"]'
          );
          if (f)
            return s.instance = f, lt(f), f;
          var v = m({}, l, {
            "data-href": l.href,
            "data-precedence": l.precedence,
            href: null,
            precedence: null
          });
          return f = (i.ownerDocument || i).createElement(
            "style"
          ), lt(f), Gn(f, "style", v), $u(f, l.precedence, i), s.instance = f;
        case "stylesheet":
          v = vo(l.href);
          var x = i.querySelector(
            Ql(v)
          );
          if (x)
            return s.state.loading |= 4, s.instance = x, lt(x), x;
          f = _x(l), (v = Fi.get(v)) && kp(f, v), x = (i.ownerDocument || i).createElement("link"), lt(x);
          var P = x;
          return P._p = new Promise(function(Y, rt) {
            P.onload = Y, P.onerror = rt;
          }), Gn(x, "link", f), s.state.loading |= 4, $u(x, l.precedence, i), s.instance = x;
        case "script":
          return x = _o(l.src), (v = i.querySelector(
            Jl(x)
          )) ? (s.instance = v, lt(v), v) : (f = l, (v = Fi.get(x)) && (f = m({}, l), Gp(f, v)), i = i.ownerDocument || i, v = i.createElement("script"), lt(v), Gn(v, "link", f), i.head.appendChild(v), s.instance = v);
        case "void":
          return null;
        default:
          throw Error(r(443, s.type));
      }
    else
      s.type === "stylesheet" && (s.state.loading & 4) === 0 && (f = s.instance, s.state.loading |= 4, $u(f, l.precedence, i));
    return s.instance;
  }
  function $u(i, s, l) {
    for (var f = l.querySelectorAll(
      'link[rel="stylesheet"][data-precedence],style[data-precedence]'
    ), v = f.length ? f[f.length - 1] : null, x = v, P = 0; P < f.length; P++) {
      var Y = f[P];
      if (Y.dataset.precedence === s) x = Y;
      else if (x !== v) break;
    }
    x ? x.parentNode.insertBefore(i, x.nextSibling) : (s = l.nodeType === 9 ? l.head : l, s.insertBefore(i, s.firstChild));
  }
  function kp(i, s) {
    i.crossOrigin == null && (i.crossOrigin = s.crossOrigin), i.referrerPolicy == null && (i.referrerPolicy = s.referrerPolicy), i.title == null && (i.title = s.title);
  }
  function Gp(i, s) {
    i.crossOrigin == null && (i.crossOrigin = s.crossOrigin), i.referrerPolicy == null && (i.referrerPolicy = s.referrerPolicy), i.integrity == null && (i.integrity = s.integrity);
  }
  var Ku = null;
  function xx(i, s, l) {
    if (Ku === null) {
      var f = /* @__PURE__ */ new Map(), v = Ku = /* @__PURE__ */ new Map();
      v.set(l, f);
    } else
      v = Ku, f = v.get(l), f || (f = /* @__PURE__ */ new Map(), v.set(l, f));
    if (f.has(i)) return f;
    for (f.set(i, null), l = l.getElementsByTagName(i), v = 0; v < l.length; v++) {
      var x = l[v];
      if (!(x[Mr] || x[sn] || i === "link" && x.getAttribute("rel") === "stylesheet") && x.namespaceURI !== "http://www.w3.org/2000/svg") {
        var P = x.getAttribute(s) || "";
        P = i + P;
        var Y = f.get(P);
        Y ? Y.push(x) : f.set(P, [x]);
      }
    }
    return f;
  }
  function Sx(i, s, l) {
    i = i.ownerDocument || i, i.head.insertBefore(
      l,
      s === "title" ? i.querySelector("head > title") : null
    );
  }
  function BA(i, s, l) {
    if (l === 1 || s.itemProp != null) return !1;
    switch (i) {
      case "meta":
      case "title":
        return !0;
      case "style":
        if (typeof s.precedence != "string" || typeof s.href != "string" || s.href === "")
          break;
        return !0;
      case "link":
        if (typeof s.rel != "string" || typeof s.href != "string" || s.href === "" || s.onLoad || s.onError)
          break;
        switch (s.rel) {
          case "stylesheet":
            return i = s.disabled, typeof s.precedence == "string" && i == null;
          default:
            return !0;
        }
      case "script":
        if (s.async && typeof s.async != "function" && typeof s.async != "symbol" && !s.onLoad && !s.onError && s.src && typeof s.src == "string")
          return !0;
    }
    return !1;
  }
  function bx(i) {
    return !(i.type === "stylesheet" && (i.state.loading & 3) === 0);
  }
  function FA(i, s, l, f) {
    if (l.type === "stylesheet" && (typeof f.media != "string" || matchMedia(f.media).matches !== !1) && (l.state.loading & 4) === 0) {
      if (l.instance === null) {
        var v = vo(f.href), x = s.querySelector(
          Ql(v)
        );
        if (x) {
          s = x._p, s !== null && typeof s == "object" && typeof s.then == "function" && (i.count++, i = Qu.bind(i), s.then(i, i)), l.state.loading |= 4, l.instance = x, lt(x);
          return;
        }
        x = s.ownerDocument || s, f = _x(f), (v = Fi.get(v)) && kp(f, v), x = x.createElement("link"), lt(x);
        var P = x;
        P._p = new Promise(function(Y, rt) {
          P.onload = Y, P.onerror = rt;
        }), Gn(x, "link", f), l.instance = x;
      }
      i.stylesheets === null && (i.stylesheets = /* @__PURE__ */ new Map()), i.stylesheets.set(l, s), (s = l.state.preload) && (l.state.loading & 3) === 0 && (i.count++, l = Qu.bind(i), s.addEventListener("load", l), s.addEventListener("error", l));
    }
  }
  var Xp = 0;
  function HA(i, s) {
    return i.stylesheets && i.count === 0 && tf(i, i.stylesheets), 0 < i.count || 0 < i.imgCount ? function(l) {
      var f = setTimeout(function() {
        if (i.stylesheets && tf(i, i.stylesheets), i.unsuspend) {
          var x = i.unsuspend;
          i.unsuspend = null, x();
        }
      }, 6e4 + s);
      0 < i.imgBytes && Xp === 0 && (Xp = 62500 * xA());
      var v = setTimeout(
        function() {
          if (i.waitingForImages = !1, i.count === 0 && (i.stylesheets && tf(i, i.stylesheets), i.unsuspend)) {
            var x = i.unsuspend;
            i.unsuspend = null, x();
          }
        },
        (i.imgBytes > Xp ? 50 : 800) + s
      );
      return i.unsuspend = l, function() {
        i.unsuspend = null, clearTimeout(f), clearTimeout(v);
      };
    } : null;
  }
  function Qu() {
    if (this.count--, this.count === 0 && (this.imgCount === 0 || !this.waitingForImages)) {
      if (this.stylesheets) tf(this, this.stylesheets);
      else if (this.unsuspend) {
        var i = this.unsuspend;
        this.unsuspend = null, i();
      }
    }
  }
  var Ju = null;
  function tf(i, s) {
    i.stylesheets = null, i.unsuspend !== null && (i.count++, Ju = /* @__PURE__ */ new Map(), s.forEach(VA, i), Ju = null, Qu.call(i));
  }
  function VA(i, s) {
    if (!(s.state.loading & 4)) {
      var l = Ju.get(i);
      if (l) var f = l.get(null);
      else {
        l = /* @__PURE__ */ new Map(), Ju.set(i, l);
        for (var v = i.querySelectorAll(
          "link[data-precedence],style[data-precedence]"
        ), x = 0; x < v.length; x++) {
          var P = v[x];
          (P.nodeName === "LINK" || P.getAttribute("media") !== "not all") && (l.set(P.dataset.precedence, P), f = P);
        }
        f && l.set(null, f);
      }
      v = s.instance, P = v.getAttribute("data-precedence"), x = l.get(P) || f, x === f && l.set(null, v), l.set(P, v), this.count++, f = Qu.bind(this), v.addEventListener("load", f), v.addEventListener("error", f), x ? x.parentNode.insertBefore(v, x.nextSibling) : (i = i.nodeType === 9 ? i.head : i, i.insertBefore(v, i.firstChild)), s.state.loading |= 4;
    }
  }
  var tc = {
    $$typeof: w,
    Provider: null,
    Consumer: null,
    _currentValue: H,
    _currentValue2: H,
    _threadCount: 0
  };
  function kA(i, s, l, f, v, x, P, Y, rt) {
    this.tag = 1, this.containerInfo = i, this.pingCache = this.current = this.pendingChildren = null, this.timeoutHandle = -1, this.callbackNode = this.next = this.pendingContext = this.context = this.cancelPendingCommit = null, this.callbackPriority = 0, this.expirationTimes = De(-1), this.entangledLanes = this.shellSuspendCounter = this.errorRecoveryDisabledLanes = this.expiredLanes = this.warmLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0, this.entanglements = De(0), this.hiddenUpdates = De(null), this.identifierPrefix = f, this.onUncaughtError = v, this.onCaughtError = x, this.onRecoverableError = P, this.pooledCache = null, this.pooledCacheLanes = 0, this.formState = rt, this.incompleteTransitions = /* @__PURE__ */ new Map();
  }
  function Mx(i, s, l, f, v, x, P, Y, rt, pt, bt, At) {
    return i = new kA(
      i,
      s,
      l,
      P,
      rt,
      pt,
      bt,
      At,
      Y
    ), s = 1, x === !0 && (s |= 24), x = _i(3, null, null, s), i.current = x, x.stateNode = i, s = Mh(), s.refCount++, i.pooledCache = s, s.refCount++, x.memoizedState = {
      element: f,
      isDehydrated: l,
      cache: s
    }, Ah(x), i;
  }
  function Ex(i) {
    return i ? (i = qa, i) : qa;
  }
  function wx(i, s, l, f, v, x) {
    v = Ex(v), f.context === null ? f.context = v : f.pendingContext = v, f = ds(s), f.payload = { element: l }, x = x === void 0 ? null : x, x !== null && (f.callback = x), l = hs(i, f, s), l !== null && (ui(l, i, s), Ll(l, i, s));
  }
  function Tx(i, s) {
    if (i = i.memoizedState, i !== null && i.dehydrated !== null) {
      var l = i.retryLane;
      i.retryLane = l !== 0 && l < s ? l : s;
    }
  }
  function jp(i, s) {
    Tx(i, s), (i = i.alternate) && Tx(i, s);
  }
  function Ax(i) {
    if (i.tag === 13 || i.tag === 31) {
      var s = ta(i, 67108864);
      s !== null && ui(s, i, 67108864), jp(i, 67108864);
    }
  }
  function Cx(i) {
    if (i.tag === 13 || i.tag === 31) {
      var s = Mi();
      s = Sr(s);
      var l = ta(i, s);
      l !== null && ui(l, i, s), jp(i, s);
    }
  }
  var ef = !0;
  function GA(i, s, l, f) {
    var v = D.T;
    D.T = null;
    var x = V.p;
    try {
      V.p = 2, Wp(i, s, l, f);
    } finally {
      V.p = x, D.T = v;
    }
  }
  function XA(i, s, l, f) {
    var v = D.T;
    D.T = null;
    var x = V.p;
    try {
      V.p = 8, Wp(i, s, l, f);
    } finally {
      V.p = x, D.T = v;
    }
  }
  function Wp(i, s, l, f) {
    if (ef) {
      var v = Yp(f);
      if (v === null)
        Lp(
          i,
          s,
          f,
          nf,
          l
        ), Dx(i, f);
      else if (WA(
        v,
        i,
        s,
        l,
        f
      ))
        f.stopPropagation();
      else if (Dx(i, f), s & 4 && -1 < jA.indexOf(i)) {
        for (; v !== null; ) {
          var x = ft(v);
          if (x !== null)
            switch (x.tag) {
              case 3:
                if (x = x.stateNode, x.current.memoizedState.isDehydrated) {
                  var P = It(x.pendingLanes);
                  if (P !== 0) {
                    var Y = x;
                    for (Y.pendingLanes |= 2, Y.entangledLanes |= 2; P; ) {
                      var rt = 1 << 31 - le(P);
                      Y.entanglements[1] |= rt, P &= ~rt;
                    }
                    ar(x), (Be & 6) === 0 && (Bu = Et() + 500, ql(0));
                  }
                }
                break;
              case 31:
              case 13:
                Y = ta(x, 2), Y !== null && ui(Y, x, 2), Hu(), jp(x, 2);
            }
          if (x = Yp(f), x === null && Lp(
            i,
            s,
            f,
            nf,
            l
          ), x === v) break;
          v = x;
        }
        v !== null && f.stopPropagation();
      } else
        Lp(
          i,
          s,
          f,
          null,
          l
        );
    }
  }
  function Yp(i) {
    return i = Zd(i), qp(i);
  }
  var nf = null;
  function qp(i) {
    if (nf = null, i = Z(i), i !== null) {
      var s = o(i);
      if (s === null) i = null;
      else {
        var l = s.tag;
        if (l === 13) {
          if (i = c(s), i !== null) return i;
          i = null;
        } else if (l === 31) {
          if (i = u(s), i !== null) return i;
          i = null;
        } else if (l === 3) {
          if (s.stateNode.current.memoizedState.isDehydrated)
            return s.tag === 3 ? s.stateNode.containerInfo : null;
          i = null;
        } else s !== i && (i = null);
      }
    }
    return nf = i, null;
  }
  function Rx(i) {
    switch (i) {
      case "beforetoggle":
      case "cancel":
      case "click":
      case "close":
      case "contextmenu":
      case "copy":
      case "cut":
      case "auxclick":
      case "dblclick":
      case "dragend":
      case "dragstart":
      case "drop":
      case "focusin":
      case "focusout":
      case "input":
      case "invalid":
      case "keydown":
      case "keypress":
      case "keyup":
      case "mousedown":
      case "mouseup":
      case "paste":
      case "pause":
      case "play":
      case "pointercancel":
      case "pointerdown":
      case "pointerup":
      case "ratechange":
      case "reset":
      case "resize":
      case "seeked":
      case "submit":
      case "toggle":
      case "touchcancel":
      case "touchend":
      case "touchstart":
      case "volumechange":
      case "change":
      case "selectionchange":
      case "textInput":
      case "compositionstart":
      case "compositionend":
      case "compositionupdate":
      case "beforeblur":
      case "afterblur":
      case "beforeinput":
      case "blur":
      case "fullscreenchange":
      case "focus":
      case "hashchange":
      case "popstate":
      case "select":
      case "selectstart":
        return 2;
      case "drag":
      case "dragenter":
      case "dragexit":
      case "dragleave":
      case "dragover":
      case "mousemove":
      case "mouseout":
      case "mouseover":
      case "pointermove":
      case "pointerout":
      case "pointerover":
      case "scroll":
      case "touchmove":
      case "wheel":
      case "mouseenter":
      case "mouseleave":
      case "pointerenter":
      case "pointerleave":
        return 8;
      case "message":
        switch (Dt()) {
          case wt:
            return 2;
          case Zt:
            return 8;
          case Pt:
          case Wt:
            return 32;
          case _e:
            return 268435456;
          default:
            return 32;
        }
      default:
        return 32;
    }
  }
  var Zp = !1, Es = null, ws = null, Ts = null, ec = /* @__PURE__ */ new Map(), nc = /* @__PURE__ */ new Map(), As = [], jA = "mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(
    " "
  );
  function Dx(i, s) {
    switch (i) {
      case "focusin":
      case "focusout":
        Es = null;
        break;
      case "dragenter":
      case "dragleave":
        ws = null;
        break;
      case "mouseover":
      case "mouseout":
        Ts = null;
        break;
      case "pointerover":
      case "pointerout":
        ec.delete(s.pointerId);
        break;
      case "gotpointercapture":
      case "lostpointercapture":
        nc.delete(s.pointerId);
    }
  }
  function ic(i, s, l, f, v, x) {
    return i === null || i.nativeEvent !== x ? (i = {
      blockedOn: s,
      domEventName: l,
      eventSystemFlags: f,
      nativeEvent: x,
      targetContainers: [v]
    }, s !== null && (s = ft(s), s !== null && Ax(s)), i) : (i.eventSystemFlags |= f, s = i.targetContainers, v !== null && s.indexOf(v) === -1 && s.push(v), i);
  }
  function WA(i, s, l, f, v) {
    switch (s) {
      case "focusin":
        return Es = ic(
          Es,
          i,
          s,
          l,
          f,
          v
        ), !0;
      case "dragenter":
        return ws = ic(
          ws,
          i,
          s,
          l,
          f,
          v
        ), !0;
      case "mouseover":
        return Ts = ic(
          Ts,
          i,
          s,
          l,
          f,
          v
        ), !0;
      case "pointerover":
        var x = v.pointerId;
        return ec.set(
          x,
          ic(
            ec.get(x) || null,
            i,
            s,
            l,
            f,
            v
          )
        ), !0;
      case "gotpointercapture":
        return x = v.pointerId, nc.set(
          x,
          ic(
            nc.get(x) || null,
            i,
            s,
            l,
            f,
            v
          )
        ), !0;
    }
    return !1;
  }
  function Nx(i) {
    var s = Z(i.target);
    if (s !== null) {
      var l = o(s);
      if (l !== null) {
        if (s = l.tag, s === 13) {
          if (s = c(l), s !== null) {
            i.blockedOn = s, br(i.priority, function() {
              Cx(l);
            });
            return;
          }
        } else if (s === 31) {
          if (s = u(l), s !== null) {
            i.blockedOn = s, br(i.priority, function() {
              Cx(l);
            });
            return;
          }
        } else if (s === 3 && l.stateNode.current.memoizedState.isDehydrated) {
          i.blockedOn = l.tag === 3 ? l.stateNode.containerInfo : null;
          return;
        }
      }
    }
    i.blockedOn = null;
  }
  function rf(i) {
    if (i.blockedOn !== null) return !1;
    for (var s = i.targetContainers; 0 < s.length; ) {
      var l = Yp(i.nativeEvent);
      if (l === null) {
        l = i.nativeEvent;
        var f = new l.constructor(
          l.type,
          l
        );
        qd = f, l.target.dispatchEvent(f), qd = null;
      } else
        return s = ft(l), s !== null && Ax(s), i.blockedOn = l, !1;
      s.shift();
    }
    return !0;
  }
  function Lx(i, s, l) {
    rf(i) && l.delete(s);
  }
  function YA() {
    Zp = !1, Es !== null && rf(Es) && (Es = null), ws !== null && rf(ws) && (ws = null), Ts !== null && rf(Ts) && (Ts = null), ec.forEach(Lx), nc.forEach(Lx);
  }
  function sf(i, s) {
    i.blockedOn === s && (i.blockedOn = null, Zp || (Zp = !0, n.unstable_scheduleCallback(
      n.unstable_NormalPriority,
      YA
    )));
  }
  var af = null;
  function Ux(i) {
    af !== i && (af = i, n.unstable_scheduleCallback(
      n.unstable_NormalPriority,
      function() {
        af === i && (af = null);
        for (var s = 0; s < i.length; s += 3) {
          var l = i[s], f = i[s + 1], v = i[s + 2];
          if (typeof f != "function") {
            if (qp(f || l) === null)
              continue;
            break;
          }
          var x = ft(l);
          x !== null && (i.splice(s, 3), s -= 3, Yh(
            x,
            {
              pending: !0,
              data: v,
              method: l.method,
              action: f
            },
            f,
            v
          ));
        }
      }
    ));
  }
  function yo(i) {
    function s(rt) {
      return sf(rt, i);
    }
    Es !== null && sf(Es, i), ws !== null && sf(ws, i), Ts !== null && sf(Ts, i), ec.forEach(s), nc.forEach(s);
    for (var l = 0; l < As.length; l++) {
      var f = As[l];
      f.blockedOn === i && (f.blockedOn = null);
    }
    for (; 0 < As.length && (l = As[0], l.blockedOn === null); )
      Nx(l), l.blockedOn === null && As.shift();
    if (l = (i.ownerDocument || i).$$reactFormReplay, l != null)
      for (f = 0; f < l.length; f += 3) {
        var v = l[f], x = l[f + 1], P = v[Tn] || null;
        if (typeof x == "function")
          P || Ux(l);
        else if (P) {
          var Y = null;
          if (x && x.hasAttribute("formAction")) {
            if (v = x, P = x[Tn] || null)
              Y = P.formAction;
            else if (qp(v) !== null) continue;
          } else Y = P.action;
          typeof Y == "function" ? l[f + 1] = Y : (l.splice(f, 3), f -= 3), Ux(l);
        }
      }
  }
  function Ox() {
    function i(x) {
      x.canIntercept && x.info === "react-transition" && x.intercept({
        handler: function() {
          return new Promise(function(P) {
            return v = P;
          });
        },
        focusReset: "manual",
        scroll: "manual"
      });
    }
    function s() {
      v !== null && (v(), v = null), f || setTimeout(l, 20);
    }
    function l() {
      if (!f && !navigation.transition) {
        var x = navigation.currentEntry;
        x && x.url != null && navigation.navigate(x.url, {
          state: x.getState(),
          info: "react-transition",
          history: "replace"
        });
      }
    }
    if (typeof navigation == "object") {
      var f = !1, v = null;
      return navigation.addEventListener("navigate", i), navigation.addEventListener("navigatesuccess", s), navigation.addEventListener("navigateerror", s), setTimeout(l, 100), function() {
        f = !0, navigation.removeEventListener("navigate", i), navigation.removeEventListener("navigatesuccess", s), navigation.removeEventListener("navigateerror", s), v !== null && (v(), v = null);
      };
    }
  }
  function $p(i) {
    this._internalRoot = i;
  }
  of.prototype.render = $p.prototype.render = function(i) {
    var s = this._internalRoot;
    if (s === null) throw Error(r(409));
    var l = s.current, f = Mi();
    wx(l, f, i, s, null, null);
  }, of.prototype.unmount = $p.prototype.unmount = function() {
    var i = this._internalRoot;
    if (i !== null) {
      this._internalRoot = null;
      var s = i.containerInfo;
      wx(i.current, 2, null, i, null, null), Hu(), s[Ni] = null;
    }
  };
  function of(i) {
    this._internalRoot = i;
  }
  of.prototype.unstable_scheduleHydration = function(i) {
    if (i) {
      var s = Zs();
      i = { blockedOn: null, target: i, priority: s };
      for (var l = 0; l < As.length && s !== 0 && s < As[l].priority; l++) ;
      As.splice(l, 0, i), l === 0 && Nx(i);
    }
  };
  var Px = t.version;
  if (Px !== "19.2.4")
    throw Error(
      r(
        527,
        Px,
        "19.2.4"
      )
    );
  V.findDOMNode = function(i) {
    var s = i._reactInternals;
    if (s === void 0)
      throw typeof i.render == "function" ? Error(r(188)) : (i = Object.keys(i).join(","), Error(r(268, i)));
    return i = h(s), i = i !== null ? p(i) : null, i = i === null ? null : i.stateNode, i;
  };
  var qA = {
    bundleType: 0,
    version: "19.2.4",
    rendererPackageName: "react-dom",
    currentDispatcherRef: D,
    reconcilerVersion: "19.2.4"
  };
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u") {
    var lf = __REACT_DEVTOOLS_GLOBAL_HOOK__;
    if (!lf.isDisabled && lf.supportsFiber)
      try {
        te = lf.inject(
          qA
        ), Kt = lf;
      } catch {
      }
  }
  return rc.createRoot = function(i, s) {
    if (!a(i)) throw Error(r(299));
    var l = !1, f = "", v = k_, x = G_, P = X_;
    return s != null && (s.unstable_strictMode === !0 && (l = !0), s.identifierPrefix !== void 0 && (f = s.identifierPrefix), s.onUncaughtError !== void 0 && (v = s.onUncaughtError), s.onCaughtError !== void 0 && (x = s.onCaughtError), s.onRecoverableError !== void 0 && (P = s.onRecoverableError)), s = Mx(
      i,
      1,
      !1,
      null,
      null,
      l,
      f,
      null,
      v,
      x,
      P,
      Ox
    ), i[Ni] = s.current, Np(i), new $p(s);
  }, rc.hydrateRoot = function(i, s, l) {
    if (!a(i)) throw Error(r(299));
    var f = !1, v = "", x = k_, P = G_, Y = X_, rt = null;
    return l != null && (l.unstable_strictMode === !0 && (f = !0), l.identifierPrefix !== void 0 && (v = l.identifierPrefix), l.onUncaughtError !== void 0 && (x = l.onUncaughtError), l.onCaughtError !== void 0 && (P = l.onCaughtError), l.onRecoverableError !== void 0 && (Y = l.onRecoverableError), l.formState !== void 0 && (rt = l.formState)), s = Mx(
      i,
      1,
      !0,
      s,
      l ?? null,
      f,
      v,
      rt,
      x,
      P,
      Y,
      Ox
    ), s.context = Ex(null), l = s.current, f = Mi(), f = Sr(f), v = ds(f), v.callback = null, hs(l, v, f), l = f, s.current.lanes = l, wn(s, l), ar(s), i[Ni] = s.current, Np(i), new of(s);
  }, rc.version = "19.2.4", rc;
}
var Gx;
function i2() {
  if (Gx) return Qp.exports;
  Gx = 1;
  function n() {
    if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ > "u" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function"))
      try {
        __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n);
      } catch (t) {
        console.error(t);
      }
  }
  return n(), Qp.exports = n2(), Qp.exports;
}
var r2 = i2(), nm = { exports: {} }, sc = {};
/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var Xx;
function s2() {
  if (Xx) return sc;
  Xx = 1;
  var n = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
  function e(r, a, o) {
    var c = null;
    if (o !== void 0 && (c = "" + o), a.key !== void 0 && (c = "" + a.key), "key" in a) {
      o = {};
      for (var u in a)
        u !== "key" && (o[u] = a[u]);
    } else o = a;
    return a = o.ref, {
      $$typeof: n,
      type: r,
      key: c,
      ref: a !== void 0 ? a : null,
      props: o
    };
  }
  return sc.Fragment = t, sc.jsx = e, sc.jsxs = e, sc;
}
var jx;
function a2() {
  return jx || (jx = 1, nm.exports = s2()), nm.exports;
}
var J = a2();
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
const p0 = "172", qo = { ROTATE: 0, DOLLY: 1, PAN: 2 }, Xo = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, o2 = 0, Wx = 1, l2 = 2, nM = 1, c2 = 2, qr = 3, Xs = 0, pi = 1, ur = 2, ks = 0, Zo = 1, Yx = 2, qx = 3, Zx = 4, u2 = 5, ba = 100, f2 = 101, d2 = 102, h2 = 103, p2 = 104, m2 = 200, g2 = 201, v2 = 202, _2 = 203, ag = 204, og = 205, y2 = 206, x2 = 207, S2 = 208, b2 = 209, M2 = 210, E2 = 211, w2 = 212, T2 = 213, A2 = 214, lg = 0, cg = 1, ug = 2, tl = 3, fg = 4, dg = 5, hg = 6, pg = 7, m0 = 0, C2 = 1, R2 = 2, Gs = 0, D2 = 1, N2 = 2, L2 = 3, U2 = 4, O2 = 5, P2 = 6, z2 = 7, iM = 300, el = 301, nl = 302, mg = 303, gg = 304, Dd = 306, vg = 1e3, Ea = 1001, _g = 1002, Yn = 1003, I2 = 1004, cf = 1005, dr = 1006, im = 1007, wa = 1008, es = 1009, rM = 1010, sM = 1011, Cc = 1012, g0 = 1013, Na = 1014, Gi = 1015, Xc = 1016, v0 = 1017, _0 = 1018, il = 1020, aM = 35902, oM = 1021, lM = 1022, Ci = 1023, cM = 1024, uM = 1025, $o = 1026, rl = 1027, y0 = 1028, x0 = 1029, fM = 1030, S0 = 1031, b0 = 1033, Jf = 33776, td = 33777, ed = 33778, nd = 33779, yg = 35840, xg = 35841, Sg = 35842, bg = 35843, Mg = 36196, Eg = 37492, wg = 37496, Tg = 37808, Ag = 37809, Cg = 37810, Rg = 37811, Dg = 37812, Ng = 37813, Lg = 37814, Ug = 37815, Og = 37816, Pg = 37817, zg = 37818, Ig = 37819, Bg = 37820, Fg = 37821, id = 36492, Hg = 36494, Vg = 36495, dM = 36283, kg = 36284, Gg = 36285, Xg = 36286, B2 = 3200, F2 = 3201, hM = 0, H2 = 1, Fs = "", Vi = "srgb", sl = "srgb-linear", dd = "linear", qe = "srgb", xo = 7680, $x = 519, V2 = 512, k2 = 513, G2 = 514, pM = 515, X2 = 516, j2 = 517, W2 = 518, Y2 = 519, Ta = 35044, So = 35048, hd = "300 es", Zr = 2e3, pd = 2001;
class Ia {
  addEventListener(t, e) {
    this._listeners === void 0 && (this._listeners = {});
    const r = this._listeners;
    r[t] === void 0 && (r[t] = []), r[t].indexOf(e) === -1 && r[t].push(e);
  }
  hasEventListener(t, e) {
    if (this._listeners === void 0) return !1;
    const r = this._listeners;
    return r[t] !== void 0 && r[t].indexOf(e) !== -1;
  }
  removeEventListener(t, e) {
    if (this._listeners === void 0) return;
    const a = this._listeners[t];
    if (a !== void 0) {
      const o = a.indexOf(e);
      o !== -1 && a.splice(o, 1);
    }
  }
  dispatchEvent(t) {
    if (this._listeners === void 0) return;
    const r = this._listeners[t.type];
    if (r !== void 0) {
      t.target = this;
      const a = r.slice(0);
      for (let o = 0, c = a.length; o < c; o++)
        a[o].call(this, t);
      t.target = null;
    }
  }
}
const Kn = ["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 Kx = 1234567;
const Ec = Math.PI / 180, Rc = 180 / Math.PI;
function Qr() {
  const n = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, r = Math.random() * 4294967295 | 0;
  return (Kn[n & 255] + Kn[n >> 8 & 255] + Kn[n >> 16 & 255] + Kn[n >> 24 & 255] + "-" + Kn[t & 255] + Kn[t >> 8 & 255] + "-" + Kn[t >> 16 & 15 | 64] + Kn[t >> 24 & 255] + "-" + Kn[e & 63 | 128] + Kn[e >> 8 & 255] + "-" + Kn[e >> 16 & 255] + Kn[e >> 24 & 255] + Kn[r & 255] + Kn[r >> 8 & 255] + Kn[r >> 16 & 255] + Kn[r >> 24 & 255]).toLowerCase();
}
function be(n, t, e) {
  return Math.max(t, Math.min(e, n));
}
function M0(n, t) {
  return (n % t + t) % t;
}
function q2(n, t, e, r, a) {
  return r + (n - t) * (a - r) / (e - t);
}
function Z2(n, t, e) {
  return n !== t ? (e - n) / (t - n) : 0;
}
function wc(n, t, e) {
  return (1 - e) * n + e * t;
}
function $2(n, t, e, r) {
  return wc(n, t, 1 - Math.exp(-e * r));
}
function K2(n, t = 1) {
  return t - Math.abs(M0(n, t * 2) - t);
}
function Q2(n, t, e) {
  return n <= t ? 0 : n >= e ? 1 : (n = (n - t) / (e - t), n * n * (3 - 2 * n));
}
function J2(n, t, e) {
  return n <= t ? 0 : n >= e ? 1 : (n = (n - t) / (e - t), n * n * n * (n * (n * 6 - 15) + 10));
}
function tC(n, t) {
  return n + Math.floor(Math.random() * (t - n + 1));
}
function eC(n, t) {
  return n + Math.random() * (t - n);
}
function nC(n) {
  return n * (0.5 - Math.random());
}
function iC(n) {
  n !== void 0 && (Kx = n);
  let t = Kx += 1831565813;
  return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
}
function rC(n) {
  return n * Ec;
}
function sC(n) {
  return n * Rc;
}
function aC(n) {
  return (n & n - 1) === 0 && n !== 0;
}
function oC(n) {
  return Math.pow(2, Math.ceil(Math.log(n) / Math.LN2));
}
function lC(n) {
  return Math.pow(2, Math.floor(Math.log(n) / Math.LN2));
}
function cC(n, t, e, r, a) {
  const o = Math.cos, c = Math.sin, u = o(e / 2), d = c(e / 2), h = o((t + r) / 2), p = c((t + r) / 2), m = o((t - r) / 2), g = c((t - r) / 2), _ = o((r - t) / 2), b = c((r - t) / 2);
  switch (a) {
    case "XYX":
      n.set(u * p, d * m, d * g, u * h);
      break;
    case "YZY":
      n.set(d * g, u * p, d * m, u * h);
      break;
    case "ZXZ":
      n.set(d * m, d * g, u * p, u * h);
      break;
    case "XZX":
      n.set(u * p, d * b, d * _, u * h);
      break;
    case "YXY":
      n.set(d * _, u * p, d * b, u * h);
      break;
    case "ZYZ":
      n.set(d * b, d * _, u * p, u * h);
      break;
    default:
      console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + a);
  }
}
function Ki(n, t) {
  switch (t.constructor) {
    case Float32Array:
      return n;
    case Uint32Array:
      return n / 4294967295;
    case Uint16Array:
      return n / 65535;
    case Uint8Array:
      return n / 255;
    case Int32Array:
      return Math.max(n / 2147483647, -1);
    case Int16Array:
      return Math.max(n / 32767, -1);
    case Int8Array:
      return Math.max(n / 127, -1);
    default:
      throw new Error("Invalid component type.");
  }
}
function ke(n, t) {
  switch (t.constructor) {
    case Float32Array:
      return n;
    case Uint32Array:
      return Math.round(n * 4294967295);
    case Uint16Array:
      return Math.round(n * 65535);
    case Uint8Array:
      return Math.round(n * 255);
    case Int32Array:
      return Math.round(n * 2147483647);
    case Int16Array:
      return Math.round(n * 32767);
    case Int8Array:
      return Math.round(n * 127);
    default:
      throw new Error("Invalid component type.");
  }
}
const mM = {
  DEG2RAD: Ec,
  RAD2DEG: Rc,
  generateUUID: Qr,
  clamp: be,
  euclideanModulo: M0,
  mapLinear: q2,
  inverseLerp: Z2,
  lerp: wc,
  damp: $2,
  pingpong: K2,
  smoothstep: Q2,
  smootherstep: J2,
  randInt: tC,
  randFloat: eC,
  randFloatSpread: nC,
  seededRandom: iC,
  degToRad: rC,
  radToDeg: sC,
  isPowerOfTwo: aC,
  ceilPowerOfTwo: oC,
  floorPowerOfTwo: lC,
  setQuaternionFromProperEuler: cC,
  normalize: ke,
  denormalize: Ki
};
class oe {
  constructor(t = 0, e = 0) {
    oe.prototype.isVector2 = !0, this.x = t, this.y = e;
  }
  get width() {
    return this.x;
  }
  set width(t) {
    this.x = t;
  }
  get height() {
    return this.y;
  }
  set height(t) {
    this.y = t;
  }
  set(t, e) {
    return this.x = t, this.y = e, this;
  }
  setScalar(t) {
    return this.x = t, this.y = t, this;
  }
  setX(t) {
    return this.x = t, this;
  }
  setY(t) {
    return this.y = t, this;
  }
  setComponent(t, e) {
    switch (t) {
      case 0:
        this.x = e;
        break;
      case 1:
        this.y = e;
        break;
      default:
        throw new Error("index is out of range: " + t);
    }
    return this;
  }
  getComponent(t) {
    switch (t) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      default:
        throw new Error("index is out of range: " + t);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y);
  }
  copy(t) {
    return this.x = t.x, this.y = t.y, this;
  }
  add(t) {
    return this.x += t.x, this.y += t.y, this;
  }
  addScalar(t) {
    return this.x += t, this.y += t, this;
  }
  addVectors(t, e) {
    return this.x = t.x + e.x, this.y = t.y + e.y, this;
  }
  addScaledVector(t, e) {
    return this.x += t.x * e, this.y += t.y * e, this;
  }
  sub(t) {
    return this.x -= t.x, this.y -= t.y, this;
  }
  subScalar(t) {
    return this.x -= t, this.y -= t, this;
  }
  subVectors(t, e) {
    return this.x = t.x - e.x, this.y = t.y - e.y, this;
  }
  multiply(t) {
    return this.x *= t.x, this.y *= t.y, this;
  }
  multiplyScalar(t) {
    return this.x *= t, this.y *= t, this;
  }
  divide(t) {
    return this.x /= t.x, this.y /= t.y, this;
  }
  divideScalar(t) {
    return this.multiplyScalar(1 / t);
  }
  applyMatrix3(t) {
    const e = this.x, r = this.y, a = t.elements;
    return this.x = a[0] * e + a[3] * r + a[6], this.y = a[1] * e + a[4] * r + a[7], this;
  }
  min(t) {
    return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this;
  }
  max(t) {
    return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this;
  }
  clamp(t, e) {
    return this.x = be(this.x, t.x, e.x), this.y = be(this.y, t.y, e.y), this;
  }
  clampScalar(t, e) {
    return this.x = be(this.x, t, e), this.y = be(this.y, t, e), this;
  }
  clampLength(t, e) {
    const r = this.length();
    return this.divideScalar(r || 1).multiplyScalar(be(r, t, e));
  }
  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(t) {
    return this.x * t.x + this.y * t.y;
  }
  cross(t) {
    return this.x * t.y - this.y * t.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(t) {
    const e = Math.sqrt(this.lengthSq() * t.lengthSq());
    if (e === 0) return Math.PI / 2;
    const r = this.dot(t) / e;
    return Math.acos(be(r, -1, 1));
  }
  distanceTo(t) {
    return Math.sqrt(this.distanceToSquared(t));
  }
  distanceToSquared(t) {
    const e = this.x - t.x, r = this.y - t.y;
    return e * e + r * r;
  }
  manhattanDistanceTo(t) {
    return Math.abs(this.x - t.x) + Math.abs(this.y - t.y);
  }
  setLength(t) {
    return this.normalize().multiplyScalar(t);
  }
  lerp(t, e) {
    return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this;
  }
  lerpVectors(t, e, r) {
    return this.x = t.x + (e.x - t.x) * r, this.y = t.y + (e.y - t.y) * r, this;
  }
  equals(t) {
    return t.x === this.x && t.y === this.y;
  }
  fromArray(t, e = 0) {
    return this.x = t[e], this.y = t[e + 1], this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this.x, t[e + 1] = this.y, t;
  }
  fromBufferAttribute(t, e) {
    return this.x = t.getX(e), this.y = t.getY(e), this;
  }
  rotateAround(t, e) {
    const r = Math.cos(e), a = Math.sin(e), o = this.x - t.x, c = this.y - t.y;
    return this.x = o * r - c * a + t.x, this.y = o * a + c * r + t.y, this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y;
  }
}
class ve {
  constructor(t, e, r, a, o, c, u, d, h) {
    ve.prototype.isMatrix3 = !0, this.elements = [
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ], t !== void 0 && this.set(t, e, r, a, o, c, u, d, h);
  }
  set(t, e, r, a, o, c, u, d, h) {
    const p = this.elements;
    return p[0] = t, p[1] = a, p[2] = u, p[3] = e, p[4] = o, p[5] = d, p[6] = r, p[7] = c, p[8] = h, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ), this;
  }
  copy(t) {
    const e = this.elements, r = t.elements;
    return e[0] = r[0], e[1] = r[1], e[2] = r[2], e[3] = r[3], e[4] = r[4], e[5] = r[5], e[6] = r[6], e[7] = r[7], e[8] = r[8], this;
  }
  extractBasis(t, e, r) {
    return t.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), r.setFromMatrix3Column(this, 2), this;
  }
  setFromMatrix4(t) {
    const e = t.elements;
    return this.set(
      e[0],
      e[4],
      e[8],
      e[1],
      e[5],
      e[9],
      e[2],
      e[6],
      e[10]
    ), this;
  }
  multiply(t) {
    return this.multiplyMatrices(this, t);
  }
  premultiply(t) {
    return this.multiplyMatrices(t, this);
  }
  multiplyMatrices(t, e) {
    const r = t.elements, a = e.elements, o = this.elements, c = r[0], u = r[3], d = r[6], h = r[1], p = r[4], m = r[7], g = r[2], _ = r[5], b = r[8], E = a[0], S = a[3], y = a[6], A = a[1], w = a[4], M = a[7], O = a[2], L = a[5], N = a[8];
    return o[0] = c * E + u * A + d * O, o[3] = c * S + u * w + d * L, o[6] = c * y + u * M + d * N, o[1] = h * E + p * A + m * O, o[4] = h * S + p * w + m * L, o[7] = h * y + p * M + m * N, o[2] = g * E + _ * A + b * O, o[5] = g * S + _ * w + b * L, o[8] = g * y + _ * M + b * N, this;
  }
  multiplyScalar(t) {
    const e = this.elements;
    return e[0] *= t, e[3] *= t, e[6] *= t, e[1] *= t, e[4] *= t, e[7] *= t, e[2] *= t, e[5] *= t, e[8] *= t, this;
  }
  determinant() {
    const t = this.elements, e = t[0], r = t[1], a = t[2], o = t[3], c = t[4], u = t[5], d = t[6], h = t[7], p = t[8];
    return e * c * p - e * u * h - r * o * p + r * u * d + a * o * h - a * c * d;
  }
  invert() {
    const t = this.elements, e = t[0], r = t[1], a = t[2], o = t[3], c = t[4], u = t[5], d = t[6], h = t[7], p = t[8], m = p * c - u * h, g = u * d - p * o, _ = h * o - c * d, b = e * m + r * g + a * _;
    if (b === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
    const E = 1 / b;
    return t[0] = m * E, t[1] = (a * h - p * r) * E, t[2] = (u * r - a * c) * E, t[3] = g * E, t[4] = (p * e - a * d) * E, t[5] = (a * o - u * e) * E, t[6] = _ * E, t[7] = (r * d - h * e) * E, t[8] = (c * e - r * o) * E, this;
  }
  transpose() {
    let t;
    const e = this.elements;
    return t = e[1], e[1] = e[3], e[3] = t, t = e[2], e[2] = e[6], e[6] = t, t = e[5], e[5] = e[7], e[7] = t, this;
  }
  getNormalMatrix(t) {
    return this.setFromMatrix4(t).invert().transpose();
  }
  transposeIntoArray(t) {
    const e = this.elements;
    return t[0] = e[0], t[1] = e[3], t[2] = e[6], t[3] = e[1], t[4] = e[4], t[5] = e[7], t[6] = e[2], t[7] = e[5], t[8] = e[8], this;
  }
  setUvTransform(t, e, r, a, o, c, u) {
    const d = Math.cos(o), h = Math.sin(o);
    return this.set(
      r * d,
      r * h,
      -r * (d * c + h * u) + c + t,
      -a * h,
      a * d,
      -a * (-h * c + d * u) + u + e,
      0,
      0,
      1
    ), this;
  }
  //
  scale(t, e) {
    return this.premultiply(rm.makeScale(t, e)), this;
  }
  rotate(t) {
    return this.premultiply(rm.makeRotation(-t)), this;
  }
  translate(t, e) {
    return this.premultiply(rm.makeTranslation(t, e)), this;
  }
  // for 2D Transforms
  makeTranslation(t, e) {
    return t.isVector2 ? this.set(
      1,
      0,
      t.x,
      0,
      1,
      t.y,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      t,
      0,
      1,
      e,
      0,
      0,
      1
    ), this;
  }
  makeRotation(t) {
    const e = Math.cos(t), r = Math.sin(t);
    return this.set(
      e,
      -r,
      0,
      r,
      e,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(t, e) {
    return this.set(
      t,
      0,
      0,
      0,
      e,
      0,
      0,
      0,
      1
    ), this;
  }
  //
  equals(t) {
    const e = this.elements, r = t.elements;
    for (let a = 0; a < 9; a++)
      if (e[a] !== r[a]) return !1;
    return !0;
  }
  fromArray(t, e = 0) {
    for (let r = 0; r < 9; r++)
      this.elements[r] = t[r + e];
    return this;
  }
  toArray(t = [], e = 0) {
    const r = this.elements;
    return t[e] = r[0], t[e + 1] = r[1], t[e + 2] = r[2], t[e + 3] = r[3], t[e + 4] = r[4], t[e + 5] = r[5], t[e + 6] = r[6], t[e + 7] = r[7], t[e + 8] = r[8], t;
  }
  clone() {
    return new this.constructor().fromArray(this.elements);
  }
}
const rm = /* @__PURE__ */ new ve();
function gM(n) {
  for (let t = n.length - 1; t >= 0; --t)
    if (n[t] >= 65535) return !0;
  return !1;
}
function md(n) {
  return document.createElementNS("http://www.w3.org/1999/xhtml", n);
}
function uC() {
  const n = md("canvas");
  return n.style.display = "block", n;
}
const Qx = {};
function ko(n) {
  n in Qx || (Qx[n] = !0, console.warn(n));
}
function fC(n, t, e) {
  return new Promise(function(r, a) {
    function o() {
      switch (n.clientWaitSync(t, n.SYNC_FLUSH_COMMANDS_BIT, 0)) {
        case n.WAIT_FAILED:
          a();
          break;
        case n.TIMEOUT_EXPIRED:
          setTimeout(o, e);
          break;
        default:
          r();
      }
    }
    setTimeout(o, e);
  });
}
function dC(n) {
  const t = n.elements;
  t[2] = 0.5 * t[2] + 0.5 * t[3], t[6] = 0.5 * t[6] + 0.5 * t[7], t[10] = 0.5 * t[10] + 0.5 * t[11], t[14] = 0.5 * t[14] + 0.5 * t[15];
}
function hC(n) {
  const t = n.elements;
  t[11] === -1 ? (t[10] = -t[10] - 1, t[14] = -t[14]) : (t[10] = -t[10], t[14] = -t[14] + 1);
}
const Jx = /* @__PURE__ */ new ve().set(
  0.4123908,
  0.3575843,
  0.1804808,
  0.212639,
  0.7151687,
  0.0721923,
  0.0193308,
  0.1191948,
  0.9505322
), tS = /* @__PURE__ */ new ve().set(
  3.2409699,
  -1.5373832,
  -0.4986108,
  -0.9692436,
  1.8759675,
  0.0415551,
  0.0556301,
  -0.203977,
  1.0569715
);
function pC() {
  const n = {
    enabled: !0,
    workingColorSpace: sl,
    /**
     * 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(a, o, c) {
      return this.enabled === !1 || o === c || !o || !c || (this.spaces[o].transfer === qe && (a.r = Jr(a.r), a.g = Jr(a.g), a.b = Jr(a.b)), this.spaces[o].primaries !== this.spaces[c].primaries && (a.applyMatrix3(this.spaces[o].toXYZ), a.applyMatrix3(this.spaces[c].fromXYZ)), this.spaces[c].transfer === qe && (a.r = Ko(a.r), a.g = Ko(a.g), a.b = Ko(a.b))), a;
    },
    fromWorkingColorSpace: function(a, o) {
      return this.convert(a, this.workingColorSpace, o);
    },
    toWorkingColorSpace: function(a, o) {
      return this.convert(a, o, this.workingColorSpace);
    },
    getPrimaries: function(a) {
      return this.spaces[a].primaries;
    },
    getTransfer: function(a) {
      return a === Fs ? dd : this.spaces[a].transfer;
    },
    getLuminanceCoefficients: function(a, o = this.workingColorSpace) {
      return a.fromArray(this.spaces[o].luminanceCoefficients);
    },
    define: function(a) {
      Object.assign(this.spaces, a);
    },
    // Internal APIs
    _getMatrix: function(a, o, c) {
      return a.copy(this.spaces[o].toXYZ).multiply(this.spaces[c].fromXYZ);
    },
    _getDrawingBufferColorSpace: function(a) {
      return this.spaces[a].outputColorSpaceConfig.drawingBufferColorSpace;
    },
    _getUnpackColorSpace: function(a = this.workingColorSpace) {
      return this.spaces[a].workingColorSpaceConfig.unpackColorSpace;
    }
  }, t = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], e = [0.2126, 0.7152, 0.0722], r = [0.3127, 0.329];
  return n.define({
    [sl]: {
      primaries: t,
      whitePoint: r,
      transfer: dd,
      toXYZ: Jx,
      fromXYZ: tS,
      luminanceCoefficients: e,
      workingColorSpaceConfig: { unpackColorSpace: Vi },
      outputColorSpaceConfig: { drawingBufferColorSpace: Vi }
    },
    [Vi]: {
      primaries: t,
      whitePoint: r,
      transfer: qe,
      toXYZ: Jx,
      fromXYZ: tS,
      luminanceCoefficients: e,
      outputColorSpaceConfig: { drawingBufferColorSpace: Vi }
    }
  }), n;
}
const Ie = /* @__PURE__ */ pC();
function Jr(n) {
  return n < 0.04045 ? n * 0.0773993808 : Math.pow(n * 0.9478672986 + 0.0521327014, 2.4);
}
function Ko(n) {
  return n < 31308e-7 ? n * 12.92 : 1.055 * Math.pow(n, 0.41666) - 0.055;
}
let bo;
class mC {
  static getDataURL(t) {
    if (/^data:/i.test(t.src) || typeof HTMLCanvasElement > "u")
      return t.src;
    let e;
    if (t instanceof HTMLCanvasElement)
      e = t;
    else {
      bo === void 0 && (bo = md("canvas")), bo.width = t.width, bo.height = t.height;
      const r = bo.getContext("2d");
      t instanceof ImageData ? r.putImageData(t, 0, 0) : r.drawImage(t, 0, 0, t.width, t.height), e = bo;
    }
    return e.width > 2048 || e.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", t), e.toDataURL("image/jpeg", 0.6)) : e.toDataURL("image/png");
  }
  static sRGBToLinear(t) {
    if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap) {
      const e = md("canvas");
      e.width = t.width, e.height = t.height;
      const r = e.getContext("2d");
      r.drawImage(t, 0, 0, t.width, t.height);
      const a = r.getImageData(0, 0, t.width, t.height), o = a.data;
      for (let c = 0; c < o.length; c++)
        o[c] = Jr(o[c] / 255) * 255;
      return r.putImageData(a, 0, 0), e;
    } else if (t.data) {
      const e = t.data.slice(0);
      for (let r = 0; r < e.length; r++)
        e instanceof Uint8Array || e instanceof Uint8ClampedArray ? e[r] = Math.floor(Jr(e[r] / 255) * 255) : e[r] = Jr(e[r]);
      return {
        data: e,
        width: t.width,
        height: t.height
      };
    } else
      return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), t;
  }
}
let gC = 0;
class vM {
  constructor(t = null) {
    this.isSource = !0, Object.defineProperty(this, "id", { value: gC++ }), this.uuid = Qr(), this.data = t, this.dataReady = !0, this.version = 0;
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string";
    if (!e && t.images[this.uuid] !== void 0)
      return t.images[this.uuid];
    const r = {
      uuid: this.uuid,
      url: ""
    }, a = this.data;
    if (a !== null) {
      let o;
      if (Array.isArray(a)) {
        o = [];
        for (let c = 0, u = a.length; c < u; c++)
          a[c].isDataTexture ? o.push(sm(a[c].image)) : o.push(sm(a[c]));
      } else
        o = sm(a);
      r.url = o;
    }
    return e || (t.images[this.uuid] = r), r;
  }
}
function sm(n) {
  return typeof HTMLImageElement < "u" && n instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && n instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && n instanceof ImageBitmap ? mC.getDataURL(n) : n.data ? {
    data: Array.from(n.data),
    width: n.width,
    height: n.height,
    type: n.data.constructor.name
  } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
}
let vC = 0;
class Jn extends Ia {
  constructor(t = Jn.DEFAULT_IMAGE, e = Jn.DEFAULT_MAPPING, r = Ea, a = Ea, o = dr, c = wa, u = Ci, d = es, h = Jn.DEFAULT_ANISOTROPY, p = Fs) {
    super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: vC++ }), this.uuid = Qr(), this.name = "", this.source = new vM(t), this.mipmaps = [], this.mapping = e, this.channel = 0, this.wrapS = r, this.wrapT = a, this.magFilter = o, this.minFilter = c, this.anisotropy = h, this.format = u, this.internalFormat = null, this.type = d, this.offset = new oe(0, 0), this.repeat = new oe(1, 1), this.center = new oe(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new ve(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = p, this.userData = {}, this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0;
  }
  get image() {
    return this.source.data;
  }
  set image(t = null) {
    this.source.data = t;
  }
  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(t) {
    return this.name = t.name, this.source = t.source, this.mipmaps = t.mipmaps.slice(0), this.mapping = t.mapping, this.channel = t.channel, this.wrapS = t.wrapS, this.wrapT = t.wrapT, this.magFilter = t.magFilter, this.minFilter = t.minFilter, this.anisotropy = t.anisotropy, this.format = t.format, this.internalFormat = t.internalFormat, this.type = t.type, this.offset.copy(t.offset), this.repeat.copy(t.repeat), this.center.copy(t.center), this.rotation = t.rotation, this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrix.copy(t.matrix), this.generateMipmaps = t.generateMipmaps, this.premultiplyAlpha = t.premultiplyAlpha, this.flipY = t.flipY, this.unpackAlignment = t.unpackAlignment, this.colorSpace = t.colorSpace, this.renderTarget = t.renderTarget, this.isRenderTargetTexture = t.isRenderTargetTexture, this.userData = JSON.parse(JSON.stringify(t.userData)), this.needsUpdate = !0, this;
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string";
    if (!e && t.textures[this.uuid] !== void 0)
      return t.textures[this.uuid];
    const r = {
      metadata: {
        version: 4.6,
        type: "Texture",
        generator: "Texture.toJSON"
      },
      uuid: this.uuid,
      name: this.name,
      image: this.source.toJSON(t).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 && (r.userData = this.userData), e || (t.textures[this.uuid] = r), r;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  transformUv(t) {
    if (this.mapping !== iM) return t;
    if (t.applyMatrix3(this.matrix), t.x < 0 || t.x > 1)
      switch (this.wrapS) {
        case vg:
          t.x = t.x - Math.floor(t.x);
          break;
        case Ea:
          t.x = t.x < 0 ? 0 : 1;
          break;
        case _g:
          Math.abs(Math.floor(t.x) % 2) === 1 ? t.x = Math.ceil(t.x) - t.x : t.x = t.x - Math.floor(t.x);
          break;
      }
    if (t.y < 0 || t.y > 1)
      switch (this.wrapT) {
        case vg:
          t.y = t.y - Math.floor(t.y);
          break;
        case Ea:
          t.y = t.y < 0 ? 0 : 1;
          break;
        case _g:
          Math.abs(Math.floor(t.y) % 2) === 1 ? t.y = Math.ceil(t.y) - t.y : t.y = t.y - Math.floor(t.y);
          break;
      }
    return this.flipY && (t.y = 1 - t.y), t;
  }
  set needsUpdate(t) {
    t === !0 && (this.version++, this.source.needsUpdate = !0);
  }
  set needsPMREMUpdate(t) {
    t === !0 && this.pmremVersion++;
  }
}
Jn.DEFAULT_IMAGE = null;
Jn.DEFAULT_MAPPING = iM;
Jn.DEFAULT_ANISOTROPY = 1;
class Ke {
  constructor(t = 0, e = 0, r = 0, a = 1) {
    Ke.prototype.isVector4 = !0, this.x = t, this.y = e, this.z = r, this.w = a;
  }
  get width() {
    return this.z;
  }
  set width(t) {
    this.z = t;
  }
  get height() {
    return this.w;
  }
  set height(t) {
    this.w = t;
  }
  set(t, e, r, a) {
    return this.x = t, this.y = e, this.z = r, this.w = a, this;
  }
  setScalar(t) {
    return this.x = t, this.y = t, this.z = t, this.w = t, this;
  }
  setX(t) {
    return this.x = t, this;
  }
  setY(t) {
    return this.y = t, this;
  }
  setZ(t) {
    return this.z = t, this;
  }
  setW(t) {
    return this.w = t, this;
  }
  setComponent(t, e) {
    switch (t) {
      case 0:
        this.x = e;
        break;
      case 1:
        this.y = e;
        break;
      case 2:
        this.z = e;
        break;
      case 3:
        this.w = e;
        break;
      default:
        throw new Error("index is out of range: " + t);
    }
    return this;
  }
  getComponent(t) {
    switch (t) {
      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: " + t);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z, this.w);
  }
  copy(t) {
    return this.x = t.x, this.y = t.y, this.z = t.z, this.w = t.w !== void 0 ? t.w : 1, this;
  }
  add(t) {
    return this.x += t.x, this.y += t.y, this.z += t.z, this.w += t.w, this;
  }
  addScalar(t) {
    return this.x += t, this.y += t, this.z += t, this.w += t, this;
  }
  addVectors(t, e) {
    return this.x = t.x + e.x, this.y = t.y + e.y, this.z = t.z + e.z, this.w = t.w + e.w, this;
  }
  addScaledVector(t, e) {
    return this.x += t.x * e, this.y += t.y * e, this.z += t.z * e, this.w += t.w * e, this;
  }
  sub(t) {
    return this.x -= t.x, this.y -= t.y, this.z -= t.z, this.w -= t.w, this;
  }
  subScalar(t) {
    return this.x -= t, this.y -= t, this.z -= t, this.w -= t, this;
  }
  subVectors(t, e) {
    return this.x = t.x - e.x, this.y = t.y - e.y, this.z = t.z - e.z, this.w = t.w - e.w, this;
  }
  multiply(t) {
    return this.x *= t.x, this.y *= t.y, this.z *= t.z, this.w *= t.w, this;
  }
  multiplyScalar(t) {
    return this.x *= t, this.y *= t, this.z *= t, this.w *= t, this;
  }
  applyMatrix4(t) {
    const e = this.x, r = this.y, a = this.z, o = this.w, c = t.elements;
    return this.x = c[0] * e + c[4] * r + c[8] * a + c[12] * o, this.y = c[1] * e + c[5] * r + c[9] * a + c[13] * o, this.z = c[2] * e + c[6] * r + c[10] * a + c[14] * o, this.w = c[3] * e + c[7] * r + c[11] * a + c[15] * o, this;
  }
  divide(t) {
    return this.x /= t.x, this.y /= t.y, this.z /= t.z, this.w /= t.w, this;
  }
  divideScalar(t) {
    return this.multiplyScalar(1 / t);
  }
  setAxisAngleFromQuaternion(t) {
    this.w = 2 * Math.acos(t.w);
    const e = Math.sqrt(1 - t.w * t.w);
    return e < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = t.x / e, this.y = t.y / e, this.z = t.z / e), this;
  }
  setAxisAngleFromRotationMatrix(t) {
    let e, r, a, o;
    const d = t.elements, h = d[0], p = d[4], m = d[8], g = d[1], _ = d[5], b = d[9], E = d[2], S = d[6], y = d[10];
    if (Math.abs(p - g) < 0.01 && Math.abs(m - E) < 0.01 && Math.abs(b - S) < 0.01) {
      if (Math.abs(p + g) < 0.1 && Math.abs(m + E) < 0.1 && Math.abs(b + S) < 0.1 && Math.abs(h + _ + y - 3) < 0.1)
        return this.set(1, 0, 0, 0), this;
      e = Math.PI;
      const w = (h + 1) / 2, M = (_ + 1) / 2, O = (y + 1) / 2, L = (p + g) / 4, N = (m + E) / 4, z = (b + S) / 4;
      return w > M && w > O ? w < 0.01 ? (r = 0, a = 0.707106781, o = 0.707106781) : (r = Math.sqrt(w), a = L / r, o = N / r) : M > O ? M < 0.01 ? (r = 0.707106781, a = 0, o = 0.707106781) : (a = Math.sqrt(M), r = L / a, o = z / a) : O < 0.01 ? (r = 0.707106781, a = 0.707106781, o = 0) : (o = Math.sqrt(O), r = N / o, a = z / o), this.set(r, a, o, e), this;
    }
    let A = Math.sqrt((S - b) * (S - b) + (m - E) * (m - E) + (g - p) * (g - p));
    return Math.abs(A) < 1e-3 && (A = 1), this.x = (S - b) / A, this.y = (m - E) / A, this.z = (g - p) / A, this.w = Math.acos((h + _ + y - 1) / 2), this;
  }
  setFromMatrixPosition(t) {
    const e = t.elements;
    return this.x = e[12], this.y = e[13], this.z = e[14], this.w = e[15], this;
  }
  min(t) {
    return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this.w = Math.min(this.w, t.w), this;
  }
  max(t) {
    return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this.w = Math.max(this.w, t.w), this;
  }
  clamp(t, e) {
    return this.x = be(this.x, t.x, e.x), this.y = be(this.y, t.y, e.y), this.z = be(this.z, t.z, e.z), this.w = be(this.w, t.w, e.w), this;
  }
  clampScalar(t, e) {
    return this.x = be(this.x, t, e), this.y = be(this.y, t, e), this.z = be(this.z, t, e), this.w = be(this.w, t, e), this;
  }
  clampLength(t, e) {
    const r = this.length();
    return this.divideScalar(r || 1).multiplyScalar(be(r, t, e));
  }
  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(t) {
    return this.x * t.x + this.y * t.y + this.z * t.z + this.w * t.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(t) {
    return this.normalize().multiplyScalar(t);
  }
  lerp(t, e) {
    return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this.z += (t.z - this.z) * e, this.w += (t.w - this.w) * e, this;
  }
  lerpVectors(t, e, r) {
    return this.x = t.x + (e.x - t.x) * r, this.y = t.y + (e.y - t.y) * r, this.z = t.z + (e.z - t.z) * r, this.w = t.w + (e.w - t.w) * r, this;
  }
  equals(t) {
    return t.x === this.x && t.y === this.y && t.z === this.z && t.w === this.w;
  }
  fromArray(t, e = 0) {
    return this.x = t[e], this.y = t[e + 1], this.z = t[e + 2], this.w = t[e + 3], this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this.x, t[e + 1] = this.y, t[e + 2] = this.z, t[e + 3] = this.w, t;
  }
  fromBufferAttribute(t, e) {
    return this.x = t.getX(e), this.y = t.getY(e), this.z = t.getZ(e), this.w = t.getW(e), 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 _C extends Ia {
  constructor(t = 1, e = 1, r = {}) {
    super(), this.isRenderTarget = !0, this.width = t, this.height = e, this.depth = 1, this.scissor = new Ke(0, 0, t, e), this.scissorTest = !1, this.viewport = new Ke(0, 0, t, e);
    const a = { width: t, height: e, depth: 1 };
    r = Object.assign({
      generateMipmaps: !1,
      internalFormat: null,
      minFilter: dr,
      depthBuffer: !0,
      stencilBuffer: !1,
      resolveDepthBuffer: !0,
      resolveStencilBuffer: !0,
      depthTexture: null,
      samples: 0,
      count: 1
    }, r);
    const o = new Jn(a, r.mapping, r.wrapS, r.wrapT, r.magFilter, r.minFilter, r.format, r.type, r.anisotropy, r.colorSpace);
    o.flipY = !1, o.generateMipmaps = r.generateMipmaps, o.internalFormat = r.internalFormat, this.textures = [];
    const c = r.count;
    for (let u = 0; u < c; u++)
      this.textures[u] = o.clone(), this.textures[u].isRenderTargetTexture = !0, this.textures[u].renderTarget = this;
    this.depthBuffer = r.depthBuffer, this.stencilBuffer = r.stencilBuffer, this.resolveDepthBuffer = r.resolveDepthBuffer, this.resolveStencilBuffer = r.resolveStencilBuffer, this._depthTexture = null, this.depthTexture = r.depthTexture, this.samples = r.samples;
  }
  get texture() {
    return this.textures[0];
  }
  set texture(t) {
    this.textures[0] = t;
  }
  set depthTexture(t) {
    this._depthTexture !== null && (this._depthTexture.renderTarget = null), t !== null && (t.renderTarget = this), this._depthTexture = t;
  }
  get depthTexture() {
    return this._depthTexture;
  }
  setSize(t, e, r = 1) {
    if (this.width !== t || this.height !== e || this.depth !== r) {
      this.width = t, this.height = e, this.depth = r;
      for (let a = 0, o = this.textures.length; a < o; a++)
        this.textures[a].image.width = t, this.textures[a].image.height = e, this.textures[a].image.depth = r;
      this.dispose();
    }
    this.viewport.set(0, 0, t, e), this.scissor.set(0, 0, t, e);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    this.width = t.width, this.height = t.height, this.depth = t.depth, this.scissor.copy(t.scissor), this.scissorTest = t.scissorTest, this.viewport.copy(t.viewport), this.textures.length = 0;
    for (let r = 0, a = t.textures.length; r < a; r++)
      this.textures[r] = t.textures[r].clone(), this.textures[r].isRenderTargetTexture = !0, this.textures[r].renderTarget = this;
    const e = Object.assign({}, t.texture.image);
    return this.texture.source = new vM(e), this.depthBuffer = t.depthBuffer, this.stencilBuffer = t.stencilBuffer, this.resolveDepthBuffer = t.resolveDepthBuffer, this.resolveStencilBuffer = t.resolveStencilBuffer, t.depthTexture !== null && (this.depthTexture = t.depthTexture.clone()), this.samples = t.samples, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
class La extends _C {
  constructor(t = 1, e = 1, r = {}) {
    super(t, e, r), this.isWebGLRenderTarget = !0;
  }
}
class _M extends Jn {
  constructor(t = null, e = 1, r = 1, a = 1) {
    super(null), this.isDataArrayTexture = !0, this.image = { data: t, width: e, height: r, depth: a }, this.magFilter = Yn, this.minFilter = Yn, this.wrapR = Ea, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set();
  }
  addLayerUpdate(t) {
    this.layerUpdates.add(t);
  }
  clearLayerUpdates() {
    this.layerUpdates.clear();
  }
}
class yC extends Jn {
  constructor(t = null, e = 1, r = 1, a = 1) {
    super(null), this.isData3DTexture = !0, this.image = { data: t, width: e, height: r, depth: a }, this.magFilter = Yn, this.minFilter = Yn, this.wrapR = Ea, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class js {
  constructor(t = 0, e = 0, r = 0, a = 1) {
    this.isQuaternion = !0, this._x = t, this._y = e, this._z = r, this._w = a;
  }
  static slerpFlat(t, e, r, a, o, c, u) {
    let d = r[a + 0], h = r[a + 1], p = r[a + 2], m = r[a + 3];
    const g = o[c + 0], _ = o[c + 1], b = o[c + 2], E = o[c + 3];
    if (u === 0) {
      t[e + 0] = d, t[e + 1] = h, t[e + 2] = p, t[e + 3] = m;
      return;
    }
    if (u === 1) {
      t[e + 0] = g, t[e + 1] = _, t[e + 2] = b, t[e + 3] = E;
      return;
    }
    if (m !== E || d !== g || h !== _ || p !== b) {
      let S = 1 - u;
      const y = d * g + h * _ + p * b + m * E, A = y >= 0 ? 1 : -1, w = 1 - y * y;
      if (w > Number.EPSILON) {
        const O = Math.sqrt(w), L = Math.atan2(O, y * A);
        S = Math.sin(S * L) / O, u = Math.sin(u * L) / O;
      }
      const M = u * A;
      if (d = d * S + g * M, h = h * S + _ * M, p = p * S + b * M, m = m * S + E * M, S === 1 - u) {
        const O = 1 / Math.sqrt(d * d + h * h + p * p + m * m);
        d *= O, h *= O, p *= O, m *= O;
      }
    }
    t[e] = d, t[e + 1] = h, t[e + 2] = p, t[e + 3] = m;
  }
  static multiplyQuaternionsFlat(t, e, r, a, o, c) {
    const u = r[a], d = r[a + 1], h = r[a + 2], p = r[a + 3], m = o[c], g = o[c + 1], _ = o[c + 2], b = o[c + 3];
    return t[e] = u * b + p * m + d * _ - h * g, t[e + 1] = d * b + p * g + h * m - u * _, t[e + 2] = h * b + p * _ + u * g - d * m, t[e + 3] = p * b - u * m - d * g - h * _, t;
  }
  get x() {
    return this._x;
  }
  set x(t) {
    this._x = t, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(t) {
    this._y = t, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(t) {
    this._z = t, this._onChangeCallback();
  }
  get w() {
    return this._w;
  }
  set w(t) {
    this._w = t, this._onChangeCallback();
  }
  set(t, e, r, a) {
    return this._x = t, this._y = e, this._z = r, this._w = a, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._w);
  }
  copy(t) {
    return this._x = t.x, this._y = t.y, this._z = t.z, this._w = t.w, this._onChangeCallback(), this;
  }
  setFromEuler(t, e = !0) {
    const r = t._x, a = t._y, o = t._z, c = t._order, u = Math.cos, d = Math.sin, h = u(r / 2), p = u(a / 2), m = u(o / 2), g = d(r / 2), _ = d(a / 2), b = d(o / 2);
    switch (c) {
      case "XYZ":
        this._x = g * p * m + h * _ * b, this._y = h * _ * m - g * p * b, this._z = h * p * b + g * _ * m, this._w = h * p * m - g * _ * b;
        break;
      case "YXZ":
        this._x = g * p * m + h * _ * b, this._y = h * _ * m - g * p * b, this._z = h * p * b - g * _ * m, this._w = h * p * m + g * _ * b;
        break;
      case "ZXY":
        this._x = g * p * m - h * _ * b, this._y = h * _ * m + g * p * b, this._z = h * p * b + g * _ * m, this._w = h * p * m - g * _ * b;
        break;
      case "ZYX":
        this._x = g * p * m - h * _ * b, this._y = h * _ * m + g * p * b, this._z = h * p * b - g * _ * m, this._w = h * p * m + g * _ * b;
        break;
      case "YZX":
        this._x = g * p * m + h * _ * b, this._y = h * _ * m + g * p * b, this._z = h * p * b - g * _ * m, this._w = h * p * m - g * _ * b;
        break;
      case "XZY":
        this._x = g * p * m - h * _ * b, this._y = h * _ * m - g * p * b, this._z = h * p * b + g * _ * m, this._w = h * p * m + g * _ * b;
        break;
      default:
        console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + c);
    }
    return e === !0 && this._onChangeCallback(), this;
  }
  setFromAxisAngle(t, e) {
    const r = e / 2, a = Math.sin(r);
    return this._x = t.x * a, this._y = t.y * a, this._z = t.z * a, this._w = Math.cos(r), this._onChangeCallback(), this;
  }
  setFromRotationMatrix(t) {
    const e = t.elements, r = e[0], a = e[4], o = e[8], c = e[1], u = e[5], d = e[9], h = e[2], p = e[6], m = e[10], g = r + u + m;
    if (g > 0) {
      const _ = 0.5 / Math.sqrt(g + 1);
      this._w = 0.25 / _, this._x = (p - d) * _, this._y = (o - h) * _, this._z = (c - a) * _;
    } else if (r > u && r > m) {
      const _ = 2 * Math.sqrt(1 + r - u - m);
      this._w = (p - d) / _, this._x = 0.25 * _, this._y = (a + c) / _, this._z = (o + h) / _;
    } else if (u > m) {
      const _ = 2 * Math.sqrt(1 + u - r - m);
      this._w = (o - h) / _, this._x = (a + c) / _, this._y = 0.25 * _, this._z = (d + p) / _;
    } else {
      const _ = 2 * Math.sqrt(1 + m - r - u);
      this._w = (c - a) / _, this._x = (o + h) / _, this._y = (d + p) / _, this._z = 0.25 * _;
    }
    return this._onChangeCallback(), this;
  }
  setFromUnitVectors(t, e) {
    let r = t.dot(e) + 1;
    return r < Number.EPSILON ? (r = 0, Math.abs(t.x) > Math.abs(t.z) ? (this._x = -t.y, this._y = t.x, this._z = 0, this._w = r) : (this._x = 0, this._y = -t.z, this._z = t.y, this._w = r)) : (this._x = t.y * e.z - t.z * e.y, this._y = t.z * e.x - t.x * e.z, this._z = t.x * e.y - t.y * e.x, this._w = r), this.normalize();
  }
  angleTo(t) {
    return 2 * Math.acos(Math.abs(be(this.dot(t), -1, 1)));
  }
  rotateTowards(t, e) {
    const r = this.angleTo(t);
    if (r === 0) return this;
    const a = Math.min(1, e / r);
    return this.slerp(t, a), 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(t) {
    return this._x * t._x + this._y * t._y + this._z * t._z + this._w * t._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 t = this.length();
    return t === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (t = 1 / t, this._x = this._x * t, this._y = this._y * t, this._z = this._z * t, this._w = this._w * t), this._onChangeCallback(), this;
  }
  multiply(t) {
    return this.multiplyQuaternions(this, t);
  }
  premultiply(t) {
    return this.multiplyQuaternions(t, this);
  }
  multiplyQuaternions(t, e) {
    const r = t._x, a = t._y, o = t._z, c = t._w, u = e._x, d = e._y, h = e._z, p = e._w;
    return this._x = r * p + c * u + a * h - o * d, this._y = a * p + c * d + o * u - r * h, this._z = o * p + c * h + r * d - a * u, this._w = c * p - r * u - a * d - o * h, this._onChangeCallback(), this;
  }
  slerp(t, e) {
    if (e === 0) return this;
    if (e === 1) return this.copy(t);
    const r = this._x, a = this._y, o = this._z, c = this._w;
    let u = c * t._w + r * t._x + a * t._y + o * t._z;
    if (u < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, u = -u) : this.copy(t), u >= 1)
      return this._w = c, this._x = r, this._y = a, this._z = o, this;
    const d = 1 - u * u;
    if (d <= Number.EPSILON) {
      const _ = 1 - e;
      return this._w = _ * c + e * this._w, this._x = _ * r + e * this._x, this._y = _ * a + e * this._y, this._z = _ * o + e * this._z, this.normalize(), this;
    }
    const h = Math.sqrt(d), p = Math.atan2(h, u), m = Math.sin((1 - e) * p) / h, g = Math.sin(e * p) / h;
    return this._w = c * m + this._w * g, this._x = r * m + this._x * g, this._y = a * m + this._y * g, this._z = o * m + this._z * g, this._onChangeCallback(), this;
  }
  slerpQuaternions(t, e, r) {
    return this.copy(t).slerp(e, r);
  }
  random() {
    const t = 2 * Math.PI * Math.random(), e = 2 * Math.PI * Math.random(), r = Math.random(), a = Math.sqrt(1 - r), o = Math.sqrt(r);
    return this.set(
      a * Math.sin(t),
      a * Math.cos(t),
      o * Math.sin(e),
      o * Math.cos(e)
    );
  }
  equals(t) {
    return t._x === this._x && t._y === this._y && t._z === this._z && t._w === this._w;
  }
  fromArray(t, e = 0) {
    return this._x = t[e], this._y = t[e + 1], this._z = t[e + 2], this._w = t[e + 3], this._onChangeCallback(), this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._w, t;
  }
  fromBufferAttribute(t, e) {
    return this._x = t.getX(e), this._y = t.getY(e), this._z = t.getZ(e), this._w = t.getW(e), this._onChangeCallback(), this;
  }
  toJSON() {
    return this.toArray();
  }
  _onChange(t) {
    return this._onChangeCallback = t, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._w;
  }
}
class ot {
  constructor(t = 0, e = 0, r = 0) {
    ot.prototype.isVector3 = !0, this.x = t, this.y = e, this.z = r;
  }
  set(t, e, r) {
    return r === void 0 && (r = this.z), this.x = t, this.y = e, this.z = r, this;
  }
  setScalar(t) {
    return this.x = t, this.y = t, this.z = t, this;
  }
  setX(t) {
    return this.x = t, this;
  }
  setY(t) {
    return this.y = t, this;
  }
  setZ(t) {
    return this.z = t, this;
  }
  setComponent(t, e) {
    switch (t) {
      case 0:
        this.x = e;
        break;
      case 1:
        this.y = e;
        break;
      case 2:
        this.z = e;
        break;
      default:
        throw new Error("index is out of range: " + t);
    }
    return this;
  }
  getComponent(t) {
    switch (t) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      default:
        throw new Error("index is out of range: " + t);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z);
  }
  copy(t) {
    return this.x = t.x, this.y = t.y, this.z = t.z, this;
  }
  add(t) {
    return this.x += t.x, this.y += t.y, this.z += t.z, this;
  }
  addScalar(t) {
    return this.x += t, this.y += t, this.z += t, this;
  }
  addVectors(t, e) {
    return this.x = t.x + e.x, this.y = t.y + e.y, this.z = t.z + e.z, this;
  }
  addScaledVector(t, e) {
    return this.x += t.x * e, this.y += t.y * e, this.z += t.z * e, this;
  }
  sub(t) {
    return this.x -= t.x, this.y -= t.y, this.z -= t.z, this;
  }
  subScalar(t) {
    return this.x -= t, this.y -= t, this.z -= t, this;
  }
  subVectors(t, e) {
    return this.x = t.x - e.x, this.y = t.y - e.y, this.z = t.z - e.z, this;
  }
  multiply(t) {
    return this.x *= t.x, this.y *= t.y, this.z *= t.z, this;
  }
  multiplyScalar(t) {
    return this.x *= t, this.y *= t, this.z *= t, this;
  }
  multiplyVectors(t, e) {
    return this.x = t.x * e.x, this.y = t.y * e.y, this.z = t.z * e.z, this;
  }
  applyEuler(t) {
    return this.applyQuaternion(eS.setFromEuler(t));
  }
  applyAxisAngle(t, e) {
    return this.applyQuaternion(eS.setFromAxisAngle(t, e));
  }
  applyMatrix3(t) {
    const e = this.x, r = this.y, a = this.z, o = t.elements;
    return this.x = o[0] * e + o[3] * r + o[6] * a, this.y = o[1] * e + o[4] * r + o[7] * a, this.z = o[2] * e + o[5] * r + o[8] * a, this;
  }
  applyNormalMatrix(t) {
    return this.applyMatrix3(t).normalize();
  }
  applyMatrix4(t) {
    const e = this.x, r = this.y, a = this.z, o = t.elements, c = 1 / (o[3] * e + o[7] * r + o[11] * a + o[15]);
    return this.x = (o[0] * e + o[4] * r + o[8] * a + o[12]) * c, this.y = (o[1] * e + o[5] * r + o[9] * a + o[13]) * c, this.z = (o[2] * e + o[6] * r + o[10] * a + o[14]) * c, this;
  }
  applyQuaternion(t) {
    const e = this.x, r = this.y, a = this.z, o = t.x, c = t.y, u = t.z, d = t.w, h = 2 * (c * a - u * r), p = 2 * (u * e - o * a), m = 2 * (o * r - c * e);
    return this.x = e + d * h + c * m - u * p, this.y = r + d * p + u * h - o * m, this.z = a + d * m + o * p - c * h, this;
  }
  project(t) {
    return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix);
  }
  unproject(t) {
    return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);
  }
  transformDirection(t) {
    const e = this.x, r = this.y, a = this.z, o = t.elements;
    return this.x = o[0] * e + o[4] * r + o[8] * a, this.y = o[1] * e + o[5] * r + o[9] * a, this.z = o[2] * e + o[6] * r + o[10] * a, this.normalize();
  }
  divide(t) {
    return this.x /= t.x, this.y /= t.y, this.z /= t.z, this;
  }
  divideScalar(t) {
    return this.multiplyScalar(1 / t);
  }
  min(t) {
    return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this;
  }
  max(t) {
    return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this;
  }
  clamp(t, e) {
    return this.x = be(this.x, t.x, e.x), this.y = be(this.y, t.y, e.y), this.z = be(this.z, t.z, e.z), this;
  }
  clampScalar(t, e) {
    return this.x = be(this.x, t, e), this.y = be(this.y, t, e), this.z = be(this.z, t, e), this;
  }
  clampLength(t, e) {
    const r = this.length();
    return this.divideScalar(r || 1).multiplyScalar(be(r, t, e));
  }
  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(t) {
    return this.x * t.x + this.y * t.y + this.z * t.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(t) {
    return this.normalize().multiplyScalar(t);
  }
  lerp(t, e) {
    return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this.z += (t.z - this.z) * e, this;
  }
  lerpVectors(t, e, r) {
    return this.x = t.x + (e.x - t.x) * r, this.y = t.y + (e.y - t.y) * r, this.z = t.z + (e.z - t.z) * r, this;
  }
  cross(t) {
    return this.crossVectors(this, t);
  }
  crossVectors(t, e) {
    const r = t.x, a = t.y, o = t.z, c = e.x, u = e.y, d = e.z;
    return this.x = a * d - o * u, this.y = o * c - r * d, this.z = r * u - a * c, this;
  }
  projectOnVector(t) {
    const e = t.lengthSq();
    if (e === 0) return this.set(0, 0, 0);
    const r = t.dot(this) / e;
    return this.copy(t).multiplyScalar(r);
  }
  projectOnPlane(t) {
    return am.copy(this).projectOnVector(t), this.sub(am);
  }
  reflect(t) {
    return this.sub(am.copy(t).multiplyScalar(2 * this.dot(t)));
  }
  angleTo(t) {
    const e = Math.sqrt(this.lengthSq() * t.lengthSq());
    if (e === 0) return Math.PI / 2;
    const r = this.dot(t) / e;
    return Math.acos(be(r, -1, 1));
  }
  distanceTo(t) {
    return Math.sqrt(this.distanceToSquared(t));
  }
  distanceToSquared(t) {
    const e = this.x - t.x, r = this.y - t.y, a = this.z - t.z;
    return e * e + r * r + a * a;
  }
  manhattanDistanceTo(t) {
    return Math.abs(this.x - t.x) + Math.abs(this.y - t.y) + Math.abs(this.z - t.z);
  }
  setFromSpherical(t) {
    return this.setFromSphericalCoords(t.radius, t.phi, t.theta);
  }
  setFromSphericalCoords(t, e, r) {
    const a = Math.sin(e) * t;
    return this.x = a * Math.sin(r), this.y = Math.cos(e) * t, this.z = a * Math.cos(r), this;
  }
  setFromCylindrical(t) {
    return this.setFromCylindricalCoords(t.radius, t.theta, t.y);
  }
  setFromCylindricalCoords(t, e, r) {
    return this.x = t * Math.sin(e), this.y = r, this.z = t * Math.cos(e), this;
  }
  setFromMatrixPosition(t) {
    const e = t.elements;
    return this.x = e[12], this.y = e[13], this.z = e[14], this;
  }
  setFromMatrixScale(t) {
    const e = this.setFromMatrixColumn(t, 0).length(), r = this.setFromMatrixColumn(t, 1).length(), a = this.setFromMatrixColumn(t, 2).length();
    return this.x = e, this.y = r, this.z = a, this;
  }
  setFromMatrixColumn(t, e) {
    return this.fromArray(t.elements, e * 4);
  }
  setFromMatrix3Column(t, e) {
    return this.fromArray(t.elements, e * 3);
  }
  setFromEuler(t) {
    return this.x = t._x, this.y = t._y, this.z = t._z, this;
  }
  setFromColor(t) {
    return this.x = t.r, this.y = t.g, this.z = t.b, this;
  }
  equals(t) {
    return t.x === this.x && t.y === this.y && t.z === this.z;
  }
  fromArray(t, e = 0) {
    return this.x = t[e], this.y = t[e + 1], this.z = t[e + 2], this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this.x, t[e + 1] = this.y, t[e + 2] = this.z, t;
  }
  fromBufferAttribute(t, e) {
    return this.x = t.getX(e), this.y = t.getY(e), this.z = t.getZ(e), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
  }
  randomDirection() {
    const t = Math.random() * Math.PI * 2, e = Math.random() * 2 - 1, r = Math.sqrt(1 - e * e);
    return this.x = r * Math.cos(t), this.y = e, this.z = r * Math.sin(t), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z;
  }
}
const am = /* @__PURE__ */ new ot(), eS = /* @__PURE__ */ new js();
class _r {
  constructor(t = new ot(1 / 0, 1 / 0, 1 / 0), e = new ot(-1 / 0, -1 / 0, -1 / 0)) {
    this.isBox3 = !0, this.min = t, this.max = e;
  }
  set(t, e) {
    return this.min.copy(t), this.max.copy(e), this;
  }
  setFromArray(t) {
    this.makeEmpty();
    for (let e = 0, r = t.length; e < r; e += 3)
      this.expandByPoint(Yi.fromArray(t, e));
    return this;
  }
  setFromBufferAttribute(t) {
    this.makeEmpty();
    for (let e = 0, r = t.count; e < r; e++)
      this.expandByPoint(Yi.fromBufferAttribute(t, e));
    return this;
  }
  setFromPoints(t) {
    this.makeEmpty();
    for (let e = 0, r = t.length; e < r; e++)
      this.expandByPoint(t[e]);
    return this;
  }
  setFromCenterAndSize(t, e) {
    const r = Yi.copy(e).multiplyScalar(0.5);
    return this.min.copy(t).sub(r), this.max.copy(t).add(r), this;
  }
  setFromObject(t, e = !1) {
    return this.makeEmpty(), this.expandByObject(t, e);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    return this.min.copy(t.min), this.max.copy(t.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(t) {
    return this.isEmpty() ? t.set(0, 0, 0) : t.addVectors(this.min, this.max).multiplyScalar(0.5);
  }
  getSize(t) {
    return this.isEmpty() ? t.set(0, 0, 0) : t.subVectors(this.max, this.min);
  }
  expandByPoint(t) {
    return this.min.min(t), this.max.max(t), this;
  }
  expandByVector(t) {
    return this.min.sub(t), this.max.add(t), this;
  }
  expandByScalar(t) {
    return this.min.addScalar(-t), this.max.addScalar(t), this;
  }
  expandByObject(t, e = !1) {
    t.updateWorldMatrix(!1, !1);
    const r = t.geometry;
    if (r !== void 0) {
      const o = r.getAttribute("position");
      if (e === !0 && o !== void 0 && t.isInstancedMesh !== !0)
        for (let c = 0, u = o.count; c < u; c++)
          t.isMesh === !0 ? t.getVertexPosition(c, Yi) : Yi.fromBufferAttribute(o, c), Yi.applyMatrix4(t.matrixWorld), this.expandByPoint(Yi);
      else
        t.boundingBox !== void 0 ? (t.boundingBox === null && t.computeBoundingBox(), uf.copy(t.boundingBox)) : (r.boundingBox === null && r.computeBoundingBox(), uf.copy(r.boundingBox)), uf.applyMatrix4(t.matrixWorld), this.union(uf);
    }
    const a = t.children;
    for (let o = 0, c = a.length; o < c; o++)
      this.expandByObject(a[o], e);
    return this;
  }
  containsPoint(t) {
    return t.x >= this.min.x && t.x <= this.max.x && t.y >= this.min.y && t.y <= this.max.y && t.z >= this.min.z && t.z <= this.max.z;
  }
  containsBox(t) {
    return this.min.x <= t.min.x && t.max.x <= this.max.x && this.min.y <= t.min.y && t.max.y <= this.max.y && this.min.z <= t.min.z && t.max.z <= this.max.z;
  }
  getParameter(t, e) {
    return e.set(
      (t.x - this.min.x) / (this.max.x - this.min.x),
      (t.y - this.min.y) / (this.max.y - this.min.y),
      (t.z - this.min.z) / (this.max.z - this.min.z)
    );
  }
  intersectsBox(t) {
    return t.max.x >= this.min.x && t.min.x <= this.max.x && t.max.y >= this.min.y && t.min.y <= this.max.y && t.max.z >= this.min.z && t.min.z <= this.max.z;
  }
  intersectsSphere(t) {
    return this.clampPoint(t.center, Yi), Yi.distanceToSquared(t.center) <= t.radius * t.radius;
  }
  intersectsPlane(t) {
    let e, r;
    return t.normal.x > 0 ? (e = t.normal.x * this.min.x, r = t.normal.x * this.max.x) : (e = t.normal.x * this.max.x, r = t.normal.x * this.min.x), t.normal.y > 0 ? (e += t.normal.y * this.min.y, r += t.normal.y * this.max.y) : (e += t.normal.y * this.max.y, r += t.normal.y * this.min.y), t.normal.z > 0 ? (e += t.normal.z * this.min.z, r += t.normal.z * this.max.z) : (e += t.normal.z * this.max.z, r += t.normal.z * this.min.z), e <= -t.constant && r >= -t.constant;
  }
  intersectsTriangle(t) {
    if (this.isEmpty())
      return !1;
    this.getCenter(ac), ff.subVectors(this.max, ac), Mo.subVectors(t.a, ac), Eo.subVectors(t.b, ac), wo.subVectors(t.c, ac), Rs.subVectors(Eo, Mo), Ds.subVectors(wo, Eo), ha.subVectors(Mo, wo);
    let e = [
      0,
      -Rs.z,
      Rs.y,
      0,
      -Ds.z,
      Ds.y,
      0,
      -ha.z,
      ha.y,
      Rs.z,
      0,
      -Rs.x,
      Ds.z,
      0,
      -Ds.x,
      ha.z,
      0,
      -ha.x,
      -Rs.y,
      Rs.x,
      0,
      -Ds.y,
      Ds.x,
      0,
      -ha.y,
      ha.x,
      0
    ];
    return !om(e, Mo, Eo, wo, ff) || (e = [1, 0, 0, 0, 1, 0, 0, 0, 1], !om(e, Mo, Eo, wo, ff)) ? !1 : (df.crossVectors(Rs, Ds), e = [df.x, df.y, df.z], om(e, Mo, Eo, wo, ff));
  }
  clampPoint(t, e) {
    return e.copy(t).clamp(this.min, this.max);
  }
  distanceToPoint(t) {
    return this.clampPoint(t, Yi).distanceTo(t);
  }
  getBoundingSphere(t) {
    return this.isEmpty() ? t.makeEmpty() : (this.getCenter(t.center), t.radius = this.getSize(Yi).length() * 0.5), t;
  }
  intersect(t) {
    return this.min.max(t.min), this.max.min(t.max), this.isEmpty() && this.makeEmpty(), this;
  }
  union(t) {
    return this.min.min(t.min), this.max.max(t.max), this;
  }
  applyMatrix4(t) {
    return this.isEmpty() ? this : (Vr[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(t), Vr[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(t), Vr[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(t), Vr[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(t), Vr[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(t), Vr[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(t), Vr[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(t), Vr[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(t), this.setFromPoints(Vr), this);
  }
  translate(t) {
    return this.min.add(t), this.max.add(t), this;
  }
  equals(t) {
    return t.min.equals(this.min) && t.max.equals(this.max);
  }
}
const Vr = [
  /* @__PURE__ */ new ot(),
  /* @__PURE__ */ new ot(),
  /* @__PURE__ */ new ot(),
  /* @__PURE__ */ new ot(),
  /* @__PURE__ */ new ot(),
  /* @__PURE__ */ new ot(),
  /* @__PURE__ */ new ot(),
  /* @__PURE__ */ new ot()
], Yi = /* @__PURE__ */ new ot(), uf = /* @__PURE__ */ new _r(), Mo = /* @__PURE__ */ new ot(), Eo = /* @__PURE__ */ new ot(), wo = /* @__PURE__ */ new ot(), Rs = /* @__PURE__ */ new ot(), Ds = /* @__PURE__ */ new ot(), ha = /* @__PURE__ */ new ot(), ac = /* @__PURE__ */ new ot(), ff = /* @__PURE__ */ new ot(), df = /* @__PURE__ */ new ot(), pa = /* @__PURE__ */ new ot();
function om(n, t, e, r, a) {
  for (let o = 0, c = n.length - 3; o <= c; o += 3) {
    pa.fromArray(n, o);
    const u = a.x * Math.abs(pa.x) + a.y * Math.abs(pa.y) + a.z * Math.abs(pa.z), d = t.dot(pa), h = e.dot(pa), p = r.dot(pa);
    if (Math.max(-Math.max(d, h, p), Math.min(d, h, p)) > u)
      return !1;
  }
  return !0;
}
const xC = /* @__PURE__ */ new _r(), oc = /* @__PURE__ */ new ot(), lm = /* @__PURE__ */ new ot();
class Ws {
  constructor(t = new ot(), e = -1) {
    this.isSphere = !0, this.center = t, this.radius = e;
  }
  set(t, e) {
    return this.center.copy(t), this.radius = e, this;
  }
  setFromPoints(t, e) {
    const r = this.center;
    e !== void 0 ? r.copy(e) : xC.setFromPoints(t).getCenter(r);
    let a = 0;
    for (let o = 0, c = t.length; o < c; o++)
      a = Math.max(a, r.distanceToSquared(t[o]));
    return this.radius = Math.sqrt(a), this;
  }
  copy(t) {
    return this.center.copy(t.center), this.radius = t.radius, this;
  }
  isEmpty() {
    return this.radius < 0;
  }
  makeEmpty() {
    return this.center.set(0, 0, 0), this.radius = -1, this;
  }
  containsPoint(t) {
    return t.distanceToSquared(this.center) <= this.radius * this.radius;
  }
  distanceToPoint(t) {
    return t.distanceTo(this.center) - this.radius;
  }
  intersectsSphere(t) {
    const e = this.radius + t.radius;
    return t.center.distanceToSquared(this.center) <= e * e;
  }
  intersectsBox(t) {
    return t.intersectsSphere(this);
  }
  intersectsPlane(t) {
    return Math.abs(t.distanceToPoint(this.center)) <= this.radius;
  }
  clampPoint(t, e) {
    const r = this.center.distanceToSquared(t);
    return e.copy(t), r > this.radius * this.radius && (e.sub(this.center).normalize(), e.multiplyScalar(this.radius).add(this.center)), e;
  }
  getBoundingBox(t) {
    return this.isEmpty() ? (t.makeEmpty(), t) : (t.set(this.center, this.center), t.expandByScalar(this.radius), t);
  }
  applyMatrix4(t) {
    return this.center.applyMatrix4(t), this.radius = this.radius * t.getMaxScaleOnAxis(), this;
  }
  translate(t) {
    return this.center.add(t), this;
  }
  expandByPoint(t) {
    if (this.isEmpty())
      return this.center.copy(t), this.radius = 0, this;
    oc.subVectors(t, this.center);
    const e = oc.lengthSq();
    if (e > this.radius * this.radius) {
      const r = Math.sqrt(e), a = (r - this.radius) * 0.5;
      this.center.addScaledVector(oc, a / r), this.radius += a;
    }
    return this;
  }
  union(t) {
    return t.isEmpty() ? this : this.isEmpty() ? (this.copy(t), this) : (this.center.equals(t.center) === !0 ? this.radius = Math.max(this.radius, t.radius) : (lm.subVectors(t.center, this.center).setLength(t.radius), this.expandByPoint(oc.copy(t.center).add(lm)), this.expandByPoint(oc.copy(t.center).sub(lm))), this);
  }
  equals(t) {
    return t.center.equals(this.center) && t.radius === this.radius;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const kr = /* @__PURE__ */ new ot(), cm = /* @__PURE__ */ new ot(), hf = /* @__PURE__ */ new ot(), Ns = /* @__PURE__ */ new ot(), um = /* @__PURE__ */ new ot(), pf = /* @__PURE__ */ new ot(), fm = /* @__PURE__ */ new ot();
class E0 {
  constructor(t = new ot(), e = new ot(0, 0, -1)) {
    this.origin = t, this.direction = e;
  }
  set(t, e) {
    return this.origin.copy(t), this.direction.copy(e), this;
  }
  copy(t) {
    return this.origin.copy(t.origin), this.direction.copy(t.direction), this;
  }
  at(t, e) {
    return e.copy(this.origin).addScaledVector(this.direction, t);
  }
  lookAt(t) {
    return this.direction.copy(t).sub(this.origin).normalize(), this;
  }
  recast(t) {
    return this.origin.copy(this.at(t, kr)), this;
  }
  closestPointToPoint(t, e) {
    e.subVectors(t, this.origin);
    const r = e.dot(this.direction);
    return r < 0 ? e.copy(this.origin) : e.copy(this.origin).addScaledVector(this.direction, r);
  }
  distanceToPoint(t) {
    return Math.sqrt(this.distanceSqToPoint(t));
  }
  distanceSqToPoint(t) {
    const e = kr.subVectors(t, this.origin).dot(this.direction);
    return e < 0 ? this.origin.distanceToSquared(t) : (kr.copy(this.origin).addScaledVector(this.direction, e), kr.distanceToSquared(t));
  }
  distanceSqToSegment(t, e, r, a) {
    cm.copy(t).add(e).multiplyScalar(0.5), hf.copy(e).sub(t).normalize(), Ns.copy(this.origin).sub(cm);
    const o = t.distanceTo(e) * 0.5, c = -this.direction.dot(hf), u = Ns.dot(this.direction), d = -Ns.dot(hf), h = Ns.lengthSq(), p = Math.abs(1 - c * c);
    let m, g, _, b;
    if (p > 0)
      if (m = c * d - u, g = c * u - d, b = o * p, m >= 0)
        if (g >= -b)
          if (g <= b) {
            const E = 1 / p;
            m *= E, g *= E, _ = m * (m + c * g + 2 * u) + g * (c * m + g + 2 * d) + h;
          } else
            g = o, m = Math.max(0, -(c * g + u)), _ = -m * m + g * (g + 2 * d) + h;
        else
          g = -o, m = Math.max(0, -(c * g + u)), _ = -m * m + g * (g + 2 * d) + h;
      else
        g <= -b ? (m = Math.max(0, -(-c * o + u)), g = m > 0 ? -o : Math.min(Math.max(-o, -d), o), _ = -m * m + g * (g + 2 * d) + h) : g <= b ? (m = 0, g = Math.min(Math.max(-o, -d), o), _ = g * (g + 2 * d) + h) : (m = Math.max(0, -(c * o + u)), g = m > 0 ? o : Math.min(Math.max(-o, -d), o), _ = -m * m + g * (g + 2 * d) + h);
    else
      g = c > 0 ? -o : o, m = Math.max(0, -(c * g + u)), _ = -m * m + g * (g + 2 * d) + h;
    return r && r.copy(this.origin).addScaledVector(this.direction, m), a && a.copy(cm).addScaledVector(hf, g), _;
  }
  intersectSphere(t, e) {
    kr.subVectors(t.center, this.origin);
    const r = kr.dot(this.direction), a = kr.dot(kr) - r * r, o = t.radius * t.radius;
    if (a > o) return null;
    const c = Math.sqrt(o - a), u = r - c, d = r + c;
    return d < 0 ? null : u < 0 ? this.at(d, e) : this.at(u, e);
  }
  intersectsSphere(t) {
    return this.distanceSqToPoint(t.center) <= t.radius * t.radius;
  }
  distanceToPlane(t) {
    const e = t.normal.dot(this.direction);
    if (e === 0)
      return t.distanceToPoint(this.origin) === 0 ? 0 : null;
    const r = -(this.origin.dot(t.normal) + t.constant) / e;
    return r >= 0 ? r : null;
  }
  intersectPlane(t, e) {
    const r = this.distanceToPlane(t);
    return r === null ? null : this.at(r, e);
  }
  intersectsPlane(t) {
    const e = t.distanceToPoint(this.origin);
    return e === 0 || t.normal.dot(this.direction) * e < 0;
  }
  intersectBox(t, e) {
    let r, a, o, c, u, d;
    const h = 1 / this.direction.x, p = 1 / this.direction.y, m = 1 / this.direction.z, g = this.origin;
    return h >= 0 ? (r = (t.min.x - g.x) * h, a = (t.max.x - g.x) * h) : (r = (t.max.x - g.x) * h, a = (t.min.x - g.x) * h), p >= 0 ? (o = (t.min.y - g.y) * p, c = (t.max.y - g.y) * p) : (o = (t.max.y - g.y) * p, c = (t.min.y - g.y) * p), r > c || o > a || ((o > r || isNaN(r)) && (r = o), (c < a || isNaN(a)) && (a = c), m >= 0 ? (u = (t.min.z - g.z) * m, d = (t.max.z - g.z) * m) : (u = (t.max.z - g.z) * m, d = (t.min.z - g.z) * m), r > d || u > a) || ((u > r || r !== r) && (r = u), (d < a || a !== a) && (a = d), a < 0) ? null : this.at(r >= 0 ? r : a, e);
  }
  intersectsBox(t) {
    return this.intersectBox(t, kr) !== null;
  }
  intersectTriangle(t, e, r, a, o) {
    um.subVectors(e, t), pf.subVectors(r, t), fm.crossVectors(um, pf);
    let c = this.direction.dot(fm), u;
    if (c > 0) {
      if (a) return null;
      u = 1;
    } else if (c < 0)
      u = -1, c = -c;
    else
      return null;
    Ns.subVectors(this.origin, t);
    const d = u * this.direction.dot(pf.crossVectors(Ns, pf));
    if (d < 0)
      return null;
    const h = u * this.direction.dot(um.cross(Ns));
    if (h < 0 || d + h > c)
      return null;
    const p = -u * Ns.dot(fm);
    return p < 0 ? null : this.at(p / c, o);
  }
  applyMatrix4(t) {
    return this.origin.applyMatrix4(t), this.direction.transformDirection(t), this;
  }
  equals(t) {
    return t.origin.equals(this.origin) && t.direction.equals(this.direction);
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Ge {
  constructor(t, e, r, a, o, c, u, d, h, p, m, g, _, b, E, S) {
    Ge.prototype.isMatrix4 = !0, this.elements = [
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ], t !== void 0 && this.set(t, e, r, a, o, c, u, d, h, p, m, g, _, b, E, S);
  }
  set(t, e, r, a, o, c, u, d, h, p, m, g, _, b, E, S) {
    const y = this.elements;
    return y[0] = t, y[4] = e, y[8] = r, y[12] = a, y[1] = o, y[5] = c, y[9] = u, y[13] = d, y[2] = h, y[6] = p, y[10] = m, y[14] = g, y[3] = _, y[7] = b, y[11] = E, y[15] = S, 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 Ge().fromArray(this.elements);
  }
  copy(t) {
    const e = this.elements, r = t.elements;
    return e[0] = r[0], e[1] = r[1], e[2] = r[2], e[3] = r[3], e[4] = r[4], e[5] = r[5], e[6] = r[6], e[7] = r[7], e[8] = r[8], e[9] = r[9], e[10] = r[10], e[11] = r[11], e[12] = r[12], e[13] = r[13], e[14] = r[14], e[15] = r[15], this;
  }
  copyPosition(t) {
    const e = this.elements, r = t.elements;
    return e[12] = r[12], e[13] = r[13], e[14] = r[14], this;
  }
  setFromMatrix3(t) {
    const e = t.elements;
    return this.set(
      e[0],
      e[3],
      e[6],
      0,
      e[1],
      e[4],
      e[7],
      0,
      e[2],
      e[5],
      e[8],
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractBasis(t, e, r) {
    return t.setFromMatrixColumn(this, 0), e.setFromMatrixColumn(this, 1), r.setFromMatrixColumn(this, 2), this;
  }
  makeBasis(t, e, r) {
    return this.set(
      t.x,
      e.x,
      r.x,
      0,
      t.y,
      e.y,
      r.y,
      0,
      t.z,
      e.z,
      r.z,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractRotation(t) {
    const e = this.elements, r = t.elements, a = 1 / To.setFromMatrixColumn(t, 0).length(), o = 1 / To.setFromMatrixColumn(t, 1).length(), c = 1 / To.setFromMatrixColumn(t, 2).length();
    return e[0] = r[0] * a, e[1] = r[1] * a, e[2] = r[2] * a, e[3] = 0, e[4] = r[4] * o, e[5] = r[5] * o, e[6] = r[6] * o, e[7] = 0, e[8] = r[8] * c, e[9] = r[9] * c, e[10] = r[10] * c, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
  }
  makeRotationFromEuler(t) {
    const e = this.elements, r = t.x, a = t.y, o = t.z, c = Math.cos(r), u = Math.sin(r), d = Math.cos(a), h = Math.sin(a), p = Math.cos(o), m = Math.sin(o);
    if (t.order === "XYZ") {
      const g = c * p, _ = c * m, b = u * p, E = u * m;
      e[0] = d * p, e[4] = -d * m, e[8] = h, e[1] = _ + b * h, e[5] = g - E * h, e[9] = -u * d, e[2] = E - g * h, e[6] = b + _ * h, e[10] = c * d;
    } else if (t.order === "YXZ") {
      const g = d * p, _ = d * m, b = h * p, E = h * m;
      e[0] = g + E * u, e[4] = b * u - _, e[8] = c * h, e[1] = c * m, e[5] = c * p, e[9] = -u, e[2] = _ * u - b, e[6] = E + g * u, e[10] = c * d;
    } else if (t.order === "ZXY") {
      const g = d * p, _ = d * m, b = h * p, E = h * m;
      e[0] = g - E * u, e[4] = -c * m, e[8] = b + _ * u, e[1] = _ + b * u, e[5] = c * p, e[9] = E - g * u, e[2] = -c * h, e[6] = u, e[10] = c * d;
    } else if (t.order === "ZYX") {
      const g = c * p, _ = c * m, b = u * p, E = u * m;
      e[0] = d * p, e[4] = b * h - _, e[8] = g * h + E, e[1] = d * m, e[5] = E * h + g, e[9] = _ * h - b, e[2] = -h, e[6] = u * d, e[10] = c * d;
    } else if (t.order === "YZX") {
      const g = c * d, _ = c * h, b = u * d, E = u * h;
      e[0] = d * p, e[4] = E - g * m, e[8] = b * m + _, e[1] = m, e[5] = c * p, e[9] = -u * p, e[2] = -h * p, e[6] = _ * m + b, e[10] = g - E * m;
    } else if (t.order === "XZY") {
      const g = c * d, _ = c * h, b = u * d, E = u * h;
      e[0] = d * p, e[4] = -m, e[8] = h * p, e[1] = g * m + E, e[5] = c * p, e[9] = _ * m - b, e[2] = b * m - _, e[6] = u * p, e[10] = E * m + g;
    }
    return e[3] = 0, e[7] = 0, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
  }
  makeRotationFromQuaternion(t) {
    return this.compose(SC, t, bC);
  }
  lookAt(t, e, r) {
    const a = this.elements;
    return Ei.subVectors(t, e), Ei.lengthSq() === 0 && (Ei.z = 1), Ei.normalize(), Ls.crossVectors(r, Ei), Ls.lengthSq() === 0 && (Math.abs(r.z) === 1 ? Ei.x += 1e-4 : Ei.z += 1e-4, Ei.normalize(), Ls.crossVectors(r, Ei)), Ls.normalize(), mf.crossVectors(Ei, Ls), a[0] = Ls.x, a[4] = mf.x, a[8] = Ei.x, a[1] = Ls.y, a[5] = mf.y, a[9] = Ei.y, a[2] = Ls.z, a[6] = mf.z, a[10] = Ei.z, this;
  }
  multiply(t) {
    return this.multiplyMatrices(this, t);
  }
  premultiply(t) {
    return this.multiplyMatrices(t, this);
  }
  multiplyMatrices(t, e) {
    const r = t.elements, a = e.elements, o = this.elements, c = r[0], u = r[4], d = r[8], h = r[12], p = r[1], m = r[5], g = r[9], _ = r[13], b = r[2], E = r[6], S = r[10], y = r[14], A = r[3], w = r[7], M = r[11], O = r[15], L = a[0], N = a[4], z = a[8], R = a[12], T = a[1], U = a[5], B = a[9], I = a[13], C = a[2], X = a[6], D = a[10], V = a[14], H = a[3], j = a[7], K = a[11], F = a[15];
    return o[0] = c * L + u * T + d * C + h * H, o[4] = c * N + u * U + d * X + h * j, o[8] = c * z + u * B + d * D + h * K, o[12] = c * R + u * I + d * V + h * F, o[1] = p * L + m * T + g * C + _ * H, o[5] = p * N + m * U + g * X + _ * j, o[9] = p * z + m * B + g * D + _ * K, o[13] = p * R + m * I + g * V + _ * F, o[2] = b * L + E * T + S * C + y * H, o[6] = b * N + E * U + S * X + y * j, o[10] = b * z + E * B + S * D + y * K, o[14] = b * R + E * I + S * V + y * F, o[3] = A * L + w * T + M * C + O * H, o[7] = A * N + w * U + M * X + O * j, o[11] = A * z + w * B + M * D + O * K, o[15] = A * R + w * I + M * V + O * F, this;
  }
  multiplyScalar(t) {
    const e = this.elements;
    return e[0] *= t, e[4] *= t, e[8] *= t, e[12] *= t, e[1] *= t, e[5] *= t, e[9] *= t, e[13] *= t, e[2] *= t, e[6] *= t, e[10] *= t, e[14] *= t, e[3] *= t, e[7] *= t, e[11] *= t, e[15] *= t, this;
  }
  determinant() {
    const t = this.elements, e = t[0], r = t[4], a = t[8], o = t[12], c = t[1], u = t[5], d = t[9], h = t[13], p = t[2], m = t[6], g = t[10], _ = t[14], b = t[3], E = t[7], S = t[11], y = t[15];
    return b * (+o * d * m - a * h * m - o * u * g + r * h * g + a * u * _ - r * d * _) + E * (+e * d * _ - e * h * g + o * c * g - a * c * _ + a * h * p - o * d * p) + S * (+e * h * m - e * u * _ - o * c * m + r * c * _ + o * u * p - r * h * p) + y * (-a * u * p - e * d * m + e * u * g + a * c * m - r * c * g + r * d * p);
  }
  transpose() {
    const t = this.elements;
    let e;
    return e = t[1], t[1] = t[4], t[4] = e, e = t[2], t[2] = t[8], t[8] = e, e = t[6], t[6] = t[9], t[9] = e, e = t[3], t[3] = t[12], t[12] = e, e = t[7], t[7] = t[13], t[13] = e, e = t[11], t[11] = t[14], t[14] = e, this;
  }
  setPosition(t, e, r) {
    const a = this.elements;
    return t.isVector3 ? (a[12] = t.x, a[13] = t.y, a[14] = t.z) : (a[12] = t, a[13] = e, a[14] = r), this;
  }
  invert() {
    const t = this.elements, e = t[0], r = t[1], a = t[2], o = t[3], c = t[4], u = t[5], d = t[6], h = t[7], p = t[8], m = t[9], g = t[10], _ = t[11], b = t[12], E = t[13], S = t[14], y = t[15], A = m * S * h - E * g * h + E * d * _ - u * S * _ - m * d * y + u * g * y, w = b * g * h - p * S * h - b * d * _ + c * S * _ + p * d * y - c * g * y, M = p * E * h - b * m * h + b * u * _ - c * E * _ - p * u * y + c * m * y, O = b * m * d - p * E * d - b * u * g + c * E * g + p * u * S - c * m * S, L = e * A + r * w + a * M + o * O;
    if (L === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    const N = 1 / L;
    return t[0] = A * N, t[1] = (E * g * o - m * S * o - E * a * _ + r * S * _ + m * a * y - r * g * y) * N, t[2] = (u * S * o - E * d * o + E * a * h - r * S * h - u * a * y + r * d * y) * N, t[3] = (m * d * o - u * g * o - m * a * h + r * g * h + u * a * _ - r * d * _) * N, t[4] = w * N, t[5] = (p * S * o - b * g * o + b * a * _ - e * S * _ - p * a * y + e * g * y) * N, t[6] = (b * d * o - c * S * o - b * a * h + e * S * h + c * a * y - e * d * y) * N, t[7] = (c * g * o - p * d * o + p * a * h - e * g * h - c * a * _ + e * d * _) * N, t[8] = M * N, t[9] = (b * m * o - p * E * o - b * r * _ + e * E * _ + p * r * y - e * m * y) * N, t[10] = (c * E * o - b * u * o + b * r * h - e * E * h - c * r * y + e * u * y) * N, t[11] = (p * u * o - c * m * o - p * r * h + e * m * h + c * r * _ - e * u * _) * N, t[12] = O * N, t[13] = (p * E * a - b * m * a + b * r * g - e * E * g - p * r * S + e * m * S) * N, t[14] = (b * u * a - c * E * a - b * r * d + e * E * d + c * r * S - e * u * S) * N, t[15] = (c * m * a - p * u * a + p * r * d - e * m * d - c * r * g + e * u * g) * N, this;
  }
  scale(t) {
    const e = this.elements, r = t.x, a = t.y, o = t.z;
    return e[0] *= r, e[4] *= a, e[8] *= o, e[1] *= r, e[5] *= a, e[9] *= o, e[2] *= r, e[6] *= a, e[10] *= o, e[3] *= r, e[7] *= a, e[11] *= o, this;
  }
  getMaxScaleOnAxis() {
    const t = this.elements, e = t[0] * t[0] + t[1] * t[1] + t[2] * t[2], r = t[4] * t[4] + t[5] * t[5] + t[6] * t[6], a = t[8] * t[8] + t[9] * t[9] + t[10] * t[10];
    return Math.sqrt(Math.max(e, r, a));
  }
  makeTranslation(t, e, r) {
    return t.isVector3 ? this.set(
      1,
      0,
      0,
      t.x,
      0,
      1,
      0,
      t.y,
      0,
      0,
      1,
      t.z,
      0,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      0,
      t,
      0,
      1,
      0,
      e,
      0,
      0,
      1,
      r,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationX(t) {
    const e = Math.cos(t), r = Math.sin(t);
    return this.set(
      1,
      0,
      0,
      0,
      0,
      e,
      -r,
      0,
      0,
      r,
      e,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationY(t) {
    const e = Math.cos(t), r = Math.sin(t);
    return this.set(
      e,
      0,
      r,
      0,
      0,
      1,
      0,
      0,
      -r,
      0,
      e,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationZ(t) {
    const e = Math.cos(t), r = Math.sin(t);
    return this.set(
      e,
      -r,
      0,
      0,
      r,
      e,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationAxis(t, e) {
    const r = Math.cos(e), a = Math.sin(e), o = 1 - r, c = t.x, u = t.y, d = t.z, h = o * c, p = o * u;
    return this.set(
      h * c + r,
      h * u - a * d,
      h * d + a * u,
      0,
      h * u + a * d,
      p * u + r,
      p * d - a * c,
      0,
      h * d - a * u,
      p * d + a * c,
      o * d * d + r,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(t, e, r) {
    return this.set(
      t,
      0,
      0,
      0,
      0,
      e,
      0,
      0,
      0,
      0,
      r,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeShear(t, e, r, a, o, c) {
    return this.set(
      1,
      r,
      o,
      0,
      t,
      1,
      c,
      0,
      e,
      a,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  compose(t, e, r) {
    const a = this.elements, o = e._x, c = e._y, u = e._z, d = e._w, h = o + o, p = c + c, m = u + u, g = o * h, _ = o * p, b = o * m, E = c * p, S = c * m, y = u * m, A = d * h, w = d * p, M = d * m, O = r.x, L = r.y, N = r.z;
    return a[0] = (1 - (E + y)) * O, a[1] = (_ + M) * O, a[2] = (b - w) * O, a[3] = 0, a[4] = (_ - M) * L, a[5] = (1 - (g + y)) * L, a[6] = (S + A) * L, a[7] = 0, a[8] = (b + w) * N, a[9] = (S - A) * N, a[10] = (1 - (g + E)) * N, a[11] = 0, a[12] = t.x, a[13] = t.y, a[14] = t.z, a[15] = 1, this;
  }
  decompose(t, e, r) {
    const a = this.elements;
    let o = To.set(a[0], a[1], a[2]).length();
    const c = To.set(a[4], a[5], a[6]).length(), u = To.set(a[8], a[9], a[10]).length();
    this.determinant() < 0 && (o = -o), t.x = a[12], t.y = a[13], t.z = a[14], qi.copy(this);
    const h = 1 / o, p = 1 / c, m = 1 / u;
    return qi.elements[0] *= h, qi.elements[1] *= h, qi.elements[2] *= h, qi.elements[4] *= p, qi.elements[5] *= p, qi.elements[6] *= p, qi.elements[8] *= m, qi.elements[9] *= m, qi.elements[10] *= m, e.setFromRotationMatrix(qi), r.x = o, r.y = c, r.z = u, this;
  }
  makePerspective(t, e, r, a, o, c, u = Zr) {
    const d = this.elements, h = 2 * o / (e - t), p = 2 * o / (r - a), m = (e + t) / (e - t), g = (r + a) / (r - a);
    let _, b;
    if (u === Zr)
      _ = -(c + o) / (c - o), b = -2 * c * o / (c - o);
    else if (u === pd)
      _ = -c / (c - o), b = -c * o / (c - o);
    else
      throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + u);
    return d[0] = h, d[4] = 0, d[8] = m, d[12] = 0, d[1] = 0, d[5] = p, d[9] = g, d[13] = 0, d[2] = 0, d[6] = 0, d[10] = _, d[14] = b, d[3] = 0, d[7] = 0, d[11] = -1, d[15] = 0, this;
  }
  makeOrthographic(t, e, r, a, o, c, u = Zr) {
    const d = this.elements, h = 1 / (e - t), p = 1 / (r - a), m = 1 / (c - o), g = (e + t) * h, _ = (r + a) * p;
    let b, E;
    if (u === Zr)
      b = (c + o) * m, E = -2 * m;
    else if (u === pd)
      b = o * m, E = -1 * m;
    else
      throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + u);
    return d[0] = 2 * h, d[4] = 0, d[8] = 0, d[12] = -g, d[1] = 0, d[5] = 2 * p, d[9] = 0, d[13] = -_, d[2] = 0, d[6] = 0, d[10] = E, d[14] = -b, d[3] = 0, d[7] = 0, d[11] = 0, d[15] = 1, this;
  }
  equals(t) {
    const e = this.elements, r = t.elements;
    for (let a = 0; a < 16; a++)
      if (e[a] !== r[a]) return !1;
    return !0;
  }
  fromArray(t, e = 0) {
    for (let r = 0; r < 16; r++)
      this.elements[r] = t[r + e];
    return this;
  }
  toArray(t = [], e = 0) {
    const r = this.elements;
    return t[e] = r[0], t[e + 1] = r[1], t[e + 2] = r[2], t[e + 3] = r[3], t[e + 4] = r[4], t[e + 5] = r[5], t[e + 6] = r[6], t[e + 7] = r[7], t[e + 8] = r[8], t[e + 9] = r[9], t[e + 10] = r[10], t[e + 11] = r[11], t[e + 12] = r[12], t[e + 13] = r[13], t[e + 14] = r[14], t[e + 15] = r[15], t;
  }
}
const To = /* @__PURE__ */ new ot(), qi = /* @__PURE__ */ new Ge(), SC = /* @__PURE__ */ new ot(0, 0, 0), bC = /* @__PURE__ */ new ot(1, 1, 1), Ls = /* @__PURE__ */ new ot(), mf = /* @__PURE__ */ new ot(), Ei = /* @__PURE__ */ new ot(), nS = /* @__PURE__ */ new Ge(), iS = /* @__PURE__ */ new js();
class mr {
  constructor(t = 0, e = 0, r = 0, a = mr.DEFAULT_ORDER) {
    this.isEuler = !0, this._x = t, this._y = e, this._z = r, this._order = a;
  }
  get x() {
    return this._x;
  }
  set x(t) {
    this._x = t, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(t) {
    this._y = t, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(t) {
    this._z = t, this._onChangeCallback();
  }
  get order() {
    return this._order;
  }
  set order(t) {
    this._order = t, this._onChangeCallback();
  }
  set(t, e, r, a = this._order) {
    return this._x = t, this._y = e, this._z = r, this._order = a, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._order);
  }
  copy(t) {
    return this._x = t._x, this._y = t._y, this._z = t._z, this._order = t._order, this._onChangeCallback(), this;
  }
  setFromRotationMatrix(t, e = this._order, r = !0) {
    const a = t.elements, o = a[0], c = a[4], u = a[8], d = a[1], h = a[5], p = a[9], m = a[2], g = a[6], _ = a[10];
    switch (e) {
      case "XYZ":
        this._y = Math.asin(be(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._x = Math.atan2(-p, _), this._z = Math.atan2(-c, o)) : (this._x = Math.atan2(g, h), this._z = 0);
        break;
      case "YXZ":
        this._x = Math.asin(-be(p, -1, 1)), Math.abs(p) < 0.9999999 ? (this._y = Math.atan2(u, _), this._z = Math.atan2(d, h)) : (this._y = Math.atan2(-m, o), this._z = 0);
        break;
      case "ZXY":
        this._x = Math.asin(be(g, -1, 1)), Math.abs(g) < 0.9999999 ? (this._y = Math.atan2(-m, _), this._z = Math.atan2(-c, h)) : (this._y = 0, this._z = Math.atan2(d, o));
        break;
      case "ZYX":
        this._y = Math.asin(-be(m, -1, 1)), Math.abs(m) < 0.9999999 ? (this._x = Math.atan2(g, _), this._z = Math.atan2(d, o)) : (this._x = 0, this._z = Math.atan2(-c, h));
        break;
      case "YZX":
        this._z = Math.asin(be(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._x = Math.atan2(-p, h), this._y = Math.atan2(-m, o)) : (this._x = 0, this._y = Math.atan2(u, _));
        break;
      case "XZY":
        this._z = Math.asin(-be(c, -1, 1)), Math.abs(c) < 0.9999999 ? (this._x = Math.atan2(g, h), this._y = Math.atan2(u, o)) : (this._x = Math.atan2(-p, _), this._y = 0);
        break;
      default:
        console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + e);
    }
    return this._order = e, r === !0 && this._onChangeCallback(), this;
  }
  setFromQuaternion(t, e, r) {
    return nS.makeRotationFromQuaternion(t), this.setFromRotationMatrix(nS, e, r);
  }
  setFromVector3(t, e = this._order) {
    return this.set(t.x, t.y, t.z, e);
  }
  reorder(t) {
    return iS.setFromEuler(this), this.setFromQuaternion(iS, t);
  }
  equals(t) {
    return t._x === this._x && t._y === this._y && t._z === this._z && t._order === this._order;
  }
  fromArray(t) {
    return this._x = t[0], this._y = t[1], this._z = t[2], t[3] !== void 0 && (this._order = t[3]), this._onChangeCallback(), this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._order, t;
  }
  _onChange(t) {
    return this._onChangeCallback = t, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._order;
  }
}
mr.DEFAULT_ORDER = "XYZ";
class yM {
  constructor() {
    this.mask = 1;
  }
  set(t) {
    this.mask = (1 << t | 0) >>> 0;
  }
  enable(t) {
    this.mask |= 1 << t | 0;
  }
  enableAll() {
    this.mask = -1;
  }
  toggle(t) {
    this.mask ^= 1 << t | 0;
  }
  disable(t) {
    this.mask &= ~(1 << t | 0);
  }
  disableAll() {
    this.mask = 0;
  }
  test(t) {
    return (this.mask & t.mask) !== 0;
  }
  isEnabled(t) {
    return (this.mask & (1 << t | 0)) !== 0;
  }
}
let MC = 0;
const rS = /* @__PURE__ */ new ot(), Ao = /* @__PURE__ */ new js(), Gr = /* @__PURE__ */ new Ge(), gf = /* @__PURE__ */ new ot(), lc = /* @__PURE__ */ new ot(), EC = /* @__PURE__ */ new ot(), wC = /* @__PURE__ */ new js(), sS = /* @__PURE__ */ new ot(1, 0, 0), aS = /* @__PURE__ */ new ot(0, 1, 0), oS = /* @__PURE__ */ new ot(0, 0, 1), lS = { type: "added" }, TC = { type: "removed" }, Co = { type: "childadded", child: null }, dm = { type: "childremoved", child: null };
class bn extends Ia {
  constructor() {
    super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: MC++ }), this.uuid = Qr(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = bn.DEFAULT_UP.clone();
    const t = new ot(), e = new mr(), r = new js(), a = new ot(1, 1, 1);
    function o() {
      r.setFromEuler(e, !1);
    }
    function c() {
      e.setFromQuaternion(r, void 0, !1);
    }
    e._onChange(o), r._onChange(c), Object.defineProperties(this, {
      position: {
        configurable: !0,
        enumerable: !0,
        value: t
      },
      rotation: {
        configurable: !0,
        enumerable: !0,
        value: e
      },
      quaternion: {
        configurable: !0,
        enumerable: !0,
        value: r
      },
      scale: {
        configurable: !0,
        enumerable: !0,
        value: a
      },
      modelViewMatrix: {
        value: new Ge()
      },
      normalMatrix: {
        value: new ve()
      }
    }), this.matrix = new Ge(), this.matrixWorld = new Ge(), this.matrixAutoUpdate = bn.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = bn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new yM(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
  }
  onBeforeShadow() {
  }
  onAfterShadow() {
  }
  onBeforeRender() {
  }
  onAfterRender() {
  }
  applyMatrix4(t) {
    this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(t), this.matrix.decompose(this.position, this.quaternion, this.scale);
  }
  applyQuaternion(t) {
    return this.quaternion.premultiply(t), this;
  }
  setRotationFromAxisAngle(t, e) {
    this.quaternion.setFromAxisAngle(t, e);
  }
  setRotationFromEuler(t) {
    this.quaternion.setFromEuler(t, !0);
  }
  setRotationFromMatrix(t) {
    this.quaternion.setFromRotationMatrix(t);
  }
  setRotationFromQuaternion(t) {
    this.quaternion.copy(t);
  }
  rotateOnAxis(t, e) {
    return Ao.setFromAxisAngle(t, e), this.quaternion.multiply(Ao), this;
  }
  rotateOnWorldAxis(t, e) {
    return Ao.setFromAxisAngle(t, e), this.quaternion.premultiply(Ao), this;
  }
  rotateX(t) {
    return this.rotateOnAxis(sS, t);
  }
  rotateY(t) {
    return this.rotateOnAxis(aS, t);
  }
  rotateZ(t) {
    return this.rotateOnAxis(oS, t);
  }
  translateOnAxis(t, e) {
    return rS.copy(t).applyQuaternion(this.quaternion), this.position.add(rS.multiplyScalar(e)), this;
  }
  translateX(t) {
    return this.translateOnAxis(sS, t);
  }
  translateY(t) {
    return this.translateOnAxis(aS, t);
  }
  translateZ(t) {
    return this.translateOnAxis(oS, t);
  }
  localToWorld(t) {
    return this.updateWorldMatrix(!0, !1), t.applyMatrix4(this.matrixWorld);
  }
  worldToLocal(t) {
    return this.updateWorldMatrix(!0, !1), t.applyMatrix4(Gr.copy(this.matrixWorld).invert());
  }
  lookAt(t, e, r) {
    t.isVector3 ? gf.copy(t) : gf.set(t, e, r);
    const a = this.parent;
    this.updateWorldMatrix(!0, !1), lc.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Gr.lookAt(lc, gf, this.up) : Gr.lookAt(gf, lc, this.up), this.quaternion.setFromRotationMatrix(Gr), a && (Gr.extractRotation(a.matrixWorld), Ao.setFromRotationMatrix(Gr), this.quaternion.premultiply(Ao.invert()));
  }
  add(t) {
    if (arguments.length > 1) {
      for (let e = 0; e < arguments.length; e++)
        this.add(arguments[e]);
      return this;
    }
    return t === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", t), this) : (t && t.isObject3D ? (t.removeFromParent(), t.parent = this, this.children.push(t), t.dispatchEvent(lS), Co.child = t, this.dispatchEvent(Co), Co.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", t), this);
  }
  remove(t) {
    if (arguments.length > 1) {
      for (let r = 0; r < arguments.length; r++)
        this.remove(arguments[r]);
      return this;
    }
    const e = this.children.indexOf(t);
    return e !== -1 && (t.parent = null, this.children.splice(e, 1), t.dispatchEvent(TC), dm.child = t, this.dispatchEvent(dm), dm.child = null), this;
  }
  removeFromParent() {
    const t = this.parent;
    return t !== null && t.remove(this), this;
  }
  clear() {
    return this.remove(...this.children);
  }
  attach(t) {
    return this.updateWorldMatrix(!0, !1), Gr.copy(this.matrixWorld).invert(), t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), Gr.multiply(t.parent.matrixWorld)), t.applyMatrix4(Gr), t.removeFromParent(), t.parent = this, this.children.push(t), t.updateWorldMatrix(!1, !0), t.dispatchEvent(lS), Co.child = t, this.dispatchEvent(Co), Co.child = null, this;
  }
  getObjectById(t) {
    return this.getObjectByProperty("id", t);
  }
  getObjectByName(t) {
    return this.getObjectByProperty("name", t);
  }
  getObjectByProperty(t, e) {
    if (this[t] === e) return this;
    for (let r = 0, a = this.children.length; r < a; r++) {
      const c = this.children[r].getObjectByProperty(t, e);
      if (c !== void 0)
        return c;
    }
  }
  getObjectsByProperty(t, e, r = []) {
    this[t] === e && r.push(this);
    const a = this.children;
    for (let o = 0, c = a.length; o < c; o++)
      a[o].getObjectsByProperty(t, e, r);
    return r;
  }
  getWorldPosition(t) {
    return this.updateWorldMatrix(!0, !1), t.setFromMatrixPosition(this.matrixWorld);
  }
  getWorldQuaternion(t) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(lc, t, EC), t;
  }
  getWorldScale(t) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(lc, wC, t), t;
  }
  getWorldDirection(t) {
    this.updateWorldMatrix(!0, !1);
    const e = this.matrixWorld.elements;
    return t.set(e[8], e[9], e[10]).normalize();
  }
  raycast() {
  }
  traverse(t) {
    t(this);
    const e = this.children;
    for (let r = 0, a = e.length; r < a; r++)
      e[r].traverse(t);
  }
  traverseVisible(t) {
    if (this.visible === !1) return;
    t(this);
    const e = this.children;
    for (let r = 0, a = e.length; r < a; r++)
      e[r].traverseVisible(t);
  }
  traverseAncestors(t) {
    const e = this.parent;
    e !== null && (t(e), e.traverseAncestors(t));
  }
  updateMatrix() {
    this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;
  }
  updateMatrixWorld(t) {
    this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || t) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, t = !0);
    const e = this.children;
    for (let r = 0, a = e.length; r < a; r++)
      e[r].updateMatrixWorld(t);
  }
  updateWorldMatrix(t, e) {
    const r = this.parent;
    if (t === !0 && r !== null && r.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)), e === !0) {
      const a = this.children;
      for (let o = 0, c = a.length; o < c; o++)
        a[o].updateWorldMatrix(!1, !0);
    }
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string", r = {};
    e && (t = {
      geometries: {},
      materials: {},
      textures: {},
      images: {},
      shapes: {},
      skeletons: {},
      animations: {},
      nodes: {}
    }, r.metadata = {
      version: 4.6,
      type: "Object",
      generator: "Object3D.toJSON"
    });
    const a = {};
    a.uuid = this.uuid, a.type = this.type, this.name !== "" && (a.name = this.name), this.castShadow === !0 && (a.castShadow = !0), this.receiveShadow === !0 && (a.receiveShadow = !0), this.visible === !1 && (a.visible = !1), this.frustumCulled === !1 && (a.frustumCulled = !1), this.renderOrder !== 0 && (a.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (a.userData = this.userData), a.layers = this.layers.mask, a.matrix = this.matrix.toArray(), a.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (a.matrixAutoUpdate = !1), this.isInstancedMesh && (a.type = "InstancedMesh", a.count = this.count, a.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (a.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (a.type = "BatchedMesh", a.perObjectFrustumCulled = this.perObjectFrustumCulled, a.sortObjects = this.sortObjects, a.drawRanges = this._drawRanges, a.reservedRanges = this._reservedRanges, a.visibility = this._visibility, a.active = this._active, a.bounds = this._bounds.map((u) => ({
      boxInitialized: u.boxInitialized,
      boxMin: u.box.min.toArray(),
      boxMax: u.box.max.toArray(),
      sphereInitialized: u.sphereInitialized,
      sphereRadius: u.sphere.radius,
      sphereCenter: u.sphere.center.toArray()
    })), a.maxInstanceCount = this._maxInstanceCount, a.maxVertexCount = this._maxVertexCount, a.maxIndexCount = this._maxIndexCount, a.geometryInitialized = this._geometryInitialized, a.geometryCount = this._geometryCount, a.matricesTexture = this._matricesTexture.toJSON(t), this._colorsTexture !== null && (a.colorsTexture = this._colorsTexture.toJSON(t)), this.boundingSphere !== null && (a.boundingSphere = {
      center: a.boundingSphere.center.toArray(),
      radius: a.boundingSphere.radius
    }), this.boundingBox !== null && (a.boundingBox = {
      min: a.boundingBox.min.toArray(),
      max: a.boundingBox.max.toArray()
    }));
    function o(u, d) {
      return u[d.uuid] === void 0 && (u[d.uuid] = d.toJSON(t)), d.uuid;
    }
    if (this.isScene)
      this.background && (this.background.isColor ? a.background = this.background.toJSON() : this.background.isTexture && (a.background = this.background.toJSON(t).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (a.environment = this.environment.toJSON(t).uuid);
    else if (this.isMesh || this.isLine || this.isPoints) {
      a.geometry = o(t.geometries, this.geometry);
      const u = this.geometry.parameters;
      if (u !== void 0 && u.shapes !== void 0) {
        const d = u.shapes;
        if (Array.isArray(d))
          for (let h = 0, p = d.length; h < p; h++) {
            const m = d[h];
            o(t.shapes, m);
          }
        else
          o(t.shapes, d);
      }
    }
    if (this.isSkinnedMesh && (a.bindMode = this.bindMode, a.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (o(t.skeletons, this.skeleton), a.skeleton = this.skeleton.uuid)), this.material !== void 0)
      if (Array.isArray(this.material)) {
        const u = [];
        for (let d = 0, h = this.material.length; d < h; d++)
          u.push(o(t.materials, this.material[d]));
        a.material = u;
      } else
        a.material = o(t.materials, this.material);
    if (this.children.length > 0) {
      a.children = [];
      for (let u = 0; u < this.children.length; u++)
        a.children.push(this.children[u].toJSON(t).object);
    }
    if (this.animations.length > 0) {
      a.animations = [];
      for (let u = 0; u < this.animations.length; u++) {
        const d = this.animations[u];
        a.animations.push(o(t.animations, d));
      }
    }
    if (e) {
      const u = c(t.geometries), d = c(t.materials), h = c(t.textures), p = c(t.images), m = c(t.shapes), g = c(t.skeletons), _ = c(t.animations), b = c(t.nodes);
      u.length > 0 && (r.geometries = u), d.length > 0 && (r.materials = d), h.length > 0 && (r.textures = h), p.length > 0 && (r.images = p), m.length > 0 && (r.shapes = m), g.length > 0 && (r.skeletons = g), _.length > 0 && (r.animations = _), b.length > 0 && (r.nodes = b);
    }
    return r.object = a, r;
    function c(u) {
      const d = [];
      for (const h in u) {
        const p = u[h];
        delete p.metadata, d.push(p);
      }
      return d;
    }
  }
  clone(t) {
    return new this.constructor().copy(this, t);
  }
  copy(t, e = !0) {
    if (this.name = t.name, this.up.copy(t.up), this.position.copy(t.position), this.rotation.order = t.rotation.order, this.quaternion.copy(t.quaternion), this.scale.copy(t.scale), this.matrix.copy(t.matrix), this.matrixWorld.copy(t.matrixWorld), this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrixWorldAutoUpdate = t.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = t.matrixWorldNeedsUpdate, this.layers.mask = t.layers.mask, this.visible = t.visible, this.castShadow = t.castShadow, this.receiveShadow = t.receiveShadow, this.frustumCulled = t.frustumCulled, this.renderOrder = t.renderOrder, this.animations = t.animations.slice(), this.userData = JSON.parse(JSON.stringify(t.userData)), e === !0)
      for (let r = 0; r < t.children.length; r++) {
        const a = t.children[r];
        this.add(a.clone());
      }
    return this;
  }
}
bn.DEFAULT_UP = /* @__PURE__ */ new ot(0, 1, 0);
bn.DEFAULT_MATRIX_AUTO_UPDATE = !0;
bn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
const Zi = /* @__PURE__ */ new ot(), Xr = /* @__PURE__ */ new ot(), hm = /* @__PURE__ */ new ot(), jr = /* @__PURE__ */ new ot(), Ro = /* @__PURE__ */ new ot(), Do = /* @__PURE__ */ new ot(), cS = /* @__PURE__ */ new ot(), pm = /* @__PURE__ */ new ot(), mm = /* @__PURE__ */ new ot(), gm = /* @__PURE__ */ new ot(), vm = /* @__PURE__ */ new Ke(), _m = /* @__PURE__ */ new Ke(), ym = /* @__PURE__ */ new Ke();
class ki {
  constructor(t = new ot(), e = new ot(), r = new ot()) {
    this.a = t, this.b = e, this.c = r;
  }
  static getNormal(t, e, r, a) {
    a.subVectors(r, e), Zi.subVectors(t, e), a.cross(Zi);
    const o = a.lengthSq();
    return o > 0 ? a.multiplyScalar(1 / Math.sqrt(o)) : a.set(0, 0, 0);
  }
  // static/instance method to calculate barycentric coordinates
  // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
  static getBarycoord(t, e, r, a, o) {
    Zi.subVectors(a, e), Xr.subVectors(r, e), hm.subVectors(t, e);
    const c = Zi.dot(Zi), u = Zi.dot(Xr), d = Zi.dot(hm), h = Xr.dot(Xr), p = Xr.dot(hm), m = c * h - u * u;
    if (m === 0)
      return o.set(0, 0, 0), null;
    const g = 1 / m, _ = (h * d - u * p) * g, b = (c * p - u * d) * g;
    return o.set(1 - _ - b, b, _);
  }
  static containsPoint(t, e, r, a) {
    return this.getBarycoord(t, e, r, a, jr) === null ? !1 : jr.x >= 0 && jr.y >= 0 && jr.x + jr.y <= 1;
  }
  static getInterpolation(t, e, r, a, o, c, u, d) {
    return this.getBarycoord(t, e, r, a, jr) === null ? (d.x = 0, d.y = 0, "z" in d && (d.z = 0), "w" in d && (d.w = 0), null) : (d.setScalar(0), d.addScaledVector(o, jr.x), d.addScaledVector(c, jr.y), d.addScaledVector(u, jr.z), d);
  }
  static getInterpolatedAttribute(t, e, r, a, o, c) {
    return vm.setScalar(0), _m.setScalar(0), ym.setScalar(0), vm.fromBufferAttribute(t, e), _m.fromBufferAttribute(t, r), ym.fromBufferAttribute(t, a), c.setScalar(0), c.addScaledVector(vm, o.x), c.addScaledVector(_m, o.y), c.addScaledVector(ym, o.z), c;
  }
  static isFrontFacing(t, e, r, a) {
    return Zi.subVectors(r, e), Xr.subVectors(t, e), Zi.cross(Xr).dot(a) < 0;
  }
  set(t, e, r) {
    return this.a.copy(t), this.b.copy(e), this.c.copy(r), this;
  }
  setFromPointsAndIndices(t, e, r, a) {
    return this.a.copy(t[e]), this.b.copy(t[r]), this.c.copy(t[a]), this;
  }
  setFromAttributeAndIndices(t, e, r, a) {
    return this.a.fromBufferAttribute(t, e), this.b.fromBufferAttribute(t, r), this.c.fromBufferAttribute(t, a), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    return this.a.copy(t.a), this.b.copy(t.b), this.c.copy(t.c), this;
  }
  getArea() {
    return Zi.subVectors(this.c, this.b), Xr.subVectors(this.a, this.b), Zi.cross(Xr).length() * 0.5;
  }
  getMidpoint(t) {
    return t.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
  }
  getNormal(t) {
    return ki.getNormal(this.a, this.b, this.c, t);
  }
  getPlane(t) {
    return t.setFromCoplanarPoints(this.a, this.b, this.c);
  }
  getBarycoord(t, e) {
    return ki.getBarycoord(t, this.a, this.b, this.c, e);
  }
  getInterpolation(t, e, r, a, o) {
    return ki.getInterpolation(t, this.a, this.b, this.c, e, r, a, o);
  }
  containsPoint(t) {
    return ki.containsPoint(t, this.a, this.b, this.c);
  }
  isFrontFacing(t) {
    return ki.isFrontFacing(this.a, this.b, this.c, t);
  }
  intersectsBox(t) {
    return t.intersectsTriangle(this);
  }
  closestPointToPoint(t, e) {
    const r = this.a, a = this.b, o = this.c;
    let c, u;
    Ro.subVectors(a, r), Do.subVectors(o, r), pm.subVectors(t, r);
    const d = Ro.dot(pm), h = Do.dot(pm);
    if (d <= 0 && h <= 0)
      return e.copy(r);
    mm.subVectors(t, a);
    const p = Ro.dot(mm), m = Do.dot(mm);
    if (p >= 0 && m <= p)
      return e.copy(a);
    const g = d * m - p * h;
    if (g <= 0 && d >= 0 && p <= 0)
      return c = d / (d - p), e.copy(r).addScaledVector(Ro, c);
    gm.subVectors(t, o);
    const _ = Ro.dot(gm), b = Do.dot(gm);
    if (b >= 0 && _ <= b)
      return e.copy(o);
    const E = _ * h - d * b;
    if (E <= 0 && h >= 0 && b <= 0)
      return u = h / (h - b), e.copy(r).addScaledVector(Do, u);
    const S = p * b - _ * m;
    if (S <= 0 && m - p >= 0 && _ - b >= 0)
      return cS.subVectors(o, a), u = (m - p) / (m - p + (_ - b)), e.copy(a).addScaledVector(cS, u);
    const y = 1 / (S + E + g);
    return c = E * y, u = g * y, e.copy(r).addScaledVector(Ro, c).addScaledVector(Do, u);
  }
  equals(t) {
    return t.a.equals(this.a) && t.b.equals(this.b) && t.c.equals(this.c);
  }
}
const xM = {
  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
}, Us = { h: 0, s: 0, l: 0 }, vf = { h: 0, s: 0, l: 0 };
function xm(n, t, e) {
  return e < 0 && (e += 1), e > 1 && (e -= 1), e < 1 / 6 ? n + (t - n) * 6 * e : e < 1 / 2 ? t : e < 2 / 3 ? n + (t - n) * 6 * (2 / 3 - e) : n;
}
let Me = class {
  constructor(t, e, r) {
    return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(t, e, r);
  }
  set(t, e, r) {
    if (e === void 0 && r === void 0) {
      const a = t;
      a && a.isColor ? this.copy(a) : typeof a == "number" ? this.setHex(a) : typeof a == "string" && this.setStyle(a);
    } else
      this.setRGB(t, e, r);
    return this;
  }
  setScalar(t) {
    return this.r = t, this.g = t, this.b = t, this;
  }
  setHex(t, e = Vi) {
    return t = Math.floor(t), this.r = (t >> 16 & 255) / 255, this.g = (t >> 8 & 255) / 255, this.b = (t & 255) / 255, Ie.toWorkingColorSpace(this, e), this;
  }
  setRGB(t, e, r, a = Ie.workingColorSpace) {
    return this.r = t, this.g = e, this.b = r, Ie.toWorkingColorSpace(this, a), this;
  }
  setHSL(t, e, r, a = Ie.workingColorSpace) {
    if (t = M0(t, 1), e = be(e, 0, 1), r = be(r, 0, 1), e === 0)
      this.r = this.g = this.b = r;
    else {
      const o = r <= 0.5 ? r * (1 + e) : r + e - r * e, c = 2 * r - o;
      this.r = xm(c, o, t + 1 / 3), this.g = xm(c, o, t), this.b = xm(c, o, t - 1 / 3);
    }
    return Ie.toWorkingColorSpace(this, a), this;
  }
  setStyle(t, e = Vi) {
    function r(o) {
      o !== void 0 && parseFloat(o) < 1 && console.warn("THREE.Color: Alpha component of " + t + " will be ignored.");
    }
    let a;
    if (a = /^(\w+)\(([^\)]*)\)/.exec(t)) {
      let o;
      const c = a[1], u = a[2];
      switch (c) {
        case "rgb":
        case "rgba":
          if (o = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))
            return r(o[4]), this.setRGB(
              Math.min(255, parseInt(o[1], 10)) / 255,
              Math.min(255, parseInt(o[2], 10)) / 255,
              Math.min(255, parseInt(o[3], 10)) / 255,
              e
            );
          if (o = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))
            return r(o[4]), this.setRGB(
              Math.min(100, parseInt(o[1], 10)) / 100,
              Math.min(100, parseInt(o[2], 10)) / 100,
              Math.min(100, parseInt(o[3], 10)) / 100,
              e
            );
          break;
        case "hsl":
        case "hsla":
          if (o = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))
            return r(o[4]), this.setHSL(
              parseFloat(o[1]) / 360,
              parseFloat(o[2]) / 100,
              parseFloat(o[3]) / 100,
              e
            );
          break;
        default:
          console.warn("THREE.Color: Unknown color model " + t);
      }
    } else if (a = /^\#([A-Fa-f\d]+)$/.exec(t)) {
      const o = a[1], c = o.length;
      if (c === 3)
        return this.setRGB(
          parseInt(o.charAt(0), 16) / 15,
          parseInt(o.charAt(1), 16) / 15,
          parseInt(o.charAt(2), 16) / 15,
          e
        );
      if (c === 6)
        return this.setHex(parseInt(o, 16), e);
      console.warn("THREE.Color: Invalid hex color " + t);
    } else if (t && t.length > 0)
      return this.setColorName(t, e);
    return this;
  }
  setColorName(t, e = Vi) {
    const r = xM[t.toLowerCase()];
    return r !== void 0 ? this.setHex(r, e) : console.warn("THREE.Color: Unknown color " + t), this;
  }
  clone() {
    return new this.constructor(this.r, this.g, this.b);
  }
  copy(t) {
    return this.r = t.r, this.g = t.g, this.b = t.b, this;
  }
  copySRGBToLinear(t) {
    return this.r = Jr(t.r), this.g = Jr(t.g), this.b = Jr(t.b), this;
  }
  copyLinearToSRGB(t) {
    return this.r = Ko(t.r), this.g = Ko(t.g), this.b = Ko(t.b), this;
  }
  convertSRGBToLinear() {
    return this.copySRGBToLinear(this), this;
  }
  convertLinearToSRGB() {
    return this.copyLinearToSRGB(this), this;
  }
  getHex(t = Vi) {
    return Ie.fromWorkingColorSpace(Qn.copy(this), t), Math.round(be(Qn.r * 255, 0, 255)) * 65536 + Math.round(be(Qn.g * 255, 0, 255)) * 256 + Math.round(be(Qn.b * 255, 0, 255));
  }
  getHexString(t = Vi) {
    return ("000000" + this.getHex(t).toString(16)).slice(-6);
  }
  getHSL(t, e = Ie.workingColorSpace) {
    Ie.fromWorkingColorSpace(Qn.copy(this), e);
    const r = Qn.r, a = Qn.g, o = Qn.b, c = Math.max(r, a, o), u = Math.min(r, a, o);
    let d, h;
    const p = (u + c) / 2;
    if (u === c)
      d = 0, h = 0;
    else {
      const m = c - u;
      switch (h = p <= 0.5 ? m / (c + u) : m / (2 - c - u), c) {
        case r:
          d = (a - o) / m + (a < o ? 6 : 0);
          break;
        case a:
          d = (o - r) / m + 2;
          break;
        case o:
          d = (r - a) / m + 4;
          break;
      }
      d /= 6;
    }
    return t.h = d, t.s = h, t.l = p, t;
  }
  getRGB(t, e = Ie.workingColorSpace) {
    return Ie.fromWorkingColorSpace(Qn.copy(this), e), t.r = Qn.r, t.g = Qn.g, t.b = Qn.b, t;
  }
  getStyle(t = Vi) {
    Ie.fromWorkingColorSpace(Qn.copy(this), t);
    const e = Qn.r, r = Qn.g, a = Qn.b;
    return t !== Vi ? `color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${a.toFixed(3)})` : `rgb(${Math.round(e * 255)},${Math.round(r * 255)},${Math.round(a * 255)})`;
  }
  offsetHSL(t, e, r) {
    return this.getHSL(Us), this.setHSL(Us.h + t, Us.s + e, Us.l + r);
  }
  add(t) {
    return this.r += t.r, this.g += t.g, this.b += t.b, this;
  }
  addColors(t, e) {
    return this.r = t.r + e.r, this.g = t.g + e.g, this.b = t.b + e.b, this;
  }
  addScalar(t) {
    return this.r += t, this.g += t, this.b += t, this;
  }
  sub(t) {
    return this.r = Math.max(0, this.r - t.r), this.g = Math.max(0, this.g - t.g), this.b = Math.max(0, this.b - t.b), this;
  }
  multiply(t) {
    return this.r *= t.r, this.g *= t.g, this.b *= t.b, this;
  }
  multiplyScalar(t) {
    return this.r *= t, this.g *= t, this.b *= t, this;
  }
  lerp(t, e) {
    return this.r += (t.r - this.r) * e, this.g += (t.g - this.g) * e, this.b += (t.b - this.b) * e, this;
  }
  lerpColors(t, e, r) {
    return this.r = t.r + (e.r - t.r) * r, this.g = t.g + (e.g - t.g) * r, this.b = t.b + (e.b - t.b) * r, this;
  }
  lerpHSL(t, e) {
    this.getHSL(Us), t.getHSL(vf);
    const r = wc(Us.h, vf.h, e), a = wc(Us.s, vf.s, e), o = wc(Us.l, vf.l, e);
    return this.setHSL(r, a, o), this;
  }
  setFromVector3(t) {
    return this.r = t.x, this.g = t.y, this.b = t.z, this;
  }
  applyMatrix3(t) {
    const e = this.r, r = this.g, a = this.b, o = t.elements;
    return this.r = o[0] * e + o[3] * r + o[6] * a, this.g = o[1] * e + o[4] * r + o[7] * a, this.b = o[2] * e + o[5] * r + o[8] * a, this;
  }
  equals(t) {
    return t.r === this.r && t.g === this.g && t.b === this.b;
  }
  fromArray(t, e = 0) {
    return this.r = t[e], this.g = t[e + 1], this.b = t[e + 2], this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this.r, t[e + 1] = this.g, t[e + 2] = this.b, t;
  }
  fromBufferAttribute(t, e) {
    return this.r = t.getX(e), this.g = t.getY(e), this.b = t.getZ(e), this;
  }
  toJSON() {
    return this.getHex();
  }
  *[Symbol.iterator]() {
    yield this.r, yield this.g, yield this.b;
  }
};
const Qn = /* @__PURE__ */ new Me();
Me.NAMES = xM;
let AC = 0;
class Ba extends Ia {
  constructor() {
    super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: AC++ }), this.uuid = Qr(), this.name = "", this.type = "Material", this.blending = Zo, this.side = Xs, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = ag, this.blendDst = og, this.blendEquation = ba, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new Me(0, 0, 0), this.blendAlpha = 0, this.depthFunc = tl, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = $x, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = xo, this.stencilZFail = xo, this.stencilZPass = xo, 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(t) {
    this._alphaTest > 0 != t > 0 && this.version++, this._alphaTest = t;
  }
  // onBeforeRender and onBeforeCompile only supported in WebGLRenderer
  onBeforeRender() {
  }
  onBeforeCompile() {
  }
  customProgramCacheKey() {
    return this.onBeforeCompile.toString();
  }
  setValues(t) {
    if (t !== void 0)
      for (const e in t) {
        const r = t[e];
        if (r === void 0) {
          console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);
          continue;
        }
        const a = this[e];
        if (a === void 0) {
          console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);
          continue;
        }
        a && a.isColor ? a.set(r) : a && a.isVector3 && r && r.isVector3 ? a.copy(r) : this[e] = r;
      }
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string";
    e && (t = {
      textures: {},
      images: {}
    });
    const r = {
      metadata: {
        version: 4.6,
        type: "Material",
        generator: "Material.toJSON"
      }
    };
    r.uuid = this.uuid, r.type = this.type, this.name !== "" && (r.name = this.name), this.color && this.color.isColor && (r.color = this.color.getHex()), this.roughness !== void 0 && (r.roughness = this.roughness), this.metalness !== void 0 && (r.metalness = this.metalness), this.sheen !== void 0 && (r.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (r.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (r.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (r.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (r.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (r.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (r.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (r.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (r.shininess = this.shininess), this.clearcoat !== void 0 && (r.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (r.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (r.clearcoatMap = this.clearcoatMap.toJSON(t).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (r.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(t).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (r.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(t).uuid, r.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.dispersion !== void 0 && (r.dispersion = this.dispersion), this.iridescence !== void 0 && (r.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (r.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (r.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (r.iridescenceMap = this.iridescenceMap.toJSON(t).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (r.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(t).uuid), this.anisotropy !== void 0 && (r.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (r.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (r.anisotropyMap = this.anisotropyMap.toJSON(t).uuid), this.map && this.map.isTexture && (r.map = this.map.toJSON(t).uuid), this.matcap && this.matcap.isTexture && (r.matcap = this.matcap.toJSON(t).uuid), this.alphaMap && this.alphaMap.isTexture && (r.alphaMap = this.alphaMap.toJSON(t).uuid), this.lightMap && this.lightMap.isTexture && (r.lightMap = this.lightMap.toJSON(t).uuid, r.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (r.aoMap = this.aoMap.toJSON(t).uuid, r.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (r.bumpMap = this.bumpMap.toJSON(t).uuid, r.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (r.normalMap = this.normalMap.toJSON(t).uuid, r.normalMapType = this.normalMapType, r.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (r.displacementMap = this.displacementMap.toJSON(t).uuid, r.displacementScale = this.displacementScale, r.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (r.roughnessMap = this.roughnessMap.toJSON(t).uuid), this.metalnessMap && this.metalnessMap.isTexture && (r.metalnessMap = this.metalnessMap.toJSON(t).uuid), this.emissiveMap && this.emissiveMap.isTexture && (r.emissiveMap = this.emissiveMap.toJSON(t).uuid), this.specularMap && this.specularMap.isTexture && (r.specularMap = this.specularMap.toJSON(t).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (r.specularIntensityMap = this.specularIntensityMap.toJSON(t).uuid), this.specularColorMap && this.specularColorMap.isTexture && (r.specularColorMap = this.specularColorMap.toJSON(t).uuid), this.envMap && this.envMap.isTexture && (r.envMap = this.envMap.toJSON(t).uuid, this.combine !== void 0 && (r.combine = this.combine)), this.envMapRotation !== void 0 && (r.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (r.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (r.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (r.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (r.gradientMap = this.gradientMap.toJSON(t).uuid), this.transmission !== void 0 && (r.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (r.transmissionMap = this.transmissionMap.toJSON(t).uuid), this.thickness !== void 0 && (r.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (r.thicknessMap = this.thicknessMap.toJSON(t).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (r.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (r.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (r.size = this.size), this.shadowSide !== null && (r.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (r.sizeAttenuation = this.sizeAttenuation), this.blending !== Zo && (r.blending = this.blending), this.side !== Xs && (r.side = this.side), this.vertexColors === !0 && (r.vertexColors = !0), this.opacity < 1 && (r.opacity = this.opacity), this.transparent === !0 && (r.transparent = !0), this.blendSrc !== ag && (r.blendSrc = this.blendSrc), this.blendDst !== og && (r.blendDst = this.blendDst), this.blendEquation !== ba && (r.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (r.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (r.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (r.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (r.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (r.blendAlpha = this.blendAlpha), this.depthFunc !== tl && (r.depthFunc = this.depthFunc), this.depthTest === !1 && (r.depthTest = this.depthTest), this.depthWrite === !1 && (r.depthWrite = this.depthWrite), this.colorWrite === !1 && (r.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (r.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== $x && (r.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (r.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (r.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== xo && (r.stencilFail = this.stencilFail), this.stencilZFail !== xo && (r.stencilZFail = this.stencilZFail), this.stencilZPass !== xo && (r.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (r.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (r.rotation = this.rotation), this.polygonOffset === !0 && (r.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (r.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (r.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (r.linewidth = this.linewidth), this.dashSize !== void 0 && (r.dashSize = this.dashSize), this.gapSize !== void 0 && (r.gapSize = this.gapSize), this.scale !== void 0 && (r.scale = this.scale), this.dithering === !0 && (r.dithering = !0), this.alphaTest > 0 && (r.alphaTest = this.alphaTest), this.alphaHash === !0 && (r.alphaHash = !0), this.alphaToCoverage === !0 && (r.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (r.premultipliedAlpha = !0), this.forceSinglePass === !0 && (r.forceSinglePass = !0), this.wireframe === !0 && (r.wireframe = !0), this.wireframeLinewidth > 1 && (r.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (r.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (r.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (r.flatShading = !0), this.visible === !1 && (r.visible = !1), this.toneMapped === !1 && (r.toneMapped = !1), this.fog === !1 && (r.fog = !1), Object.keys(this.userData).length > 0 && (r.userData = this.userData);
    function a(o) {
      const c = [];
      for (const u in o) {
        const d = o[u];
        delete d.metadata, c.push(d);
      }
      return c;
    }
    if (e) {
      const o = a(t.textures), c = a(t.images);
      o.length > 0 && (r.textures = o), c.length > 0 && (r.images = c);
    }
    return r;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    this.name = t.name, this.blending = t.blending, this.side = t.side, this.vertexColors = t.vertexColors, this.opacity = t.opacity, this.transparent = t.transparent, this.blendSrc = t.blendSrc, this.blendDst = t.blendDst, this.blendEquation = t.blendEquation, this.blendSrcAlpha = t.blendSrcAlpha, this.blendDstAlpha = t.blendDstAlpha, this.blendEquationAlpha = t.blendEquationAlpha, this.blendColor.copy(t.blendColor), this.blendAlpha = t.blendAlpha, this.depthFunc = t.depthFunc, this.depthTest = t.depthTest, this.depthWrite = t.depthWrite, this.stencilWriteMask = t.stencilWriteMask, this.stencilFunc = t.stencilFunc, this.stencilRef = t.stencilRef, this.stencilFuncMask = t.stencilFuncMask, this.stencilFail = t.stencilFail, this.stencilZFail = t.stencilZFail, this.stencilZPass = t.stencilZPass, this.stencilWrite = t.stencilWrite;
    const e = t.clippingPlanes;
    let r = null;
    if (e !== null) {
      const a = e.length;
      r = new Array(a);
      for (let o = 0; o !== a; ++o)
        r[o] = e[o].clone();
    }
    return this.clippingPlanes = r, this.clipIntersection = t.clipIntersection, this.clipShadows = t.clipShadows, this.shadowSide = t.shadowSide, this.colorWrite = t.colorWrite, this.precision = t.precision, this.polygonOffset = t.polygonOffset, this.polygonOffsetFactor = t.polygonOffsetFactor, this.polygonOffsetUnits = t.polygonOffsetUnits, this.dithering = t.dithering, this.alphaTest = t.alphaTest, this.alphaHash = t.alphaHash, this.alphaToCoverage = t.alphaToCoverage, this.premultipliedAlpha = t.premultipliedAlpha, this.forceSinglePass = t.forceSinglePass, this.visible = t.visible, this.toneMapped = t.toneMapped, this.userData = JSON.parse(JSON.stringify(t.userData)), this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  onBuild() {
    console.warn("Material: onBuild() has been removed.");
  }
}
class Nd extends Ba {
  constructor(t) {
    super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new Me(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 mr(), this.combine = m0, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.color.copy(t.color), this.map = t.map, this.lightMap = t.lightMap, this.lightMapIntensity = t.lightMapIntensity, this.aoMap = t.aoMap, this.aoMapIntensity = t.aoMapIntensity, this.specularMap = t.specularMap, this.alphaMap = t.alphaMap, this.envMap = t.envMap, this.envMapRotation.copy(t.envMapRotation), this.combine = t.combine, this.reflectivity = t.reflectivity, this.refractionRatio = t.refractionRatio, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.wireframeLinecap = t.wireframeLinecap, this.wireframeLinejoin = t.wireframeLinejoin, this.fog = t.fog, this;
  }
}
const Sn = /* @__PURE__ */ new ot(), _f = /* @__PURE__ */ new oe();
class fn {
  constructor(t, e, r = !1) {
    if (Array.isArray(t))
      throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
    this.isBufferAttribute = !0, this.name = "", this.array = t, this.itemSize = e, this.count = t !== void 0 ? t.length / e : 0, this.normalized = r, this.usage = Ta, this.updateRanges = [], this.gpuType = Gi, this.version = 0;
  }
  onUploadCallback() {
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  setUsage(t) {
    return this.usage = t, this;
  }
  addUpdateRange(t, e) {
    this.updateRanges.push({ start: t, count: e });
  }
  clearUpdateRanges() {
    this.updateRanges.length = 0;
  }
  copy(t) {
    return this.name = t.name, this.array = new t.array.constructor(t.array), this.itemSize = t.itemSize, this.count = t.count, this.normalized = t.normalized, this.usage = t.usage, this.gpuType = t.gpuType, this;
  }
  copyAt(t, e, r) {
    t *= this.itemSize, r *= e.itemSize;
    for (let a = 0, o = this.itemSize; a < o; a++)
      this.array[t + a] = e.array[r + a];
    return this;
  }
  copyArray(t) {
    return this.array.set(t), this;
  }
  applyMatrix3(t) {
    if (this.itemSize === 2)
      for (let e = 0, r = this.count; e < r; e++)
        _f.fromBufferAttribute(this, e), _f.applyMatrix3(t), this.setXY(e, _f.x, _f.y);
    else if (this.itemSize === 3)
      for (let e = 0, r = this.count; e < r; e++)
        Sn.fromBufferAttribute(this, e), Sn.applyMatrix3(t), this.setXYZ(e, Sn.x, Sn.y, Sn.z);
    return this;
  }
  applyMatrix4(t) {
    for (let e = 0, r = this.count; e < r; e++)
      Sn.fromBufferAttribute(this, e), Sn.applyMatrix4(t), this.setXYZ(e, Sn.x, Sn.y, Sn.z);
    return this;
  }
  applyNormalMatrix(t) {
    for (let e = 0, r = this.count; e < r; e++)
      Sn.fromBufferAttribute(this, e), Sn.applyNormalMatrix(t), this.setXYZ(e, Sn.x, Sn.y, Sn.z);
    return this;
  }
  transformDirection(t) {
    for (let e = 0, r = this.count; e < r; e++)
      Sn.fromBufferAttribute(this, e), Sn.transformDirection(t), this.setXYZ(e, Sn.x, Sn.y, Sn.z);
    return this;
  }
  set(t, e = 0) {
    return this.array.set(t, e), this;
  }
  getComponent(t, e) {
    let r = this.array[t * this.itemSize + e];
    return this.normalized && (r = Ki(r, this.array)), r;
  }
  setComponent(t, e, r) {
    return this.normalized && (r = ke(r, this.array)), this.array[t * this.itemSize + e] = r, this;
  }
  getX(t) {
    let e = this.array[t * this.itemSize];
    return this.normalized && (e = Ki(e, this.array)), e;
  }
  setX(t, e) {
    return this.normalized && (e = ke(e, this.array)), this.array[t * this.itemSize] = e, this;
  }
  getY(t) {
    let e = this.array[t * this.itemSize + 1];
    return this.normalized && (e = Ki(e, this.array)), e;
  }
  setY(t, e) {
    return this.normalized && (e = ke(e, this.array)), this.array[t * this.itemSize + 1] = e, this;
  }
  getZ(t) {
    let e = this.array[t * this.itemSize + 2];
    return this.normalized && (e = Ki(e, this.array)), e;
  }
  setZ(t, e) {
    return this.normalized && (e = ke(e, this.array)), this.array[t * this.itemSize + 2] = e, this;
  }
  getW(t) {
    let e = this.array[t * this.itemSize + 3];
    return this.normalized && (e = Ki(e, this.array)), e;
  }
  setW(t, e) {
    return this.normalized && (e = ke(e, this.array)), this.array[t * this.itemSize + 3] = e, this;
  }
  setXY(t, e, r) {
    return t *= this.itemSize, this.normalized && (e = ke(e, this.array), r = ke(r, this.array)), this.array[t + 0] = e, this.array[t + 1] = r, this;
  }
  setXYZ(t, e, r, a) {
    return t *= this.itemSize, this.normalized && (e = ke(e, this.array), r = ke(r, this.array), a = ke(a, this.array)), this.array[t + 0] = e, this.array[t + 1] = r, this.array[t + 2] = a, this;
  }
  setXYZW(t, e, r, a, o) {
    return t *= this.itemSize, this.normalized && (e = ke(e, this.array), r = ke(r, this.array), a = ke(a, this.array), o = ke(o, this.array)), this.array[t + 0] = e, this.array[t + 1] = r, this.array[t + 2] = a, this.array[t + 3] = o, this;
  }
  onUpload(t) {
    return this.onUploadCallback = t, this;
  }
  clone() {
    return new this.constructor(this.array, this.itemSize).copy(this);
  }
  toJSON() {
    const t = {
      itemSize: this.itemSize,
      type: this.array.constructor.name,
      array: Array.from(this.array),
      normalized: this.normalized
    };
    return this.name !== "" && (t.name = this.name), this.usage !== Ta && (t.usage = this.usage), t;
  }
}
class SM extends fn {
  constructor(t, e, r) {
    super(new Uint16Array(t), e, r);
  }
}
class bM extends fn {
  constructor(t, e, r) {
    super(new Uint32Array(t), e, r);
  }
}
class Nn extends fn {
  constructor(t, e, r) {
    super(new Float32Array(t), e, r);
  }
}
let CC = 0;
const Hi = /* @__PURE__ */ new Ge(), Sm = /* @__PURE__ */ new bn(), No = /* @__PURE__ */ new ot(), wi = /* @__PURE__ */ new _r(), cc = /* @__PURE__ */ new _r(), zn = /* @__PURE__ */ new ot();
class qn extends Ia {
  constructor() {
    super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: CC++ }), this.uuid = Qr(), 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(t) {
    return Array.isArray(t) ? this.index = new (gM(t) ? bM : SM)(t, 1) : this.index = t, this;
  }
  setIndirect(t) {
    return this.indirect = t, this;
  }
  getIndirect() {
    return this.indirect;
  }
  getAttribute(t) {
    return this.attributes[t];
  }
  setAttribute(t, e) {
    return this.attributes[t] = e, this;
  }
  deleteAttribute(t) {
    return delete this.attributes[t], this;
  }
  hasAttribute(t) {
    return this.attributes[t] !== void 0;
  }
  addGroup(t, e, r = 0) {
    this.groups.push({
      start: t,
      count: e,
      materialIndex: r
    });
  }
  clearGroups() {
    this.groups = [];
  }
  setDrawRange(t, e) {
    this.drawRange.start = t, this.drawRange.count = e;
  }
  applyMatrix4(t) {
    const e = this.attributes.position;
    e !== void 0 && (e.applyMatrix4(t), e.needsUpdate = !0);
    const r = this.attributes.normal;
    if (r !== void 0) {
      const o = new ve().getNormalMatrix(t);
      r.applyNormalMatrix(o), r.needsUpdate = !0;
    }
    const a = this.attributes.tangent;
    return a !== void 0 && (a.transformDirection(t), a.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;
  }
  applyQuaternion(t) {
    return Hi.makeRotationFromQuaternion(t), this.applyMatrix4(Hi), this;
  }
  rotateX(t) {
    return Hi.makeRotationX(t), this.applyMatrix4(Hi), this;
  }
  rotateY(t) {
    return Hi.makeRotationY(t), this.applyMatrix4(Hi), this;
  }
  rotateZ(t) {
    return Hi.makeRotationZ(t), this.applyMatrix4(Hi), this;
  }
  translate(t, e, r) {
    return Hi.makeTranslation(t, e, r), this.applyMatrix4(Hi), this;
  }
  scale(t, e, r) {
    return Hi.makeScale(t, e, r), this.applyMatrix4(Hi), this;
  }
  lookAt(t) {
    return Sm.lookAt(t), Sm.updateMatrix(), this.applyMatrix4(Sm.matrix), this;
  }
  center() {
    return this.computeBoundingBox(), this.boundingBox.getCenter(No).negate(), this.translate(No.x, No.y, No.z), this;
  }
  setFromPoints(t) {
    const e = this.getAttribute("position");
    if (e === void 0) {
      const r = [];
      for (let a = 0, o = t.length; a < o; a++) {
        const c = t[a];
        r.push(c.x, c.y, c.z || 0);
      }
      this.setAttribute("position", new Nn(r, 3));
    } else {
      const r = Math.min(t.length, e.count);
      for (let a = 0; a < r; a++) {
        const o = t[a];
        e.setXYZ(a, o.x, o.y, o.z || 0);
      }
      t.length > e.count && console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."), e.needsUpdate = !0;
    }
    return this;
  }
  computeBoundingBox() {
    this.boundingBox === null && (this.boundingBox = new _r());
    const t = this.attributes.position, e = this.morphAttributes.position;
    if (t && t.isGLBufferAttribute) {
      console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set(
        new ot(-1 / 0, -1 / 0, -1 / 0),
        new ot(1 / 0, 1 / 0, 1 / 0)
      );
      return;
    }
    if (t !== void 0) {
      if (this.boundingBox.setFromBufferAttribute(t), e)
        for (let r = 0, a = e.length; r < a; r++) {
          const o = e[r];
          wi.setFromBufferAttribute(o), this.morphTargetsRelative ? (zn.addVectors(this.boundingBox.min, wi.min), this.boundingBox.expandByPoint(zn), zn.addVectors(this.boundingBox.max, wi.max), this.boundingBox.expandByPoint(zn)) : (this.boundingBox.expandByPoint(wi.min), this.boundingBox.expandByPoint(wi.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 Ws());
    const t = this.attributes.position, e = this.morphAttributes.position;
    if (t && t.isGLBufferAttribute) {
      console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new ot(), 1 / 0);
      return;
    }
    if (t) {
      const r = this.boundingSphere.center;
      if (wi.setFromBufferAttribute(t), e)
        for (let o = 0, c = e.length; o < c; o++) {
          const u = e[o];
          cc.setFromBufferAttribute(u), this.morphTargetsRelative ? (zn.addVectors(wi.min, cc.min), wi.expandByPoint(zn), zn.addVectors(wi.max, cc.max), wi.expandByPoint(zn)) : (wi.expandByPoint(cc.min), wi.expandByPoint(cc.max));
        }
      wi.getCenter(r);
      let a = 0;
      for (let o = 0, c = t.count; o < c; o++)
        zn.fromBufferAttribute(t, o), a = Math.max(a, r.distanceToSquared(zn));
      if (e)
        for (let o = 0, c = e.length; o < c; o++) {
          const u = e[o], d = this.morphTargetsRelative;
          for (let h = 0, p = u.count; h < p; h++)
            zn.fromBufferAttribute(u, h), d && (No.fromBufferAttribute(t, h), zn.add(No)), a = Math.max(a, r.distanceToSquared(zn));
        }
      this.boundingSphere.radius = Math.sqrt(a), 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 t = this.index, e = this.attributes;
    if (t === null || e.position === void 0 || e.normal === void 0 || e.uv === void 0) {
      console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");
      return;
    }
    const r = e.position, a = e.normal, o = e.uv;
    this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new fn(new Float32Array(4 * r.count), 4));
    const c = this.getAttribute("tangent"), u = [], d = [];
    for (let z = 0; z < r.count; z++)
      u[z] = new ot(), d[z] = new ot();
    const h = new ot(), p = new ot(), m = new ot(), g = new oe(), _ = new oe(), b = new oe(), E = new ot(), S = new ot();
    function y(z, R, T) {
      h.fromBufferAttribute(r, z), p.fromBufferAttribute(r, R), m.fromBufferAttribute(r, T), g.fromBufferAttribute(o, z), _.fromBufferAttribute(o, R), b.fromBufferAttribute(o, T), p.sub(h), m.sub(h), _.sub(g), b.sub(g);
      const U = 1 / (_.x * b.y - b.x * _.y);
      isFinite(U) && (E.copy(p).multiplyScalar(b.y).addScaledVector(m, -_.y).multiplyScalar(U), S.copy(m).multiplyScalar(_.x).addScaledVector(p, -b.x).multiplyScalar(U), u[z].add(E), u[R].add(E), u[T].add(E), d[z].add(S), d[R].add(S), d[T].add(S));
    }
    let A = this.groups;
    A.length === 0 && (A = [{
      start: 0,
      count: t.count
    }]);
    for (let z = 0, R = A.length; z < R; ++z) {
      const T = A[z], U = T.start, B = T.count;
      for (let I = U, C = U + B; I < C; I += 3)
        y(
          t.getX(I + 0),
          t.getX(I + 1),
          t.getX(I + 2)
        );
    }
    const w = new ot(), M = new ot(), O = new ot(), L = new ot();
    function N(z) {
      O.fromBufferAttribute(a, z), L.copy(O);
      const R = u[z];
      w.copy(R), w.sub(O.multiplyScalar(O.dot(R))).normalize(), M.crossVectors(L, R);
      const U = M.dot(d[z]) < 0 ? -1 : 1;
      c.setXYZW(z, w.x, w.y, w.z, U);
    }
    for (let z = 0, R = A.length; z < R; ++z) {
      const T = A[z], U = T.start, B = T.count;
      for (let I = U, C = U + B; I < C; I += 3)
        N(t.getX(I + 0)), N(t.getX(I + 1)), N(t.getX(I + 2));
    }
  }
  computeVertexNormals() {
    const t = this.index, e = this.getAttribute("position");
    if (e !== void 0) {
      let r = this.getAttribute("normal");
      if (r === void 0)
        r = new fn(new Float32Array(e.count * 3), 3), this.setAttribute("normal", r);
      else
        for (let g = 0, _ = r.count; g < _; g++)
          r.setXYZ(g, 0, 0, 0);
      const a = new ot(), o = new ot(), c = new ot(), u = new ot(), d = new ot(), h = new ot(), p = new ot(), m = new ot();
      if (t)
        for (let g = 0, _ = t.count; g < _; g += 3) {
          const b = t.getX(g + 0), E = t.getX(g + 1), S = t.getX(g + 2);
          a.fromBufferAttribute(e, b), o.fromBufferAttribute(e, E), c.fromBufferAttribute(e, S), p.subVectors(c, o), m.subVectors(a, o), p.cross(m), u.fromBufferAttribute(r, b), d.fromBufferAttribute(r, E), h.fromBufferAttribute(r, S), u.add(p), d.add(p), h.add(p), r.setXYZ(b, u.x, u.y, u.z), r.setXYZ(E, d.x, d.y, d.z), r.setXYZ(S, h.x, h.y, h.z);
        }
      else
        for (let g = 0, _ = e.count; g < _; g += 3)
          a.fromBufferAttribute(e, g + 0), o.fromBufferAttribute(e, g + 1), c.fromBufferAttribute(e, g + 2), p.subVectors(c, o), m.subVectors(a, o), p.cross(m), r.setXYZ(g + 0, p.x, p.y, p.z), r.setXYZ(g + 1, p.x, p.y, p.z), r.setXYZ(g + 2, p.x, p.y, p.z);
      this.normalizeNormals(), r.needsUpdate = !0;
    }
  }
  normalizeNormals() {
    const t = this.attributes.normal;
    for (let e = 0, r = t.count; e < r; e++)
      zn.fromBufferAttribute(t, e), zn.normalize(), t.setXYZ(e, zn.x, zn.y, zn.z);
  }
  toNonIndexed() {
    function t(u, d) {
      const h = u.array, p = u.itemSize, m = u.normalized, g = new h.constructor(d.length * p);
      let _ = 0, b = 0;
      for (let E = 0, S = d.length; E < S; E++) {
        u.isInterleavedBufferAttribute ? _ = d[E] * u.data.stride + u.offset : _ = d[E] * p;
        for (let y = 0; y < p; y++)
          g[b++] = h[_++];
      }
      return new fn(g, p, m);
    }
    if (this.index === null)
      return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;
    const e = new qn(), r = this.index.array, a = this.attributes;
    for (const u in a) {
      const d = a[u], h = t(d, r);
      e.setAttribute(u, h);
    }
    const o = this.morphAttributes;
    for (const u in o) {
      const d = [], h = o[u];
      for (let p = 0, m = h.length; p < m; p++) {
        const g = h[p], _ = t(g, r);
        d.push(_);
      }
      e.morphAttributes[u] = d;
    }
    e.morphTargetsRelative = this.morphTargetsRelative;
    const c = this.groups;
    for (let u = 0, d = c.length; u < d; u++) {
      const h = c[u];
      e.addGroup(h.start, h.count, h.materialIndex);
    }
    return e;
  }
  toJSON() {
    const t = {
      metadata: {
        version: 4.6,
        type: "BufferGeometry",
        generator: "BufferGeometry.toJSON"
      }
    };
    if (t.uuid = this.uuid, t.type = this.type, this.name !== "" && (t.name = this.name), Object.keys(this.userData).length > 0 && (t.userData = this.userData), this.parameters !== void 0) {
      const d = this.parameters;
      for (const h in d)
        d[h] !== void 0 && (t[h] = d[h]);
      return t;
    }
    t.data = { attributes: {} };
    const e = this.index;
    e !== null && (t.data.index = {
      type: e.array.constructor.name,
      array: Array.prototype.slice.call(e.array)
    });
    const r = this.attributes;
    for (const d in r) {
      const h = r[d];
      t.data.attributes[d] = h.toJSON(t.data);
    }
    const a = {};
    let o = !1;
    for (const d in this.morphAttributes) {
      const h = this.morphAttributes[d], p = [];
      for (let m = 0, g = h.length; m < g; m++) {
        const _ = h[m];
        p.push(_.toJSON(t.data));
      }
      p.length > 0 && (a[d] = p, o = !0);
    }
    o && (t.data.morphAttributes = a, t.data.morphTargetsRelative = this.morphTargetsRelative);
    const c = this.groups;
    c.length > 0 && (t.data.groups = JSON.parse(JSON.stringify(c)));
    const u = this.boundingSphere;
    return u !== null && (t.data.boundingSphere = {
      center: u.center.toArray(),
      radius: u.radius
    }), t;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null;
    const e = {};
    this.name = t.name;
    const r = t.index;
    r !== null && this.setIndex(r.clone(e));
    const a = t.attributes;
    for (const h in a) {
      const p = a[h];
      this.setAttribute(h, p.clone(e));
    }
    const o = t.morphAttributes;
    for (const h in o) {
      const p = [], m = o[h];
      for (let g = 0, _ = m.length; g < _; g++)
        p.push(m[g].clone(e));
      this.morphAttributes[h] = p;
    }
    this.morphTargetsRelative = t.morphTargetsRelative;
    const c = t.groups;
    for (let h = 0, p = c.length; h < p; h++) {
      const m = c[h];
      this.addGroup(m.start, m.count, m.materialIndex);
    }
    const u = t.boundingBox;
    u !== null && (this.boundingBox = u.clone());
    const d = t.boundingSphere;
    return d !== null && (this.boundingSphere = d.clone()), this.drawRange.start = t.drawRange.start, this.drawRange.count = t.drawRange.count, this.userData = t.userData, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
const uS = /* @__PURE__ */ new Ge(), ma = /* @__PURE__ */ new E0(), yf = /* @__PURE__ */ new Ws(), fS = /* @__PURE__ */ new ot(), xf = /* @__PURE__ */ new ot(), Sf = /* @__PURE__ */ new ot(), bf = /* @__PURE__ */ new ot(), bm = /* @__PURE__ */ new ot(), Mf = /* @__PURE__ */ new ot(), dS = /* @__PURE__ */ new ot(), Ef = /* @__PURE__ */ new ot();
class Dn extends bn {
  constructor(t = new qn(), e = new Nd()) {
    super(), this.isMesh = !0, this.type = "Mesh", this.geometry = t, this.material = e, this.updateMorphTargets();
  }
  copy(t, e) {
    return super.copy(t, e), t.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = t.morphTargetInfluences.slice()), t.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, t.morphTargetDictionary)), this.material = Array.isArray(t.material) ? t.material.slice() : t.material, this.geometry = t.geometry, this;
  }
  updateMorphTargets() {
    const e = this.geometry.morphAttributes, r = Object.keys(e);
    if (r.length > 0) {
      const a = e[r[0]];
      if (a !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let o = 0, c = a.length; o < c; o++) {
          const u = a[o].name || String(o);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[u] = o;
        }
      }
    }
  }
  getVertexPosition(t, e) {
    const r = this.geometry, a = r.attributes.position, o = r.morphAttributes.position, c = r.morphTargetsRelative;
    e.fromBufferAttribute(a, t);
    const u = this.morphTargetInfluences;
    if (o && u) {
      Mf.set(0, 0, 0);
      for (let d = 0, h = o.length; d < h; d++) {
        const p = u[d], m = o[d];
        p !== 0 && (bm.fromBufferAttribute(m, t), c ? Mf.addScaledVector(bm, p) : Mf.addScaledVector(bm.sub(e), p));
      }
      e.add(Mf);
    }
    return e;
  }
  raycast(t, e) {
    const r = this.geometry, a = this.material, o = this.matrixWorld;
    a !== void 0 && (r.boundingSphere === null && r.computeBoundingSphere(), yf.copy(r.boundingSphere), yf.applyMatrix4(o), ma.copy(t.ray).recast(t.near), !(yf.containsPoint(ma.origin) === !1 && (ma.intersectSphere(yf, fS) === null || ma.origin.distanceToSquared(fS) > (t.far - t.near) ** 2)) && (uS.copy(o).invert(), ma.copy(t.ray).applyMatrix4(uS), !(r.boundingBox !== null && ma.intersectsBox(r.boundingBox) === !1) && this._computeIntersections(t, e, ma)));
  }
  _computeIntersections(t, e, r) {
    let a;
    const o = this.geometry, c = this.material, u = o.index, d = o.attributes.position, h = o.attributes.uv, p = o.attributes.uv1, m = o.attributes.normal, g = o.groups, _ = o.drawRange;
    if (u !== null)
      if (Array.isArray(c))
        for (let b = 0, E = g.length; b < E; b++) {
          const S = g[b], y = c[S.materialIndex], A = Math.max(S.start, _.start), w = Math.min(u.count, Math.min(S.start + S.count, _.start + _.count));
          for (let M = A, O = w; M < O; M += 3) {
            const L = u.getX(M), N = u.getX(M + 1), z = u.getX(M + 2);
            a = wf(this, y, t, r, h, p, m, L, N, z), a && (a.faceIndex = Math.floor(M / 3), a.face.materialIndex = S.materialIndex, e.push(a));
          }
        }
      else {
        const b = Math.max(0, _.start), E = Math.min(u.count, _.start + _.count);
        for (let S = b, y = E; S < y; S += 3) {
          const A = u.getX(S), w = u.getX(S + 1), M = u.getX(S + 2);
          a = wf(this, c, t, r, h, p, m, A, w, M), a && (a.faceIndex = Math.floor(S / 3), e.push(a));
        }
      }
    else if (d !== void 0)
      if (Array.isArray(c))
        for (let b = 0, E = g.length; b < E; b++) {
          const S = g[b], y = c[S.materialIndex], A = Math.max(S.start, _.start), w = Math.min(d.count, Math.min(S.start + S.count, _.start + _.count));
          for (let M = A, O = w; M < O; M += 3) {
            const L = M, N = M + 1, z = M + 2;
            a = wf(this, y, t, r, h, p, m, L, N, z), a && (a.faceIndex = Math.floor(M / 3), a.face.materialIndex = S.materialIndex, e.push(a));
          }
        }
      else {
        const b = Math.max(0, _.start), E = Math.min(d.count, _.start + _.count);
        for (let S = b, y = E; S < y; S += 3) {
          const A = S, w = S + 1, M = S + 2;
          a = wf(this, c, t, r, h, p, m, A, w, M), a && (a.faceIndex = Math.floor(S / 3), e.push(a));
        }
      }
  }
}
function RC(n, t, e, r, a, o, c, u) {
  let d;
  if (t.side === pi ? d = r.intersectTriangle(c, o, a, !0, u) : d = r.intersectTriangle(a, o, c, t.side === Xs, u), d === null) return null;
  Ef.copy(u), Ef.applyMatrix4(n.matrixWorld);
  const h = e.ray.origin.distanceTo(Ef);
  return h < e.near || h > e.far ? null : {
    distance: h,
    point: Ef.clone(),
    object: n
  };
}
function wf(n, t, e, r, a, o, c, u, d, h) {
  n.getVertexPosition(u, xf), n.getVertexPosition(d, Sf), n.getVertexPosition(h, bf);
  const p = RC(n, t, e, r, xf, Sf, bf, dS);
  if (p) {
    const m = new ot();
    ki.getBarycoord(dS, xf, Sf, bf, m), a && (p.uv = ki.getInterpolatedAttribute(a, u, d, h, m, new oe())), o && (p.uv1 = ki.getInterpolatedAttribute(o, u, d, h, m, new oe())), c && (p.normal = ki.getInterpolatedAttribute(c, u, d, h, m, new ot()), p.normal.dot(r.direction) > 0 && p.normal.multiplyScalar(-1));
    const g = {
      a: u,
      b: d,
      c: h,
      normal: new ot(),
      materialIndex: 0
    };
    ki.getNormal(xf, Sf, bf, g.normal), p.face = g, p.barycoord = m;
  }
  return p;
}
class jc extends qn {
  constructor(t = 1, e = 1, r = 1, a = 1, o = 1, c = 1) {
    super(), this.type = "BoxGeometry", this.parameters = {
      width: t,
      height: e,
      depth: r,
      widthSegments: a,
      heightSegments: o,
      depthSegments: c
    };
    const u = this;
    a = Math.floor(a), o = Math.floor(o), c = Math.floor(c);
    const d = [], h = [], p = [], m = [];
    let g = 0, _ = 0;
    b("z", "y", "x", -1, -1, r, e, t, c, o, 0), b("z", "y", "x", 1, -1, r, e, -t, c, o, 1), b("x", "z", "y", 1, 1, t, r, e, a, c, 2), b("x", "z", "y", 1, -1, t, r, -e, a, c, 3), b("x", "y", "z", 1, -1, t, e, r, a, o, 4), b("x", "y", "z", -1, -1, t, e, -r, a, o, 5), this.setIndex(d), this.setAttribute("position", new Nn(h, 3)), this.setAttribute("normal", new Nn(p, 3)), this.setAttribute("uv", new Nn(m, 2));
    function b(E, S, y, A, w, M, O, L, N, z, R) {
      const T = M / N, U = O / z, B = M / 2, I = O / 2, C = L / 2, X = N + 1, D = z + 1;
      let V = 0, H = 0;
      const j = new ot();
      for (let K = 0; K < D; K++) {
        const F = K * U - I;
        for (let q = 0; q < X; q++) {
          const it = q * T - B;
          j[E] = it * A, j[S] = F * w, j[y] = C, h.push(j.x, j.y, j.z), j[E] = 0, j[S] = 0, j[y] = L > 0 ? 1 : -1, p.push(j.x, j.y, j.z), m.push(q / N), m.push(1 - K / z), V += 1;
        }
      }
      for (let K = 0; K < z; K++)
        for (let F = 0; F < N; F++) {
          const q = g + F + X * K, it = g + F + X * (K + 1), G = g + (F + 1) + X * (K + 1), k = g + (F + 1) + X * K;
          d.push(q, it, k), d.push(it, G, k), H += 6;
        }
      u.addGroup(_, H, R), _ += H, g += V;
    }
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new jc(t.width, t.height, t.depth, t.widthSegments, t.heightSegments, t.depthSegments);
  }
}
function al(n) {
  const t = {};
  for (const e in n) {
    t[e] = {};
    for (const r in n[e]) {
      const a = n[e][r];
      a && (a.isColor || a.isMatrix3 || a.isMatrix4 || a.isVector2 || a.isVector3 || a.isVector4 || a.isTexture || a.isQuaternion) ? a.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), t[e][r] = null) : t[e][r] = a.clone() : Array.isArray(a) ? t[e][r] = a.slice() : t[e][r] = a;
    }
  }
  return t;
}
function ni(n) {
  const t = {};
  for (let e = 0; e < n.length; e++) {
    const r = al(n[e]);
    for (const a in r)
      t[a] = r[a];
  }
  return t;
}
function DC(n) {
  const t = [];
  for (let e = 0; e < n.length; e++)
    t.push(n[e].clone());
  return t;
}
function MM(n) {
  const t = n.getRenderTarget();
  return t === null ? n.outputColorSpace : t.isXRRenderTarget === !0 ? t.texture.colorSpace : Ie.workingColorSpace;
}
const w0 = { clone: al, merge: ni };
var NC = `void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`, LC = `void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;
class gr extends Ba {
  constructor(t) {
    super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = NC, this.fragmentShader = LC, 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, t !== void 0 && this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.fragmentShader = t.fragmentShader, this.vertexShader = t.vertexShader, this.uniforms = al(t.uniforms), this.uniformsGroups = DC(t.uniformsGroups), this.defines = Object.assign({}, t.defines), this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.fog = t.fog, this.lights = t.lights, this.clipping = t.clipping, this.extensions = Object.assign({}, t.extensions), this.glslVersion = t.glslVersion, this;
  }
  toJSON(t) {
    const e = super.toJSON(t);
    e.glslVersion = this.glslVersion, e.uniforms = {};
    for (const a in this.uniforms) {
      const c = this.uniforms[a].value;
      c && c.isTexture ? e.uniforms[a] = {
        type: "t",
        value: c.toJSON(t).uuid
      } : c && c.isColor ? e.uniforms[a] = {
        type: "c",
        value: c.getHex()
      } : c && c.isVector2 ? e.uniforms[a] = {
        type: "v2",
        value: c.toArray()
      } : c && c.isVector3 ? e.uniforms[a] = {
        type: "v3",
        value: c.toArray()
      } : c && c.isVector4 ? e.uniforms[a] = {
        type: "v4",
        value: c.toArray()
      } : c && c.isMatrix3 ? e.uniforms[a] = {
        type: "m3",
        value: c.toArray()
      } : c && c.isMatrix4 ? e.uniforms[a] = {
        type: "m4",
        value: c.toArray()
      } : e.uniforms[a] = {
        value: c
      };
    }
    Object.keys(this.defines).length > 0 && (e.defines = this.defines), e.vertexShader = this.vertexShader, e.fragmentShader = this.fragmentShader, e.lights = this.lights, e.clipping = this.clipping;
    const r = {};
    for (const a in this.extensions)
      this.extensions[a] === !0 && (r[a] = !0);
    return Object.keys(r).length > 0 && (e.extensions = r), e;
  }
}
class EM extends bn {
  constructor() {
    super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new Ge(), this.projectionMatrix = new Ge(), this.projectionMatrixInverse = new Ge(), this.coordinateSystem = Zr;
  }
  copy(t, e) {
    return super.copy(t, e), this.matrixWorldInverse.copy(t.matrixWorldInverse), this.projectionMatrix.copy(t.projectionMatrix), this.projectionMatrixInverse.copy(t.projectionMatrixInverse), this.coordinateSystem = t.coordinateSystem, this;
  }
  getWorldDirection(t) {
    return super.getWorldDirection(t).negate();
  }
  updateMatrixWorld(t) {
    super.updateMatrixWorld(t), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  updateWorldMatrix(t, e) {
    super.updateWorldMatrix(t, e), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const Os = /* @__PURE__ */ new ot(), hS = /* @__PURE__ */ new oe(), pS = /* @__PURE__ */ new oe();
class Ti extends EM {
  constructor(t = 50, e = 1, r = 0.1, a = 2e3) {
    super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = t, this.zoom = 1, this.near = r, this.far = a, this.focus = 10, this.aspect = e, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix();
  }
  copy(t, e) {
    return super.copy(t, e), this.fov = t.fov, this.zoom = t.zoom, this.near = t.near, this.far = t.far, this.focus = t.focus, this.aspect = t.aspect, this.view = t.view === null ? null : Object.assign({}, t.view), this.filmGauge = t.filmGauge, this.filmOffset = t.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.
   *
   * @param {number} focalLength - Values for focal length and film gauge must have the same unit.
   */
  setFocalLength(t) {
    const e = 0.5 * this.getFilmHeight() / t;
    this.fov = Rc * 2 * Math.atan(e), this.updateProjectionMatrix();
  }
  /**
   * Calculates the focal length from the current .fov and .filmGauge.
   *
   * @returns {number}
   */
  getFocalLength() {
    const t = Math.tan(Ec * 0.5 * this.fov);
    return 0.5 * this.getFilmHeight() / t;
  }
  getEffectiveFOV() {
    return Rc * 2 * Math.atan(
      Math.tan(Ec * 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.
   *
   * @param {number} distance
   * @param {Vector2} minTarget
   * @param {Vector2} maxTarget
   */
  getViewBounds(t, e, r) {
    Os.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), e.set(Os.x, Os.y).multiplyScalar(-t / Os.z), Os.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), r.set(Os.x, Os.y).multiplyScalar(-t / Os.z);
  }
  /**
   * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction.
   *
   * @param {number} distance
   * @param {Vector2} target - Vector2 target used to store result where x is width and y is height.
   * @returns {Vector2}
   */
  getViewSize(t, e) {
    return this.getViewBounds(t, hS, pS), e.subVectors(pS, hS);
  }
  /**
   * 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.
   *
   * @param {number} fullWidth
   * @param {number} fullHeight
   * @param {number} x
   * @param {number} y
   * @param {number} width
   * @param {number} height
   */
  setViewOffset(t, e, r, a, o, c) {
    this.aspect = t / e, 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 = t, this.view.fullHeight = e, this.view.offsetX = r, this.view.offsetY = a, this.view.width = o, this.view.height = c, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const t = this.near;
    let e = t * Math.tan(Ec * 0.5 * this.fov) / this.zoom, r = 2 * e, a = this.aspect * r, o = -0.5 * a;
    const c = this.view;
    if (this.view !== null && this.view.enabled) {
      const d = c.fullWidth, h = c.fullHeight;
      o += c.offsetX * a / d, e -= c.offsetY * r / h, a *= c.width / d, r *= c.height / h;
    }
    const u = this.filmOffset;
    u !== 0 && (o += t * u / this.getFilmWidth()), this.projectionMatrix.makePerspective(o, o + a, e, e - r, t, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(t) {
    const e = super.toJSON(t);
    return e.object.fov = this.fov, e.object.zoom = this.zoom, e.object.near = this.near, e.object.far = this.far, e.object.focus = this.focus, e.object.aspect = this.aspect, this.view !== null && (e.object.view = Object.assign({}, this.view)), e.object.filmGauge = this.filmGauge, e.object.filmOffset = this.filmOffset, e;
  }
}
const Lo = -90, Uo = 1;
class UC extends bn {
  constructor(t, e, r) {
    super(), this.type = "CubeCamera", this.renderTarget = r, this.coordinateSystem = null, this.activeMipmapLevel = 0;
    const a = new Ti(Lo, Uo, t, e);
    a.layers = this.layers, this.add(a);
    const o = new Ti(Lo, Uo, t, e);
    o.layers = this.layers, this.add(o);
    const c = new Ti(Lo, Uo, t, e);
    c.layers = this.layers, this.add(c);
    const u = new Ti(Lo, Uo, t, e);
    u.layers = this.layers, this.add(u);
    const d = new Ti(Lo, Uo, t, e);
    d.layers = this.layers, this.add(d);
    const h = new Ti(Lo, Uo, t, e);
    h.layers = this.layers, this.add(h);
  }
  updateCoordinateSystem() {
    const t = this.coordinateSystem, e = this.children.concat(), [r, a, o, c, u, d] = e;
    for (const h of e) this.remove(h);
    if (t === Zr)
      r.up.set(0, 1, 0), r.lookAt(1, 0, 0), a.up.set(0, 1, 0), a.lookAt(-1, 0, 0), o.up.set(0, 0, -1), o.lookAt(0, 1, 0), c.up.set(0, 0, 1), c.lookAt(0, -1, 0), u.up.set(0, 1, 0), u.lookAt(0, 0, 1), d.up.set(0, 1, 0), d.lookAt(0, 0, -1);
    else if (t === pd)
      r.up.set(0, -1, 0), r.lookAt(-1, 0, 0), a.up.set(0, -1, 0), a.lookAt(1, 0, 0), o.up.set(0, 0, 1), o.lookAt(0, 1, 0), c.up.set(0, 0, -1), c.lookAt(0, -1, 0), u.up.set(0, -1, 0), u.lookAt(0, 0, 1), d.up.set(0, -1, 0), d.lookAt(0, 0, -1);
    else
      throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + t);
    for (const h of e)
      this.add(h), h.updateMatrixWorld();
  }
  update(t, e) {
    this.parent === null && this.updateMatrixWorld();
    const { renderTarget: r, activeMipmapLevel: a } = this;
    this.coordinateSystem !== t.coordinateSystem && (this.coordinateSystem = t.coordinateSystem, this.updateCoordinateSystem());
    const [o, c, u, d, h, p] = this.children, m = t.getRenderTarget(), g = t.getActiveCubeFace(), _ = t.getActiveMipmapLevel(), b = t.xr.enabled;
    t.xr.enabled = !1;
    const E = r.texture.generateMipmaps;
    r.texture.generateMipmaps = !1, t.setRenderTarget(r, 0, a), t.render(e, o), t.setRenderTarget(r, 1, a), t.render(e, c), t.setRenderTarget(r, 2, a), t.render(e, u), t.setRenderTarget(r, 3, a), t.render(e, d), t.setRenderTarget(r, 4, a), t.render(e, h), r.texture.generateMipmaps = E, t.setRenderTarget(r, 5, a), t.render(e, p), t.setRenderTarget(m, g, _), t.xr.enabled = b, r.texture.needsPMREMUpdate = !0;
  }
}
class wM extends Jn {
  constructor(t, e, r, a, o, c, u, d, h, p) {
    t = t !== void 0 ? t : [], e = e !== void 0 ? e : el, super(t, e, r, a, o, c, u, d, h, p), this.isCubeTexture = !0, this.flipY = !1;
  }
  get images() {
    return this.image;
  }
  set images(t) {
    this.image = t;
  }
}
class OC extends La {
  constructor(t = 1, e = {}) {
    super(t, t, e), this.isWebGLCubeRenderTarget = !0;
    const r = { width: t, height: t, depth: 1 }, a = [r, r, r, r, r, r];
    this.texture = new wM(a, e.mapping, e.wrapS, e.wrapT, e.magFilter, e.minFilter, e.format, e.type, e.anisotropy, e.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = e.generateMipmaps !== void 0 ? e.generateMipmaps : !1, this.texture.minFilter = e.minFilter !== void 0 ? e.minFilter : dr;
  }
  fromEquirectangularTexture(t, e) {
    this.texture.type = e.type, this.texture.colorSpace = e.colorSpace, this.texture.generateMipmaps = e.generateMipmaps, this.texture.minFilter = e.minFilter, this.texture.magFilter = e.magFilter;
    const r = {
      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 );

				}
			`
      )
    }, a = new jc(5, 5, 5), o = new gr({
      name: "CubemapFromEquirect",
      uniforms: al(r.uniforms),
      vertexShader: r.vertexShader,
      fragmentShader: r.fragmentShader,
      side: pi,
      blending: ks
    });
    o.uniforms.tEquirect.value = e;
    const c = new Dn(a, o), u = e.minFilter;
    return e.minFilter === wa && (e.minFilter = dr), new UC(1, 10, this).update(t, c), e.minFilter = u, c.geometry.dispose(), c.material.dispose(), this;
  }
  clear(t, e, r, a) {
    const o = t.getRenderTarget();
    for (let c = 0; c < 6; c++)
      t.setRenderTarget(this, c), t.clear(e, r, a);
    t.setRenderTarget(o);
  }
}
class TM extends bn {
  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 mr(), this.environmentIntensity = 1, this.environmentRotation = new mr(), this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  copy(t, e) {
    return super.copy(t, e), t.background !== null && (this.background = t.background.clone()), t.environment !== null && (this.environment = t.environment.clone()), t.fog !== null && (this.fog = t.fog.clone()), this.backgroundBlurriness = t.backgroundBlurriness, this.backgroundIntensity = t.backgroundIntensity, this.backgroundRotation.copy(t.backgroundRotation), this.environmentIntensity = t.environmentIntensity, this.environmentRotation.copy(t.environmentRotation), t.overrideMaterial !== null && (this.overrideMaterial = t.overrideMaterial.clone()), this.matrixAutoUpdate = t.matrixAutoUpdate, this;
  }
  toJSON(t) {
    const e = super.toJSON(t);
    return this.fog !== null && (e.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (e.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (e.object.backgroundIntensity = this.backgroundIntensity), e.object.backgroundRotation = this.backgroundRotation.toArray(), this.environmentIntensity !== 1 && (e.object.environmentIntensity = this.environmentIntensity), e.object.environmentRotation = this.environmentRotation.toArray(), e;
  }
}
class AM {
  constructor(t, e) {
    this.isInterleavedBuffer = !0, this.array = t, this.stride = e, this.count = t !== void 0 ? t.length / e : 0, this.usage = Ta, this.updateRanges = [], this.version = 0, this.uuid = Qr();
  }
  onUploadCallback() {
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  setUsage(t) {
    return this.usage = t, this;
  }
  addUpdateRange(t, e) {
    this.updateRanges.push({ start: t, count: e });
  }
  clearUpdateRanges() {
    this.updateRanges.length = 0;
  }
  copy(t) {
    return this.array = new t.array.constructor(t.array), this.count = t.count, this.stride = t.stride, this.usage = t.usage, this;
  }
  copyAt(t, e, r) {
    t *= this.stride, r *= e.stride;
    for (let a = 0, o = this.stride; a < o; a++)
      this.array[t + a] = e.array[r + a];
    return this;
  }
  set(t, e = 0) {
    return this.array.set(t, e), this;
  }
  clone(t) {
    t.arrayBuffers === void 0 && (t.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Qr()), t.arrayBuffers[this.array.buffer._uuid] === void 0 && (t.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer);
    const e = new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]), r = new this.constructor(e, this.stride);
    return r.setUsage(this.usage), r;
  }
  onUpload(t) {
    return this.onUploadCallback = t, this;
  }
  toJSON(t) {
    return t.arrayBuffers === void 0 && (t.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Qr()), t.arrayBuffers[this.array.buffer._uuid] === void 0 && (t.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 ei = /* @__PURE__ */ new ot();
class hr {
  constructor(t, e, r, a = !1) {
    this.isInterleavedBufferAttribute = !0, this.name = "", this.data = t, this.itemSize = e, this.offset = r, this.normalized = a;
  }
  get count() {
    return this.data.count;
  }
  get array() {
    return this.data.array;
  }
  set needsUpdate(t) {
    this.data.needsUpdate = t;
  }
  applyMatrix4(t) {
    for (let e = 0, r = this.data.count; e < r; e++)
      ei.fromBufferAttribute(this, e), ei.applyMatrix4(t), this.setXYZ(e, ei.x, ei.y, ei.z);
    return this;
  }
  applyNormalMatrix(t) {
    for (let e = 0, r = this.count; e < r; e++)
      ei.fromBufferAttribute(this, e), ei.applyNormalMatrix(t), this.setXYZ(e, ei.x, ei.y, ei.z);
    return this;
  }
  transformDirection(t) {
    for (let e = 0, r = this.count; e < r; e++)
      ei.fromBufferAttribute(this, e), ei.transformDirection(t), this.setXYZ(e, ei.x, ei.y, ei.z);
    return this;
  }
  getComponent(t, e) {
    let r = this.array[t * this.data.stride + this.offset + e];
    return this.normalized && (r = Ki(r, this.array)), r;
  }
  setComponent(t, e, r) {
    return this.normalized && (r = ke(r, this.array)), this.data.array[t * this.data.stride + this.offset + e] = r, this;
  }
  setX(t, e) {
    return this.normalized && (e = ke(e, this.array)), this.data.array[t * this.data.stride + this.offset] = e, this;
  }
  setY(t, e) {
    return this.normalized && (e = ke(e, this.array)), this.data.array[t * this.data.stride + this.offset + 1] = e, this;
  }
  setZ(t, e) {
    return this.normalized && (e = ke(e, this.array)), this.data.array[t * this.data.stride + this.offset + 2] = e, this;
  }
  setW(t, e) {
    return this.normalized && (e = ke(e, this.array)), this.data.array[t * this.data.stride + this.offset + 3] = e, this;
  }
  getX(t) {
    let e = this.data.array[t * this.data.stride + this.offset];
    return this.normalized && (e = Ki(e, this.array)), e;
  }
  getY(t) {
    let e = this.data.array[t * this.data.stride + this.offset + 1];
    return this.normalized && (e = Ki(e, this.array)), e;
  }
  getZ(t) {
    let e = this.data.array[t * this.data.stride + this.offset + 2];
    return this.normalized && (e = Ki(e, this.array)), e;
  }
  getW(t) {
    let e = this.data.array[t * this.data.stride + this.offset + 3];
    return this.normalized && (e = Ki(e, this.array)), e;
  }
  setXY(t, e, r) {
    return t = t * this.data.stride + this.offset, this.normalized && (e = ke(e, this.array), r = ke(r, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = r, this;
  }
  setXYZ(t, e, r, a) {
    return t = t * this.data.stride + this.offset, this.normalized && (e = ke(e, this.array), r = ke(r, this.array), a = ke(a, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = r, this.data.array[t + 2] = a, this;
  }
  setXYZW(t, e, r, a, o) {
    return t = t * this.data.stride + this.offset, this.normalized && (e = ke(e, this.array), r = ke(r, this.array), a = ke(a, this.array), o = ke(o, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = r, this.data.array[t + 2] = a, this.data.array[t + 3] = o, this;
  }
  clone(t) {
    if (t === void 0) {
      console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");
      const e = [];
      for (let r = 0; r < this.count; r++) {
        const a = r * this.data.stride + this.offset;
        for (let o = 0; o < this.itemSize; o++)
          e.push(this.data.array[a + o]);
      }
      return new fn(new this.array.constructor(e), this.itemSize, this.normalized);
    } else
      return t.interleavedBuffers === void 0 && (t.interleavedBuffers = {}), t.interleavedBuffers[this.data.uuid] === void 0 && (t.interleavedBuffers[this.data.uuid] = this.data.clone(t)), new hr(t.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized);
  }
  toJSON(t) {
    if (t === void 0) {
      console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");
      const e = [];
      for (let r = 0; r < this.count; r++) {
        const a = r * this.data.stride + this.offset;
        for (let o = 0; o < this.itemSize; o++)
          e.push(this.data.array[a + o]);
      }
      return {
        itemSize: this.itemSize,
        type: this.array.constructor.name,
        array: e,
        normalized: this.normalized
      };
    } else
      return t.interleavedBuffers === void 0 && (t.interleavedBuffers = {}), t.interleavedBuffers[this.data.uuid] === void 0 && (t.interleavedBuffers[this.data.uuid] = this.data.toJSON(t)), {
        isInterleavedBufferAttribute: !0,
        itemSize: this.itemSize,
        data: this.data.uuid,
        offset: this.offset,
        normalized: this.normalized
      };
  }
}
class jg extends Ba {
  constructor(t) {
    super(), this.isSpriteMaterial = !0, this.type = "SpriteMaterial", this.color = new Me(16777215), this.map = null, this.alphaMap = null, this.rotation = 0, this.sizeAttenuation = !0, this.transparent = !0, this.fog = !0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.color.copy(t.color), this.map = t.map, this.alphaMap = t.alphaMap, this.rotation = t.rotation, this.sizeAttenuation = t.sizeAttenuation, this.fog = t.fog, this;
  }
}
let Oo;
const uc = /* @__PURE__ */ new ot(), Po = /* @__PURE__ */ new ot(), zo = /* @__PURE__ */ new ot(), Io = /* @__PURE__ */ new oe(), fc = /* @__PURE__ */ new oe(), CM = /* @__PURE__ */ new Ge(), Tf = /* @__PURE__ */ new ot(), dc = /* @__PURE__ */ new ot(), Af = /* @__PURE__ */ new ot(), mS = /* @__PURE__ */ new oe(), Mm = /* @__PURE__ */ new oe(), gS = /* @__PURE__ */ new oe();
class Em extends bn {
  constructor(t = new jg()) {
    if (super(), this.isSprite = !0, this.type = "Sprite", Oo === void 0) {
      Oo = new qn();
      const e = new Float32Array([
        -0.5,
        -0.5,
        0,
        0,
        0,
        0.5,
        -0.5,
        0,
        1,
        0,
        0.5,
        0.5,
        0,
        1,
        1,
        -0.5,
        0.5,
        0,
        0,
        1
      ]), r = new AM(e, 5);
      Oo.setIndex([0, 1, 2, 0, 2, 3]), Oo.setAttribute("position", new hr(r, 3, 0, !1)), Oo.setAttribute("uv", new hr(r, 2, 3, !1));
    }
    this.geometry = Oo, this.material = t, this.center = new oe(0.5, 0.5);
  }
  raycast(t, e) {
    t.camera === null && console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'), Po.setFromMatrixScale(this.matrixWorld), CM.copy(t.camera.matrixWorld), this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse, this.matrixWorld), zo.setFromMatrixPosition(this.modelViewMatrix), t.camera.isPerspectiveCamera && this.material.sizeAttenuation === !1 && Po.multiplyScalar(-zo.z);
    const r = this.material.rotation;
    let a, o;
    r !== 0 && (o = Math.cos(r), a = Math.sin(r));
    const c = this.center;
    Cf(Tf.set(-0.5, -0.5, 0), zo, c, Po, a, o), Cf(dc.set(0.5, -0.5, 0), zo, c, Po, a, o), Cf(Af.set(0.5, 0.5, 0), zo, c, Po, a, o), mS.set(0, 0), Mm.set(1, 0), gS.set(1, 1);
    let u = t.ray.intersectTriangle(Tf, dc, Af, !1, uc);
    if (u === null && (Cf(dc.set(-0.5, 0.5, 0), zo, c, Po, a, o), Mm.set(0, 1), u = t.ray.intersectTriangle(Tf, Af, dc, !1, uc), u === null))
      return;
    const d = t.ray.origin.distanceTo(uc);
    d < t.near || d > t.far || e.push({
      distance: d,
      point: uc.clone(),
      uv: ki.getInterpolation(uc, Tf, dc, Af, mS, Mm, gS, new oe()),
      face: null,
      object: this
    });
  }
  copy(t, e) {
    return super.copy(t, e), t.center !== void 0 && this.center.copy(t.center), this.material = t.material, this;
  }
}
function Cf(n, t, e, r, a, o) {
  Io.subVectors(n, e).addScalar(0.5).multiply(r), a !== void 0 ? (fc.x = o * Io.x - a * Io.y, fc.y = a * Io.x + o * Io.y) : fc.copy(Io), n.copy(t), n.x += fc.x, n.y += fc.y, n.applyMatrix4(CM);
}
class Wg extends Jn {
  constructor(t = null, e = 1, r = 1, a, o, c, u, d, h = Yn, p = Yn, m, g) {
    super(null, c, u, d, h, p, a, o, m, g), this.isDataTexture = !0, this.image = { data: t, width: e, height: r }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class Rn extends fn {
  constructor(t, e, r, a = 1) {
    super(t, e, r), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = a;
  }
  copy(t) {
    return super.copy(t), this.meshPerAttribute = t.meshPerAttribute, this;
  }
  toJSON() {
    const t = super.toJSON();
    return t.meshPerAttribute = this.meshPerAttribute, t.isInstancedBufferAttribute = !0, t;
  }
}
const Bo = /* @__PURE__ */ new Ge(), vS = /* @__PURE__ */ new Ge(), Rf = [], _S = /* @__PURE__ */ new _r(), PC = /* @__PURE__ */ new Ge(), hc = /* @__PURE__ */ new Dn(), pc = /* @__PURE__ */ new Ws();
class yS extends Dn {
  constructor(t, e, r) {
    super(t, e), this.isInstancedMesh = !0, this.instanceMatrix = new Rn(new Float32Array(r * 16), 16), this.instanceColor = null, this.morphTexture = null, this.count = r, this.boundingBox = null, this.boundingSphere = null;
    for (let a = 0; a < r; a++)
      this.setMatrixAt(a, PC);
  }
  computeBoundingBox() {
    const t = this.geometry, e = this.count;
    this.boundingBox === null && (this.boundingBox = new _r()), t.boundingBox === null && t.computeBoundingBox(), this.boundingBox.makeEmpty();
    for (let r = 0; r < e; r++)
      this.getMatrixAt(r, Bo), _S.copy(t.boundingBox).applyMatrix4(Bo), this.boundingBox.union(_S);
  }
  computeBoundingSphere() {
    const t = this.geometry, e = this.count;
    this.boundingSphere === null && (this.boundingSphere = new Ws()), t.boundingSphere === null && t.computeBoundingSphere(), this.boundingSphere.makeEmpty();
    for (let r = 0; r < e; r++)
      this.getMatrixAt(r, Bo), pc.copy(t.boundingSphere).applyMatrix4(Bo), this.boundingSphere.union(pc);
  }
  copy(t, e) {
    return super.copy(t, e), this.instanceMatrix.copy(t.instanceMatrix), t.morphTexture !== null && (this.morphTexture = t.morphTexture.clone()), t.instanceColor !== null && (this.instanceColor = t.instanceColor.clone()), this.count = t.count, t.boundingBox !== null && (this.boundingBox = t.boundingBox.clone()), t.boundingSphere !== null && (this.boundingSphere = t.boundingSphere.clone()), this;
  }
  getColorAt(t, e) {
    e.fromArray(this.instanceColor.array, t * 3);
  }
  getMatrixAt(t, e) {
    e.fromArray(this.instanceMatrix.array, t * 16);
  }
  getMorphAt(t, e) {
    const r = e.morphTargetInfluences, a = this.morphTexture.source.data.data, o = r.length + 1, c = t * o + 1;
    for (let u = 0; u < r.length; u++)
      r[u] = a[c + u];
  }
  raycast(t, e) {
    const r = this.matrixWorld, a = this.count;
    if (hc.geometry = this.geometry, hc.material = this.material, hc.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), pc.copy(this.boundingSphere), pc.applyMatrix4(r), t.ray.intersectsSphere(pc) !== !1))
      for (let o = 0; o < a; o++) {
        this.getMatrixAt(o, Bo), vS.multiplyMatrices(r, Bo), hc.matrixWorld = vS, hc.raycast(t, Rf);
        for (let c = 0, u = Rf.length; c < u; c++) {
          const d = Rf[c];
          d.instanceId = o, d.object = this, e.push(d);
        }
        Rf.length = 0;
      }
  }
  setColorAt(t, e) {
    this.instanceColor === null && (this.instanceColor = new Rn(new Float32Array(this.instanceMatrix.count * 3).fill(1), 3)), e.toArray(this.instanceColor.array, t * 3);
  }
  setMatrixAt(t, e) {
    e.toArray(this.instanceMatrix.array, t * 16);
  }
  setMorphAt(t, e) {
    const r = e.morphTargetInfluences, a = r.length + 1;
    this.morphTexture === null && (this.morphTexture = new Wg(new Float32Array(a * this.count), a, this.count, y0, Gi));
    const o = this.morphTexture.source.data.data;
    let c = 0;
    for (let h = 0; h < r.length; h++)
      c += r[h];
    const u = this.geometry.morphTargetsRelative ? 1 : 1 - c, d = a * t;
    o[d] = u, o.set(r, d + 1);
  }
  updateMorphTargets() {
  }
  dispose() {
    return this.dispatchEvent({ type: "dispose" }), this.morphTexture !== null && (this.morphTexture.dispose(), this.morphTexture = null), this;
  }
}
const wm = /* @__PURE__ */ new ot(), zC = /* @__PURE__ */ new ot(), IC = /* @__PURE__ */ new ve();
class Bs {
  constructor(t = new ot(1, 0, 0), e = 0) {
    this.isPlane = !0, this.normal = t, this.constant = e;
  }
  set(t, e) {
    return this.normal.copy(t), this.constant = e, this;
  }
  setComponents(t, e, r, a) {
    return this.normal.set(t, e, r), this.constant = a, this;
  }
  setFromNormalAndCoplanarPoint(t, e) {
    return this.normal.copy(t), this.constant = -e.dot(this.normal), this;
  }
  setFromCoplanarPoints(t, e, r) {
    const a = wm.subVectors(r, e).cross(zC.subVectors(t, e)).normalize();
    return this.setFromNormalAndCoplanarPoint(a, t), this;
  }
  copy(t) {
    return this.normal.copy(t.normal), this.constant = t.constant, this;
  }
  normalize() {
    const t = 1 / this.normal.length();
    return this.normal.multiplyScalar(t), this.constant *= t, this;
  }
  negate() {
    return this.constant *= -1, this.normal.negate(), this;
  }
  distanceToPoint(t) {
    return this.normal.dot(t) + this.constant;
  }
  distanceToSphere(t) {
    return this.distanceToPoint(t.center) - t.radius;
  }
  projectPoint(t, e) {
    return e.copy(t).addScaledVector(this.normal, -this.distanceToPoint(t));
  }
  intersectLine(t, e) {
    const r = t.delta(wm), a = this.normal.dot(r);
    if (a === 0)
      return this.distanceToPoint(t.start) === 0 ? e.copy(t.start) : null;
    const o = -(t.start.dot(this.normal) + this.constant) / a;
    return o < 0 || o > 1 ? null : e.copy(t.start).addScaledVector(r, o);
  }
  intersectsLine(t) {
    const e = this.distanceToPoint(t.start), r = this.distanceToPoint(t.end);
    return e < 0 && r > 0 || r < 0 && e > 0;
  }
  intersectsBox(t) {
    return t.intersectsPlane(this);
  }
  intersectsSphere(t) {
    return t.intersectsPlane(this);
  }
  coplanarPoint(t) {
    return t.copy(this.normal).multiplyScalar(-this.constant);
  }
  applyMatrix4(t, e) {
    const r = e || IC.getNormalMatrix(t), a = this.coplanarPoint(wm).applyMatrix4(t), o = this.normal.applyMatrix3(r).normalize();
    return this.constant = -a.dot(o), this;
  }
  translate(t) {
    return this.constant -= t.dot(this.normal), this;
  }
  equals(t) {
    return t.normal.equals(this.normal) && t.constant === this.constant;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const ga = /* @__PURE__ */ new Ws(), Df = /* @__PURE__ */ new ot();
class T0 {
  constructor(t = new Bs(), e = new Bs(), r = new Bs(), a = new Bs(), o = new Bs(), c = new Bs()) {
    this.planes = [t, e, r, a, o, c];
  }
  set(t, e, r, a, o, c) {
    const u = this.planes;
    return u[0].copy(t), u[1].copy(e), u[2].copy(r), u[3].copy(a), u[4].copy(o), u[5].copy(c), this;
  }
  copy(t) {
    const e = this.planes;
    for (let r = 0; r < 6; r++)
      e[r].copy(t.planes[r]);
    return this;
  }
  setFromProjectionMatrix(t, e = Zr) {
    const r = this.planes, a = t.elements, o = a[0], c = a[1], u = a[2], d = a[3], h = a[4], p = a[5], m = a[6], g = a[7], _ = a[8], b = a[9], E = a[10], S = a[11], y = a[12], A = a[13], w = a[14], M = a[15];
    if (r[0].setComponents(d - o, g - h, S - _, M - y).normalize(), r[1].setComponents(d + o, g + h, S + _, M + y).normalize(), r[2].setComponents(d + c, g + p, S + b, M + A).normalize(), r[3].setComponents(d - c, g - p, S - b, M - A).normalize(), r[4].setComponents(d - u, g - m, S - E, M - w).normalize(), e === Zr)
      r[5].setComponents(d + u, g + m, S + E, M + w).normalize();
    else if (e === pd)
      r[5].setComponents(u, m, E, w).normalize();
    else
      throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + e);
    return this;
  }
  intersectsObject(t) {
    if (t.boundingSphere !== void 0)
      t.boundingSphere === null && t.computeBoundingSphere(), ga.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);
    else {
      const e = t.geometry;
      e.boundingSphere === null && e.computeBoundingSphere(), ga.copy(e.boundingSphere).applyMatrix4(t.matrixWorld);
    }
    return this.intersectsSphere(ga);
  }
  intersectsSprite(t) {
    return ga.center.set(0, 0, 0), ga.radius = 0.7071067811865476, ga.applyMatrix4(t.matrixWorld), this.intersectsSphere(ga);
  }
  intersectsSphere(t) {
    const e = this.planes, r = t.center, a = -t.radius;
    for (let o = 0; o < 6; o++)
      if (e[o].distanceToPoint(r) < a)
        return !1;
    return !0;
  }
  intersectsBox(t) {
    const e = this.planes;
    for (let r = 0; r < 6; r++) {
      const a = e[r];
      if (Df.x = a.normal.x > 0 ? t.max.x : t.min.x, Df.y = a.normal.y > 0 ? t.max.y : t.min.y, Df.z = a.normal.z > 0 ? t.max.z : t.min.z, a.distanceToPoint(Df) < 0)
        return !1;
    }
    return !0;
  }
  containsPoint(t) {
    const e = this.planes;
    for (let r = 0; r < 6; r++)
      if (e[r].distanceToPoint(t) < 0)
        return !1;
    return !0;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Ld extends Ba {
  constructor(t) {
    super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new Me(16777215), this.map = null, this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.fog = !0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.color.copy(t.color), this.map = t.map, this.linewidth = t.linewidth, this.linecap = t.linecap, this.linejoin = t.linejoin, this.fog = t.fog, this;
  }
}
const gd = /* @__PURE__ */ new ot(), vd = /* @__PURE__ */ new ot(), xS = /* @__PURE__ */ new Ge(), mc = /* @__PURE__ */ new E0(), Nf = /* @__PURE__ */ new Ws(), Tm = /* @__PURE__ */ new ot(), SS = /* @__PURE__ */ new ot();
class Dc extends bn {
  constructor(t = new qn(), e = new Ld()) {
    super(), this.isLine = !0, this.type = "Line", this.geometry = t, this.material = e, this.updateMorphTargets();
  }
  copy(t, e) {
    return super.copy(t, e), this.material = Array.isArray(t.material) ? t.material.slice() : t.material, this.geometry = t.geometry, this;
  }
  computeLineDistances() {
    const t = this.geometry;
    if (t.index === null) {
      const e = t.attributes.position, r = [0];
      for (let a = 1, o = e.count; a < o; a++)
        gd.fromBufferAttribute(e, a - 1), vd.fromBufferAttribute(e, a), r[a] = r[a - 1], r[a] += gd.distanceTo(vd);
      t.setAttribute("lineDistance", new Nn(r, 1));
    } else
      console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
  raycast(t, e) {
    const r = this.geometry, a = this.matrixWorld, o = t.params.Line.threshold, c = r.drawRange;
    if (r.boundingSphere === null && r.computeBoundingSphere(), Nf.copy(r.boundingSphere), Nf.applyMatrix4(a), Nf.radius += o, t.ray.intersectsSphere(Nf) === !1) return;
    xS.copy(a).invert(), mc.copy(t.ray).applyMatrix4(xS);
    const u = o / ((this.scale.x + this.scale.y + this.scale.z) / 3), d = u * u, h = this.isLineSegments ? 2 : 1, p = r.index, g = r.attributes.position;
    if (p !== null) {
      const _ = Math.max(0, c.start), b = Math.min(p.count, c.start + c.count);
      for (let E = _, S = b - 1; E < S; E += h) {
        const y = p.getX(E), A = p.getX(E + 1), w = Lf(this, t, mc, d, y, A);
        w && e.push(w);
      }
      if (this.isLineLoop) {
        const E = p.getX(b - 1), S = p.getX(_), y = Lf(this, t, mc, d, E, S);
        y && e.push(y);
      }
    } else {
      const _ = Math.max(0, c.start), b = Math.min(g.count, c.start + c.count);
      for (let E = _, S = b - 1; E < S; E += h) {
        const y = Lf(this, t, mc, d, E, E + 1);
        y && e.push(y);
      }
      if (this.isLineLoop) {
        const E = Lf(this, t, mc, d, b - 1, _);
        E && e.push(E);
      }
    }
  }
  updateMorphTargets() {
    const e = this.geometry.morphAttributes, r = Object.keys(e);
    if (r.length > 0) {
      const a = e[r[0]];
      if (a !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let o = 0, c = a.length; o < c; o++) {
          const u = a[o].name || String(o);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[u] = o;
        }
      }
    }
  }
}
function Lf(n, t, e, r, a, o) {
  const c = n.geometry.attributes.position;
  if (gd.fromBufferAttribute(c, a), vd.fromBufferAttribute(c, o), e.distanceSqToSegment(gd, vd, Tm, SS) > r) return;
  Tm.applyMatrix4(n.matrixWorld);
  const d = t.ray.origin.distanceTo(Tm);
  if (!(d < t.near || d > t.far))
    return {
      distance: d,
      // What do we want? intersection point on the ray or on the segment??
      // point: raycaster.ray.at( distance ),
      point: SS.clone().applyMatrix4(n.matrixWorld),
      index: a,
      face: null,
      faceIndex: null,
      barycoord: null,
      object: n
    };
}
const bS = /* @__PURE__ */ new ot(), MS = /* @__PURE__ */ new ot();
class BC extends Dc {
  constructor(t, e) {
    super(t, e), this.isLineSegments = !0, this.type = "LineSegments";
  }
  computeLineDistances() {
    const t = this.geometry;
    if (t.index === null) {
      const e = t.attributes.position, r = [];
      for (let a = 0, o = e.count; a < o; a += 2)
        bS.fromBufferAttribute(e, a), MS.fromBufferAttribute(e, a + 1), r[a] = a === 0 ? 0 : r[a - 1], r[a + 1] = r[a] + bS.distanceTo(MS);
      t.setAttribute("lineDistance", new Nn(r, 1));
    } else
      console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
}
class Vs extends bn {
  constructor() {
    super(), this.isGroup = !0, this.type = "Group";
  }
}
class FC extends Jn {
  constructor(t, e, r, a, o, c, u, d, h) {
    super(t, e, r, a, o, c, u, d, h), this.isCanvasTexture = !0, this.needsUpdate = !0;
  }
}
class RM extends Jn {
  constructor(t, e, r, a, o, c, u, d, h, p = $o) {
    if (p !== $o && p !== rl)
      throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
    r === void 0 && p === $o && (r = Na), r === void 0 && p === rl && (r = il), super(null, a, o, c, u, d, p, r, h), this.isDepthTexture = !0, this.image = { width: t, height: e }, this.magFilter = u !== void 0 ? u : Yn, this.minFilter = d !== void 0 ? d : Yn, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
  }
  copy(t) {
    return super.copy(t), this.compareFunction = t.compareFunction, this;
  }
  toJSON(t) {
    const e = super.toJSON(t);
    return this.compareFunction !== null && (e.compareFunction = this.compareFunction), e;
  }
}
class Wc extends qn {
  constructor(t = 1, e = 1, r = 1, a = 32, o = 1, c = !1, u = 0, d = Math.PI * 2) {
    super(), this.type = "CylinderGeometry", this.parameters = {
      radiusTop: t,
      radiusBottom: e,
      height: r,
      radialSegments: a,
      heightSegments: o,
      openEnded: c,
      thetaStart: u,
      thetaLength: d
    };
    const h = this;
    a = Math.floor(a), o = Math.floor(o);
    const p = [], m = [], g = [], _ = [];
    let b = 0;
    const E = [], S = r / 2;
    let y = 0;
    A(), c === !1 && (t > 0 && w(!0), e > 0 && w(!1)), this.setIndex(p), this.setAttribute("position", new Nn(m, 3)), this.setAttribute("normal", new Nn(g, 3)), this.setAttribute("uv", new Nn(_, 2));
    function A() {
      const M = new ot(), O = new ot();
      let L = 0;
      const N = (e - t) / r;
      for (let z = 0; z <= o; z++) {
        const R = [], T = z / o, U = T * (e - t) + t;
        for (let B = 0; B <= a; B++) {
          const I = B / a, C = I * d + u, X = Math.sin(C), D = Math.cos(C);
          O.x = U * X, O.y = -T * r + S, O.z = U * D, m.push(O.x, O.y, O.z), M.set(X, N, D).normalize(), g.push(M.x, M.y, M.z), _.push(I, 1 - T), R.push(b++);
        }
        E.push(R);
      }
      for (let z = 0; z < a; z++)
        for (let R = 0; R < o; R++) {
          const T = E[R][z], U = E[R + 1][z], B = E[R + 1][z + 1], I = E[R][z + 1];
          (t > 0 || R !== 0) && (p.push(T, U, I), L += 3), (e > 0 || R !== o - 1) && (p.push(U, B, I), L += 3);
        }
      h.addGroup(y, L, 0), y += L;
    }
    function w(M) {
      const O = b, L = new oe(), N = new ot();
      let z = 0;
      const R = M === !0 ? t : e, T = M === !0 ? 1 : -1;
      for (let B = 1; B <= a; B++)
        m.push(0, S * T, 0), g.push(0, T, 0), _.push(0.5, 0.5), b++;
      const U = b;
      for (let B = 0; B <= a; B++) {
        const C = B / a * d + u, X = Math.cos(C), D = Math.sin(C);
        N.x = R * D, N.y = S * T, N.z = R * X, m.push(N.x, N.y, N.z), g.push(0, T, 0), L.x = X * 0.5 + 0.5, L.y = D * 0.5 * T + 0.5, _.push(L.x, L.y), b++;
      }
      for (let B = 0; B < a; B++) {
        const I = O + B, C = U + B;
        M === !0 ? p.push(C, C + 1, I) : p.push(C + 1, C, I), z += 3;
      }
      h.addGroup(y, z, M === !0 ? 1 : 2), y += z;
    }
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new Wc(t.radiusTop, t.radiusBottom, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength);
  }
}
class A0 extends Wc {
  constructor(t = 1, e = 1, r = 32, a = 1, o = !1, c = 0, u = Math.PI * 2) {
    super(0, t, e, r, a, o, c, u), this.type = "ConeGeometry", this.parameters = {
      radius: t,
      height: e,
      radialSegments: r,
      heightSegments: a,
      openEnded: o,
      thetaStart: c,
      thetaLength: u
    };
  }
  static fromJSON(t) {
    return new A0(t.radius, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength);
  }
}
class Ud extends qn {
  constructor(t = 1, e = 1, r = 1, a = 1) {
    super(), this.type = "PlaneGeometry", this.parameters = {
      width: t,
      height: e,
      widthSegments: r,
      heightSegments: a
    };
    const o = t / 2, c = e / 2, u = Math.floor(r), d = Math.floor(a), h = u + 1, p = d + 1, m = t / u, g = e / d, _ = [], b = [], E = [], S = [];
    for (let y = 0; y < p; y++) {
      const A = y * g - c;
      for (let w = 0; w < h; w++) {
        const M = w * m - o;
        b.push(M, -A, 0), E.push(0, 0, 1), S.push(w / u), S.push(1 - y / d);
      }
    }
    for (let y = 0; y < d; y++)
      for (let A = 0; A < u; A++) {
        const w = A + h * y, M = A + h * (y + 1), O = A + 1 + h * (y + 1), L = A + 1 + h * y;
        _.push(w, M, L), _.push(M, O, L);
      }
    this.setIndex(_), this.setAttribute("position", new Nn(b, 3)), this.setAttribute("normal", new Nn(E, 3)), this.setAttribute("uv", new Nn(S, 2));
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new Ud(t.width, t.height, t.widthSegments, t.heightSegments);
  }
}
class C0 extends qn {
  constructor(t = 1, e = 32, r = 16, a = 0, o = Math.PI * 2, c = 0, u = Math.PI) {
    super(), this.type = "SphereGeometry", this.parameters = {
      radius: t,
      widthSegments: e,
      heightSegments: r,
      phiStart: a,
      phiLength: o,
      thetaStart: c,
      thetaLength: u
    }, e = Math.max(3, Math.floor(e)), r = Math.max(2, Math.floor(r));
    const d = Math.min(c + u, Math.PI);
    let h = 0;
    const p = [], m = new ot(), g = new ot(), _ = [], b = [], E = [], S = [];
    for (let y = 0; y <= r; y++) {
      const A = [], w = y / r;
      let M = 0;
      y === 0 && c === 0 ? M = 0.5 / e : y === r && d === Math.PI && (M = -0.5 / e);
      for (let O = 0; O <= e; O++) {
        const L = O / e;
        m.x = -t * Math.cos(a + L * o) * Math.sin(c + w * u), m.y = t * Math.cos(c + w * u), m.z = t * Math.sin(a + L * o) * Math.sin(c + w * u), b.push(m.x, m.y, m.z), g.copy(m).normalize(), E.push(g.x, g.y, g.z), S.push(L + M, 1 - w), A.push(h++);
      }
      p.push(A);
    }
    for (let y = 0; y < r; y++)
      for (let A = 0; A < e; A++) {
        const w = p[y][A + 1], M = p[y][A], O = p[y + 1][A], L = p[y + 1][A + 1];
        (y !== 0 || c > 0) && _.push(w, M, L), (y !== r - 1 || d < Math.PI) && _.push(M, O, L);
      }
    this.setIndex(_), this.setAttribute("position", new Nn(b, 3)), this.setAttribute("normal", new Nn(E, 3)), this.setAttribute("uv", new Nn(S, 2));
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new C0(t.radius, t.widthSegments, t.heightSegments, t.phiStart, t.phiLength, t.thetaStart, t.thetaLength);
  }
}
class HC extends qn {
  constructor(t = null) {
    if (super(), this.type = "WireframeGeometry", this.parameters = {
      geometry: t
    }, t !== null) {
      const e = [], r = /* @__PURE__ */ new Set(), a = new ot(), o = new ot();
      if (t.index !== null) {
        const c = t.attributes.position, u = t.index;
        let d = t.groups;
        d.length === 0 && (d = [{ start: 0, count: u.count, materialIndex: 0 }]);
        for (let h = 0, p = d.length; h < p; ++h) {
          const m = d[h], g = m.start, _ = m.count;
          for (let b = g, E = g + _; b < E; b += 3)
            for (let S = 0; S < 3; S++) {
              const y = u.getX(b + S), A = u.getX(b + (S + 1) % 3);
              a.fromBufferAttribute(c, y), o.fromBufferAttribute(c, A), ES(a, o, r) === !0 && (e.push(a.x, a.y, a.z), e.push(o.x, o.y, o.z));
            }
        }
      } else {
        const c = t.attributes.position;
        for (let u = 0, d = c.count / 3; u < d; u++)
          for (let h = 0; h < 3; h++) {
            const p = 3 * u + h, m = 3 * u + (h + 1) % 3;
            a.fromBufferAttribute(c, p), o.fromBufferAttribute(c, m), ES(a, o, r) === !0 && (e.push(a.x, a.y, a.z), e.push(o.x, o.y, o.z));
          }
      }
      this.setAttribute("position", new Nn(e, 3));
    }
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
}
function ES(n, t, e) {
  const r = `${n.x},${n.y},${n.z}-${t.x},${t.y},${t.z}`, a = `${t.x},${t.y},${t.z}-${n.x},${n.y},${n.z}`;
  return e.has(r) === !0 || e.has(a) === !0 ? !1 : (e.add(r), e.add(a), !0);
}
class DM extends gr {
  constructor(t) {
    super(t), this.isRawShaderMaterial = !0, this.type = "RawShaderMaterial";
  }
}
class Yg extends Ba {
  constructor(t) {
    super(), this.isMeshPhongMaterial = !0, this.type = "MeshPhongMaterial", this.color = new Me(16777215), this.specular = new Me(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new Me(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = hM, this.normalScale = new oe(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new mr(), this.combine = m0, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.fog = !0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.color.copy(t.color), this.specular.copy(t.specular), this.shininess = t.shininess, this.map = t.map, this.lightMap = t.lightMap, this.lightMapIntensity = t.lightMapIntensity, this.aoMap = t.aoMap, this.aoMapIntensity = t.aoMapIntensity, this.emissive.copy(t.emissive), this.emissiveMap = t.emissiveMap, this.emissiveIntensity = t.emissiveIntensity, this.bumpMap = t.bumpMap, this.bumpScale = t.bumpScale, this.normalMap = t.normalMap, this.normalMapType = t.normalMapType, this.normalScale.copy(t.normalScale), this.displacementMap = t.displacementMap, this.displacementScale = t.displacementScale, this.displacementBias = t.displacementBias, this.specularMap = t.specularMap, this.alphaMap = t.alphaMap, this.envMap = t.envMap, this.envMapRotation.copy(t.envMapRotation), this.combine = t.combine, this.reflectivity = t.reflectivity, this.refractionRatio = t.refractionRatio, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.wireframeLinecap = t.wireframeLinecap, this.wireframeLinejoin = t.wireframeLinejoin, this.flatShading = t.flatShading, this.fog = t.fog, this;
  }
}
class VC extends Ba {
  constructor(t) {
    super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = B2, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.depthPacking = t.depthPacking, this.map = t.map, this.alphaMap = t.alphaMap, this.displacementMap = t.displacementMap, this.displacementScale = t.displacementScale, this.displacementBias = t.displacementBias, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this;
  }
}
class kC extends Ba {
  constructor(t) {
    super(), this.isMeshDistanceMaterial = !0, this.type = "MeshDistanceMaterial", this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.map = t.map, this.alphaMap = t.alphaMap, this.displacementMap = t.displacementMap, this.displacementScale = t.displacementScale, this.displacementBias = t.displacementBias, this;
  }
}
class R0 extends bn {
  constructor(t, e = 1) {
    super(), this.isLight = !0, this.type = "Light", this.color = new Me(t), this.intensity = e;
  }
  dispose() {
  }
  copy(t, e) {
    return super.copy(t, e), this.color.copy(t.color), this.intensity = t.intensity, this;
  }
  toJSON(t) {
    const e = super.toJSON(t);
    return e.object.color = this.color.getHex(), e.object.intensity = this.intensity, this.groundColor !== void 0 && (e.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (e.object.distance = this.distance), this.angle !== void 0 && (e.object.angle = this.angle), this.decay !== void 0 && (e.object.decay = this.decay), this.penumbra !== void 0 && (e.object.penumbra = this.penumbra), this.shadow !== void 0 && (e.object.shadow = this.shadow.toJSON()), this.target !== void 0 && (e.object.target = this.target.uuid), e;
  }
}
class GC extends R0 {
  constructor(t, e, r) {
    super(t, r), this.isHemisphereLight = !0, this.type = "HemisphereLight", this.position.copy(bn.DEFAULT_UP), this.updateMatrix(), this.groundColor = new Me(e);
  }
  copy(t, e) {
    return super.copy(t, e), this.groundColor.copy(t.groundColor), this;
  }
}
const Am = /* @__PURE__ */ new Ge(), wS = /* @__PURE__ */ new ot(), TS = /* @__PURE__ */ new ot();
class XC {
  constructor(t) {
    this.camera = t, this.intensity = 1, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new oe(512, 512), this.map = null, this.mapPass = null, this.matrix = new Ge(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new T0(), this._frameExtents = new oe(1, 1), this._viewportCount = 1, this._viewports = [
      new Ke(0, 0, 1, 1)
    ];
  }
  getViewportCount() {
    return this._viewportCount;
  }
  getFrustum() {
    return this._frustum;
  }
  updateMatrices(t) {
    const e = this.camera, r = this.matrix;
    wS.setFromMatrixPosition(t.matrixWorld), e.position.copy(wS), TS.setFromMatrixPosition(t.target.matrixWorld), e.lookAt(TS), e.updateMatrixWorld(), Am.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), this._frustum.setFromProjectionMatrix(Am), r.set(
      0.5,
      0,
      0,
      0.5,
      0,
      0.5,
      0,
      0.5,
      0,
      0,
      0.5,
      0.5,
      0,
      0,
      0,
      1
    ), r.multiply(Am);
  }
  getViewport(t) {
    return this._viewports[t];
  }
  getFrameExtents() {
    return this._frameExtents;
  }
  dispose() {
    this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose();
  }
  copy(t) {
    return this.camera = t.camera.clone(), this.intensity = t.intensity, this.bias = t.bias, this.radius = t.radius, this.mapSize.copy(t.mapSize), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  toJSON() {
    const t = {};
    return this.intensity !== 1 && (t.intensity = this.intensity), this.bias !== 0 && (t.bias = this.bias), this.normalBias !== 0 && (t.normalBias = this.normalBias), this.radius !== 1 && (t.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (t.mapSize = this.mapSize.toArray()), t.camera = this.camera.toJSON(!1).object, delete t.camera.matrix, t;
  }
}
class $r extends EM {
  constructor(t = -1, e = 1, r = 1, a = -1, o = 0.1, c = 2e3) {
    super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = t, this.right = e, this.top = r, this.bottom = a, this.near = o, this.far = c, this.updateProjectionMatrix();
  }
  copy(t, e) {
    return super.copy(t, e), this.left = t.left, this.right = t.right, this.top = t.top, this.bottom = t.bottom, this.near = t.near, this.far = t.far, this.zoom = t.zoom, this.view = t.view === null ? null : Object.assign({}, t.view), this;
  }
  setViewOffset(t, e, r, a, o, c) {
    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 = t, this.view.fullHeight = e, this.view.offsetX = r, this.view.offsetY = a, this.view.width = o, this.view.height = c, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const t = (this.right - this.left) / (2 * this.zoom), e = (this.top - this.bottom) / (2 * this.zoom), r = (this.right + this.left) / 2, a = (this.top + this.bottom) / 2;
    let o = r - t, c = r + t, u = a + e, d = a - e;
    if (this.view !== null && this.view.enabled) {
      const h = (this.right - this.left) / this.view.fullWidth / this.zoom, p = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
      o += h * this.view.offsetX, c = o + h * this.view.width, u -= p * this.view.offsetY, d = u - p * this.view.height;
    }
    this.projectionMatrix.makeOrthographic(o, c, u, d, this.near, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(t) {
    const e = super.toJSON(t);
    return e.object.zoom = this.zoom, e.object.left = this.left, e.object.right = this.right, e.object.top = this.top, e.object.bottom = this.bottom, e.object.near = this.near, e.object.far = this.far, this.view !== null && (e.object.view = Object.assign({}, this.view)), e;
  }
}
class jC extends XC {
  constructor() {
    super(new $r(-5, 5, 5, -5, 0.5, 500)), this.isDirectionalLightShadow = !0;
  }
}
class rd extends R0 {
  constructor(t, e) {
    super(t, e), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(bn.DEFAULT_UP), this.updateMatrix(), this.target = new bn(), this.shadow = new jC();
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(t) {
    return super.copy(t), this.target = t.target.clone(), this.shadow = t.shadow.clone(), this;
  }
}
class WC extends R0 {
  constructor(t, e) {
    super(t, e), this.isAmbientLight = !0, this.type = "AmbientLight";
  }
}
class D0 extends qn {
  constructor() {
    super(), this.isInstancedBufferGeometry = !0, this.type = "InstancedBufferGeometry", this.instanceCount = 1 / 0;
  }
  copy(t) {
    return super.copy(t), this.instanceCount = t.instanceCount, this;
  }
  toJSON() {
    const t = super.toJSON();
    return t.instanceCount = this.instanceCount, t.isInstancedBufferGeometry = !0, t;
  }
}
class YC extends Ti {
  constructor(t = []) {
    super(), this.isArrayCamera = !0, this.cameras = t;
  }
}
class qg extends AM {
  constructor(t, e, r = 1) {
    super(t, e), this.isInstancedInterleavedBuffer = !0, this.meshPerAttribute = r;
  }
  copy(t) {
    return super.copy(t), this.meshPerAttribute = t.meshPerAttribute, this;
  }
  clone(t) {
    const e = super.clone(t);
    return e.meshPerAttribute = this.meshPerAttribute, e;
  }
  toJSON(t) {
    const e = super.toJSON(t);
    return e.isInstancedInterleavedBuffer = !0, e.meshPerAttribute = this.meshPerAttribute, e;
  }
}
class AS {
  constructor(t = 1, e = 0, r = 0) {
    return this.radius = t, this.phi = e, this.theta = r, this;
  }
  set(t, e, r) {
    return this.radius = t, this.phi = e, this.theta = r, this;
  }
  copy(t) {
    return this.radius = t.radius, this.phi = t.phi, this.theta = t.theta, this;
  }
  // restrict phi to be between EPS and PI-EPS
  makeSafe() {
    return this.phi = be(this.phi, 1e-6, Math.PI - 1e-6), this;
  }
  setFromVector3(t) {
    return this.setFromCartesianCoords(t.x, t.y, t.z);
  }
  setFromCartesianCoords(t, e, r) {
    return this.radius = Math.sqrt(t * t + e * e + r * r), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(t, r), this.phi = Math.acos(be(e / this.radius, -1, 1))), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const CS = /* @__PURE__ */ new ot(), Uf = /* @__PURE__ */ new ot();
class qC {
  constructor(t = new ot(), e = new ot()) {
    this.start = t, this.end = e;
  }
  set(t, e) {
    return this.start.copy(t), this.end.copy(e), this;
  }
  copy(t) {
    return this.start.copy(t.start), this.end.copy(t.end), this;
  }
  getCenter(t) {
    return t.addVectors(this.start, this.end).multiplyScalar(0.5);
  }
  delta(t) {
    return t.subVectors(this.end, this.start);
  }
  distanceSq() {
    return this.start.distanceToSquared(this.end);
  }
  distance() {
    return this.start.distanceTo(this.end);
  }
  at(t, e) {
    return this.delta(e).multiplyScalar(t).add(this.start);
  }
  closestPointToPointParameter(t, e) {
    CS.subVectors(t, this.start), Uf.subVectors(this.end, this.start);
    const r = Uf.dot(Uf);
    let o = Uf.dot(CS) / r;
    return e && (o = be(o, 0, 1)), o;
  }
  closestPointToPoint(t, e, r) {
    const a = this.closestPointToPointParameter(t, e);
    return this.delta(r).multiplyScalar(a).add(this.start);
  }
  applyMatrix4(t) {
    return this.start.applyMatrix4(t), this.end.applyMatrix4(t), this;
  }
  equals(t) {
    return t.start.equals(this.start) && t.end.equals(this.end);
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const RS = /* @__PURE__ */ new ot();
let Of, Cm;
class ZC extends bn {
  // dir is assumed to be normalized
  constructor(t = new ot(0, 0, 1), e = new ot(0, 0, 0), r = 1, a = 16776960, o = r * 0.2, c = o * 0.2) {
    super(), this.type = "ArrowHelper", Of === void 0 && (Of = new qn(), Of.setAttribute("position", new Nn([0, 0, 0, 0, 1, 0], 3)), Cm = new Wc(0, 0.5, 1, 5, 1), Cm.translate(0, -0.5, 0)), this.position.copy(e), this.line = new Dc(Of, new Ld({ color: a, toneMapped: !1 })), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new Dn(Cm, new Nd({ color: a, toneMapped: !1 })), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(t), this.setLength(r, o, c);
  }
  setDirection(t) {
    if (t.y > 0.99999)
      this.quaternion.set(0, 0, 0, 1);
    else if (t.y < -0.99999)
      this.quaternion.set(1, 0, 0, 0);
    else {
      RS.set(t.z, 0, -t.x).normalize();
      const e = Math.acos(t.y);
      this.quaternion.setFromAxisAngle(RS, e);
    }
  }
  setLength(t, e = t * 0.2, r = e * 0.2) {
    this.line.scale.set(1, Math.max(1e-4, t - e), 1), this.line.updateMatrix(), this.cone.scale.set(r, e, r), this.cone.position.y = t, this.cone.updateMatrix();
  }
  setColor(t) {
    this.line.material.color.set(t), this.cone.material.color.set(t);
  }
  copy(t) {
    return super.copy(t, !1), this.line.copy(t.line), this.cone.copy(t.cone), this;
  }
  dispose() {
    this.line.geometry.dispose(), this.line.material.dispose(), this.cone.geometry.dispose(), this.cone.material.dispose();
  }
}
let $C = class extends Ia {
  constructor(t, e = null) {
    super(), this.object = t, this.domElement = e, 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() {
  }
};
function DS(n, t, e, r) {
  const a = KC(r);
  switch (e) {
    // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
    case oM:
      return n * t;
    case cM:
      return n * t;
    case uM:
      return n * t * 2;
    case y0:
      return n * t / a.components * a.byteLength;
    case x0:
      return n * t / a.components * a.byteLength;
    case fM:
      return n * t * 2 / a.components * a.byteLength;
    case S0:
      return n * t * 2 / a.components * a.byteLength;
    case lM:
      return n * t * 3 / a.components * a.byteLength;
    case Ci:
      return n * t * 4 / a.components * a.byteLength;
    case b0:
      return n * t * 4 / a.components * a.byteLength;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
    case Jf:
    case td:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 8;
    case ed:
    case nd:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
    case xg:
    case bg:
      return Math.max(n, 16) * Math.max(t, 8) / 4;
    case yg:
    case Sg:
      return Math.max(n, 8) * Math.max(t, 8) / 2;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
    case Mg:
    case Eg:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 8;
    case wg:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
    case Tg:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    case Ag:
      return Math.floor((n + 4) / 5) * Math.floor((t + 3) / 4) * 16;
    case Cg:
      return Math.floor((n + 4) / 5) * Math.floor((t + 4) / 5) * 16;
    case Rg:
      return Math.floor((n + 5) / 6) * Math.floor((t + 4) / 5) * 16;
    case Dg:
      return Math.floor((n + 5) / 6) * Math.floor((t + 5) / 6) * 16;
    case Ng:
      return Math.floor((n + 7) / 8) * Math.floor((t + 4) / 5) * 16;
    case Lg:
      return Math.floor((n + 7) / 8) * Math.floor((t + 5) / 6) * 16;
    case Ug:
      return Math.floor((n + 7) / 8) * Math.floor((t + 7) / 8) * 16;
    case Og:
      return Math.floor((n + 9) / 10) * Math.floor((t + 4) / 5) * 16;
    case Pg:
      return Math.floor((n + 9) / 10) * Math.floor((t + 5) / 6) * 16;
    case zg:
      return Math.floor((n + 9) / 10) * Math.floor((t + 7) / 8) * 16;
    case Ig:
      return Math.floor((n + 9) / 10) * Math.floor((t + 9) / 10) * 16;
    case Bg:
      return Math.floor((n + 11) / 12) * Math.floor((t + 9) / 10) * 16;
    case Fg:
      return Math.floor((n + 11) / 12) * Math.floor((t + 11) / 12) * 16;
    // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
    case id:
    case Hg:
    case Vg:
      return Math.ceil(n / 4) * Math.ceil(t / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
    case dM:
    case kg:
      return Math.ceil(n / 4) * Math.ceil(t / 4) * 8;
    case Gg:
    case Xg:
      return Math.ceil(n / 4) * Math.ceil(t / 4) * 16;
  }
  throw new Error(
    `Unable to determine texture byte length for ${e} format.`
  );
}
function KC(n) {
  switch (n) {
    case es:
    case rM:
      return { byteLength: 1, components: 1 };
    case Cc:
    case sM:
    case Xc:
      return { byteLength: 2, components: 1 };
    case v0:
    case _0:
      return { byteLength: 2, components: 4 };
    case Na:
    case g0:
    case Gi:
      return { byteLength: 4, components: 1 };
    case aM:
      return { byteLength: 4, components: 3 };
  }
  throw new Error(`Unknown texture type ${n}.`);
}
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  revision: p0
} }));
typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = p0);
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
function NM() {
  let n = null, t = !1, e = null, r = null;
  function a(o, c) {
    e(o, c), r = n.requestAnimationFrame(a);
  }
  return {
    start: function() {
      t !== !0 && e !== null && (r = n.requestAnimationFrame(a), t = !0);
    },
    stop: function() {
      n.cancelAnimationFrame(r), t = !1;
    },
    setAnimationLoop: function(o) {
      e = o;
    },
    setContext: function(o) {
      n = o;
    }
  };
}
function QC(n) {
  const t = /* @__PURE__ */ new WeakMap();
  function e(u, d) {
    const h = u.array, p = u.usage, m = h.byteLength, g = n.createBuffer();
    n.bindBuffer(d, g), n.bufferData(d, h, p), u.onUploadCallback();
    let _;
    if (h instanceof Float32Array)
      _ = n.FLOAT;
    else if (h instanceof Uint16Array)
      u.isFloat16BufferAttribute ? _ = n.HALF_FLOAT : _ = n.UNSIGNED_SHORT;
    else if (h instanceof Int16Array)
      _ = n.SHORT;
    else if (h instanceof Uint32Array)
      _ = n.UNSIGNED_INT;
    else if (h instanceof Int32Array)
      _ = n.INT;
    else if (h instanceof Int8Array)
      _ = n.BYTE;
    else if (h instanceof Uint8Array)
      _ = n.UNSIGNED_BYTE;
    else if (h instanceof Uint8ClampedArray)
      _ = n.UNSIGNED_BYTE;
    else
      throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + h);
    return {
      buffer: g,
      type: _,
      bytesPerElement: h.BYTES_PER_ELEMENT,
      version: u.version,
      size: m
    };
  }
  function r(u, d, h) {
    const p = d.array, m = d.updateRanges;
    if (n.bindBuffer(h, u), m.length === 0)
      n.bufferSubData(h, 0, p);
    else {
      m.sort((_, b) => _.start - b.start);
      let g = 0;
      for (let _ = 1; _ < m.length; _++) {
        const b = m[g], E = m[_];
        E.start <= b.start + b.count + 1 ? b.count = Math.max(
          b.count,
          E.start + E.count - b.start
        ) : (++g, m[g] = E);
      }
      m.length = g + 1;
      for (let _ = 0, b = m.length; _ < b; _++) {
        const E = m[_];
        n.bufferSubData(
          h,
          E.start * p.BYTES_PER_ELEMENT,
          p,
          E.start,
          E.count
        );
      }
      d.clearUpdateRanges();
    }
    d.onUploadCallback();
  }
  function a(u) {
    return u.isInterleavedBufferAttribute && (u = u.data), t.get(u);
  }
  function o(u) {
    u.isInterleavedBufferAttribute && (u = u.data);
    const d = t.get(u);
    d && (n.deleteBuffer(d.buffer), t.delete(u));
  }
  function c(u, d) {
    if (u.isInterleavedBufferAttribute && (u = u.data), u.isGLBufferAttribute) {
      const p = t.get(u);
      (!p || p.version < u.version) && t.set(u, {
        buffer: u.buffer,
        type: u.type,
        bytesPerElement: u.elementSize,
        version: u.version
      });
      return;
    }
    const h = t.get(u);
    if (h === void 0)
      t.set(u, e(u, d));
    else if (h.version < u.version) {
      if (h.size !== u.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.");
      r(h.buffer, u, d), h.version = u.version;
    }
  }
  return {
    get: a,
    remove: o,
    update: c
  };
}
var JC = `#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`, tR = `#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`, eR = `#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`, nR = `#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, iR = `#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`, rR = `#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`, sR = `#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`, aR = `#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`, oR = `#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`, lR = `#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`, cR = `vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`, uR = `vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`, fR = `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`, dR = `#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`, hR = `#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`, pR = `#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`, mR = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`, gR = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`, vR = `#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`, _R = `#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`, yR = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`, xR = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`, SR = `#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`, bR = `#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`, MR = `#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`, ER = `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`, wR = `#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`, TR = `#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`, AR = `#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`, CR = `#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`, RR = "gl_FragColor = linearToOutputTexel( gl_FragColor );", DR = `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 );
}`, NR = `#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`, LR = `#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`, UR = `#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`, OR = `#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`, PR = `#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`, zR = `#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`, IR = `#ifdef USE_FOG
	varying float vFogDepth;
#endif`, BR = `#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`, FR = `#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`, HR = `#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
}`, VR = `#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`, kR = `LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`, GR = `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`, XR = `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`, jR = `#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`, WR = `ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`, YR = `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`, qR = `BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`, ZR = `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`, $R = `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`, KR = `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 );
}`, QR = `
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`, JR = `#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`, t3 = `#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`, e3 = `#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`, n3 = `#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, i3 = `#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, r3 = `#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`, s3 = `#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`, a3 = `#ifdef USE_MAP
	uniform sampler2D map;
#endif`, o3 = `#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`, l3 = `#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`, c3 = `float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`, u3 = `#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`, f3 = `#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`, d3 = `#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`, h3 = `#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`, p3 = `#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`, m3 = `#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`, g3 = `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;`, v3 = `#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`, _3 = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, y3 = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, x3 = `#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`, S3 = `#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`, b3 = `#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`, M3 = `#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`, E3 = `#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`, w3 = `#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`, T3 = `#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, A3 = `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 );
}`, C3 = `#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`, R3 = `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;`, D3 = `#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`, N3 = `#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`, L3 = `float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`, U3 = `#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`, O3 = `#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`, P3 = `#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`, z3 = `#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`, I3 = `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;
}`, B3 = `#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`, F3 = `#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`, H3 = `#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`, V3 = `#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`, k3 = `float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`, G3 = `#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`, X3 = `#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`, j3 = `#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; }`, W3 = `#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`, Y3 = `#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`, q3 = `#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`, Z3 = `#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`, $3 = `#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`, K3 = `#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 Q3 = `varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`, J3 = `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>
}`, tD = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, eD = `#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>
}`, nD = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, iD = `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>
}`, rD = `#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;
}`, sD = `#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
}`, aD = `#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;
}`, oD = `#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 );
}`, lD = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`, cD = `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>
}`, uD = `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>
}`, fD = `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>
}`, dD = `#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>
}`, hD = `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>
}`, pD = `#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>
}`, mD = `#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>
}`, gD = `#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;
}`, vD = `#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>
}`, _D = `#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
}`, yD = `#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
}`, xD = `#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>
}`, SD = `#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>
}`, bD = `#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
}`, MD = `#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>
}`, ED = `#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>
}`, wD = `#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>
}`, TD = `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>
}`, AD = `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>
}`, CD = `#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>
}`, RD = `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>
}`, DD = `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>
}`, ND = `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: JC,
  alphahash_pars_fragment: tR,
  alphamap_fragment: eR,
  alphamap_pars_fragment: nR,
  alphatest_fragment: iR,
  alphatest_pars_fragment: rR,
  aomap_fragment: sR,
  aomap_pars_fragment: aR,
  batching_pars_vertex: oR,
  batching_vertex: lR,
  begin_vertex: cR,
  beginnormal_vertex: uR,
  bsdfs: fR,
  iridescence_fragment: dR,
  bumpmap_pars_fragment: hR,
  clipping_planes_fragment: pR,
  clipping_planes_pars_fragment: mR,
  clipping_planes_pars_vertex: gR,
  clipping_planes_vertex: vR,
  color_fragment: _R,
  color_pars_fragment: yR,
  color_pars_vertex: xR,
  color_vertex: SR,
  common: bR,
  cube_uv_reflection_fragment: MR,
  defaultnormal_vertex: ER,
  displacementmap_pars_vertex: wR,
  displacementmap_vertex: TR,
  emissivemap_fragment: AR,
  emissivemap_pars_fragment: CR,
  colorspace_fragment: RR,
  colorspace_pars_fragment: DR,
  envmap_fragment: NR,
  envmap_common_pars_fragment: LR,
  envmap_pars_fragment: UR,
  envmap_pars_vertex: OR,
  envmap_physical_pars_fragment: jR,
  envmap_vertex: PR,
  fog_vertex: zR,
  fog_pars_vertex: IR,
  fog_fragment: BR,
  fog_pars_fragment: FR,
  gradientmap_pars_fragment: HR,
  lightmap_pars_fragment: VR,
  lights_lambert_fragment: kR,
  lights_lambert_pars_fragment: GR,
  lights_pars_begin: XR,
  lights_toon_fragment: WR,
  lights_toon_pars_fragment: YR,
  lights_phong_fragment: qR,
  lights_phong_pars_fragment: ZR,
  lights_physical_fragment: $R,
  lights_physical_pars_fragment: KR,
  lights_fragment_begin: QR,
  lights_fragment_maps: JR,
  lights_fragment_end: t3,
  logdepthbuf_fragment: e3,
  logdepthbuf_pars_fragment: n3,
  logdepthbuf_pars_vertex: i3,
  logdepthbuf_vertex: r3,
  map_fragment: s3,
  map_pars_fragment: a3,
  map_particle_fragment: o3,
  map_particle_pars_fragment: l3,
  metalnessmap_fragment: c3,
  metalnessmap_pars_fragment: u3,
  morphinstance_vertex: f3,
  morphcolor_vertex: d3,
  morphnormal_vertex: h3,
  morphtarget_pars_vertex: p3,
  morphtarget_vertex: m3,
  normal_fragment_begin: g3,
  normal_fragment_maps: v3,
  normal_pars_fragment: _3,
  normal_pars_vertex: y3,
  normal_vertex: x3,
  normalmap_pars_fragment: S3,
  clearcoat_normal_fragment_begin: b3,
  clearcoat_normal_fragment_maps: M3,
  clearcoat_pars_fragment: E3,
  iridescence_pars_fragment: w3,
  opaque_fragment: T3,
  packing: A3,
  premultiplied_alpha_fragment: C3,
  project_vertex: R3,
  dithering_fragment: D3,
  dithering_pars_fragment: N3,
  roughnessmap_fragment: L3,
  roughnessmap_pars_fragment: U3,
  shadowmap_pars_fragment: O3,
  shadowmap_pars_vertex: P3,
  shadowmap_vertex: z3,
  shadowmask_pars_fragment: I3,
  skinbase_vertex: B3,
  skinning_pars_vertex: F3,
  skinning_vertex: H3,
  skinnormal_vertex: V3,
  specularmap_fragment: k3,
  specularmap_pars_fragment: G3,
  tonemapping_fragment: X3,
  tonemapping_pars_fragment: j3,
  transmission_fragment: W3,
  transmission_pars_fragment: Y3,
  uv_pars_fragment: q3,
  uv_pars_vertex: Z3,
  uv_vertex: $3,
  worldpos_vertex: K3,
  background_vert: Q3,
  background_frag: J3,
  backgroundCube_vert: tD,
  backgroundCube_frag: eD,
  cube_vert: nD,
  cube_frag: iD,
  depth_vert: rD,
  depth_frag: sD,
  distanceRGBA_vert: aD,
  distanceRGBA_frag: oD,
  equirect_vert: lD,
  equirect_frag: cD,
  linedashed_vert: uD,
  linedashed_frag: fD,
  meshbasic_vert: dD,
  meshbasic_frag: hD,
  meshlambert_vert: pD,
  meshlambert_frag: mD,
  meshmatcap_vert: gD,
  meshmatcap_frag: vD,
  meshnormal_vert: _D,
  meshnormal_frag: yD,
  meshphong_vert: xD,
  meshphong_frag: SD,
  meshphysical_vert: bD,
  meshphysical_frag: MD,
  meshtoon_vert: ED,
  meshtoon_frag: wD,
  points_vert: TD,
  points_frag: AD,
  shadow_vert: CD,
  shadow_frag: RD,
  sprite_vert: DD,
  sprite_frag: ND
}, Bt = {
  common: {
    diffuse: { value: /* @__PURE__ */ new Me(16777215) },
    opacity: { value: 1 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new ve() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new ve() },
    alphaTest: { value: 0 }
  },
  specularmap: {
    specularMap: { value: null },
    specularMapTransform: { value: /* @__PURE__ */ new ve() }
  },
  envmap: {
    envMap: { value: null },
    envMapRotation: { value: /* @__PURE__ */ new ve() },
    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 ve() }
  },
  lightmap: {
    lightMap: { value: null },
    lightMapIntensity: { value: 1 },
    lightMapTransform: { value: /* @__PURE__ */ new ve() }
  },
  bumpmap: {
    bumpMap: { value: null },
    bumpMapTransform: { value: /* @__PURE__ */ new ve() },
    bumpScale: { value: 1 }
  },
  normalmap: {
    normalMap: { value: null },
    normalMapTransform: { value: /* @__PURE__ */ new ve() },
    normalScale: { value: /* @__PURE__ */ new oe(1, 1) }
  },
  displacementmap: {
    displacementMap: { value: null },
    displacementMapTransform: { value: /* @__PURE__ */ new ve() },
    displacementScale: { value: 1 },
    displacementBias: { value: 0 }
  },
  emissivemap: {
    emissiveMap: { value: null },
    emissiveMapTransform: { value: /* @__PURE__ */ new ve() }
  },
  metalnessmap: {
    metalnessMap: { value: null },
    metalnessMapTransform: { value: /* @__PURE__ */ new ve() }
  },
  roughnessmap: {
    roughnessMap: { value: null },
    roughnessMapTransform: { value: /* @__PURE__ */ new ve() }
  },
  gradientmap: {
    gradientMap: { value: null }
  },
  fog: {
    fogDensity: { value: 25e-5 },
    fogNear: { value: 1 },
    fogFar: { value: 2e3 },
    fogColor: { value: /* @__PURE__ */ new Me(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 Me(16777215) },
    opacity: { value: 1 },
    size: { value: 1 },
    scale: { value: 1 },
    map: { value: null },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new ve() },
    alphaTest: { value: 0 },
    uvTransform: { value: /* @__PURE__ */ new ve() }
  },
  sprite: {
    diffuse: { value: /* @__PURE__ */ new Me(16777215) },
    opacity: { value: 1 },
    center: { value: /* @__PURE__ */ new oe(0.5, 0.5) },
    rotation: { value: 0 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new ve() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new ve() },
    alphaTest: { value: 0 }
  }
}, di = {
  basic: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.specularmap,
      Bt.envmap,
      Bt.aomap,
      Bt.lightmap,
      Bt.fog
    ]),
    vertexShader: ye.meshbasic_vert,
    fragmentShader: ye.meshbasic_frag
  },
  lambert: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.specularmap,
      Bt.envmap,
      Bt.aomap,
      Bt.lightmap,
      Bt.emissivemap,
      Bt.bumpmap,
      Bt.normalmap,
      Bt.displacementmap,
      Bt.fog,
      Bt.lights,
      {
        emissive: { value: /* @__PURE__ */ new Me(0) }
      }
    ]),
    vertexShader: ye.meshlambert_vert,
    fragmentShader: ye.meshlambert_frag
  },
  phong: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.specularmap,
      Bt.envmap,
      Bt.aomap,
      Bt.lightmap,
      Bt.emissivemap,
      Bt.bumpmap,
      Bt.normalmap,
      Bt.displacementmap,
      Bt.fog,
      Bt.lights,
      {
        emissive: { value: /* @__PURE__ */ new Me(0) },
        specular: { value: /* @__PURE__ */ new Me(1118481) },
        shininess: { value: 30 }
      }
    ]),
    vertexShader: ye.meshphong_vert,
    fragmentShader: ye.meshphong_frag
  },
  standard: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.envmap,
      Bt.aomap,
      Bt.lightmap,
      Bt.emissivemap,
      Bt.bumpmap,
      Bt.normalmap,
      Bt.displacementmap,
      Bt.roughnessmap,
      Bt.metalnessmap,
      Bt.fog,
      Bt.lights,
      {
        emissive: { value: /* @__PURE__ */ new Me(0) },
        roughness: { value: 1 },
        metalness: { value: 0 },
        envMapIntensity: { value: 1 }
      }
    ]),
    vertexShader: ye.meshphysical_vert,
    fragmentShader: ye.meshphysical_frag
  },
  toon: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.aomap,
      Bt.lightmap,
      Bt.emissivemap,
      Bt.bumpmap,
      Bt.normalmap,
      Bt.displacementmap,
      Bt.gradientmap,
      Bt.fog,
      Bt.lights,
      {
        emissive: { value: /* @__PURE__ */ new Me(0) }
      }
    ]),
    vertexShader: ye.meshtoon_vert,
    fragmentShader: ye.meshtoon_frag
  },
  matcap: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.bumpmap,
      Bt.normalmap,
      Bt.displacementmap,
      Bt.fog,
      {
        matcap: { value: null }
      }
    ]),
    vertexShader: ye.meshmatcap_vert,
    fragmentShader: ye.meshmatcap_frag
  },
  points: {
    uniforms: /* @__PURE__ */ ni([
      Bt.points,
      Bt.fog
    ]),
    vertexShader: ye.points_vert,
    fragmentShader: ye.points_frag
  },
  dashed: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.fog,
      {
        scale: { value: 1 },
        dashSize: { value: 1 },
        totalSize: { value: 2 }
      }
    ]),
    vertexShader: ye.linedashed_vert,
    fragmentShader: ye.linedashed_frag
  },
  depth: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.displacementmap
    ]),
    vertexShader: ye.depth_vert,
    fragmentShader: ye.depth_frag
  },
  normal: {
    uniforms: /* @__PURE__ */ ni([
      Bt.common,
      Bt.bumpmap,
      Bt.normalmap,
      Bt.displacementmap,
      {
        opacity: { value: 1 }
      }
    ]),
    vertexShader: ye.meshnormal_vert,
    fragmentShader: ye.meshnormal_frag
  },
  sprite: {
    uniforms: /* @__PURE__ */ ni([
      Bt.sprite,
      Bt.fog
    ]),
    vertexShader: ye.sprite_vert,
    fragmentShader: ye.sprite_frag
  },
  background: {
    uniforms: {
      uvTransform: { value: /* @__PURE__ */ new ve() },
      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 ve() }
    },
    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__ */ ni([
      Bt.common,
      Bt.displacementmap,
      {
        referencePosition: { value: /* @__PURE__ */ new ot() },
        nearDistance: { value: 1 },
        farDistance: { value: 1e3 }
      }
    ]),
    vertexShader: ye.distanceRGBA_vert,
    fragmentShader: ye.distanceRGBA_frag
  },
  shadow: {
    uniforms: /* @__PURE__ */ ni([
      Bt.lights,
      Bt.fog,
      {
        color: { value: /* @__PURE__ */ new Me(0) },
        opacity: { value: 1 }
      }
    ]),
    vertexShader: ye.shadow_vert,
    fragmentShader: ye.shadow_frag
  }
};
di.physical = {
  uniforms: /* @__PURE__ */ ni([
    di.standard.uniforms,
    {
      clearcoat: { value: 0 },
      clearcoatMap: { value: null },
      clearcoatMapTransform: { value: /* @__PURE__ */ new ve() },
      clearcoatNormalMap: { value: null },
      clearcoatNormalMapTransform: { value: /* @__PURE__ */ new ve() },
      clearcoatNormalScale: { value: /* @__PURE__ */ new oe(1, 1) },
      clearcoatRoughness: { value: 0 },
      clearcoatRoughnessMap: { value: null },
      clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new ve() },
      dispersion: { value: 0 },
      iridescence: { value: 0 },
      iridescenceMap: { value: null },
      iridescenceMapTransform: { value: /* @__PURE__ */ new ve() },
      iridescenceIOR: { value: 1.3 },
      iridescenceThicknessMinimum: { value: 100 },
      iridescenceThicknessMaximum: { value: 400 },
      iridescenceThicknessMap: { value: null },
      iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new ve() },
      sheen: { value: 0 },
      sheenColor: { value: /* @__PURE__ */ new Me(0) },
      sheenColorMap: { value: null },
      sheenColorMapTransform: { value: /* @__PURE__ */ new ve() },
      sheenRoughness: { value: 1 },
      sheenRoughnessMap: { value: null },
      sheenRoughnessMapTransform: { value: /* @__PURE__ */ new ve() },
      transmission: { value: 0 },
      transmissionMap: { value: null },
      transmissionMapTransform: { value: /* @__PURE__ */ new ve() },
      transmissionSamplerSize: { value: /* @__PURE__ */ new oe() },
      transmissionSamplerMap: { value: null },
      thickness: { value: 0 },
      thicknessMap: { value: null },
      thicknessMapTransform: { value: /* @__PURE__ */ new ve() },
      attenuationDistance: { value: 0 },
      attenuationColor: { value: /* @__PURE__ */ new Me(0) },
      specularColor: { value: /* @__PURE__ */ new Me(1, 1, 1) },
      specularColorMap: { value: null },
      specularColorMapTransform: { value: /* @__PURE__ */ new ve() },
      specularIntensity: { value: 1 },
      specularIntensityMap: { value: null },
      specularIntensityMapTransform: { value: /* @__PURE__ */ new ve() },
      anisotropyVector: { value: /* @__PURE__ */ new oe() },
      anisotropyMap: { value: null },
      anisotropyMapTransform: { value: /* @__PURE__ */ new ve() }
    }
  ]),
  vertexShader: ye.meshphysical_vert,
  fragmentShader: ye.meshphysical_frag
};
const Pf = { r: 0, b: 0, g: 0 }, va = /* @__PURE__ */ new mr(), LD = /* @__PURE__ */ new Ge();
function UD(n, t, e, r, a, o, c) {
  const u = new Me(0);
  let d = o === !0 ? 0 : 1, h, p, m = null, g = 0, _ = null;
  function b(w) {
    let M = w.isScene === !0 ? w.background : null;
    return M && M.isTexture && (M = (w.backgroundBlurriness > 0 ? e : t).get(M)), M;
  }
  function E(w) {
    let M = !1;
    const O = b(w);
    O === null ? y(u, d) : O && O.isColor && (y(O, 1), M = !0);
    const L = n.xr.getEnvironmentBlendMode();
    L === "additive" ? r.buffers.color.setClear(0, 0, 0, 1, c) : L === "alpha-blend" && r.buffers.color.setClear(0, 0, 0, 0, c), (n.autoClear || M) && (r.buffers.depth.setTest(!0), r.buffers.depth.setMask(!0), r.buffers.color.setMask(!0), n.clear(n.autoClearColor, n.autoClearDepth, n.autoClearStencil));
  }
  function S(w, M) {
    const O = b(M);
    O && (O.isCubeTexture || O.mapping === Dd) ? (p === void 0 && (p = new Dn(
      new jc(1, 1, 1),
      new gr({
        name: "BackgroundCubeMaterial",
        uniforms: al(di.backgroundCube.uniforms),
        vertexShader: di.backgroundCube.vertexShader,
        fragmentShader: di.backgroundCube.fragmentShader,
        side: pi,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), p.geometry.deleteAttribute("normal"), p.geometry.deleteAttribute("uv"), p.onBeforeRender = function(L, N, z) {
      this.matrixWorld.copyPosition(z.matrixWorld);
    }, Object.defineProperty(p.material, "envMap", {
      get: function() {
        return this.uniforms.envMap.value;
      }
    }), a.update(p)), va.copy(M.backgroundRotation), va.x *= -1, va.y *= -1, va.z *= -1, O.isCubeTexture && O.isRenderTargetTexture === !1 && (va.y *= -1, va.z *= -1), p.material.uniforms.envMap.value = O, p.material.uniforms.flipEnvMap.value = O.isCubeTexture && O.isRenderTargetTexture === !1 ? -1 : 1, p.material.uniforms.backgroundBlurriness.value = M.backgroundBlurriness, p.material.uniforms.backgroundIntensity.value = M.backgroundIntensity, p.material.uniforms.backgroundRotation.value.setFromMatrix4(LD.makeRotationFromEuler(va)), p.material.toneMapped = Ie.getTransfer(O.colorSpace) !== qe, (m !== O || g !== O.version || _ !== n.toneMapping) && (p.material.needsUpdate = !0, m = O, g = O.version, _ = n.toneMapping), p.layers.enableAll(), w.unshift(p, p.geometry, p.material, 0, 0, null)) : O && O.isTexture && (h === void 0 && (h = new Dn(
      new Ud(2, 2),
      new gr({
        name: "BackgroundMaterial",
        uniforms: al(di.background.uniforms),
        vertexShader: di.background.vertexShader,
        fragmentShader: di.background.fragmentShader,
        side: Xs,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), h.geometry.deleteAttribute("normal"), Object.defineProperty(h.material, "map", {
      get: function() {
        return this.uniforms.t2D.value;
      }
    }), a.update(h)), h.material.uniforms.t2D.value = O, h.material.uniforms.backgroundIntensity.value = M.backgroundIntensity, h.material.toneMapped = Ie.getTransfer(O.colorSpace) !== qe, O.matrixAutoUpdate === !0 && O.updateMatrix(), h.material.uniforms.uvTransform.value.copy(O.matrix), (m !== O || g !== O.version || _ !== n.toneMapping) && (h.material.needsUpdate = !0, m = O, g = O.version, _ = n.toneMapping), h.layers.enableAll(), w.unshift(h, h.geometry, h.material, 0, 0, null));
  }
  function y(w, M) {
    w.getRGB(Pf, MM(n)), r.buffers.color.setClear(Pf.r, Pf.g, Pf.b, M, c);
  }
  function A() {
    p !== void 0 && (p.geometry.dispose(), p.material.dispose()), h !== void 0 && (h.geometry.dispose(), h.material.dispose());
  }
  return {
    getClearColor: function() {
      return u;
    },
    setClearColor: function(w, M = 1) {
      u.set(w), d = M, y(u, d);
    },
    getClearAlpha: function() {
      return d;
    },
    setClearAlpha: function(w) {
      d = w, y(u, d);
    },
    render: E,
    addToRenderList: S,
    dispose: A
  };
}
function OD(n, t) {
  const e = n.getParameter(n.MAX_VERTEX_ATTRIBS), r = {}, a = g(null);
  let o = a, c = !1;
  function u(T, U, B, I, C) {
    let X = !1;
    const D = m(I, B, U);
    o !== D && (o = D, h(o.object)), X = _(T, I, B, C), X && b(T, I, B, C), C !== null && t.update(C, n.ELEMENT_ARRAY_BUFFER), (X || c) && (c = !1, M(T, U, B, I), C !== null && n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, t.get(C).buffer));
  }
  function d() {
    return n.createVertexArray();
  }
  function h(T) {
    return n.bindVertexArray(T);
  }
  function p(T) {
    return n.deleteVertexArray(T);
  }
  function m(T, U, B) {
    const I = B.wireframe === !0;
    let C = r[T.id];
    C === void 0 && (C = {}, r[T.id] = C);
    let X = C[U.id];
    X === void 0 && (X = {}, C[U.id] = X);
    let D = X[I];
    return D === void 0 && (D = g(d()), X[I] = D), D;
  }
  function g(T) {
    const U = [], B = [], I = [];
    for (let C = 0; C < e; C++)
      U[C] = 0, B[C] = 0, I[C] = 0;
    return {
      // for backward compatibility on non-VAO support browser
      geometry: null,
      program: null,
      wireframe: !1,
      newAttributes: U,
      enabledAttributes: B,
      attributeDivisors: I,
      object: T,
      attributes: {},
      index: null
    };
  }
  function _(T, U, B, I) {
    const C = o.attributes, X = U.attributes;
    let D = 0;
    const V = B.getAttributes();
    for (const H in V)
      if (V[H].location >= 0) {
        const K = C[H];
        let F = X[H];
        if (F === void 0 && (H === "instanceMatrix" && T.instanceMatrix && (F = T.instanceMatrix), H === "instanceColor" && T.instanceColor && (F = T.instanceColor)), K === void 0 || K.attribute !== F || F && K.data !== F.data) return !0;
        D++;
      }
    return o.attributesNum !== D || o.index !== I;
  }
  function b(T, U, B, I) {
    const C = {}, X = U.attributes;
    let D = 0;
    const V = B.getAttributes();
    for (const H in V)
      if (V[H].location >= 0) {
        let K = X[H];
        K === void 0 && (H === "instanceMatrix" && T.instanceMatrix && (K = T.instanceMatrix), H === "instanceColor" && T.instanceColor && (K = T.instanceColor));
        const F = {};
        F.attribute = K, K && K.data && (F.data = K.data), C[H] = F, D++;
      }
    o.attributes = C, o.attributesNum = D, o.index = I;
  }
  function E() {
    const T = o.newAttributes;
    for (let U = 0, B = T.length; U < B; U++)
      T[U] = 0;
  }
  function S(T) {
    y(T, 0);
  }
  function y(T, U) {
    const B = o.newAttributes, I = o.enabledAttributes, C = o.attributeDivisors;
    B[T] = 1, I[T] === 0 && (n.enableVertexAttribArray(T), I[T] = 1), C[T] !== U && (n.vertexAttribDivisor(T, U), C[T] = U);
  }
  function A() {
    const T = o.newAttributes, U = o.enabledAttributes;
    for (let B = 0, I = U.length; B < I; B++)
      U[B] !== T[B] && (n.disableVertexAttribArray(B), U[B] = 0);
  }
  function w(T, U, B, I, C, X, D) {
    D === !0 ? n.vertexAttribIPointer(T, U, B, C, X) : n.vertexAttribPointer(T, U, B, I, C, X);
  }
  function M(T, U, B, I) {
    E();
    const C = I.attributes, X = B.getAttributes(), D = U.defaultAttributeValues;
    for (const V in X) {
      const H = X[V];
      if (H.location >= 0) {
        let j = C[V];
        if (j === void 0 && (V === "instanceMatrix" && T.instanceMatrix && (j = T.instanceMatrix), V === "instanceColor" && T.instanceColor && (j = T.instanceColor)), j !== void 0) {
          const K = j.normalized, F = j.itemSize, q = t.get(j);
          if (q === void 0) continue;
          const it = q.buffer, G = q.type, k = q.bytesPerElement, $ = G === n.INT || G === n.UNSIGNED_INT || j.gpuType === g0;
          if (j.isInterleavedBufferAttribute) {
            const Q = j.data, et = Q.stride, st = j.offset;
            if (Q.isInstancedInterleavedBuffer) {
              for (let _t = 0; _t < H.locationSize; _t++)
                y(H.location + _t, Q.meshPerAttribute);
              T.isInstancedMesh !== !0 && I._maxInstanceCount === void 0 && (I._maxInstanceCount = Q.meshPerAttribute * Q.count);
            } else
              for (let _t = 0; _t < H.locationSize; _t++)
                S(H.location + _t);
            n.bindBuffer(n.ARRAY_BUFFER, it);
            for (let _t = 0; _t < H.locationSize; _t++)
              w(
                H.location + _t,
                F / H.locationSize,
                G,
                K,
                et * k,
                (st + F / H.locationSize * _t) * k,
                $
              );
          } else {
            if (j.isInstancedBufferAttribute) {
              for (let Q = 0; Q < H.locationSize; Q++)
                y(H.location + Q, j.meshPerAttribute);
              T.isInstancedMesh !== !0 && I._maxInstanceCount === void 0 && (I._maxInstanceCount = j.meshPerAttribute * j.count);
            } else
              for (let Q = 0; Q < H.locationSize; Q++)
                S(H.location + Q);
            n.bindBuffer(n.ARRAY_BUFFER, it);
            for (let Q = 0; Q < H.locationSize; Q++)
              w(
                H.location + Q,
                F / H.locationSize,
                G,
                K,
                F * k,
                F / H.locationSize * Q * k,
                $
              );
          }
        } else if (D !== void 0) {
          const K = D[V];
          if (K !== void 0)
            switch (K.length) {
              case 2:
                n.vertexAttrib2fv(H.location, K);
                break;
              case 3:
                n.vertexAttrib3fv(H.location, K);
                break;
              case 4:
                n.vertexAttrib4fv(H.location, K);
                break;
              default:
                n.vertexAttrib1fv(H.location, K);
            }
        }
      }
    }
    A();
  }
  function O() {
    z();
    for (const T in r) {
      const U = r[T];
      for (const B in U) {
        const I = U[B];
        for (const C in I)
          p(I[C].object), delete I[C];
        delete U[B];
      }
      delete r[T];
    }
  }
  function L(T) {
    if (r[T.id] === void 0) return;
    const U = r[T.id];
    for (const B in U) {
      const I = U[B];
      for (const C in I)
        p(I[C].object), delete I[C];
      delete U[B];
    }
    delete r[T.id];
  }
  function N(T) {
    for (const U in r) {
      const B = r[U];
      if (B[T.id] === void 0) continue;
      const I = B[T.id];
      for (const C in I)
        p(I[C].object), delete I[C];
      delete B[T.id];
    }
  }
  function z() {
    R(), c = !0, o !== a && (o = a, h(o.object));
  }
  function R() {
    a.geometry = null, a.program = null, a.wireframe = !1;
  }
  return {
    setup: u,
    reset: z,
    resetDefaultState: R,
    dispose: O,
    releaseStatesOfGeometry: L,
    releaseStatesOfProgram: N,
    initAttributes: E,
    enableAttribute: S,
    disableUnusedAttributes: A
  };
}
function PD(n, t, e) {
  let r;
  function a(h) {
    r = h;
  }
  function o(h, p) {
    n.drawArrays(r, h, p), e.update(p, r, 1);
  }
  function c(h, p, m) {
    m !== 0 && (n.drawArraysInstanced(r, h, p, m), e.update(p, r, m));
  }
  function u(h, p, m) {
    if (m === 0) return;
    t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r, h, 0, p, 0, m);
    let _ = 0;
    for (let b = 0; b < m; b++)
      _ += p[b];
    e.update(_, r, 1);
  }
  function d(h, p, m, g) {
    if (m === 0) return;
    const _ = t.get("WEBGL_multi_draw");
    if (_ === null)
      for (let b = 0; b < h.length; b++)
        c(h[b], p[b], g[b]);
    else {
      _.multiDrawArraysInstancedWEBGL(r, h, 0, p, 0, g, 0, m);
      let b = 0;
      for (let E = 0; E < m; E++)
        b += p[E] * g[E];
      e.update(b, r, 1);
    }
  }
  this.setMode = a, this.render = o, this.renderInstances = c, this.renderMultiDraw = u, this.renderMultiDrawInstances = d;
}
function zD(n, t, e, r) {
  let a;
  function o() {
    if (a !== void 0) return a;
    if (t.has("EXT_texture_filter_anisotropic") === !0) {
      const N = t.get("EXT_texture_filter_anisotropic");
      a = n.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
    } else
      a = 0;
    return a;
  }
  function c(N) {
    return !(N !== Ci && r.convert(N) !== n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT));
  }
  function u(N) {
    const z = N === Xc && (t.has("EXT_color_buffer_half_float") || t.has("EXT_color_buffer_float"));
    return !(N !== es && r.convert(N) !== n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)
    N !== Gi && !z);
  }
  function d(N) {
    if (N === "highp") {
      if (n.getShaderPrecisionFormat(n.VERTEX_SHADER, n.HIGH_FLOAT).precision > 0 && n.getShaderPrecisionFormat(n.FRAGMENT_SHADER, n.HIGH_FLOAT).precision > 0)
        return "highp";
      N = "mediump";
    }
    return N === "mediump" && n.getShaderPrecisionFormat(n.VERTEX_SHADER, n.MEDIUM_FLOAT).precision > 0 && n.getShaderPrecisionFormat(n.FRAGMENT_SHADER, n.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp";
  }
  let h = e.precision !== void 0 ? e.precision : "highp";
  const p = d(h);
  p !== h && (console.warn("THREE.WebGLRenderer:", h, "not supported, using", p, "instead."), h = p);
  const m = e.logarithmicDepthBuffer === !0, g = e.reverseDepthBuffer === !0 && t.has("EXT_clip_control"), _ = n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS), b = n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS), E = n.getParameter(n.MAX_TEXTURE_SIZE), S = n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE), y = n.getParameter(n.MAX_VERTEX_ATTRIBS), A = n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS), w = n.getParameter(n.MAX_VARYING_VECTORS), M = n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS), O = b > 0, L = n.getParameter(n.MAX_SAMPLES);
  return {
    isWebGL2: !0,
    // keeping this for backwards compatibility
    getMaxAnisotropy: o,
    getMaxPrecision: d,
    textureFormatReadable: c,
    textureTypeReadable: u,
    precision: h,
    logarithmicDepthBuffer: m,
    reverseDepthBuffer: g,
    maxTextures: _,
    maxVertexTextures: b,
    maxTextureSize: E,
    maxCubemapSize: S,
    maxAttributes: y,
    maxVertexUniforms: A,
    maxVaryings: w,
    maxFragmentUniforms: M,
    vertexTextures: O,
    maxSamples: L
  };
}
function ID(n) {
  const t = this;
  let e = null, r = 0, a = !1, o = !1;
  const c = new Bs(), u = new ve(), d = { value: null, needsUpdate: !1 };
  this.uniform = d, this.numPlanes = 0, this.numIntersection = 0, this.init = function(m, g) {
    const _ = m.length !== 0 || g || // enable state of previous frame - the clipping code has to
    // run another frame in order to reset the state:
    r !== 0 || a;
    return a = g, r = m.length, _;
  }, this.beginShadows = function() {
    o = !0, p(null);
  }, this.endShadows = function() {
    o = !1;
  }, this.setGlobalState = function(m, g) {
    e = p(m, g, 0);
  }, this.setState = function(m, g, _) {
    const b = m.clippingPlanes, E = m.clipIntersection, S = m.clipShadows, y = n.get(m);
    if (!a || b === null || b.length === 0 || o && !S)
      o ? p(null) : h();
    else {
      const A = o ? 0 : r, w = A * 4;
      let M = y.clippingState || null;
      d.value = M, M = p(b, g, w, _);
      for (let O = 0; O !== w; ++O)
        M[O] = e[O];
      y.clippingState = M, this.numIntersection = E ? this.numPlanes : 0, this.numPlanes += A;
    }
  };
  function h() {
    d.value !== e && (d.value = e, d.needsUpdate = r > 0), t.numPlanes = r, t.numIntersection = 0;
  }
  function p(m, g, _, b) {
    const E = m !== null ? m.length : 0;
    let S = null;
    if (E !== 0) {
      if (S = d.value, b !== !0 || S === null) {
        const y = _ + E * 4, A = g.matrixWorldInverse;
        u.getNormalMatrix(A), (S === null || S.length < y) && (S = new Float32Array(y));
        for (let w = 0, M = _; w !== E; ++w, M += 4)
          c.copy(m[w]).applyMatrix4(A, u), c.normal.toArray(S, M), S[M + 3] = c.constant;
      }
      d.value = S, d.needsUpdate = !0;
    }
    return t.numPlanes = E, t.numIntersection = 0, S;
  }
}
function BD(n) {
  let t = /* @__PURE__ */ new WeakMap();
  function e(c, u) {
    return u === mg ? c.mapping = el : u === gg && (c.mapping = nl), c;
  }
  function r(c) {
    if (c && c.isTexture) {
      const u = c.mapping;
      if (u === mg || u === gg)
        if (t.has(c)) {
          const d = t.get(c).texture;
          return e(d, c.mapping);
        } else {
          const d = c.image;
          if (d && d.height > 0) {
            const h = new OC(d.height);
            return h.fromEquirectangularTexture(n, c), t.set(c, h), c.addEventListener("dispose", a), e(h.texture, c.mapping);
          } else
            return null;
        }
    }
    return c;
  }
  function a(c) {
    const u = c.target;
    u.removeEventListener("dispose", a);
    const d = t.get(u);
    d !== void 0 && (t.delete(u), d.dispose());
  }
  function o() {
    t = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: r,
    dispose: o
  };
}
const jo = 4, NS = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], Ma = 20, Rm = /* @__PURE__ */ new $r(), LS = /* @__PURE__ */ new Me();
let Dm = null, Nm = 0, Lm = 0, Um = !1;
const xa = (1 + Math.sqrt(5)) / 2, Fo = 1 / xa, US = [
  /* @__PURE__ */ new ot(-xa, Fo, 0),
  /* @__PURE__ */ new ot(xa, Fo, 0),
  /* @__PURE__ */ new ot(-Fo, 0, xa),
  /* @__PURE__ */ new ot(Fo, 0, xa),
  /* @__PURE__ */ new ot(0, xa, -Fo),
  /* @__PURE__ */ new ot(0, xa, Fo),
  /* @__PURE__ */ new ot(-1, 1, -1),
  /* @__PURE__ */ new ot(1, 1, -1),
  /* @__PURE__ */ new ot(-1, 1, 1),
  /* @__PURE__ */ new ot(1, 1, 1)
];
class OS {
  constructor(t) {
    this._renderer = t, 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).
   *
   * @param {Scene} scene
   * @param {number} sigma
   * @param {number} near
   * @param {number} far
   * @return {WebGLRenderTarget}
   */
  fromScene(t, e = 0, r = 0.1, a = 100) {
    Dm = this._renderer.getRenderTarget(), Nm = this._renderer.getActiveCubeFace(), Lm = this._renderer.getActiveMipmapLevel(), Um = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(256);
    const o = this._allocateTargets();
    return o.depthBuffer = !0, this._sceneToCubeUV(t, r, a, o), e > 0 && this._blur(o, 0, 0, e), this._applyPMREM(o), this._cleanup(o), o;
  }
  /**
   * 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.
   *
   * @param {Texture} equirectangular
   * @param {WebGLRenderTarget} [renderTarget=null] - Optional render target.
   * @return {WebGLRenderTarget}
   */
  fromEquirectangular(t, e = null) {
    return this._fromTexture(t, e);
  }
  /**
   * 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.
   *
   * @param {Texture} cubemap
   * @param {null} [renderTarget=null] - Optional render target.
   * @return {WebGLRenderTarget}
   */
  fromCubemap(t, e = null) {
    return this._fromTexture(t, e);
  }
  /**
   * 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 = IS(), 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 = zS(), 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(t) {
    this._lodMax = Math.floor(Math.log2(t)), this._cubeSize = Math.pow(2, this._lodMax);
  }
  _dispose() {
    this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose();
    for (let t = 0; t < this._lodPlanes.length; t++)
      this._lodPlanes[t].dispose();
  }
  _cleanup(t) {
    this._renderer.setRenderTarget(Dm, Nm, Lm), this._renderer.xr.enabled = Um, t.scissorTest = !1, zf(t, 0, 0, t.width, t.height);
  }
  _fromTexture(t, e) {
    t.mapping === el || t.mapping === nl ? this._setSize(t.image.length === 0 ? 16 : t.image[0].width || t.image[0].image.width) : this._setSize(t.image.width / 4), Dm = this._renderer.getRenderTarget(), Nm = this._renderer.getActiveCubeFace(), Lm = this._renderer.getActiveMipmapLevel(), Um = this._renderer.xr.enabled, this._renderer.xr.enabled = !1;
    const r = e || this._allocateTargets();
    return this._textureToCubeUV(t, r), this._applyPMREM(r), this._cleanup(r), r;
  }
  _allocateTargets() {
    const t = 3 * Math.max(this._cubeSize, 112), e = 4 * this._cubeSize, r = {
      magFilter: dr,
      minFilter: dr,
      generateMipmaps: !1,
      type: Xc,
      format: Ci,
      colorSpace: sl,
      depthBuffer: !1
    }, a = PS(t, e, r);
    if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== t || this._pingPongRenderTarget.height !== e) {
      this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = PS(t, e, r);
      const { _lodMax: o } = this;
      ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = FD(o)), this._blurMaterial = HD(o, t, e);
    }
    return a;
  }
  _compileMaterial(t) {
    const e = new Dn(this._lodPlanes[0], t);
    this._renderer.compile(e, Rm);
  }
  _sceneToCubeUV(t, e, r, a) {
    const u = new Ti(90, 1, e, r), d = [1, -1, 1, 1, 1, 1], h = [1, 1, 1, -1, -1, -1], p = this._renderer, m = p.autoClear, g = p.toneMapping;
    p.getClearColor(LS), p.toneMapping = Gs, p.autoClear = !1;
    const _ = new Nd({
      name: "PMREM.Background",
      side: pi,
      depthWrite: !1,
      depthTest: !1
    }), b = new Dn(new jc(), _);
    let E = !1;
    const S = t.background;
    S ? S.isColor && (_.color.copy(S), t.background = null, E = !0) : (_.color.copy(LS), E = !0);
    for (let y = 0; y < 6; y++) {
      const A = y % 3;
      A === 0 ? (u.up.set(0, d[y], 0), u.lookAt(h[y], 0, 0)) : A === 1 ? (u.up.set(0, 0, d[y]), u.lookAt(0, h[y], 0)) : (u.up.set(0, d[y], 0), u.lookAt(0, 0, h[y]));
      const w = this._cubeSize;
      zf(a, A * w, y > 2 ? w : 0, w, w), p.setRenderTarget(a), E && p.render(b, u), p.render(t, u);
    }
    b.geometry.dispose(), b.material.dispose(), p.toneMapping = g, p.autoClear = m, t.background = S;
  }
  _textureToCubeUV(t, e) {
    const r = this._renderer, a = t.mapping === el || t.mapping === nl;
    a ? (this._cubemapMaterial === null && (this._cubemapMaterial = IS()), this._cubemapMaterial.uniforms.flipEnvMap.value = t.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = zS());
    const o = a ? this._cubemapMaterial : this._equirectMaterial, c = new Dn(this._lodPlanes[0], o), u = o.uniforms;
    u.envMap.value = t;
    const d = this._cubeSize;
    zf(e, 0, 0, 3 * d, 2 * d), r.setRenderTarget(e), r.render(c, Rm);
  }
  _applyPMREM(t) {
    const e = this._renderer, r = e.autoClear;
    e.autoClear = !1;
    const a = this._lodPlanes.length;
    for (let o = 1; o < a; o++) {
      const c = Math.sqrt(this._sigmas[o] * this._sigmas[o] - this._sigmas[o - 1] * this._sigmas[o - 1]), u = US[(a - o - 1) % US.length];
      this._blur(t, o - 1, o, c, u);
    }
    e.autoClear = r;
  }
  /**
   * 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.
   *
   * @param {WebGLRenderTarget} cubeUVRenderTarget
   * @param {number} lodIn
   * @param {number} lodOut
   * @param {number} sigma
   * @param {Vector3} [poleAxis]
   */
  _blur(t, e, r, a, o) {
    const c = this._pingPongRenderTarget;
    this._halfBlur(
      t,
      c,
      e,
      r,
      a,
      "latitudinal",
      o
    ), this._halfBlur(
      c,
      t,
      r,
      r,
      a,
      "longitudinal",
      o
    );
  }
  _halfBlur(t, e, r, a, o, c, u) {
    const d = this._renderer, h = this._blurMaterial;
    c !== "latitudinal" && c !== "longitudinal" && console.error(
      "blur direction must be either latitudinal or longitudinal!"
    );
    const p = 3, m = new Dn(this._lodPlanes[a], h), g = h.uniforms, _ = this._sizeLods[r] - 1, b = isFinite(o) ? Math.PI / (2 * _) : 2 * Math.PI / (2 * Ma - 1), E = o / b, S = isFinite(o) ? 1 + Math.floor(p * E) : Ma;
    S > Ma && console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${Ma}`);
    const y = [];
    let A = 0;
    for (let N = 0; N < Ma; ++N) {
      const z = N / E, R = Math.exp(-z * z / 2);
      y.push(R), N === 0 ? A += R : N < S && (A += 2 * R);
    }
    for (let N = 0; N < y.length; N++)
      y[N] = y[N] / A;
    g.envMap.value = t.texture, g.samples.value = S, g.weights.value = y, g.latitudinal.value = c === "latitudinal", u && (g.poleAxis.value = u);
    const { _lodMax: w } = this;
    g.dTheta.value = b, g.mipInt.value = w - r;
    const M = this._sizeLods[a], O = 3 * M * (a > w - jo ? a - w + jo : 0), L = 4 * (this._cubeSize - M);
    zf(e, O, L, 3 * M, 2 * M), d.setRenderTarget(e), d.render(m, Rm);
  }
}
function FD(n) {
  const t = [], e = [], r = [];
  let a = n;
  const o = n - jo + 1 + NS.length;
  for (let c = 0; c < o; c++) {
    const u = Math.pow(2, a);
    e.push(u);
    let d = 1 / u;
    c > n - jo ? d = NS[c - n + jo - 1] : c === 0 && (d = 0), r.push(d);
    const h = 1 / (u - 2), p = -h, m = 1 + h, g = [p, p, m, p, m, m, p, p, m, m, p, m], _ = 6, b = 6, E = 3, S = 2, y = 1, A = new Float32Array(E * b * _), w = new Float32Array(S * b * _), M = new Float32Array(y * b * _);
    for (let L = 0; L < _; L++) {
      const N = L % 3 * 2 / 3 - 1, z = L > 2 ? 0 : -1, R = [
        N,
        z,
        0,
        N + 2 / 3,
        z,
        0,
        N + 2 / 3,
        z + 1,
        0,
        N,
        z,
        0,
        N + 2 / 3,
        z + 1,
        0,
        N,
        z + 1,
        0
      ];
      A.set(R, E * b * L), w.set(g, S * b * L);
      const T = [L, L, L, L, L, L];
      M.set(T, y * b * L);
    }
    const O = new qn();
    O.setAttribute("position", new fn(A, E)), O.setAttribute("uv", new fn(w, S)), O.setAttribute("faceIndex", new fn(M, y)), t.push(O), a > jo && a--;
  }
  return { lodPlanes: t, sizeLods: e, sigmas: r };
}
function PS(n, t, e) {
  const r = new La(n, t, e);
  return r.texture.mapping = Dd, r.texture.name = "PMREM.cubeUv", r.scissorTest = !0, r;
}
function zf(n, t, e, r, a) {
  n.viewport.set(t, e, r, a), n.scissor.set(t, e, r, a);
}
function HD(n, t, e) {
  const r = new Float32Array(Ma), a = new ot(0, 1, 0);
  return new gr({
    name: "SphericalGaussianBlur",
    defines: {
      n: Ma,
      CUBEUV_TEXEL_WIDTH: 1 / t,
      CUBEUV_TEXEL_HEIGHT: 1 / e,
      CUBEUV_MAX_MIP: `${n}.0`
    },
    uniforms: {
      envMap: { value: null },
      samples: { value: 1 },
      weights: { value: r },
      latitudinal: { value: !1 },
      dTheta: { value: 0 },
      mipInt: { value: 0 },
      poleAxis: { value: a }
    },
    vertexShader: N0(),
    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: ks,
    depthTest: !1,
    depthWrite: !1
  });
}
function zS() {
  return new gr({
    name: "EquirectangularToCubeUV",
    uniforms: {
      envMap: { value: null }
    },
    vertexShader: N0(),
    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: ks,
    depthTest: !1,
    depthWrite: !1
  });
}
function IS() {
  return new gr({
    name: "CubemapToCubeUV",
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 }
    },
    vertexShader: N0(),
    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: ks,
    depthTest: !1,
    depthWrite: !1
  });
}
function N0() {
  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 VD(n) {
  let t = /* @__PURE__ */ new WeakMap(), e = null;
  function r(u) {
    if (u && u.isTexture) {
      const d = u.mapping, h = d === mg || d === gg, p = d === el || d === nl;
      if (h || p) {
        let m = t.get(u);
        const g = m !== void 0 ? m.texture.pmremVersion : 0;
        if (u.isRenderTargetTexture && u.pmremVersion !== g)
          return e === null && (e = new OS(n)), m = h ? e.fromEquirectangular(u, m) : e.fromCubemap(u, m), m.texture.pmremVersion = u.pmremVersion, t.set(u, m), m.texture;
        if (m !== void 0)
          return m.texture;
        {
          const _ = u.image;
          return h && _ && _.height > 0 || p && _ && a(_) ? (e === null && (e = new OS(n)), m = h ? e.fromEquirectangular(u) : e.fromCubemap(u), m.texture.pmremVersion = u.pmremVersion, t.set(u, m), u.addEventListener("dispose", o), m.texture) : null;
        }
      }
    }
    return u;
  }
  function a(u) {
    let d = 0;
    const h = 6;
    for (let p = 0; p < h; p++)
      u[p] !== void 0 && d++;
    return d === h;
  }
  function o(u) {
    const d = u.target;
    d.removeEventListener("dispose", o);
    const h = t.get(d);
    h !== void 0 && (t.delete(d), h.dispose());
  }
  function c() {
    t = /* @__PURE__ */ new WeakMap(), e !== null && (e.dispose(), e = null);
  }
  return {
    get: r,
    dispose: c
  };
}
function kD(n) {
  const t = {};
  function e(r) {
    if (t[r] !== void 0)
      return t[r];
    let a;
    switch (r) {
      case "WEBGL_depth_texture":
        a = n.getExtension("WEBGL_depth_texture") || n.getExtension("MOZ_WEBGL_depth_texture") || n.getExtension("WEBKIT_WEBGL_depth_texture");
        break;
      case "EXT_texture_filter_anisotropic":
        a = n.getExtension("EXT_texture_filter_anisotropic") || n.getExtension("MOZ_EXT_texture_filter_anisotropic") || n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
        break;
      case "WEBGL_compressed_texture_s3tc":
        a = n.getExtension("WEBGL_compressed_texture_s3tc") || n.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
        break;
      case "WEBGL_compressed_texture_pvrtc":
        a = n.getExtension("WEBGL_compressed_texture_pvrtc") || n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
        break;
      default:
        a = n.getExtension(r);
    }
    return t[r] = a, a;
  }
  return {
    has: function(r) {
      return e(r) !== null;
    },
    init: function() {
      e("EXT_color_buffer_float"), e("WEBGL_clip_cull_distance"), e("OES_texture_float_linear"), e("EXT_color_buffer_half_float"), e("WEBGL_multisampled_render_to_texture"), e("WEBGL_render_shared_exponent");
    },
    get: function(r) {
      const a = e(r);
      return a === null && ko("THREE.WebGLRenderer: " + r + " extension not supported."), a;
    }
  };
}
function GD(n, t, e, r) {
  const a = {}, o = /* @__PURE__ */ new WeakMap();
  function c(m) {
    const g = m.target;
    g.index !== null && t.remove(g.index);
    for (const b in g.attributes)
      t.remove(g.attributes[b]);
    g.removeEventListener("dispose", c), delete a[g.id];
    const _ = o.get(g);
    _ && (t.remove(_), o.delete(g)), r.releaseStatesOfGeometry(g), g.isInstancedBufferGeometry === !0 && delete g._maxInstanceCount, e.memory.geometries--;
  }
  function u(m, g) {
    return a[g.id] === !0 || (g.addEventListener("dispose", c), a[g.id] = !0, e.memory.geometries++), g;
  }
  function d(m) {
    const g = m.attributes;
    for (const _ in g)
      t.update(g[_], n.ARRAY_BUFFER);
  }
  function h(m) {
    const g = [], _ = m.index, b = m.attributes.position;
    let E = 0;
    if (_ !== null) {
      const A = _.array;
      E = _.version;
      for (let w = 0, M = A.length; w < M; w += 3) {
        const O = A[w + 0], L = A[w + 1], N = A[w + 2];
        g.push(O, L, L, N, N, O);
      }
    } else if (b !== void 0) {
      const A = b.array;
      E = b.version;
      for (let w = 0, M = A.length / 3 - 1; w < M; w += 3) {
        const O = w + 0, L = w + 1, N = w + 2;
        g.push(O, L, L, N, N, O);
      }
    } else
      return;
    const S = new (gM(g) ? bM : SM)(g, 1);
    S.version = E;
    const y = o.get(m);
    y && t.remove(y), o.set(m, S);
  }
  function p(m) {
    const g = o.get(m);
    if (g) {
      const _ = m.index;
      _ !== null && g.version < _.version && h(m);
    } else
      h(m);
    return o.get(m);
  }
  return {
    get: u,
    update: d,
    getWireframeAttribute: p
  };
}
function XD(n, t, e) {
  let r;
  function a(g) {
    r = g;
  }
  let o, c;
  function u(g) {
    o = g.type, c = g.bytesPerElement;
  }
  function d(g, _) {
    n.drawElements(r, _, o, g * c), e.update(_, r, 1);
  }
  function h(g, _, b) {
    b !== 0 && (n.drawElementsInstanced(r, _, o, g * c, b), e.update(_, r, b));
  }
  function p(g, _, b) {
    if (b === 0) return;
    t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r, _, 0, o, g, 0, b);
    let S = 0;
    for (let y = 0; y < b; y++)
      S += _[y];
    e.update(S, r, 1);
  }
  function m(g, _, b, E) {
    if (b === 0) return;
    const S = t.get("WEBGL_multi_draw");
    if (S === null)
      for (let y = 0; y < g.length; y++)
        h(g[y] / c, _[y], E[y]);
    else {
      S.multiDrawElementsInstancedWEBGL(r, _, 0, o, g, 0, E, 0, b);
      let y = 0;
      for (let A = 0; A < b; A++)
        y += _[A] * E[A];
      e.update(y, r, 1);
    }
  }
  this.setMode = a, this.setIndex = u, this.render = d, this.renderInstances = h, this.renderMultiDraw = p, this.renderMultiDrawInstances = m;
}
function jD(n) {
  const t = {
    geometries: 0,
    textures: 0
  }, e = {
    frame: 0,
    calls: 0,
    triangles: 0,
    points: 0,
    lines: 0
  };
  function r(o, c, u) {
    switch (e.calls++, c) {
      case n.TRIANGLES:
        e.triangles += u * (o / 3);
        break;
      case n.LINES:
        e.lines += u * (o / 2);
        break;
      case n.LINE_STRIP:
        e.lines += u * (o - 1);
        break;
      case n.LINE_LOOP:
        e.lines += u * o;
        break;
      case n.POINTS:
        e.points += u * o;
        break;
      default:
        console.error("THREE.WebGLInfo: Unknown draw mode:", c);
        break;
    }
  }
  function a() {
    e.calls = 0, e.triangles = 0, e.points = 0, e.lines = 0;
  }
  return {
    memory: t,
    render: e,
    programs: null,
    autoReset: !0,
    reset: a,
    update: r
  };
}
function WD(n, t, e) {
  const r = /* @__PURE__ */ new WeakMap(), a = new Ke();
  function o(c, u, d) {
    const h = c.morphTargetInfluences, p = u.morphAttributes.position || u.morphAttributes.normal || u.morphAttributes.color, m = p !== void 0 ? p.length : 0;
    let g = r.get(u);
    if (g === void 0 || g.count !== m) {
      let R = function() {
        N.dispose(), r.delete(u), u.removeEventListener("dispose", R);
      };
      g !== void 0 && g.texture.dispose();
      const _ = u.morphAttributes.position !== void 0, b = u.morphAttributes.normal !== void 0, E = u.morphAttributes.color !== void 0, S = u.morphAttributes.position || [], y = u.morphAttributes.normal || [], A = u.morphAttributes.color || [];
      let w = 0;
      _ === !0 && (w = 1), b === !0 && (w = 2), E === !0 && (w = 3);
      let M = u.attributes.position.count * w, O = 1;
      M > t.maxTextureSize && (O = Math.ceil(M / t.maxTextureSize), M = t.maxTextureSize);
      const L = new Float32Array(M * O * 4 * m), N = new _M(L, M, O, m);
      N.type = Gi, N.needsUpdate = !0;
      const z = w * 4;
      for (let T = 0; T < m; T++) {
        const U = S[T], B = y[T], I = A[T], C = M * O * 4 * T;
        for (let X = 0; X < U.count; X++) {
          const D = X * z;
          _ === !0 && (a.fromBufferAttribute(U, X), L[C + D + 0] = a.x, L[C + D + 1] = a.y, L[C + D + 2] = a.z, L[C + D + 3] = 0), b === !0 && (a.fromBufferAttribute(B, X), L[C + D + 4] = a.x, L[C + D + 5] = a.y, L[C + D + 6] = a.z, L[C + D + 7] = 0), E === !0 && (a.fromBufferAttribute(I, X), L[C + D + 8] = a.x, L[C + D + 9] = a.y, L[C + D + 10] = a.z, L[C + D + 11] = I.itemSize === 4 ? a.w : 1);
        }
      }
      g = {
        count: m,
        texture: N,
        size: new oe(M, O)
      }, r.set(u, g), u.addEventListener("dispose", R);
    }
    if (c.isInstancedMesh === !0 && c.morphTexture !== null)
      d.getUniforms().setValue(n, "morphTexture", c.morphTexture, e);
    else {
      let _ = 0;
      for (let E = 0; E < h.length; E++)
        _ += h[E];
      const b = u.morphTargetsRelative ? 1 : 1 - _;
      d.getUniforms().setValue(n, "morphTargetBaseInfluence", b), d.getUniforms().setValue(n, "morphTargetInfluences", h);
    }
    d.getUniforms().setValue(n, "morphTargetsTexture", g.texture, e), d.getUniforms().setValue(n, "morphTargetsTextureSize", g.size);
  }
  return {
    update: o
  };
}
function YD(n, t, e, r) {
  let a = /* @__PURE__ */ new WeakMap();
  function o(d) {
    const h = r.render.frame, p = d.geometry, m = t.get(d, p);
    if (a.get(m) !== h && (t.update(m), a.set(m, h)), d.isInstancedMesh && (d.hasEventListener("dispose", u) === !1 && d.addEventListener("dispose", u), a.get(d) !== h && (e.update(d.instanceMatrix, n.ARRAY_BUFFER), d.instanceColor !== null && e.update(d.instanceColor, n.ARRAY_BUFFER), a.set(d, h))), d.isSkinnedMesh) {
      const g = d.skeleton;
      a.get(g) !== h && (g.update(), a.set(g, h));
    }
    return m;
  }
  function c() {
    a = /* @__PURE__ */ new WeakMap();
  }
  function u(d) {
    const h = d.target;
    h.removeEventListener("dispose", u), e.remove(h.instanceMatrix), h.instanceColor !== null && e.remove(h.instanceColor);
  }
  return {
    update: o,
    dispose: c
  };
}
const LM = /* @__PURE__ */ new Jn(), BS = /* @__PURE__ */ new RM(1, 1), UM = /* @__PURE__ */ new _M(), OM = /* @__PURE__ */ new yC(), PM = /* @__PURE__ */ new wM(), FS = [], HS = [], VS = new Float32Array(16), kS = new Float32Array(9), GS = new Float32Array(4);
function ml(n, t, e) {
  const r = n[0];
  if (r <= 0 || r > 0) return n;
  const a = t * e;
  let o = FS[a];
  if (o === void 0 && (o = new Float32Array(a), FS[a] = o), t !== 0) {
    r.toArray(o, 0);
    for (let c = 1, u = 0; c !== t; ++c)
      u += e, n[c].toArray(o, u);
  }
  return o;
}
function Ln(n, t) {
  if (n.length !== t.length) return !1;
  for (let e = 0, r = n.length; e < r; e++)
    if (n[e] !== t[e]) return !1;
  return !0;
}
function Un(n, t) {
  for (let e = 0, r = t.length; e < r; e++)
    n[e] = t[e];
}
function Od(n, t) {
  let e = HS[t];
  e === void 0 && (e = new Int32Array(t), HS[t] = e);
  for (let r = 0; r !== t; ++r)
    e[r] = n.allocateTextureUnit();
  return e;
}
function qD(n, t) {
  const e = this.cache;
  e[0] !== t && (n.uniform1f(this.addr, t), e[0] = t);
}
function ZD(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y) && (n.uniform2f(this.addr, t.x, t.y), e[0] = t.x, e[1] = t.y);
  else {
    if (Ln(e, t)) return;
    n.uniform2fv(this.addr, t), Un(e, t);
  }
}
function $D(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z) && (n.uniform3f(this.addr, t.x, t.y, t.z), e[0] = t.x, e[1] = t.y, e[2] = t.z);
  else if (t.r !== void 0)
    (e[0] !== t.r || e[1] !== t.g || e[2] !== t.b) && (n.uniform3f(this.addr, t.r, t.g, t.b), e[0] = t.r, e[1] = t.g, e[2] = t.b);
  else {
    if (Ln(e, t)) return;
    n.uniform3fv(this.addr, t), Un(e, t);
  }
}
function KD(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z || e[3] !== t.w) && (n.uniform4f(this.addr, t.x, t.y, t.z, t.w), e[0] = t.x, e[1] = t.y, e[2] = t.z, e[3] = t.w);
  else {
    if (Ln(e, t)) return;
    n.uniform4fv(this.addr, t), Un(e, t);
  }
}
function QD(n, t) {
  const e = this.cache, r = t.elements;
  if (r === void 0) {
    if (Ln(e, t)) return;
    n.uniformMatrix2fv(this.addr, !1, t), Un(e, t);
  } else {
    if (Ln(e, r)) return;
    GS.set(r), n.uniformMatrix2fv(this.addr, !1, GS), Un(e, r);
  }
}
function JD(n, t) {
  const e = this.cache, r = t.elements;
  if (r === void 0) {
    if (Ln(e, t)) return;
    n.uniformMatrix3fv(this.addr, !1, t), Un(e, t);
  } else {
    if (Ln(e, r)) return;
    kS.set(r), n.uniformMatrix3fv(this.addr, !1, kS), Un(e, r);
  }
}
function tN(n, t) {
  const e = this.cache, r = t.elements;
  if (r === void 0) {
    if (Ln(e, t)) return;
    n.uniformMatrix4fv(this.addr, !1, t), Un(e, t);
  } else {
    if (Ln(e, r)) return;
    VS.set(r), n.uniformMatrix4fv(this.addr, !1, VS), Un(e, r);
  }
}
function eN(n, t) {
  const e = this.cache;
  e[0] !== t && (n.uniform1i(this.addr, t), e[0] = t);
}
function nN(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y) && (n.uniform2i(this.addr, t.x, t.y), e[0] = t.x, e[1] = t.y);
  else {
    if (Ln(e, t)) return;
    n.uniform2iv(this.addr, t), Un(e, t);
  }
}
function iN(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z) && (n.uniform3i(this.addr, t.x, t.y, t.z), e[0] = t.x, e[1] = t.y, e[2] = t.z);
  else {
    if (Ln(e, t)) return;
    n.uniform3iv(this.addr, t), Un(e, t);
  }
}
function rN(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z || e[3] !== t.w) && (n.uniform4i(this.addr, t.x, t.y, t.z, t.w), e[0] = t.x, e[1] = t.y, e[2] = t.z, e[3] = t.w);
  else {
    if (Ln(e, t)) return;
    n.uniform4iv(this.addr, t), Un(e, t);
  }
}
function sN(n, t) {
  const e = this.cache;
  e[0] !== t && (n.uniform1ui(this.addr, t), e[0] = t);
}
function aN(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y) && (n.uniform2ui(this.addr, t.x, t.y), e[0] = t.x, e[1] = t.y);
  else {
    if (Ln(e, t)) return;
    n.uniform2uiv(this.addr, t), Un(e, t);
  }
}
function oN(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z) && (n.uniform3ui(this.addr, t.x, t.y, t.z), e[0] = t.x, e[1] = t.y, e[2] = t.z);
  else {
    if (Ln(e, t)) return;
    n.uniform3uiv(this.addr, t), Un(e, t);
  }
}
function lN(n, t) {
  const e = this.cache;
  if (t.x !== void 0)
    (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z || e[3] !== t.w) && (n.uniform4ui(this.addr, t.x, t.y, t.z, t.w), e[0] = t.x, e[1] = t.y, e[2] = t.z, e[3] = t.w);
  else {
    if (Ln(e, t)) return;
    n.uniform4uiv(this.addr, t), Un(e, t);
  }
}
function cN(n, t, e) {
  const r = this.cache, a = e.allocateTextureUnit();
  r[0] !== a && (n.uniform1i(this.addr, a), r[0] = a);
  let o;
  this.type === n.SAMPLER_2D_SHADOW ? (BS.compareFunction = pM, o = BS) : o = LM, e.setTexture2D(t || o, a);
}
function uN(n, t, e) {
  const r = this.cache, a = e.allocateTextureUnit();
  r[0] !== a && (n.uniform1i(this.addr, a), r[0] = a), e.setTexture3D(t || OM, a);
}
function fN(n, t, e) {
  const r = this.cache, a = e.allocateTextureUnit();
  r[0] !== a && (n.uniform1i(this.addr, a), r[0] = a), e.setTextureCube(t || PM, a);
}
function dN(n, t, e) {
  const r = this.cache, a = e.allocateTextureUnit();
  r[0] !== a && (n.uniform1i(this.addr, a), r[0] = a), e.setTexture2DArray(t || UM, a);
}
function hN(n) {
  switch (n) {
    case 5126:
      return qD;
    // FLOAT
    case 35664:
      return ZD;
    // _VEC2
    case 35665:
      return $D;
    // _VEC3
    case 35666:
      return KD;
    // _VEC4
    case 35674:
      return QD;
    // _MAT2
    case 35675:
      return JD;
    // _MAT3
    case 35676:
      return tN;
    // _MAT4
    case 5124:
    case 35670:
      return eN;
    // INT, BOOL
    case 35667:
    case 35671:
      return nN;
    // _VEC2
    case 35668:
    case 35672:
      return iN;
    // _VEC3
    case 35669:
    case 35673:
      return rN;
    // _VEC4
    case 5125:
      return sN;
    // UINT
    case 36294:
      return aN;
    // _VEC2
    case 36295:
      return oN;
    // _VEC3
    case 36296:
      return lN;
    // _VEC4
    case 35678:
    // SAMPLER_2D
    case 36198:
    // SAMPLER_EXTERNAL_OES
    case 36298:
    // INT_SAMPLER_2D
    case 36306:
    // UNSIGNED_INT_SAMPLER_2D
    case 35682:
      return cN;
    case 35679:
    // SAMPLER_3D
    case 36299:
    // INT_SAMPLER_3D
    case 36307:
      return uN;
    case 35680:
    // SAMPLER_CUBE
    case 36300:
    // INT_SAMPLER_CUBE
    case 36308:
    // UNSIGNED_INT_SAMPLER_CUBE
    case 36293:
      return fN;
    case 36289:
    // SAMPLER_2D_ARRAY
    case 36303:
    // INT_SAMPLER_2D_ARRAY
    case 36311:
    // UNSIGNED_INT_SAMPLER_2D_ARRAY
    case 36292:
      return dN;
  }
}
function pN(n, t) {
  n.uniform1fv(this.addr, t);
}
function mN(n, t) {
  const e = ml(t, this.size, 2);
  n.uniform2fv(this.addr, e);
}
function gN(n, t) {
  const e = ml(t, this.size, 3);
  n.uniform3fv(this.addr, e);
}
function vN(n, t) {
  const e = ml(t, this.size, 4);
  n.uniform4fv(this.addr, e);
}
function _N(n, t) {
  const e = ml(t, this.size, 4);
  n.uniformMatrix2fv(this.addr, !1, e);
}
function yN(n, t) {
  const e = ml(t, this.size, 9);
  n.uniformMatrix3fv(this.addr, !1, e);
}
function xN(n, t) {
  const e = ml(t, this.size, 16);
  n.uniformMatrix4fv(this.addr, !1, e);
}
function SN(n, t) {
  n.uniform1iv(this.addr, t);
}
function bN(n, t) {
  n.uniform2iv(this.addr, t);
}
function MN(n, t) {
  n.uniform3iv(this.addr, t);
}
function EN(n, t) {
  n.uniform4iv(this.addr, t);
}
function wN(n, t) {
  n.uniform1uiv(this.addr, t);
}
function TN(n, t) {
  n.uniform2uiv(this.addr, t);
}
function AN(n, t) {
  n.uniform3uiv(this.addr, t);
}
function CN(n, t) {
  n.uniform4uiv(this.addr, t);
}
function RN(n, t, e) {
  const r = this.cache, a = t.length, o = Od(e, a);
  Ln(r, o) || (n.uniform1iv(this.addr, o), Un(r, o));
  for (let c = 0; c !== a; ++c)
    e.setTexture2D(t[c] || LM, o[c]);
}
function DN(n, t, e) {
  const r = this.cache, a = t.length, o = Od(e, a);
  Ln(r, o) || (n.uniform1iv(this.addr, o), Un(r, o));
  for (let c = 0; c !== a; ++c)
    e.setTexture3D(t[c] || OM, o[c]);
}
function NN(n, t, e) {
  const r = this.cache, a = t.length, o = Od(e, a);
  Ln(r, o) || (n.uniform1iv(this.addr, o), Un(r, o));
  for (let c = 0; c !== a; ++c)
    e.setTextureCube(t[c] || PM, o[c]);
}
function LN(n, t, e) {
  const r = this.cache, a = t.length, o = Od(e, a);
  Ln(r, o) || (n.uniform1iv(this.addr, o), Un(r, o));
  for (let c = 0; c !== a; ++c)
    e.setTexture2DArray(t[c] || UM, o[c]);
}
function UN(n) {
  switch (n) {
    case 5126:
      return pN;
    // FLOAT
    case 35664:
      return mN;
    // _VEC2
    case 35665:
      return gN;
    // _VEC3
    case 35666:
      return vN;
    // _VEC4
    case 35674:
      return _N;
    // _MAT2
    case 35675:
      return yN;
    // _MAT3
    case 35676:
      return xN;
    // _MAT4
    case 5124:
    case 35670:
      return SN;
    // INT, BOOL
    case 35667:
    case 35671:
      return bN;
    // _VEC2
    case 35668:
    case 35672:
      return MN;
    // _VEC3
    case 35669:
    case 35673:
      return EN;
    // _VEC4
    case 5125:
      return wN;
    // UINT
    case 36294:
      return TN;
    // _VEC2
    case 36295:
      return AN;
    // _VEC3
    case 36296:
      return CN;
    // _VEC4
    case 35678:
    // SAMPLER_2D
    case 36198:
    // SAMPLER_EXTERNAL_OES
    case 36298:
    // INT_SAMPLER_2D
    case 36306:
    // UNSIGNED_INT_SAMPLER_2D
    case 35682:
      return RN;
    case 35679:
    // SAMPLER_3D
    case 36299:
    // INT_SAMPLER_3D
    case 36307:
      return DN;
    case 35680:
    // SAMPLER_CUBE
    case 36300:
    // INT_SAMPLER_CUBE
    case 36308:
    // UNSIGNED_INT_SAMPLER_CUBE
    case 36293:
      return NN;
    case 36289:
    // SAMPLER_2D_ARRAY
    case 36303:
    // INT_SAMPLER_2D_ARRAY
    case 36311:
    // UNSIGNED_INT_SAMPLER_2D_ARRAY
    case 36292:
      return LN;
  }
}
class ON {
  constructor(t, e, r) {
    this.id = t, this.addr = r, this.cache = [], this.type = e.type, this.setValue = hN(e.type);
  }
}
class PN {
  constructor(t, e, r) {
    this.id = t, this.addr = r, this.cache = [], this.type = e.type, this.size = e.size, this.setValue = UN(e.type);
  }
}
class zN {
  constructor(t) {
    this.id = t, this.seq = [], this.map = {};
  }
  setValue(t, e, r) {
    const a = this.seq;
    for (let o = 0, c = a.length; o !== c; ++o) {
      const u = a[o];
      u.setValue(t, e[u.id], r);
    }
  }
}
const Om = /(\w+)(\])?(\[|\.)?/g;
function XS(n, t) {
  n.seq.push(t), n.map[t.id] = t;
}
function IN(n, t, e) {
  const r = n.name, a = r.length;
  for (Om.lastIndex = 0; ; ) {
    const o = Om.exec(r), c = Om.lastIndex;
    let u = o[1];
    const d = o[2] === "]", h = o[3];
    if (d && (u = u | 0), h === void 0 || h === "[" && c + 2 === a) {
      XS(e, h === void 0 ? new ON(u, n, t) : new PN(u, n, t));
      break;
    } else {
      let m = e.map[u];
      m === void 0 && (m = new zN(u), XS(e, m)), e = m;
    }
  }
}
class sd {
  constructor(t, e) {
    this.seq = [], this.map = {};
    const r = t.getProgramParameter(e, t.ACTIVE_UNIFORMS);
    for (let a = 0; a < r; ++a) {
      const o = t.getActiveUniform(e, a), c = t.getUniformLocation(e, o.name);
      IN(o, c, this);
    }
  }
  setValue(t, e, r, a) {
    const o = this.map[e];
    o !== void 0 && o.setValue(t, r, a);
  }
  setOptional(t, e, r) {
    const a = e[r];
    a !== void 0 && this.setValue(t, r, a);
  }
  static upload(t, e, r, a) {
    for (let o = 0, c = e.length; o !== c; ++o) {
      const u = e[o], d = r[u.id];
      d.needsUpdate !== !1 && u.setValue(t, d.value, a);
    }
  }
  static seqWithValue(t, e) {
    const r = [];
    for (let a = 0, o = t.length; a !== o; ++a) {
      const c = t[a];
      c.id in e && r.push(c);
    }
    return r;
  }
}
function jS(n, t, e) {
  const r = n.createShader(t);
  return n.shaderSource(r, e), n.compileShader(r), r;
}
const BN = 37297;
let FN = 0;
function HN(n, t) {
  const e = n.split(`
`), r = [], a = Math.max(t - 6, 0), o = Math.min(t + 6, e.length);
  for (let c = a; c < o; c++) {
    const u = c + 1;
    r.push(`${u === t ? ">" : " "} ${u}: ${e[c]}`);
  }
  return r.join(`
`);
}
const WS = /* @__PURE__ */ new ve();
function VN(n) {
  Ie._getMatrix(WS, Ie.workingColorSpace, n);
  const t = `mat3( ${WS.elements.map((e) => e.toFixed(4))} )`;
  switch (Ie.getTransfer(n)) {
    case dd:
      return [t, "LinearTransferOETF"];
    case qe:
      return [t, "sRGBTransferOETF"];
    default:
      return console.warn("THREE.WebGLProgram: Unsupported color space: ", n), [t, "LinearTransferOETF"];
  }
}
function YS(n, t, e) {
  const r = n.getShaderParameter(t, n.COMPILE_STATUS), a = n.getShaderInfoLog(t).trim();
  if (r && a === "") return "";
  const o = /ERROR: 0:(\d+)/.exec(a);
  if (o) {
    const c = parseInt(o[1]);
    return e.toUpperCase() + `

` + a + `

` + HN(n.getShaderSource(t), c);
  } else
    return a;
}
function kN(n, t) {
  const e = VN(t);
  return [
    `vec4 ${n}( vec4 value ) {`,
    `	return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,
    "}"
  ].join(`
`);
}
function GN(n, t) {
  let e;
  switch (t) {
    case D2:
      e = "Linear";
      break;
    case N2:
      e = "Reinhard";
      break;
    case L2:
      e = "Cineon";
      break;
    case U2:
      e = "ACESFilmic";
      break;
    case P2:
      e = "AgX";
      break;
    case z2:
      e = "Neutral";
      break;
    case O2:
      e = "Custom";
      break;
    default:
      console.warn("THREE.WebGLProgram: Unsupported toneMapping:", t), e = "Linear";
  }
  return "vec3 " + n + "( vec3 color ) { return " + e + "ToneMapping( color ); }";
}
const If = /* @__PURE__ */ new ot();
function XN() {
  Ie.getLuminanceCoefficients(If);
  const n = If.x.toFixed(4), t = If.y.toFixed(4), e = If.z.toFixed(4);
  return [
    "float luminance( const in vec3 rgb ) {",
    `	const vec3 weights = vec3( ${n}, ${t}, ${e} );`,
    "	return dot( weights, rgb );",
    "}"
  ].join(`
`);
}
function jN(n) {
  return [
    n.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "",
    n.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""
  ].filter(Sc).join(`
`);
}
function WN(n) {
  const t = [];
  for (const e in n) {
    const r = n[e];
    r !== !1 && t.push("#define " + e + " " + r);
  }
  return t.join(`
`);
}
function YN(n, t) {
  const e = {}, r = n.getProgramParameter(t, n.ACTIVE_ATTRIBUTES);
  for (let a = 0; a < r; a++) {
    const o = n.getActiveAttrib(t, a), c = o.name;
    let u = 1;
    o.type === n.FLOAT_MAT2 && (u = 2), o.type === n.FLOAT_MAT3 && (u = 3), o.type === n.FLOAT_MAT4 && (u = 4), e[c] = {
      type: o.type,
      location: n.getAttribLocation(t, c),
      locationSize: u
    };
  }
  return e;
}
function Sc(n) {
  return n !== "";
}
function qS(n, t) {
  const e = t.numSpotLightShadows + t.numSpotLightMaps - t.numSpotLightShadowsWithMaps;
  return n.replace(/NUM_DIR_LIGHTS/g, t.numDirLights).replace(/NUM_SPOT_LIGHTS/g, t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, e).replace(/NUM_RECT_AREA_LIGHTS/g, t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, t.numPointLights).replace(/NUM_HEMI_LIGHTS/g, t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, t.numPointLightShadows);
}
function ZS(n, t) {
  return n.replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection);
}
const qN = /^[ \t]*#include +<([\w\d./]+)>/gm;
function Zg(n) {
  return n.replace(qN, $N);
}
const ZN = /* @__PURE__ */ new Map();
function $N(n, t) {
  let e = ye[t];
  if (e === void 0) {
    const r = ZN.get(t);
    if (r !== void 0)
      e = ye[r], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', t, r);
    else
      throw new Error("Can not resolve #include <" + t + ">");
  }
  return Zg(e);
}
const KN = /#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 $S(n) {
  return n.replace(KN, QN);
}
function QN(n, t, e, r) {
  let a = "";
  for (let o = parseInt(t); o < parseInt(e); o++)
    a += r.replace(/\[\s*i\s*\]/g, "[ " + o + " ]").replace(/UNROLLED_LOOP_INDEX/g, o);
  return a;
}
function KS(n) {
  let t = `precision ${n.precision} float;
	precision ${n.precision} int;
	precision ${n.precision} sampler2D;
	precision ${n.precision} samplerCube;
	precision ${n.precision} sampler3D;
	precision ${n.precision} sampler2DArray;
	precision ${n.precision} sampler2DShadow;
	precision ${n.precision} samplerCubeShadow;
	precision ${n.precision} sampler2DArrayShadow;
	precision ${n.precision} isampler2D;
	precision ${n.precision} isampler3D;
	precision ${n.precision} isamplerCube;
	precision ${n.precision} isampler2DArray;
	precision ${n.precision} usampler2D;
	precision ${n.precision} usampler3D;
	precision ${n.precision} usamplerCube;
	precision ${n.precision} usampler2DArray;
	`;
  return n.precision === "highp" ? t += `
#define HIGH_PRECISION` : n.precision === "mediump" ? t += `
#define MEDIUM_PRECISION` : n.precision === "lowp" && (t += `
#define LOW_PRECISION`), t;
}
function JN(n) {
  let t = "SHADOWMAP_TYPE_BASIC";
  return n.shadowMapType === nM ? t = "SHADOWMAP_TYPE_PCF" : n.shadowMapType === c2 ? t = "SHADOWMAP_TYPE_PCF_SOFT" : n.shadowMapType === qr && (t = "SHADOWMAP_TYPE_VSM"), t;
}
function tL(n) {
  let t = "ENVMAP_TYPE_CUBE";
  if (n.envMap)
    switch (n.envMapMode) {
      case el:
      case nl:
        t = "ENVMAP_TYPE_CUBE";
        break;
      case Dd:
        t = "ENVMAP_TYPE_CUBE_UV";
        break;
    }
  return t;
}
function eL(n) {
  let t = "ENVMAP_MODE_REFLECTION";
  if (n.envMap)
    switch (n.envMapMode) {
      case nl:
        t = "ENVMAP_MODE_REFRACTION";
        break;
    }
  return t;
}
function nL(n) {
  let t = "ENVMAP_BLENDING_NONE";
  if (n.envMap)
    switch (n.combine) {
      case m0:
        t = "ENVMAP_BLENDING_MULTIPLY";
        break;
      case C2:
        t = "ENVMAP_BLENDING_MIX";
        break;
      case R2:
        t = "ENVMAP_BLENDING_ADD";
        break;
    }
  return t;
}
function iL(n) {
  const t = n.envMapCubeUVHeight;
  if (t === null) return null;
  const e = Math.log2(t) - 2, r = 1 / t;
  return { texelWidth: 1 / (3 * Math.max(Math.pow(2, e), 112)), texelHeight: r, maxMip: e };
}
function rL(n, t, e, r) {
  const a = n.getContext(), o = e.defines;
  let c = e.vertexShader, u = e.fragmentShader;
  const d = JN(e), h = tL(e), p = eL(e), m = nL(e), g = iL(e), _ = jN(e), b = WN(o), E = a.createProgram();
  let S, y, A = e.glslVersion ? "#version " + e.glslVersion + `
` : "";
  e.isRawShaderMaterial ? (S = [
    "#define SHADER_TYPE " + e.shaderType,
    "#define SHADER_NAME " + e.shaderName,
    b
  ].filter(Sc).join(`
`), S.length > 0 && (S += `
`), y = [
    "#define SHADER_TYPE " + e.shaderType,
    "#define SHADER_NAME " + e.shaderName,
    b
  ].filter(Sc).join(`
`), y.length > 0 && (y += `
`)) : (S = [
    KS(e),
    "#define SHADER_TYPE " + e.shaderType,
    "#define SHADER_NAME " + e.shaderName,
    b,
    e.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "",
    e.batching ? "#define USE_BATCHING" : "",
    e.batchingColor ? "#define USE_BATCHING_COLOR" : "",
    e.instancing ? "#define USE_INSTANCING" : "",
    e.instancingColor ? "#define USE_INSTANCING_COLOR" : "",
    e.instancingMorph ? "#define USE_INSTANCING_MORPH" : "",
    e.useFog && e.fog ? "#define USE_FOG" : "",
    e.useFog && e.fogExp2 ? "#define FOG_EXP2" : "",
    e.map ? "#define USE_MAP" : "",
    e.envMap ? "#define USE_ENVMAP" : "",
    e.envMap ? "#define " + p : "",
    e.lightMap ? "#define USE_LIGHTMAP" : "",
    e.aoMap ? "#define USE_AOMAP" : "",
    e.bumpMap ? "#define USE_BUMPMAP" : "",
    e.normalMap ? "#define USE_NORMALMAP" : "",
    e.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    e.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    e.displacementMap ? "#define USE_DISPLACEMENTMAP" : "",
    e.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    e.anisotropy ? "#define USE_ANISOTROPY" : "",
    e.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    e.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    e.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    e.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    e.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    e.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    e.specularMap ? "#define USE_SPECULARMAP" : "",
    e.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    e.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    e.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    e.metalnessMap ? "#define USE_METALNESSMAP" : "",
    e.alphaMap ? "#define USE_ALPHAMAP" : "",
    e.alphaHash ? "#define USE_ALPHAHASH" : "",
    e.transmission ? "#define USE_TRANSMISSION" : "",
    e.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    e.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    e.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    e.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    //
    e.mapUv ? "#define MAP_UV " + e.mapUv : "",
    e.alphaMapUv ? "#define ALPHAMAP_UV " + e.alphaMapUv : "",
    e.lightMapUv ? "#define LIGHTMAP_UV " + e.lightMapUv : "",
    e.aoMapUv ? "#define AOMAP_UV " + e.aoMapUv : "",
    e.emissiveMapUv ? "#define EMISSIVEMAP_UV " + e.emissiveMapUv : "",
    e.bumpMapUv ? "#define BUMPMAP_UV " + e.bumpMapUv : "",
    e.normalMapUv ? "#define NORMALMAP_UV " + e.normalMapUv : "",
    e.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + e.displacementMapUv : "",
    e.metalnessMapUv ? "#define METALNESSMAP_UV " + e.metalnessMapUv : "",
    e.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + e.roughnessMapUv : "",
    e.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + e.anisotropyMapUv : "",
    e.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + e.clearcoatMapUv : "",
    e.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + e.clearcoatNormalMapUv : "",
    e.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + e.clearcoatRoughnessMapUv : "",
    e.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + e.iridescenceMapUv : "",
    e.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + e.iridescenceThicknessMapUv : "",
    e.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + e.sheenColorMapUv : "",
    e.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + e.sheenRoughnessMapUv : "",
    e.specularMapUv ? "#define SPECULARMAP_UV " + e.specularMapUv : "",
    e.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + e.specularColorMapUv : "",
    e.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + e.specularIntensityMapUv : "",
    e.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + e.transmissionMapUv : "",
    e.thicknessMapUv ? "#define THICKNESSMAP_UV " + e.thicknessMapUv : "",
    //
    e.vertexTangents && e.flatShading === !1 ? "#define USE_TANGENT" : "",
    e.vertexColors ? "#define USE_COLOR" : "",
    e.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    e.vertexUv1s ? "#define USE_UV1" : "",
    e.vertexUv2s ? "#define USE_UV2" : "",
    e.vertexUv3s ? "#define USE_UV3" : "",
    e.pointsUvs ? "#define USE_POINTS_UV" : "",
    e.flatShading ? "#define FLAT_SHADED" : "",
    e.skinning ? "#define USE_SKINNING" : "",
    e.morphTargets ? "#define USE_MORPHTARGETS" : "",
    e.morphNormals && e.flatShading === !1 ? "#define USE_MORPHNORMALS" : "",
    e.morphColors ? "#define USE_MORPHCOLORS" : "",
    e.morphTargetsCount > 0 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + e.morphTextureStride : "",
    e.morphTargetsCount > 0 ? "#define MORPHTARGETS_COUNT " + e.morphTargetsCount : "",
    e.doubleSided ? "#define DOUBLE_SIDED" : "",
    e.flipSided ? "#define FLIP_SIDED" : "",
    e.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    e.shadowMapEnabled ? "#define " + d : "",
    e.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",
    e.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    e.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    e.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(Sc).join(`
`), y = [
    KS(e),
    "#define SHADER_TYPE " + e.shaderType,
    "#define SHADER_NAME " + e.shaderName,
    b,
    e.useFog && e.fog ? "#define USE_FOG" : "",
    e.useFog && e.fogExp2 ? "#define FOG_EXP2" : "",
    e.alphaToCoverage ? "#define ALPHA_TO_COVERAGE" : "",
    e.map ? "#define USE_MAP" : "",
    e.matcap ? "#define USE_MATCAP" : "",
    e.envMap ? "#define USE_ENVMAP" : "",
    e.envMap ? "#define " + h : "",
    e.envMap ? "#define " + p : "",
    e.envMap ? "#define " + m : "",
    g ? "#define CUBEUV_TEXEL_WIDTH " + g.texelWidth : "",
    g ? "#define CUBEUV_TEXEL_HEIGHT " + g.texelHeight : "",
    g ? "#define CUBEUV_MAX_MIP " + g.maxMip + ".0" : "",
    e.lightMap ? "#define USE_LIGHTMAP" : "",
    e.aoMap ? "#define USE_AOMAP" : "",
    e.bumpMap ? "#define USE_BUMPMAP" : "",
    e.normalMap ? "#define USE_NORMALMAP" : "",
    e.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    e.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    e.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    e.anisotropy ? "#define USE_ANISOTROPY" : "",
    e.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    e.clearcoat ? "#define USE_CLEARCOAT" : "",
    e.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    e.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    e.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    e.dispersion ? "#define USE_DISPERSION" : "",
    e.iridescence ? "#define USE_IRIDESCENCE" : "",
    e.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    e.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    e.specularMap ? "#define USE_SPECULARMAP" : "",
    e.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    e.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    e.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    e.metalnessMap ? "#define USE_METALNESSMAP" : "",
    e.alphaMap ? "#define USE_ALPHAMAP" : "",
    e.alphaTest ? "#define USE_ALPHATEST" : "",
    e.alphaHash ? "#define USE_ALPHAHASH" : "",
    e.sheen ? "#define USE_SHEEN" : "",
    e.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    e.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    e.transmission ? "#define USE_TRANSMISSION" : "",
    e.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    e.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    e.vertexTangents && e.flatShading === !1 ? "#define USE_TANGENT" : "",
    e.vertexColors || e.instancingColor || e.batchingColor ? "#define USE_COLOR" : "",
    e.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    e.vertexUv1s ? "#define USE_UV1" : "",
    e.vertexUv2s ? "#define USE_UV2" : "",
    e.vertexUv3s ? "#define USE_UV3" : "",
    e.pointsUvs ? "#define USE_POINTS_UV" : "",
    e.gradientMap ? "#define USE_GRADIENTMAP" : "",
    e.flatShading ? "#define FLAT_SHADED" : "",
    e.doubleSided ? "#define DOUBLE_SIDED" : "",
    e.flipSided ? "#define FLIP_SIDED" : "",
    e.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    e.shadowMapEnabled ? "#define " + d : "",
    e.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
    e.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    e.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
    e.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
    e.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    e.reverseDepthBuffer ? "#define USE_REVERSEDEPTHBUF" : "",
    "uniform mat4 viewMatrix;",
    "uniform vec3 cameraPosition;",
    "uniform bool isOrthographic;",
    e.toneMapping !== Gs ? "#define TONE_MAPPING" : "",
    e.toneMapping !== Gs ? ye.tonemapping_pars_fragment : "",
    // this code is required here because it is used by the toneMapping() function defined below
    e.toneMapping !== Gs ? GN("toneMapping", e.toneMapping) : "",
    e.dithering ? "#define DITHERING" : "",
    e.opaque ? "#define OPAQUE" : "",
    ye.colorspace_pars_fragment,
    // this code is required here because it is used by the various encoding/decoding function defined below
    kN("linearToOutputTexel", e.outputColorSpace),
    XN(),
    e.useDepthPacking ? "#define DEPTH_PACKING " + e.depthPacking : "",
    `
`
  ].filter(Sc).join(`
`)), c = Zg(c), c = qS(c, e), c = ZS(c, e), u = Zg(u), u = qS(u, e), u = ZS(u, e), c = $S(c), u = $S(u), e.isRawShaderMaterial !== !0 && (A = `#version 300 es
`, S = [
    _,
    "#define attribute in",
    "#define varying out",
    "#define texture2D texture"
  ].join(`
`) + `
` + S, y = [
    "#define varying in",
    e.glslVersion === hd ? "" : "layout(location = 0) out highp vec4 pc_fragColor;",
    e.glslVersion === hd ? "" : "#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(`
`) + `
` + y);
  const w = A + S + c, M = A + y + u, O = jS(a, a.VERTEX_SHADER, w), L = jS(a, a.FRAGMENT_SHADER, M);
  a.attachShader(E, O), a.attachShader(E, L), e.index0AttributeName !== void 0 ? a.bindAttribLocation(E, 0, e.index0AttributeName) : e.morphTargets === !0 && a.bindAttribLocation(E, 0, "position"), a.linkProgram(E);
  function N(U) {
    if (n.debug.checkShaderErrors) {
      const B = a.getProgramInfoLog(E).trim(), I = a.getShaderInfoLog(O).trim(), C = a.getShaderInfoLog(L).trim();
      let X = !0, D = !0;
      if (a.getProgramParameter(E, a.LINK_STATUS) === !1)
        if (X = !1, typeof n.debug.onShaderError == "function")
          n.debug.onShaderError(a, E, O, L);
        else {
          const V = YS(a, O, "vertex"), H = YS(a, L, "fragment");
          console.error(
            "THREE.WebGLProgram: Shader Error " + a.getError() + " - VALIDATE_STATUS " + a.getProgramParameter(E, a.VALIDATE_STATUS) + `

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

Program Info Log: ` + B + `
` + V + `
` + H
          );
        }
      else B !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", B) : (I === "" || C === "") && (D = !1);
      D && (U.diagnostics = {
        runnable: X,
        programLog: B,
        vertexShader: {
          log: I,
          prefix: S
        },
        fragmentShader: {
          log: C,
          prefix: y
        }
      });
    }
    a.deleteShader(O), a.deleteShader(L), z = new sd(a, E), R = YN(a, E);
  }
  let z;
  this.getUniforms = function() {
    return z === void 0 && N(this), z;
  };
  let R;
  this.getAttributes = function() {
    return R === void 0 && N(this), R;
  };
  let T = e.rendererExtensionParallelShaderCompile === !1;
  return this.isReady = function() {
    return T === !1 && (T = a.getProgramParameter(E, BN)), T;
  }, this.destroy = function() {
    r.releaseStatesOfProgram(this), a.deleteProgram(E), this.program = void 0;
  }, this.type = e.shaderType, this.name = e.shaderName, this.id = FN++, this.cacheKey = t, this.usedTimes = 1, this.program = E, this.vertexShader = O, this.fragmentShader = L, this;
}
let sL = 0;
class aL {
  constructor() {
    this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();
  }
  update(t) {
    const e = t.vertexShader, r = t.fragmentShader, a = this._getShaderStage(e), o = this._getShaderStage(r), c = this._getShaderCacheForMaterial(t);
    return c.has(a) === !1 && (c.add(a), a.usedTimes++), c.has(o) === !1 && (c.add(o), o.usedTimes++), this;
  }
  remove(t) {
    const e = this.materialCache.get(t);
    for (const r of e)
      r.usedTimes--, r.usedTimes === 0 && this.shaderCache.delete(r.code);
    return this.materialCache.delete(t), this;
  }
  getVertexShaderID(t) {
    return this._getShaderStage(t.vertexShader).id;
  }
  getFragmentShaderID(t) {
    return this._getShaderStage(t.fragmentShader).id;
  }
  dispose() {
    this.shaderCache.clear(), this.materialCache.clear();
  }
  _getShaderCacheForMaterial(t) {
    const e = this.materialCache;
    let r = e.get(t);
    return r === void 0 && (r = /* @__PURE__ */ new Set(), e.set(t, r)), r;
  }
  _getShaderStage(t) {
    const e = this.shaderCache;
    let r = e.get(t);
    return r === void 0 && (r = new oL(t), e.set(t, r)), r;
  }
}
class oL {
  constructor(t) {
    this.id = sL++, this.code = t, this.usedTimes = 0;
  }
}
function lL(n, t, e, r, a, o, c) {
  const u = new yM(), d = new aL(), h = /* @__PURE__ */ new Set(), p = [], m = a.logarithmicDepthBuffer, g = a.vertexTextures;
  let _ = a.precision;
  const b = {
    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 E(R) {
    return h.add(R), R === 0 ? "uv" : `uv${R}`;
  }
  function S(R, T, U, B, I) {
    const C = B.fog, X = I.geometry, D = R.isMeshStandardMaterial ? B.environment : null, V = (R.isMeshStandardMaterial ? e : t).get(R.envMap || D), H = V && V.mapping === Dd ? V.image.height : null, j = b[R.type];
    R.precision !== null && (_ = a.getMaxPrecision(R.precision), _ !== R.precision && console.warn("THREE.WebGLProgram.getParameters:", R.precision, "not supported, using", _, "instead."));
    const K = X.morphAttributes.position || X.morphAttributes.normal || X.morphAttributes.color, F = K !== void 0 ? K.length : 0;
    let q = 0;
    X.morphAttributes.position !== void 0 && (q = 1), X.morphAttributes.normal !== void 0 && (q = 2), X.morphAttributes.color !== void 0 && (q = 3);
    let it, G, k, $;
    if (j) {
      const De = di[j];
      it = De.vertexShader, G = De.fragmentShader;
    } else
      it = R.vertexShader, G = R.fragmentShader, d.update(R), k = d.getVertexShaderID(R), $ = d.getFragmentShaderID(R);
    const Q = n.getRenderTarget(), et = n.state.buffers.depth.getReversed(), st = I.isInstancedMesh === !0, _t = I.isBatchedMesh === !0, Mt = !!R.map, Rt = !!R.matcap, Ot = !!V, nt = !!R.aoMap, Jt = !!R.lightMap, Ft = !!R.bumpMap, ne = !!R.normalMap, jt = !!R.displacementMap, xe = !!R.emissiveMap, qt = !!R.metalnessMap, tt = !!R.roughnessMap, W = R.anisotropy > 0, mt = R.clearcoat > 0, Et = R.dispersion > 0, Dt = R.iridescence > 0, wt = R.sheen > 0, Zt = R.transmission > 0, Pt = W && !!R.anisotropyMap, Wt = mt && !!R.clearcoatMap, _e = mt && !!R.clearcoatNormalMap, Ut = mt && !!R.clearcoatRoughnessMap, Yt = Dt && !!R.iridescenceMap, te = Dt && !!R.iridescenceThicknessMap, Kt = wt && !!R.sheenColorMap, Gt = wt && !!R.sheenRoughnessMap, le = !!R.specularMap, he = !!R.specularColorMap, Fe = !!R.specularIntensityMap, ut = Zt && !!R.transmissionMap, zt = Zt && !!R.thicknessMap, St = !!R.gradientMap, Ct = !!R.alphaMap, It = R.alphaTest > 0, Ht = !!R.alphaHash, ue = !!R.extensions;
    let tn = Gs;
    R.toneMapped && (Q === null || Q.isXRRenderTarget === !0) && (tn = n.toneMapping);
    const dn = {
      shaderID: j,
      shaderType: R.type,
      shaderName: R.name,
      vertexShader: it,
      fragmentShader: G,
      defines: R.defines,
      customVertexShaderID: k,
      customFragmentShaderID: $,
      isRawShaderMaterial: R.isRawShaderMaterial === !0,
      glslVersion: R.glslVersion,
      precision: _,
      batching: _t,
      batchingColor: _t && I._colorsTexture !== null,
      instancing: st,
      instancingColor: st && I.instanceColor !== null,
      instancingMorph: st && I.morphTexture !== null,
      supportsVertexTextures: g,
      outputColorSpace: Q === null ? n.outputColorSpace : Q.isXRRenderTarget === !0 ? Q.texture.colorSpace : sl,
      alphaToCoverage: !!R.alphaToCoverage,
      map: Mt,
      matcap: Rt,
      envMap: Ot,
      envMapMode: Ot && V.mapping,
      envMapCubeUVHeight: H,
      aoMap: nt,
      lightMap: Jt,
      bumpMap: Ft,
      normalMap: ne,
      displacementMap: g && jt,
      emissiveMap: xe,
      normalMapObjectSpace: ne && R.normalMapType === H2,
      normalMapTangentSpace: ne && R.normalMapType === hM,
      metalnessMap: qt,
      roughnessMap: tt,
      anisotropy: W,
      anisotropyMap: Pt,
      clearcoat: mt,
      clearcoatMap: Wt,
      clearcoatNormalMap: _e,
      clearcoatRoughnessMap: Ut,
      dispersion: Et,
      iridescence: Dt,
      iridescenceMap: Yt,
      iridescenceThicknessMap: te,
      sheen: wt,
      sheenColorMap: Kt,
      sheenRoughnessMap: Gt,
      specularMap: le,
      specularColorMap: he,
      specularIntensityMap: Fe,
      transmission: Zt,
      transmissionMap: ut,
      thicknessMap: zt,
      gradientMap: St,
      opaque: R.transparent === !1 && R.blending === Zo && R.alphaToCoverage === !1,
      alphaMap: Ct,
      alphaTest: It,
      alphaHash: Ht,
      combine: R.combine,
      //
      mapUv: Mt && E(R.map.channel),
      aoMapUv: nt && E(R.aoMap.channel),
      lightMapUv: Jt && E(R.lightMap.channel),
      bumpMapUv: Ft && E(R.bumpMap.channel),
      normalMapUv: ne && E(R.normalMap.channel),
      displacementMapUv: jt && E(R.displacementMap.channel),
      emissiveMapUv: xe && E(R.emissiveMap.channel),
      metalnessMapUv: qt && E(R.metalnessMap.channel),
      roughnessMapUv: tt && E(R.roughnessMap.channel),
      anisotropyMapUv: Pt && E(R.anisotropyMap.channel),
      clearcoatMapUv: Wt && E(R.clearcoatMap.channel),
      clearcoatNormalMapUv: _e && E(R.clearcoatNormalMap.channel),
      clearcoatRoughnessMapUv: Ut && E(R.clearcoatRoughnessMap.channel),
      iridescenceMapUv: Yt && E(R.iridescenceMap.channel),
      iridescenceThicknessMapUv: te && E(R.iridescenceThicknessMap.channel),
      sheenColorMapUv: Kt && E(R.sheenColorMap.channel),
      sheenRoughnessMapUv: Gt && E(R.sheenRoughnessMap.channel),
      specularMapUv: le && E(R.specularMap.channel),
      specularColorMapUv: he && E(R.specularColorMap.channel),
      specularIntensityMapUv: Fe && E(R.specularIntensityMap.channel),
      transmissionMapUv: ut && E(R.transmissionMap.channel),
      thicknessMapUv: zt && E(R.thicknessMap.channel),
      alphaMapUv: Ct && E(R.alphaMap.channel),
      //
      vertexTangents: !!X.attributes.tangent && (ne || W),
      vertexColors: R.vertexColors,
      vertexAlphas: R.vertexColors === !0 && !!X.attributes.color && X.attributes.color.itemSize === 4,
      pointsUvs: I.isPoints === !0 && !!X.attributes.uv && (Mt || Ct),
      fog: !!C,
      useFog: R.fog === !0,
      fogExp2: !!C && C.isFogExp2,
      flatShading: R.flatShading === !0,
      sizeAttenuation: R.sizeAttenuation === !0,
      logarithmicDepthBuffer: m,
      reverseDepthBuffer: et,
      skinning: I.isSkinnedMesh === !0,
      morphTargets: X.morphAttributes.position !== void 0,
      morphNormals: X.morphAttributes.normal !== void 0,
      morphColors: X.morphAttributes.color !== void 0,
      morphTargetsCount: F,
      morphTextureStride: q,
      numDirLights: T.directional.length,
      numPointLights: T.point.length,
      numSpotLights: T.spot.length,
      numSpotLightMaps: T.spotLightMap.length,
      numRectAreaLights: T.rectArea.length,
      numHemiLights: T.hemi.length,
      numDirLightShadows: T.directionalShadowMap.length,
      numPointLightShadows: T.pointShadowMap.length,
      numSpotLightShadows: T.spotShadowMap.length,
      numSpotLightShadowsWithMaps: T.numSpotLightShadowsWithMaps,
      numLightProbes: T.numLightProbes,
      numClippingPlanes: c.numPlanes,
      numClipIntersection: c.numIntersection,
      dithering: R.dithering,
      shadowMapEnabled: n.shadowMap.enabled && U.length > 0,
      shadowMapType: n.shadowMap.type,
      toneMapping: tn,
      decodeVideoTexture: Mt && R.map.isVideoTexture === !0 && Ie.getTransfer(R.map.colorSpace) === qe,
      decodeVideoTextureEmissive: xe && R.emissiveMap.isVideoTexture === !0 && Ie.getTransfer(R.emissiveMap.colorSpace) === qe,
      premultipliedAlpha: R.premultipliedAlpha,
      doubleSided: R.side === ur,
      flipSided: R.side === pi,
      useDepthPacking: R.depthPacking >= 0,
      depthPacking: R.depthPacking || 0,
      index0AttributeName: R.index0AttributeName,
      extensionClipCullDistance: ue && R.extensions.clipCullDistance === !0 && r.has("WEBGL_clip_cull_distance"),
      extensionMultiDraw: (ue && R.extensions.multiDraw === !0 || _t) && r.has("WEBGL_multi_draw"),
      rendererExtensionParallelShaderCompile: r.has("KHR_parallel_shader_compile"),
      customProgramCacheKey: R.customProgramCacheKey()
    };
    return dn.vertexUv1s = h.has(1), dn.vertexUv2s = h.has(2), dn.vertexUv3s = h.has(3), h.clear(), dn;
  }
  function y(R) {
    const T = [];
    if (R.shaderID ? T.push(R.shaderID) : (T.push(R.customVertexShaderID), T.push(R.customFragmentShaderID)), R.defines !== void 0)
      for (const U in R.defines)
        T.push(U), T.push(R.defines[U]);
    return R.isRawShaderMaterial === !1 && (A(T, R), w(T, R), T.push(n.outputColorSpace)), T.push(R.customProgramCacheKey), T.join();
  }
  function A(R, T) {
    R.push(T.precision), R.push(T.outputColorSpace), R.push(T.envMapMode), R.push(T.envMapCubeUVHeight), R.push(T.mapUv), R.push(T.alphaMapUv), R.push(T.lightMapUv), R.push(T.aoMapUv), R.push(T.bumpMapUv), R.push(T.normalMapUv), R.push(T.displacementMapUv), R.push(T.emissiveMapUv), R.push(T.metalnessMapUv), R.push(T.roughnessMapUv), R.push(T.anisotropyMapUv), R.push(T.clearcoatMapUv), R.push(T.clearcoatNormalMapUv), R.push(T.clearcoatRoughnessMapUv), R.push(T.iridescenceMapUv), R.push(T.iridescenceThicknessMapUv), R.push(T.sheenColorMapUv), R.push(T.sheenRoughnessMapUv), R.push(T.specularMapUv), R.push(T.specularColorMapUv), R.push(T.specularIntensityMapUv), R.push(T.transmissionMapUv), R.push(T.thicknessMapUv), R.push(T.combine), R.push(T.fogExp2), R.push(T.sizeAttenuation), R.push(T.morphTargetsCount), R.push(T.morphAttributeCount), R.push(T.numDirLights), R.push(T.numPointLights), R.push(T.numSpotLights), R.push(T.numSpotLightMaps), R.push(T.numHemiLights), R.push(T.numRectAreaLights), R.push(T.numDirLightShadows), R.push(T.numPointLightShadows), R.push(T.numSpotLightShadows), R.push(T.numSpotLightShadowsWithMaps), R.push(T.numLightProbes), R.push(T.shadowMapType), R.push(T.toneMapping), R.push(T.numClippingPlanes), R.push(T.numClipIntersection), R.push(T.depthPacking);
  }
  function w(R, T) {
    u.disableAll(), T.supportsVertexTextures && u.enable(0), T.instancing && u.enable(1), T.instancingColor && u.enable(2), T.instancingMorph && u.enable(3), T.matcap && u.enable(4), T.envMap && u.enable(5), T.normalMapObjectSpace && u.enable(6), T.normalMapTangentSpace && u.enable(7), T.clearcoat && u.enable(8), T.iridescence && u.enable(9), T.alphaTest && u.enable(10), T.vertexColors && u.enable(11), T.vertexAlphas && u.enable(12), T.vertexUv1s && u.enable(13), T.vertexUv2s && u.enable(14), T.vertexUv3s && u.enable(15), T.vertexTangents && u.enable(16), T.anisotropy && u.enable(17), T.alphaHash && u.enable(18), T.batching && u.enable(19), T.dispersion && u.enable(20), T.batchingColor && u.enable(21), R.push(u.mask), u.disableAll(), T.fog && u.enable(0), T.useFog && u.enable(1), T.flatShading && u.enable(2), T.logarithmicDepthBuffer && u.enable(3), T.reverseDepthBuffer && u.enable(4), T.skinning && u.enable(5), T.morphTargets && u.enable(6), T.morphNormals && u.enable(7), T.morphColors && u.enable(8), T.premultipliedAlpha && u.enable(9), T.shadowMapEnabled && u.enable(10), T.doubleSided && u.enable(11), T.flipSided && u.enable(12), T.useDepthPacking && u.enable(13), T.dithering && u.enable(14), T.transmission && u.enable(15), T.sheen && u.enable(16), T.opaque && u.enable(17), T.pointsUvs && u.enable(18), T.decodeVideoTexture && u.enable(19), T.decodeVideoTextureEmissive && u.enable(20), T.alphaToCoverage && u.enable(21), R.push(u.mask);
  }
  function M(R) {
    const T = b[R.type];
    let U;
    if (T) {
      const B = di[T];
      U = w0.clone(B.uniforms);
    } else
      U = R.uniforms;
    return U;
  }
  function O(R, T) {
    let U;
    for (let B = 0, I = p.length; B < I; B++) {
      const C = p[B];
      if (C.cacheKey === T) {
        U = C, ++U.usedTimes;
        break;
      }
    }
    return U === void 0 && (U = new rL(n, T, R, o), p.push(U)), U;
  }
  function L(R) {
    if (--R.usedTimes === 0) {
      const T = p.indexOf(R);
      p[T] = p[p.length - 1], p.pop(), R.destroy();
    }
  }
  function N(R) {
    d.remove(R);
  }
  function z() {
    d.dispose();
  }
  return {
    getParameters: S,
    getProgramCacheKey: y,
    getUniforms: M,
    acquireProgram: O,
    releaseProgram: L,
    releaseShaderCache: N,
    // Exposed for resource monitoring & error feedback via renderer.info:
    programs: p,
    dispose: z
  };
}
function cL() {
  let n = /* @__PURE__ */ new WeakMap();
  function t(c) {
    return n.has(c);
  }
  function e(c) {
    let u = n.get(c);
    return u === void 0 && (u = {}, n.set(c, u)), u;
  }
  function r(c) {
    n.delete(c);
  }
  function a(c, u, d) {
    n.get(c)[u] = d;
  }
  function o() {
    n = /* @__PURE__ */ new WeakMap();
  }
  return {
    has: t,
    get: e,
    remove: r,
    update: a,
    dispose: o
  };
}
function uL(n, t) {
  return n.groupOrder !== t.groupOrder ? n.groupOrder - t.groupOrder : n.renderOrder !== t.renderOrder ? n.renderOrder - t.renderOrder : n.material.id !== t.material.id ? n.material.id - t.material.id : n.z !== t.z ? n.z - t.z : n.id - t.id;
}
function QS(n, t) {
  return n.groupOrder !== t.groupOrder ? n.groupOrder - t.groupOrder : n.renderOrder !== t.renderOrder ? n.renderOrder - t.renderOrder : n.z !== t.z ? t.z - n.z : n.id - t.id;
}
function JS() {
  const n = [];
  let t = 0;
  const e = [], r = [], a = [];
  function o() {
    t = 0, e.length = 0, r.length = 0, a.length = 0;
  }
  function c(m, g, _, b, E, S) {
    let y = n[t];
    return y === void 0 ? (y = {
      id: m.id,
      object: m,
      geometry: g,
      material: _,
      groupOrder: b,
      renderOrder: m.renderOrder,
      z: E,
      group: S
    }, n[t] = y) : (y.id = m.id, y.object = m, y.geometry = g, y.material = _, y.groupOrder = b, y.renderOrder = m.renderOrder, y.z = E, y.group = S), t++, y;
  }
  function u(m, g, _, b, E, S) {
    const y = c(m, g, _, b, E, S);
    _.transmission > 0 ? r.push(y) : _.transparent === !0 ? a.push(y) : e.push(y);
  }
  function d(m, g, _, b, E, S) {
    const y = c(m, g, _, b, E, S);
    _.transmission > 0 ? r.unshift(y) : _.transparent === !0 ? a.unshift(y) : e.unshift(y);
  }
  function h(m, g) {
    e.length > 1 && e.sort(m || uL), r.length > 1 && r.sort(g || QS), a.length > 1 && a.sort(g || QS);
  }
  function p() {
    for (let m = t, g = n.length; m < g; m++) {
      const _ = n[m];
      if (_.id === null) break;
      _.id = null, _.object = null, _.geometry = null, _.material = null, _.group = null;
    }
  }
  return {
    opaque: e,
    transmissive: r,
    transparent: a,
    init: o,
    push: u,
    unshift: d,
    finish: p,
    sort: h
  };
}
function fL() {
  let n = /* @__PURE__ */ new WeakMap();
  function t(r, a) {
    const o = n.get(r);
    let c;
    return o === void 0 ? (c = new JS(), n.set(r, [c])) : a >= o.length ? (c = new JS(), o.push(c)) : c = o[a], c;
  }
  function e() {
    n = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: t,
    dispose: e
  };
}
function dL() {
  const n = {};
  return {
    get: function(t) {
      if (n[t.id] !== void 0)
        return n[t.id];
      let e;
      switch (t.type) {
        case "DirectionalLight":
          e = {
            direction: new ot(),
            color: new Me()
          };
          break;
        case "SpotLight":
          e = {
            position: new ot(),
            direction: new ot(),
            color: new Me(),
            distance: 0,
            coneCos: 0,
            penumbraCos: 0,
            decay: 0
          };
          break;
        case "PointLight":
          e = {
            position: new ot(),
            color: new Me(),
            distance: 0,
            decay: 0
          };
          break;
        case "HemisphereLight":
          e = {
            direction: new ot(),
            skyColor: new Me(),
            groundColor: new Me()
          };
          break;
        case "RectAreaLight":
          e = {
            color: new Me(),
            position: new ot(),
            halfWidth: new ot(),
            halfHeight: new ot()
          };
          break;
      }
      return n[t.id] = e, e;
    }
  };
}
function hL() {
  const n = {};
  return {
    get: function(t) {
      if (n[t.id] !== void 0)
        return n[t.id];
      let e;
      switch (t.type) {
        case "DirectionalLight":
          e = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new oe()
          };
          break;
        case "SpotLight":
          e = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new oe()
          };
          break;
        case "PointLight":
          e = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new oe(),
            shadowCameraNear: 1,
            shadowCameraFar: 1e3
          };
          break;
      }
      return n[t.id] = e, e;
    }
  };
}
let pL = 0;
function mL(n, t) {
  return (t.castShadow ? 2 : 0) - (n.castShadow ? 2 : 0) + (t.map ? 1 : 0) - (n.map ? 1 : 0);
}
function gL(n) {
  const t = new dL(), e = hL(), r = {
    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 h = 0; h < 9; h++) r.probe.push(new ot());
  const a = new ot(), o = new Ge(), c = new Ge();
  function u(h) {
    let p = 0, m = 0, g = 0;
    for (let R = 0; R < 9; R++) r.probe[R].set(0, 0, 0);
    let _ = 0, b = 0, E = 0, S = 0, y = 0, A = 0, w = 0, M = 0, O = 0, L = 0, N = 0;
    h.sort(mL);
    for (let R = 0, T = h.length; R < T; R++) {
      const U = h[R], B = U.color, I = U.intensity, C = U.distance, X = U.shadow && U.shadow.map ? U.shadow.map.texture : null;
      if (U.isAmbientLight)
        p += B.r * I, m += B.g * I, g += B.b * I;
      else if (U.isLightProbe) {
        for (let D = 0; D < 9; D++)
          r.probe[D].addScaledVector(U.sh.coefficients[D], I);
        N++;
      } else if (U.isDirectionalLight) {
        const D = t.get(U);
        if (D.color.copy(U.color).multiplyScalar(U.intensity), U.castShadow) {
          const V = U.shadow, H = e.get(U);
          H.shadowIntensity = V.intensity, H.shadowBias = V.bias, H.shadowNormalBias = V.normalBias, H.shadowRadius = V.radius, H.shadowMapSize = V.mapSize, r.directionalShadow[_] = H, r.directionalShadowMap[_] = X, r.directionalShadowMatrix[_] = U.shadow.matrix, A++;
        }
        r.directional[_] = D, _++;
      } else if (U.isSpotLight) {
        const D = t.get(U);
        D.position.setFromMatrixPosition(U.matrixWorld), D.color.copy(B).multiplyScalar(I), D.distance = C, D.coneCos = Math.cos(U.angle), D.penumbraCos = Math.cos(U.angle * (1 - U.penumbra)), D.decay = U.decay, r.spot[E] = D;
        const V = U.shadow;
        if (U.map && (r.spotLightMap[O] = U.map, O++, V.updateMatrices(U), U.castShadow && L++), r.spotLightMatrix[E] = V.matrix, U.castShadow) {
          const H = e.get(U);
          H.shadowIntensity = V.intensity, H.shadowBias = V.bias, H.shadowNormalBias = V.normalBias, H.shadowRadius = V.radius, H.shadowMapSize = V.mapSize, r.spotShadow[E] = H, r.spotShadowMap[E] = X, M++;
        }
        E++;
      } else if (U.isRectAreaLight) {
        const D = t.get(U);
        D.color.copy(B).multiplyScalar(I), D.halfWidth.set(U.width * 0.5, 0, 0), D.halfHeight.set(0, U.height * 0.5, 0), r.rectArea[S] = D, S++;
      } else if (U.isPointLight) {
        const D = t.get(U);
        if (D.color.copy(U.color).multiplyScalar(U.intensity), D.distance = U.distance, D.decay = U.decay, U.castShadow) {
          const V = U.shadow, H = e.get(U);
          H.shadowIntensity = V.intensity, H.shadowBias = V.bias, H.shadowNormalBias = V.normalBias, H.shadowRadius = V.radius, H.shadowMapSize = V.mapSize, H.shadowCameraNear = V.camera.near, H.shadowCameraFar = V.camera.far, r.pointShadow[b] = H, r.pointShadowMap[b] = X, r.pointShadowMatrix[b] = U.shadow.matrix, w++;
        }
        r.point[b] = D, b++;
      } else if (U.isHemisphereLight) {
        const D = t.get(U);
        D.skyColor.copy(U.color).multiplyScalar(I), D.groundColor.copy(U.groundColor).multiplyScalar(I), r.hemi[y] = D, y++;
      }
    }
    S > 0 && (n.has("OES_texture_float_linear") === !0 ? (r.rectAreaLTC1 = Bt.LTC_FLOAT_1, r.rectAreaLTC2 = Bt.LTC_FLOAT_2) : (r.rectAreaLTC1 = Bt.LTC_HALF_1, r.rectAreaLTC2 = Bt.LTC_HALF_2)), r.ambient[0] = p, r.ambient[1] = m, r.ambient[2] = g;
    const z = r.hash;
    (z.directionalLength !== _ || z.pointLength !== b || z.spotLength !== E || z.rectAreaLength !== S || z.hemiLength !== y || z.numDirectionalShadows !== A || z.numPointShadows !== w || z.numSpotShadows !== M || z.numSpotMaps !== O || z.numLightProbes !== N) && (r.directional.length = _, r.spot.length = E, r.rectArea.length = S, r.point.length = b, r.hemi.length = y, r.directionalShadow.length = A, r.directionalShadowMap.length = A, r.pointShadow.length = w, r.pointShadowMap.length = w, r.spotShadow.length = M, r.spotShadowMap.length = M, r.directionalShadowMatrix.length = A, r.pointShadowMatrix.length = w, r.spotLightMatrix.length = M + O - L, r.spotLightMap.length = O, r.numSpotLightShadowsWithMaps = L, r.numLightProbes = N, z.directionalLength = _, z.pointLength = b, z.spotLength = E, z.rectAreaLength = S, z.hemiLength = y, z.numDirectionalShadows = A, z.numPointShadows = w, z.numSpotShadows = M, z.numSpotMaps = O, z.numLightProbes = N, r.version = pL++);
  }
  function d(h, p) {
    let m = 0, g = 0, _ = 0, b = 0, E = 0;
    const S = p.matrixWorldInverse;
    for (let y = 0, A = h.length; y < A; y++) {
      const w = h[y];
      if (w.isDirectionalLight) {
        const M = r.directional[m];
        M.direction.setFromMatrixPosition(w.matrixWorld), a.setFromMatrixPosition(w.target.matrixWorld), M.direction.sub(a), M.direction.transformDirection(S), m++;
      } else if (w.isSpotLight) {
        const M = r.spot[_];
        M.position.setFromMatrixPosition(w.matrixWorld), M.position.applyMatrix4(S), M.direction.setFromMatrixPosition(w.matrixWorld), a.setFromMatrixPosition(w.target.matrixWorld), M.direction.sub(a), M.direction.transformDirection(S), _++;
      } else if (w.isRectAreaLight) {
        const M = r.rectArea[b];
        M.position.setFromMatrixPosition(w.matrixWorld), M.position.applyMatrix4(S), c.identity(), o.copy(w.matrixWorld), o.premultiply(S), c.extractRotation(o), M.halfWidth.set(w.width * 0.5, 0, 0), M.halfHeight.set(0, w.height * 0.5, 0), M.halfWidth.applyMatrix4(c), M.halfHeight.applyMatrix4(c), b++;
      } else if (w.isPointLight) {
        const M = r.point[g];
        M.position.setFromMatrixPosition(w.matrixWorld), M.position.applyMatrix4(S), g++;
      } else if (w.isHemisphereLight) {
        const M = r.hemi[E];
        M.direction.setFromMatrixPosition(w.matrixWorld), M.direction.transformDirection(S), E++;
      }
    }
  }
  return {
    setup: u,
    setupView: d,
    state: r
  };
}
function tb(n) {
  const t = new gL(n), e = [], r = [];
  function a(p) {
    h.camera = p, e.length = 0, r.length = 0;
  }
  function o(p) {
    e.push(p);
  }
  function c(p) {
    r.push(p);
  }
  function u() {
    t.setup(e);
  }
  function d(p) {
    t.setupView(e, p);
  }
  const h = {
    lightsArray: e,
    shadowsArray: r,
    camera: null,
    lights: t,
    transmissionRenderTarget: {}
  };
  return {
    init: a,
    state: h,
    setupLights: u,
    setupLightsView: d,
    pushLight: o,
    pushShadow: c
  };
}
function vL(n) {
  let t = /* @__PURE__ */ new WeakMap();
  function e(a, o = 0) {
    const c = t.get(a);
    let u;
    return c === void 0 ? (u = new tb(n), t.set(a, [u])) : o >= c.length ? (u = new tb(n), c.push(u)) : u = c[o], u;
  }
  function r() {
    t = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: e,
    dispose: r
  };
}
const _L = `void main() {
	gl_Position = vec4( position, 1.0 );
}`, yL = `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 xL(n, t, e) {
  let r = new T0();
  const a = new oe(), o = new oe(), c = new Ke(), u = new VC({ depthPacking: F2 }), d = new kC(), h = {}, p = e.maxTextureSize, m = { [Xs]: pi, [pi]: Xs, [ur]: ur }, g = new gr({
    defines: {
      VSM_SAMPLES: 8
    },
    uniforms: {
      shadow_pass: { value: null },
      resolution: { value: new oe() },
      radius: { value: 4 }
    },
    vertexShader: _L,
    fragmentShader: yL
  }), _ = g.clone();
  _.defines.HORIZONTAL_PASS = 1;
  const b = new qn();
  b.setAttribute(
    "position",
    new fn(
      new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),
      3
    )
  );
  const E = new Dn(b, g), S = this;
  this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = nM;
  let y = this.type;
  this.render = function(L, N, z) {
    if (S.enabled === !1 || S.autoUpdate === !1 && S.needsUpdate === !1 || L.length === 0) return;
    const R = n.getRenderTarget(), T = n.getActiveCubeFace(), U = n.getActiveMipmapLevel(), B = n.state;
    B.setBlending(ks), B.buffers.color.setClear(1, 1, 1, 1), B.buffers.depth.setTest(!0), B.setScissorTest(!1);
    const I = y !== qr && this.type === qr, C = y === qr && this.type !== qr;
    for (let X = 0, D = L.length; X < D; X++) {
      const V = L[X], H = V.shadow;
      if (H === void 0) {
        console.warn("THREE.WebGLShadowMap:", V, "has no shadow.");
        continue;
      }
      if (H.autoUpdate === !1 && H.needsUpdate === !1) continue;
      a.copy(H.mapSize);
      const j = H.getFrameExtents();
      if (a.multiply(j), o.copy(H.mapSize), (a.x > p || a.y > p) && (a.x > p && (o.x = Math.floor(p / j.x), a.x = o.x * j.x, H.mapSize.x = o.x), a.y > p && (o.y = Math.floor(p / j.y), a.y = o.y * j.y, H.mapSize.y = o.y)), H.map === null || I === !0 || C === !0) {
        const F = this.type !== qr ? { minFilter: Yn, magFilter: Yn } : {};
        H.map !== null && H.map.dispose(), H.map = new La(a.x, a.y, F), H.map.texture.name = V.name + ".shadowMap", H.camera.updateProjectionMatrix();
      }
      n.setRenderTarget(H.map), n.clear();
      const K = H.getViewportCount();
      for (let F = 0; F < K; F++) {
        const q = H.getViewport(F);
        c.set(
          o.x * q.x,
          o.y * q.y,
          o.x * q.z,
          o.y * q.w
        ), B.viewport(c), H.updateMatrices(V, F), r = H.getFrustum(), M(N, z, H.camera, V, this.type);
      }
      H.isPointLightShadow !== !0 && this.type === qr && A(H, z), H.needsUpdate = !1;
    }
    y = this.type, S.needsUpdate = !1, n.setRenderTarget(R, T, U);
  };
  function A(L, N) {
    const z = t.update(E);
    g.defines.VSM_SAMPLES !== L.blurSamples && (g.defines.VSM_SAMPLES = L.blurSamples, _.defines.VSM_SAMPLES = L.blurSamples, g.needsUpdate = !0, _.needsUpdate = !0), L.mapPass === null && (L.mapPass = new La(a.x, a.y)), g.uniforms.shadow_pass.value = L.map.texture, g.uniforms.resolution.value = L.mapSize, g.uniforms.radius.value = L.radius, n.setRenderTarget(L.mapPass), n.clear(), n.renderBufferDirect(N, null, z, g, E, null), _.uniforms.shadow_pass.value = L.mapPass.texture, _.uniforms.resolution.value = L.mapSize, _.uniforms.radius.value = L.radius, n.setRenderTarget(L.map), n.clear(), n.renderBufferDirect(N, null, z, _, E, null);
  }
  function w(L, N, z, R) {
    let T = null;
    const U = z.isPointLight === !0 ? L.customDistanceMaterial : L.customDepthMaterial;
    if (U !== void 0)
      T = U;
    else if (T = z.isPointLight === !0 ? d : u, n.localClippingEnabled && N.clipShadows === !0 && Array.isArray(N.clippingPlanes) && N.clippingPlanes.length !== 0 || N.displacementMap && N.displacementScale !== 0 || N.alphaMap && N.alphaTest > 0 || N.map && N.alphaTest > 0) {
      const B = T.uuid, I = N.uuid;
      let C = h[B];
      C === void 0 && (C = {}, h[B] = C);
      let X = C[I];
      X === void 0 && (X = T.clone(), C[I] = X, N.addEventListener("dispose", O)), T = X;
    }
    if (T.visible = N.visible, T.wireframe = N.wireframe, R === qr ? T.side = N.shadowSide !== null ? N.shadowSide : N.side : T.side = N.shadowSide !== null ? N.shadowSide : m[N.side], T.alphaMap = N.alphaMap, T.alphaTest = N.alphaTest, T.map = N.map, T.clipShadows = N.clipShadows, T.clippingPlanes = N.clippingPlanes, T.clipIntersection = N.clipIntersection, T.displacementMap = N.displacementMap, T.displacementScale = N.displacementScale, T.displacementBias = N.displacementBias, T.wireframeLinewidth = N.wireframeLinewidth, T.linewidth = N.linewidth, z.isPointLight === !0 && T.isMeshDistanceMaterial === !0) {
      const B = n.properties.get(T);
      B.light = z;
    }
    return T;
  }
  function M(L, N, z, R, T) {
    if (L.visible === !1) return;
    if (L.layers.test(N.layers) && (L.isMesh || L.isLine || L.isPoints) && (L.castShadow || L.receiveShadow && T === qr) && (!L.frustumCulled || r.intersectsObject(L))) {
      L.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse, L.matrixWorld);
      const I = t.update(L), C = L.material;
      if (Array.isArray(C)) {
        const X = I.groups;
        for (let D = 0, V = X.length; D < V; D++) {
          const H = X[D], j = C[H.materialIndex];
          if (j && j.visible) {
            const K = w(L, j, R, T);
            L.onBeforeShadow(n, L, N, z, I, K, H), n.renderBufferDirect(z, null, I, K, L, H), L.onAfterShadow(n, L, N, z, I, K, H);
          }
        }
      } else if (C.visible) {
        const X = w(L, C, R, T);
        L.onBeforeShadow(n, L, N, z, I, X, null), n.renderBufferDirect(z, null, I, X, L, null), L.onAfterShadow(n, L, N, z, I, X, null);
      }
    }
    const B = L.children;
    for (let I = 0, C = B.length; I < C; I++)
      M(B[I], N, z, R, T);
  }
  function O(L) {
    L.target.removeEventListener("dispose", O);
    for (const z in h) {
      const R = h[z], T = L.target.uuid;
      T in R && (R[T].dispose(), delete R[T]);
    }
  }
}
const SL = {
  [lg]: cg,
  [ug]: hg,
  [fg]: pg,
  [tl]: dg,
  [cg]: lg,
  [hg]: ug,
  [pg]: fg,
  [dg]: tl
};
function bL(n, t) {
  function e() {
    let ut = !1;
    const zt = new Ke();
    let St = null;
    const Ct = new Ke(0, 0, 0, 0);
    return {
      setMask: function(It) {
        St !== It && !ut && (n.colorMask(It, It, It, It), St = It);
      },
      setLocked: function(It) {
        ut = It;
      },
      setClear: function(It, Ht, ue, tn, dn) {
        dn === !0 && (It *= tn, Ht *= tn, ue *= tn), zt.set(It, Ht, ue, tn), Ct.equals(zt) === !1 && (n.clearColor(It, Ht, ue, tn), Ct.copy(zt));
      },
      reset: function() {
        ut = !1, St = null, Ct.set(-1, 0, 0, 0);
      }
    };
  }
  function r() {
    let ut = !1, zt = !1, St = null, Ct = null, It = null;
    return {
      setReversed: function(Ht) {
        if (zt !== Ht) {
          const ue = t.get("EXT_clip_control");
          zt ? ue.clipControlEXT(ue.LOWER_LEFT_EXT, ue.ZERO_TO_ONE_EXT) : ue.clipControlEXT(ue.LOWER_LEFT_EXT, ue.NEGATIVE_ONE_TO_ONE_EXT);
          const tn = It;
          It = null, this.setClear(tn);
        }
        zt = Ht;
      },
      getReversed: function() {
        return zt;
      },
      setTest: function(Ht) {
        Ht ? Q(n.DEPTH_TEST) : et(n.DEPTH_TEST);
      },
      setMask: function(Ht) {
        St !== Ht && !ut && (n.depthMask(Ht), St = Ht);
      },
      setFunc: function(Ht) {
        if (zt && (Ht = SL[Ht]), Ct !== Ht) {
          switch (Ht) {
            case lg:
              n.depthFunc(n.NEVER);
              break;
            case cg:
              n.depthFunc(n.ALWAYS);
              break;
            case ug:
              n.depthFunc(n.LESS);
              break;
            case tl:
              n.depthFunc(n.LEQUAL);
              break;
            case fg:
              n.depthFunc(n.EQUAL);
              break;
            case dg:
              n.depthFunc(n.GEQUAL);
              break;
            case hg:
              n.depthFunc(n.GREATER);
              break;
            case pg:
              n.depthFunc(n.NOTEQUAL);
              break;
            default:
              n.depthFunc(n.LEQUAL);
          }
          Ct = Ht;
        }
      },
      setLocked: function(Ht) {
        ut = Ht;
      },
      setClear: function(Ht) {
        It !== Ht && (zt && (Ht = 1 - Ht), n.clearDepth(Ht), It = Ht);
      },
      reset: function() {
        ut = !1, St = null, Ct = null, It = null, zt = !1;
      }
    };
  }
  function a() {
    let ut = !1, zt = null, St = null, Ct = null, It = null, Ht = null, ue = null, tn = null, dn = null;
    return {
      setTest: function(De) {
        ut || (De ? Q(n.STENCIL_TEST) : et(n.STENCIL_TEST));
      },
      setMask: function(De) {
        zt !== De && !ut && (n.stencilMask(De), zt = De);
      },
      setFunc: function(De, wn, mi) {
        (St !== De || Ct !== wn || It !== mi) && (n.stencilFunc(De, wn, mi), St = De, Ct = wn, It = mi);
      },
      setOp: function(De, wn, mi) {
        (Ht !== De || ue !== wn || tn !== mi) && (n.stencilOp(De, wn, mi), Ht = De, ue = wn, tn = mi);
      },
      setLocked: function(De) {
        ut = De;
      },
      setClear: function(De) {
        dn !== De && (n.clearStencil(De), dn = De);
      },
      reset: function() {
        ut = !1, zt = null, St = null, Ct = null, It = null, Ht = null, ue = null, tn = null, dn = null;
      }
    };
  }
  const o = new e(), c = new r(), u = new a(), d = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap();
  let p = {}, m = {}, g = /* @__PURE__ */ new WeakMap(), _ = [], b = null, E = !1, S = null, y = null, A = null, w = null, M = null, O = null, L = null, N = new Me(0, 0, 0), z = 0, R = !1, T = null, U = null, B = null, I = null, C = null;
  const X = n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  let D = !1, V = 0;
  const H = n.getParameter(n.VERSION);
  H.indexOf("WebGL") !== -1 ? (V = parseFloat(/^WebGL (\d)/.exec(H)[1]), D = V >= 1) : H.indexOf("OpenGL ES") !== -1 && (V = parseFloat(/^OpenGL ES (\d)/.exec(H)[1]), D = V >= 2);
  let j = null, K = {};
  const F = n.getParameter(n.SCISSOR_BOX), q = n.getParameter(n.VIEWPORT), it = new Ke().fromArray(F), G = new Ke().fromArray(q);
  function k(ut, zt, St, Ct) {
    const It = new Uint8Array(4), Ht = n.createTexture();
    n.bindTexture(ut, Ht), n.texParameteri(ut, n.TEXTURE_MIN_FILTER, n.NEAREST), n.texParameteri(ut, n.TEXTURE_MAG_FILTER, n.NEAREST);
    for (let ue = 0; ue < St; ue++)
      ut === n.TEXTURE_3D || ut === n.TEXTURE_2D_ARRAY ? n.texImage3D(zt, 0, n.RGBA, 1, 1, Ct, 0, n.RGBA, n.UNSIGNED_BYTE, It) : n.texImage2D(zt + ue, 0, n.RGBA, 1, 1, 0, n.RGBA, n.UNSIGNED_BYTE, It);
    return Ht;
  }
  const $ = {};
  $[n.TEXTURE_2D] = k(n.TEXTURE_2D, n.TEXTURE_2D, 1), $[n.TEXTURE_CUBE_MAP] = k(n.TEXTURE_CUBE_MAP, n.TEXTURE_CUBE_MAP_POSITIVE_X, 6), $[n.TEXTURE_2D_ARRAY] = k(n.TEXTURE_2D_ARRAY, n.TEXTURE_2D_ARRAY, 1, 1), $[n.TEXTURE_3D] = k(n.TEXTURE_3D, n.TEXTURE_3D, 1, 1), o.setClear(0, 0, 0, 1), c.setClear(1), u.setClear(0), Q(n.DEPTH_TEST), c.setFunc(tl), Ft(!1), ne(Wx), Q(n.CULL_FACE), nt(ks);
  function Q(ut) {
    p[ut] !== !0 && (n.enable(ut), p[ut] = !0);
  }
  function et(ut) {
    p[ut] !== !1 && (n.disable(ut), p[ut] = !1);
  }
  function st(ut, zt) {
    return m[ut] !== zt ? (n.bindFramebuffer(ut, zt), m[ut] = zt, ut === n.DRAW_FRAMEBUFFER && (m[n.FRAMEBUFFER] = zt), ut === n.FRAMEBUFFER && (m[n.DRAW_FRAMEBUFFER] = zt), !0) : !1;
  }
  function _t(ut, zt) {
    let St = _, Ct = !1;
    if (ut) {
      St = g.get(zt), St === void 0 && (St = [], g.set(zt, St));
      const It = ut.textures;
      if (St.length !== It.length || St[0] !== n.COLOR_ATTACHMENT0) {
        for (let Ht = 0, ue = It.length; Ht < ue; Ht++)
          St[Ht] = n.COLOR_ATTACHMENT0 + Ht;
        St.length = It.length, Ct = !0;
      }
    } else
      St[0] !== n.BACK && (St[0] = n.BACK, Ct = !0);
    Ct && n.drawBuffers(St);
  }
  function Mt(ut) {
    return b !== ut ? (n.useProgram(ut), b = ut, !0) : !1;
  }
  const Rt = {
    [ba]: n.FUNC_ADD,
    [f2]: n.FUNC_SUBTRACT,
    [d2]: n.FUNC_REVERSE_SUBTRACT
  };
  Rt[h2] = n.MIN, Rt[p2] = n.MAX;
  const Ot = {
    [m2]: n.ZERO,
    [g2]: n.ONE,
    [v2]: n.SRC_COLOR,
    [ag]: n.SRC_ALPHA,
    [M2]: n.SRC_ALPHA_SATURATE,
    [S2]: n.DST_COLOR,
    [y2]: n.DST_ALPHA,
    [_2]: n.ONE_MINUS_SRC_COLOR,
    [og]: n.ONE_MINUS_SRC_ALPHA,
    [b2]: n.ONE_MINUS_DST_COLOR,
    [x2]: n.ONE_MINUS_DST_ALPHA,
    [E2]: n.CONSTANT_COLOR,
    [w2]: n.ONE_MINUS_CONSTANT_COLOR,
    [T2]: n.CONSTANT_ALPHA,
    [A2]: n.ONE_MINUS_CONSTANT_ALPHA
  };
  function nt(ut, zt, St, Ct, It, Ht, ue, tn, dn, De) {
    if (ut === ks) {
      E === !0 && (et(n.BLEND), E = !1);
      return;
    }
    if (E === !1 && (Q(n.BLEND), E = !0), ut !== u2) {
      if (ut !== S || De !== R) {
        if ((y !== ba || M !== ba) && (n.blendEquation(n.FUNC_ADD), y = ba, M = ba), De)
          switch (ut) {
            case Zo:
              n.blendFuncSeparate(n.ONE, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA);
              break;
            case Yx:
              n.blendFunc(n.ONE, n.ONE);
              break;
            case qx:
              n.blendFuncSeparate(n.ZERO, n.ONE_MINUS_SRC_COLOR, n.ZERO, n.ONE);
              break;
            case Zx:
              n.blendFuncSeparate(n.ZERO, n.SRC_COLOR, n.ZERO, n.SRC_ALPHA);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", ut);
              break;
          }
        else
          switch (ut) {
            case Zo:
              n.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA);
              break;
            case Yx:
              n.blendFunc(n.SRC_ALPHA, n.ONE);
              break;
            case qx:
              n.blendFuncSeparate(n.ZERO, n.ONE_MINUS_SRC_COLOR, n.ZERO, n.ONE);
              break;
            case Zx:
              n.blendFunc(n.ZERO, n.SRC_COLOR);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", ut);
              break;
          }
        A = null, w = null, O = null, L = null, N.set(0, 0, 0), z = 0, S = ut, R = De;
      }
      return;
    }
    It = It || zt, Ht = Ht || St, ue = ue || Ct, (zt !== y || It !== M) && (n.blendEquationSeparate(Rt[zt], Rt[It]), y = zt, M = It), (St !== A || Ct !== w || Ht !== O || ue !== L) && (n.blendFuncSeparate(Ot[St], Ot[Ct], Ot[Ht], Ot[ue]), A = St, w = Ct, O = Ht, L = ue), (tn.equals(N) === !1 || dn !== z) && (n.blendColor(tn.r, tn.g, tn.b, dn), N.copy(tn), z = dn), S = ut, R = !1;
  }
  function Jt(ut, zt) {
    ut.side === ur ? et(n.CULL_FACE) : Q(n.CULL_FACE);
    let St = ut.side === pi;
    zt && (St = !St), Ft(St), ut.blending === Zo && ut.transparent === !1 ? nt(ks) : nt(ut.blending, ut.blendEquation, ut.blendSrc, ut.blendDst, ut.blendEquationAlpha, ut.blendSrcAlpha, ut.blendDstAlpha, ut.blendColor, ut.blendAlpha, ut.premultipliedAlpha), c.setFunc(ut.depthFunc), c.setTest(ut.depthTest), c.setMask(ut.depthWrite), o.setMask(ut.colorWrite);
    const Ct = ut.stencilWrite;
    u.setTest(Ct), Ct && (u.setMask(ut.stencilWriteMask), u.setFunc(ut.stencilFunc, ut.stencilRef, ut.stencilFuncMask), u.setOp(ut.stencilFail, ut.stencilZFail, ut.stencilZPass)), xe(ut.polygonOffset, ut.polygonOffsetFactor, ut.polygonOffsetUnits), ut.alphaToCoverage === !0 ? Q(n.SAMPLE_ALPHA_TO_COVERAGE) : et(n.SAMPLE_ALPHA_TO_COVERAGE);
  }
  function Ft(ut) {
    T !== ut && (ut ? n.frontFace(n.CW) : n.frontFace(n.CCW), T = ut);
  }
  function ne(ut) {
    ut !== o2 ? (Q(n.CULL_FACE), ut !== U && (ut === Wx ? n.cullFace(n.BACK) : ut === l2 ? n.cullFace(n.FRONT) : n.cullFace(n.FRONT_AND_BACK))) : et(n.CULL_FACE), U = ut;
  }
  function jt(ut) {
    ut !== B && (D && n.lineWidth(ut), B = ut);
  }
  function xe(ut, zt, St) {
    ut ? (Q(n.POLYGON_OFFSET_FILL), (I !== zt || C !== St) && (n.polygonOffset(zt, St), I = zt, C = St)) : et(n.POLYGON_OFFSET_FILL);
  }
  function qt(ut) {
    ut ? Q(n.SCISSOR_TEST) : et(n.SCISSOR_TEST);
  }
  function tt(ut) {
    ut === void 0 && (ut = n.TEXTURE0 + X - 1), j !== ut && (n.activeTexture(ut), j = ut);
  }
  function W(ut, zt, St) {
    St === void 0 && (j === null ? St = n.TEXTURE0 + X - 1 : St = j);
    let Ct = K[St];
    Ct === void 0 && (Ct = { type: void 0, texture: void 0 }, K[St] = Ct), (Ct.type !== ut || Ct.texture !== zt) && (j !== St && (n.activeTexture(St), j = St), n.bindTexture(ut, zt || $[ut]), Ct.type = ut, Ct.texture = zt);
  }
  function mt() {
    const ut = K[j];
    ut !== void 0 && ut.type !== void 0 && (n.bindTexture(ut.type, null), ut.type = void 0, ut.texture = void 0);
  }
  function Et() {
    try {
      n.compressedTexImage2D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function Dt() {
    try {
      n.compressedTexImage3D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function wt() {
    try {
      n.texSubImage2D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function Zt() {
    try {
      n.texSubImage3D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function Pt() {
    try {
      n.compressedTexSubImage2D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function Wt() {
    try {
      n.compressedTexSubImage3D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function _e() {
    try {
      n.texStorage2D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function Ut() {
    try {
      n.texStorage3D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function Yt() {
    try {
      n.texImage2D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function te() {
    try {
      n.texImage3D.apply(n, arguments);
    } catch (ut) {
      console.error("THREE.WebGLState:", ut);
    }
  }
  function Kt(ut) {
    it.equals(ut) === !1 && (n.scissor(ut.x, ut.y, ut.z, ut.w), it.copy(ut));
  }
  function Gt(ut) {
    G.equals(ut) === !1 && (n.viewport(ut.x, ut.y, ut.z, ut.w), G.copy(ut));
  }
  function le(ut, zt) {
    let St = h.get(zt);
    St === void 0 && (St = /* @__PURE__ */ new WeakMap(), h.set(zt, St));
    let Ct = St.get(ut);
    Ct === void 0 && (Ct = n.getUniformBlockIndex(zt, ut.name), St.set(ut, Ct));
  }
  function he(ut, zt) {
    const Ct = h.get(zt).get(ut);
    d.get(zt) !== Ct && (n.uniformBlockBinding(zt, Ct, ut.__bindingPointIndex), d.set(zt, Ct));
  }
  function Fe() {
    n.disable(n.BLEND), n.disable(n.CULL_FACE), n.disable(n.DEPTH_TEST), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SCISSOR_TEST), n.disable(n.STENCIL_TEST), n.disable(n.SAMPLE_ALPHA_TO_COVERAGE), n.blendEquation(n.FUNC_ADD), n.blendFunc(n.ONE, n.ZERO), n.blendFuncSeparate(n.ONE, n.ZERO, n.ONE, n.ZERO), n.blendColor(0, 0, 0, 0), n.colorMask(!0, !0, !0, !0), n.clearColor(0, 0, 0, 0), n.depthMask(!0), n.depthFunc(n.LESS), c.setReversed(!1), n.clearDepth(1), n.stencilMask(4294967295), n.stencilFunc(n.ALWAYS, 0, 4294967295), n.stencilOp(n.KEEP, n.KEEP, n.KEEP), n.clearStencil(0), n.cullFace(n.BACK), n.frontFace(n.CCW), n.polygonOffset(0, 0), n.activeTexture(n.TEXTURE0), n.bindFramebuffer(n.FRAMEBUFFER, null), n.bindFramebuffer(n.DRAW_FRAMEBUFFER, null), n.bindFramebuffer(n.READ_FRAMEBUFFER, null), n.useProgram(null), n.lineWidth(1), n.scissor(0, 0, n.canvas.width, n.canvas.height), n.viewport(0, 0, n.canvas.width, n.canvas.height), p = {}, j = null, K = {}, m = {}, g = /* @__PURE__ */ new WeakMap(), _ = [], b = null, E = !1, S = null, y = null, A = null, w = null, M = null, O = null, L = null, N = new Me(0, 0, 0), z = 0, R = !1, T = null, U = null, B = null, I = null, C = null, it.set(0, 0, n.canvas.width, n.canvas.height), G.set(0, 0, n.canvas.width, n.canvas.height), o.reset(), c.reset(), u.reset();
  }
  return {
    buffers: {
      color: o,
      depth: c,
      stencil: u
    },
    enable: Q,
    disable: et,
    bindFramebuffer: st,
    drawBuffers: _t,
    useProgram: Mt,
    setBlending: nt,
    setMaterial: Jt,
    setFlipSided: Ft,
    setCullFace: ne,
    setLineWidth: jt,
    setPolygonOffset: xe,
    setScissorTest: qt,
    activeTexture: tt,
    bindTexture: W,
    unbindTexture: mt,
    compressedTexImage2D: Et,
    compressedTexImage3D: Dt,
    texImage2D: Yt,
    texImage3D: te,
    updateUBOMapping: le,
    uniformBlockBinding: he,
    texStorage2D: _e,
    texStorage3D: Ut,
    texSubImage2D: wt,
    texSubImage3D: Zt,
    compressedTexSubImage2D: Pt,
    compressedTexSubImage3D: Wt,
    scissor: Kt,
    viewport: Gt,
    reset: Fe
  };
}
function ML(n, t, e, r, a, o, c) {
  const u = t.has("WEBGL_multisampled_render_to_texture") ? t.get("WEBGL_multisampled_render_to_texture") : null, d = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), h = new oe(), p = /* @__PURE__ */ new WeakMap();
  let m;
  const g = /* @__PURE__ */ new WeakMap();
  let _ = !1;
  try {
    _ = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
  } catch {
  }
  function b(tt, W) {
    return _ ? (
      // eslint-disable-next-line compat/compat
      new OffscreenCanvas(tt, W)
    ) : md("canvas");
  }
  function E(tt, W, mt) {
    let Et = 1;
    const Dt = qt(tt);
    if ((Dt.width > mt || Dt.height > mt) && (Et = mt / Math.max(Dt.width, Dt.height)), Et < 1)
      if (typeof HTMLImageElement < "u" && tt instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && tt instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && tt instanceof ImageBitmap || typeof VideoFrame < "u" && tt instanceof VideoFrame) {
        const wt = Math.floor(Et * Dt.width), Zt = Math.floor(Et * Dt.height);
        m === void 0 && (m = b(wt, Zt));
        const Pt = W ? b(wt, Zt) : m;
        return Pt.width = wt, Pt.height = Zt, Pt.getContext("2d").drawImage(tt, 0, 0, wt, Zt), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + Dt.width + "x" + Dt.height + ") to (" + wt + "x" + Zt + ")."), Pt;
      } else
        return "data" in tt && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + Dt.width + "x" + Dt.height + ")."), tt;
    return tt;
  }
  function S(tt) {
    return tt.generateMipmaps;
  }
  function y(tt) {
    n.generateMipmap(tt);
  }
  function A(tt) {
    return tt.isWebGLCubeRenderTarget ? n.TEXTURE_CUBE_MAP : tt.isWebGL3DRenderTarget ? n.TEXTURE_3D : tt.isWebGLArrayRenderTarget || tt.isCompressedArrayTexture ? n.TEXTURE_2D_ARRAY : n.TEXTURE_2D;
  }
  function w(tt, W, mt, Et, Dt = !1) {
    if (tt !== null) {
      if (n[tt] !== void 0) return n[tt];
      console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + tt + "'");
    }
    let wt = W;
    if (W === n.RED && (mt === n.FLOAT && (wt = n.R32F), mt === n.HALF_FLOAT && (wt = n.R16F), mt === n.UNSIGNED_BYTE && (wt = n.R8)), W === n.RED_INTEGER && (mt === n.UNSIGNED_BYTE && (wt = n.R8UI), mt === n.UNSIGNED_SHORT && (wt = n.R16UI), mt === n.UNSIGNED_INT && (wt = n.R32UI), mt === n.BYTE && (wt = n.R8I), mt === n.SHORT && (wt = n.R16I), mt === n.INT && (wt = n.R32I)), W === n.RG && (mt === n.FLOAT && (wt = n.RG32F), mt === n.HALF_FLOAT && (wt = n.RG16F), mt === n.UNSIGNED_BYTE && (wt = n.RG8)), W === n.RG_INTEGER && (mt === n.UNSIGNED_BYTE && (wt = n.RG8UI), mt === n.UNSIGNED_SHORT && (wt = n.RG16UI), mt === n.UNSIGNED_INT && (wt = n.RG32UI), mt === n.BYTE && (wt = n.RG8I), mt === n.SHORT && (wt = n.RG16I), mt === n.INT && (wt = n.RG32I)), W === n.RGB_INTEGER && (mt === n.UNSIGNED_BYTE && (wt = n.RGB8UI), mt === n.UNSIGNED_SHORT && (wt = n.RGB16UI), mt === n.UNSIGNED_INT && (wt = n.RGB32UI), mt === n.BYTE && (wt = n.RGB8I), mt === n.SHORT && (wt = n.RGB16I), mt === n.INT && (wt = n.RGB32I)), W === n.RGBA_INTEGER && (mt === n.UNSIGNED_BYTE && (wt = n.RGBA8UI), mt === n.UNSIGNED_SHORT && (wt = n.RGBA16UI), mt === n.UNSIGNED_INT && (wt = n.RGBA32UI), mt === n.BYTE && (wt = n.RGBA8I), mt === n.SHORT && (wt = n.RGBA16I), mt === n.INT && (wt = n.RGBA32I)), W === n.RGB && mt === n.UNSIGNED_INT_5_9_9_9_REV && (wt = n.RGB9_E5), W === n.RGBA) {
      const Zt = Dt ? dd : Ie.getTransfer(Et);
      mt === n.FLOAT && (wt = n.RGBA32F), mt === n.HALF_FLOAT && (wt = n.RGBA16F), mt === n.UNSIGNED_BYTE && (wt = Zt === qe ? n.SRGB8_ALPHA8 : n.RGBA8), mt === n.UNSIGNED_SHORT_4_4_4_4 && (wt = n.RGBA4), mt === n.UNSIGNED_SHORT_5_5_5_1 && (wt = n.RGB5_A1);
    }
    return (wt === n.R16F || wt === n.R32F || wt === n.RG16F || wt === n.RG32F || wt === n.RGBA16F || wt === n.RGBA32F) && t.get("EXT_color_buffer_float"), wt;
  }
  function M(tt, W) {
    let mt;
    return tt ? W === null || W === Na || W === il ? mt = n.DEPTH24_STENCIL8 : W === Gi ? mt = n.DEPTH32F_STENCIL8 : W === Cc && (mt = n.DEPTH24_STENCIL8, console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : W === null || W === Na || W === il ? mt = n.DEPTH_COMPONENT24 : W === Gi ? mt = n.DEPTH_COMPONENT32F : W === Cc && (mt = n.DEPTH_COMPONENT16), mt;
  }
  function O(tt, W) {
    return S(tt) === !0 || tt.isFramebufferTexture && tt.minFilter !== Yn && tt.minFilter !== dr ? Math.log2(Math.max(W.width, W.height)) + 1 : tt.mipmaps !== void 0 && tt.mipmaps.length > 0 ? tt.mipmaps.length : tt.isCompressedTexture && Array.isArray(tt.image) ? W.mipmaps.length : 1;
  }
  function L(tt) {
    const W = tt.target;
    W.removeEventListener("dispose", L), z(W), W.isVideoTexture && p.delete(W);
  }
  function N(tt) {
    const W = tt.target;
    W.removeEventListener("dispose", N), T(W);
  }
  function z(tt) {
    const W = r.get(tt);
    if (W.__webglInit === void 0) return;
    const mt = tt.source, Et = g.get(mt);
    if (Et) {
      const Dt = Et[W.__cacheKey];
      Dt.usedTimes--, Dt.usedTimes === 0 && R(tt), Object.keys(Et).length === 0 && g.delete(mt);
    }
    r.remove(tt);
  }
  function R(tt) {
    const W = r.get(tt);
    n.deleteTexture(W.__webglTexture);
    const mt = tt.source, Et = g.get(mt);
    delete Et[W.__cacheKey], c.memory.textures--;
  }
  function T(tt) {
    const W = r.get(tt);
    if (tt.depthTexture && (tt.depthTexture.dispose(), r.remove(tt.depthTexture)), tt.isWebGLCubeRenderTarget)
      for (let Et = 0; Et < 6; Et++) {
        if (Array.isArray(W.__webglFramebuffer[Et]))
          for (let Dt = 0; Dt < W.__webglFramebuffer[Et].length; Dt++) n.deleteFramebuffer(W.__webglFramebuffer[Et][Dt]);
        else
          n.deleteFramebuffer(W.__webglFramebuffer[Et]);
        W.__webglDepthbuffer && n.deleteRenderbuffer(W.__webglDepthbuffer[Et]);
      }
    else {
      if (Array.isArray(W.__webglFramebuffer))
        for (let Et = 0; Et < W.__webglFramebuffer.length; Et++) n.deleteFramebuffer(W.__webglFramebuffer[Et]);
      else
        n.deleteFramebuffer(W.__webglFramebuffer);
      if (W.__webglDepthbuffer && n.deleteRenderbuffer(W.__webglDepthbuffer), W.__webglMultisampledFramebuffer && n.deleteFramebuffer(W.__webglMultisampledFramebuffer), W.__webglColorRenderbuffer)
        for (let Et = 0; Et < W.__webglColorRenderbuffer.length; Et++)
          W.__webglColorRenderbuffer[Et] && n.deleteRenderbuffer(W.__webglColorRenderbuffer[Et]);
      W.__webglDepthRenderbuffer && n.deleteRenderbuffer(W.__webglDepthRenderbuffer);
    }
    const mt = tt.textures;
    for (let Et = 0, Dt = mt.length; Et < Dt; Et++) {
      const wt = r.get(mt[Et]);
      wt.__webglTexture && (n.deleteTexture(wt.__webglTexture), c.memory.textures--), r.remove(mt[Et]);
    }
    r.remove(tt);
  }
  let U = 0;
  function B() {
    U = 0;
  }
  function I() {
    const tt = U;
    return tt >= a.maxTextures && console.warn("THREE.WebGLTextures: Trying to use " + tt + " texture units while this GPU supports only " + a.maxTextures), U += 1, tt;
  }
  function C(tt) {
    const W = [];
    return W.push(tt.wrapS), W.push(tt.wrapT), W.push(tt.wrapR || 0), W.push(tt.magFilter), W.push(tt.minFilter), W.push(tt.anisotropy), W.push(tt.internalFormat), W.push(tt.format), W.push(tt.type), W.push(tt.generateMipmaps), W.push(tt.premultiplyAlpha), W.push(tt.flipY), W.push(tt.unpackAlignment), W.push(tt.colorSpace), W.join();
  }
  function X(tt, W) {
    const mt = r.get(tt);
    if (tt.isVideoTexture && jt(tt), tt.isRenderTargetTexture === !1 && tt.version > 0 && mt.__version !== tt.version) {
      const Et = tt.image;
      if (Et === null)
        console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");
      else if (Et.complete === !1)
        console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");
      else {
        G(mt, tt, W);
        return;
      }
    }
    e.bindTexture(n.TEXTURE_2D, mt.__webglTexture, n.TEXTURE0 + W);
  }
  function D(tt, W) {
    const mt = r.get(tt);
    if (tt.version > 0 && mt.__version !== tt.version) {
      G(mt, tt, W);
      return;
    }
    e.bindTexture(n.TEXTURE_2D_ARRAY, mt.__webglTexture, n.TEXTURE0 + W);
  }
  function V(tt, W) {
    const mt = r.get(tt);
    if (tt.version > 0 && mt.__version !== tt.version) {
      G(mt, tt, W);
      return;
    }
    e.bindTexture(n.TEXTURE_3D, mt.__webglTexture, n.TEXTURE0 + W);
  }
  function H(tt, W) {
    const mt = r.get(tt);
    if (tt.version > 0 && mt.__version !== tt.version) {
      k(mt, tt, W);
      return;
    }
    e.bindTexture(n.TEXTURE_CUBE_MAP, mt.__webglTexture, n.TEXTURE0 + W);
  }
  const j = {
    [vg]: n.REPEAT,
    [Ea]: n.CLAMP_TO_EDGE,
    [_g]: n.MIRRORED_REPEAT
  }, K = {
    [Yn]: n.NEAREST,
    [I2]: n.NEAREST_MIPMAP_NEAREST,
    [cf]: n.NEAREST_MIPMAP_LINEAR,
    [dr]: n.LINEAR,
    [im]: n.LINEAR_MIPMAP_NEAREST,
    [wa]: n.LINEAR_MIPMAP_LINEAR
  }, F = {
    [V2]: n.NEVER,
    [Y2]: n.ALWAYS,
    [k2]: n.LESS,
    [pM]: n.LEQUAL,
    [G2]: n.EQUAL,
    [W2]: n.GEQUAL,
    [X2]: n.GREATER,
    [j2]: n.NOTEQUAL
  };
  function q(tt, W) {
    if (W.type === Gi && t.has("OES_texture_float_linear") === !1 && (W.magFilter === dr || W.magFilter === im || W.magFilter === cf || W.magFilter === wa || W.minFilter === dr || W.minFilter === im || W.minFilter === cf || W.minFilter === wa) && console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), n.texParameteri(tt, n.TEXTURE_WRAP_S, j[W.wrapS]), n.texParameteri(tt, n.TEXTURE_WRAP_T, j[W.wrapT]), (tt === n.TEXTURE_3D || tt === n.TEXTURE_2D_ARRAY) && n.texParameteri(tt, n.TEXTURE_WRAP_R, j[W.wrapR]), n.texParameteri(tt, n.TEXTURE_MAG_FILTER, K[W.magFilter]), n.texParameteri(tt, n.TEXTURE_MIN_FILTER, K[W.minFilter]), W.compareFunction && (n.texParameteri(tt, n.TEXTURE_COMPARE_MODE, n.COMPARE_REF_TO_TEXTURE), n.texParameteri(tt, n.TEXTURE_COMPARE_FUNC, F[W.compareFunction])), t.has("EXT_texture_filter_anisotropic") === !0) {
      if (W.magFilter === Yn || W.minFilter !== cf && W.minFilter !== wa || W.type === Gi && t.has("OES_texture_float_linear") === !1) return;
      if (W.anisotropy > 1 || r.get(W).__currentAnisotropy) {
        const mt = t.get("EXT_texture_filter_anisotropic");
        n.texParameterf(tt, mt.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(W.anisotropy, a.getMaxAnisotropy())), r.get(W).__currentAnisotropy = W.anisotropy;
      }
    }
  }
  function it(tt, W) {
    let mt = !1;
    tt.__webglInit === void 0 && (tt.__webglInit = !0, W.addEventListener("dispose", L));
    const Et = W.source;
    let Dt = g.get(Et);
    Dt === void 0 && (Dt = {}, g.set(Et, Dt));
    const wt = C(W);
    if (wt !== tt.__cacheKey) {
      Dt[wt] === void 0 && (Dt[wt] = {
        texture: n.createTexture(),
        usedTimes: 0
      }, c.memory.textures++, mt = !0), Dt[wt].usedTimes++;
      const Zt = Dt[tt.__cacheKey];
      Zt !== void 0 && (Dt[tt.__cacheKey].usedTimes--, Zt.usedTimes === 0 && R(W)), tt.__cacheKey = wt, tt.__webglTexture = Dt[wt].texture;
    }
    return mt;
  }
  function G(tt, W, mt) {
    let Et = n.TEXTURE_2D;
    (W.isDataArrayTexture || W.isCompressedArrayTexture) && (Et = n.TEXTURE_2D_ARRAY), W.isData3DTexture && (Et = n.TEXTURE_3D);
    const Dt = it(tt, W), wt = W.source;
    e.bindTexture(Et, tt.__webglTexture, n.TEXTURE0 + mt);
    const Zt = r.get(wt);
    if (wt.version !== Zt.__version || Dt === !0) {
      e.activeTexture(n.TEXTURE0 + mt);
      const Pt = Ie.getPrimaries(Ie.workingColorSpace), Wt = W.colorSpace === Fs ? null : Ie.getPrimaries(W.colorSpace), _e = W.colorSpace === Fs || Pt === Wt ? n.NONE : n.BROWSER_DEFAULT_WEBGL;
      n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, W.flipY), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, W.premultiplyAlpha), n.pixelStorei(n.UNPACK_ALIGNMENT, W.unpackAlignment), n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL, _e);
      let Ut = E(W.image, !1, a.maxTextureSize);
      Ut = xe(W, Ut);
      const Yt = o.convert(W.format, W.colorSpace), te = o.convert(W.type);
      let Kt = w(W.internalFormat, Yt, te, W.colorSpace, W.isVideoTexture);
      q(Et, W);
      let Gt;
      const le = W.mipmaps, he = W.isVideoTexture !== !0, Fe = Zt.__version === void 0 || Dt === !0, ut = wt.dataReady, zt = O(W, Ut);
      if (W.isDepthTexture)
        Kt = M(W.format === rl, W.type), Fe && (he ? e.texStorage2D(n.TEXTURE_2D, 1, Kt, Ut.width, Ut.height) : e.texImage2D(n.TEXTURE_2D, 0, Kt, Ut.width, Ut.height, 0, Yt, te, null));
      else if (W.isDataTexture)
        if (le.length > 0) {
          he && Fe && e.texStorage2D(n.TEXTURE_2D, zt, Kt, le[0].width, le[0].height);
          for (let St = 0, Ct = le.length; St < Ct; St++)
            Gt = le[St], he ? ut && e.texSubImage2D(n.TEXTURE_2D, St, 0, 0, Gt.width, Gt.height, Yt, te, Gt.data) : e.texImage2D(n.TEXTURE_2D, St, Kt, Gt.width, Gt.height, 0, Yt, te, Gt.data);
          W.generateMipmaps = !1;
        } else
          he ? (Fe && e.texStorage2D(n.TEXTURE_2D, zt, Kt, Ut.width, Ut.height), ut && e.texSubImage2D(n.TEXTURE_2D, 0, 0, 0, Ut.width, Ut.height, Yt, te, Ut.data)) : e.texImage2D(n.TEXTURE_2D, 0, Kt, Ut.width, Ut.height, 0, Yt, te, Ut.data);
      else if (W.isCompressedTexture)
        if (W.isCompressedArrayTexture) {
          he && Fe && e.texStorage3D(n.TEXTURE_2D_ARRAY, zt, Kt, le[0].width, le[0].height, Ut.depth);
          for (let St = 0, Ct = le.length; St < Ct; St++)
            if (Gt = le[St], W.format !== Ci)
              if (Yt !== null)
                if (he) {
                  if (ut)
                    if (W.layerUpdates.size > 0) {
                      const It = DS(Gt.width, Gt.height, W.format, W.type);
                      for (const Ht of W.layerUpdates) {
                        const ue = Gt.data.subarray(
                          Ht * It / Gt.data.BYTES_PER_ELEMENT,
                          (Ht + 1) * It / Gt.data.BYTES_PER_ELEMENT
                        );
                        e.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY, St, 0, 0, Ht, Gt.width, Gt.height, 1, Yt, ue);
                      }
                      W.clearLayerUpdates();
                    } else
                      e.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY, St, 0, 0, 0, Gt.width, Gt.height, Ut.depth, Yt, Gt.data);
                } else
                  e.compressedTexImage3D(n.TEXTURE_2D_ARRAY, St, Kt, Gt.width, Gt.height, Ut.depth, 0, Gt.data, 0, 0);
              else
                console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");
            else
              he ? ut && e.texSubImage3D(n.TEXTURE_2D_ARRAY, St, 0, 0, 0, Gt.width, Gt.height, Ut.depth, Yt, te, Gt.data) : e.texImage3D(n.TEXTURE_2D_ARRAY, St, Kt, Gt.width, Gt.height, Ut.depth, 0, Yt, te, Gt.data);
        } else {
          he && Fe && e.texStorage2D(n.TEXTURE_2D, zt, Kt, le[0].width, le[0].height);
          for (let St = 0, Ct = le.length; St < Ct; St++)
            Gt = le[St], W.format !== Ci ? Yt !== null ? he ? ut && e.compressedTexSubImage2D(n.TEXTURE_2D, St, 0, 0, Gt.width, Gt.height, Yt, Gt.data) : e.compressedTexImage2D(n.TEXTURE_2D, St, Kt, Gt.width, Gt.height, 0, Gt.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : he ? ut && e.texSubImage2D(n.TEXTURE_2D, St, 0, 0, Gt.width, Gt.height, Yt, te, Gt.data) : e.texImage2D(n.TEXTURE_2D, St, Kt, Gt.width, Gt.height, 0, Yt, te, Gt.data);
        }
      else if (W.isDataArrayTexture)
        if (he) {
          if (Fe && e.texStorage3D(n.TEXTURE_2D_ARRAY, zt, Kt, Ut.width, Ut.height, Ut.depth), ut)
            if (W.layerUpdates.size > 0) {
              const St = DS(Ut.width, Ut.height, W.format, W.type);
              for (const Ct of W.layerUpdates) {
                const It = Ut.data.subarray(
                  Ct * St / Ut.data.BYTES_PER_ELEMENT,
                  (Ct + 1) * St / Ut.data.BYTES_PER_ELEMENT
                );
                e.texSubImage3D(n.TEXTURE_2D_ARRAY, 0, 0, 0, Ct, Ut.width, Ut.height, 1, Yt, te, It);
              }
              W.clearLayerUpdates();
            } else
              e.texSubImage3D(n.TEXTURE_2D_ARRAY, 0, 0, 0, 0, Ut.width, Ut.height, Ut.depth, Yt, te, Ut.data);
        } else
          e.texImage3D(n.TEXTURE_2D_ARRAY, 0, Kt, Ut.width, Ut.height, Ut.depth, 0, Yt, te, Ut.data);
      else if (W.isData3DTexture)
        he ? (Fe && e.texStorage3D(n.TEXTURE_3D, zt, Kt, Ut.width, Ut.height, Ut.depth), ut && e.texSubImage3D(n.TEXTURE_3D, 0, 0, 0, 0, Ut.width, Ut.height, Ut.depth, Yt, te, Ut.data)) : e.texImage3D(n.TEXTURE_3D, 0, Kt, Ut.width, Ut.height, Ut.depth, 0, Yt, te, Ut.data);
      else if (W.isFramebufferTexture) {
        if (Fe)
          if (he)
            e.texStorage2D(n.TEXTURE_2D, zt, Kt, Ut.width, Ut.height);
          else {
            let St = Ut.width, Ct = Ut.height;
            for (let It = 0; It < zt; It++)
              e.texImage2D(n.TEXTURE_2D, It, Kt, St, Ct, 0, Yt, te, null), St >>= 1, Ct >>= 1;
          }
      } else if (le.length > 0) {
        if (he && Fe) {
          const St = qt(le[0]);
          e.texStorage2D(n.TEXTURE_2D, zt, Kt, St.width, St.height);
        }
        for (let St = 0, Ct = le.length; St < Ct; St++)
          Gt = le[St], he ? ut && e.texSubImage2D(n.TEXTURE_2D, St, 0, 0, Yt, te, Gt) : e.texImage2D(n.TEXTURE_2D, St, Kt, Yt, te, Gt);
        W.generateMipmaps = !1;
      } else if (he) {
        if (Fe) {
          const St = qt(Ut);
          e.texStorage2D(n.TEXTURE_2D, zt, Kt, St.width, St.height);
        }
        ut && e.texSubImage2D(n.TEXTURE_2D, 0, 0, 0, Yt, te, Ut);
      } else
        e.texImage2D(n.TEXTURE_2D, 0, Kt, Yt, te, Ut);
      S(W) && y(Et), Zt.__version = wt.version, W.onUpdate && W.onUpdate(W);
    }
    tt.__version = W.version;
  }
  function k(tt, W, mt) {
    if (W.image.length !== 6) return;
    const Et = it(tt, W), Dt = W.source;
    e.bindTexture(n.TEXTURE_CUBE_MAP, tt.__webglTexture, n.TEXTURE0 + mt);
    const wt = r.get(Dt);
    if (Dt.version !== wt.__version || Et === !0) {
      e.activeTexture(n.TEXTURE0 + mt);
      const Zt = Ie.getPrimaries(Ie.workingColorSpace), Pt = W.colorSpace === Fs ? null : Ie.getPrimaries(W.colorSpace), Wt = W.colorSpace === Fs || Zt === Pt ? n.NONE : n.BROWSER_DEFAULT_WEBGL;
      n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, W.flipY), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, W.premultiplyAlpha), n.pixelStorei(n.UNPACK_ALIGNMENT, W.unpackAlignment), n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL, Wt);
      const _e = W.isCompressedTexture || W.image[0].isCompressedTexture, Ut = W.image[0] && W.image[0].isDataTexture, Yt = [];
      for (let Ct = 0; Ct < 6; Ct++)
        !_e && !Ut ? Yt[Ct] = E(W.image[Ct], !0, a.maxCubemapSize) : Yt[Ct] = Ut ? W.image[Ct].image : W.image[Ct], Yt[Ct] = xe(W, Yt[Ct]);
      const te = Yt[0], Kt = o.convert(W.format, W.colorSpace), Gt = o.convert(W.type), le = w(W.internalFormat, Kt, Gt, W.colorSpace), he = W.isVideoTexture !== !0, Fe = wt.__version === void 0 || Et === !0, ut = Dt.dataReady;
      let zt = O(W, te);
      q(n.TEXTURE_CUBE_MAP, W);
      let St;
      if (_e) {
        he && Fe && e.texStorage2D(n.TEXTURE_CUBE_MAP, zt, le, te.width, te.height);
        for (let Ct = 0; Ct < 6; Ct++) {
          St = Yt[Ct].mipmaps;
          for (let It = 0; It < St.length; It++) {
            const Ht = St[It];
            W.format !== Ci ? Kt !== null ? he ? ut && e.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, It, 0, 0, Ht.width, Ht.height, Kt, Ht.data) : e.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, It, le, Ht.width, Ht.height, 0, Ht.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : he ? ut && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, It, 0, 0, Ht.width, Ht.height, Kt, Gt, Ht.data) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, It, le, Ht.width, Ht.height, 0, Kt, Gt, Ht.data);
          }
        }
      } else {
        if (St = W.mipmaps, he && Fe) {
          St.length > 0 && zt++;
          const Ct = qt(Yt[0]);
          e.texStorage2D(n.TEXTURE_CUBE_MAP, zt, le, Ct.width, Ct.height);
        }
        for (let Ct = 0; Ct < 6; Ct++)
          if (Ut) {
            he ? ut && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, 0, 0, 0, Yt[Ct].width, Yt[Ct].height, Kt, Gt, Yt[Ct].data) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, 0, le, Yt[Ct].width, Yt[Ct].height, 0, Kt, Gt, Yt[Ct].data);
            for (let It = 0; It < St.length; It++) {
              const ue = St[It].image[Ct].image;
              he ? ut && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, It + 1, 0, 0, ue.width, ue.height, Kt, Gt, ue.data) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, It + 1, le, ue.width, ue.height, 0, Kt, Gt, ue.data);
            }
          } else {
            he ? ut && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, 0, 0, 0, Kt, Gt, Yt[Ct]) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, 0, le, Kt, Gt, Yt[Ct]);
            for (let It = 0; It < St.length; It++) {
              const Ht = St[It];
              he ? ut && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, It + 1, 0, 0, Kt, Gt, Ht.image[Ct]) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + Ct, It + 1, le, Kt, Gt, Ht.image[Ct]);
            }
          }
      }
      S(W) && y(n.TEXTURE_CUBE_MAP), wt.__version = Dt.version, W.onUpdate && W.onUpdate(W);
    }
    tt.__version = W.version;
  }
  function $(tt, W, mt, Et, Dt, wt) {
    const Zt = o.convert(mt.format, mt.colorSpace), Pt = o.convert(mt.type), Wt = w(mt.internalFormat, Zt, Pt, mt.colorSpace), _e = r.get(W), Ut = r.get(mt);
    if (Ut.__renderTarget = W, !_e.__hasExternalTextures) {
      const Yt = Math.max(1, W.width >> wt), te = Math.max(1, W.height >> wt);
      Dt === n.TEXTURE_3D || Dt === n.TEXTURE_2D_ARRAY ? e.texImage3D(Dt, wt, Wt, Yt, te, W.depth, 0, Zt, Pt, null) : e.texImage2D(Dt, wt, Wt, Yt, te, 0, Zt, Pt, null);
    }
    e.bindFramebuffer(n.FRAMEBUFFER, tt), ne(W) ? u.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, Et, Dt, Ut.__webglTexture, 0, Ft(W)) : (Dt === n.TEXTURE_2D || Dt >= n.TEXTURE_CUBE_MAP_POSITIVE_X && Dt <= n.TEXTURE_CUBE_MAP_NEGATIVE_Z) && n.framebufferTexture2D(n.FRAMEBUFFER, Et, Dt, Ut.__webglTexture, wt), e.bindFramebuffer(n.FRAMEBUFFER, null);
  }
  function Q(tt, W, mt) {
    if (n.bindRenderbuffer(n.RENDERBUFFER, tt), W.depthBuffer) {
      const Et = W.depthTexture, Dt = Et && Et.isDepthTexture ? Et.type : null, wt = M(W.stencilBuffer, Dt), Zt = W.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, Pt = Ft(W);
      ne(W) ? u.renderbufferStorageMultisampleEXT(n.RENDERBUFFER, Pt, wt, W.width, W.height) : mt ? n.renderbufferStorageMultisample(n.RENDERBUFFER, Pt, wt, W.width, W.height) : n.renderbufferStorage(n.RENDERBUFFER, wt, W.width, W.height), n.framebufferRenderbuffer(n.FRAMEBUFFER, Zt, n.RENDERBUFFER, tt);
    } else {
      const Et = W.textures;
      for (let Dt = 0; Dt < Et.length; Dt++) {
        const wt = Et[Dt], Zt = o.convert(wt.format, wt.colorSpace), Pt = o.convert(wt.type), Wt = w(wt.internalFormat, Zt, Pt, wt.colorSpace), _e = Ft(W);
        mt && ne(W) === !1 ? n.renderbufferStorageMultisample(n.RENDERBUFFER, _e, Wt, W.width, W.height) : ne(W) ? u.renderbufferStorageMultisampleEXT(n.RENDERBUFFER, _e, Wt, W.width, W.height) : n.renderbufferStorage(n.RENDERBUFFER, Wt, W.width, W.height);
      }
    }
    n.bindRenderbuffer(n.RENDERBUFFER, null);
  }
  function et(tt, W) {
    if (W && W.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported");
    if (e.bindFramebuffer(n.FRAMEBUFFER, tt), !(W.depthTexture && W.depthTexture.isDepthTexture))
      throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
    const Et = r.get(W.depthTexture);
    Et.__renderTarget = W, (!Et.__webglTexture || W.depthTexture.image.width !== W.width || W.depthTexture.image.height !== W.height) && (W.depthTexture.image.width = W.width, W.depthTexture.image.height = W.height, W.depthTexture.needsUpdate = !0), X(W.depthTexture, 0);
    const Dt = Et.__webglTexture, wt = Ft(W);
    if (W.depthTexture.format === $o)
      ne(W) ? u.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, n.DEPTH_ATTACHMENT, n.TEXTURE_2D, Dt, 0, wt) : n.framebufferTexture2D(n.FRAMEBUFFER, n.DEPTH_ATTACHMENT, n.TEXTURE_2D, Dt, 0);
    else if (W.depthTexture.format === rl)
      ne(W) ? u.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, n.DEPTH_STENCIL_ATTACHMENT, n.TEXTURE_2D, Dt, 0, wt) : n.framebufferTexture2D(n.FRAMEBUFFER, n.DEPTH_STENCIL_ATTACHMENT, n.TEXTURE_2D, Dt, 0);
    else
      throw new Error("Unknown depthTexture format");
  }
  function st(tt) {
    const W = r.get(tt), mt = tt.isWebGLCubeRenderTarget === !0;
    if (W.__boundDepthTexture !== tt.depthTexture) {
      const Et = tt.depthTexture;
      if (W.__depthDisposeCallback && W.__depthDisposeCallback(), Et) {
        const Dt = () => {
          delete W.__boundDepthTexture, delete W.__depthDisposeCallback, Et.removeEventListener("dispose", Dt);
        };
        Et.addEventListener("dispose", Dt), W.__depthDisposeCallback = Dt;
      }
      W.__boundDepthTexture = Et;
    }
    if (tt.depthTexture && !W.__autoAllocateDepthBuffer) {
      if (mt) throw new Error("target.depthTexture not supported in Cube render targets");
      et(W.__webglFramebuffer, tt);
    } else if (mt) {
      W.__webglDepthbuffer = [];
      for (let Et = 0; Et < 6; Et++)
        if (e.bindFramebuffer(n.FRAMEBUFFER, W.__webglFramebuffer[Et]), W.__webglDepthbuffer[Et] === void 0)
          W.__webglDepthbuffer[Et] = n.createRenderbuffer(), Q(W.__webglDepthbuffer[Et], tt, !1);
        else {
          const Dt = tt.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, wt = W.__webglDepthbuffer[Et];
          n.bindRenderbuffer(n.RENDERBUFFER, wt), n.framebufferRenderbuffer(n.FRAMEBUFFER, Dt, n.RENDERBUFFER, wt);
        }
    } else if (e.bindFramebuffer(n.FRAMEBUFFER, W.__webglFramebuffer), W.__webglDepthbuffer === void 0)
      W.__webglDepthbuffer = n.createRenderbuffer(), Q(W.__webglDepthbuffer, tt, !1);
    else {
      const Et = tt.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, Dt = W.__webglDepthbuffer;
      n.bindRenderbuffer(n.RENDERBUFFER, Dt), n.framebufferRenderbuffer(n.FRAMEBUFFER, Et, n.RENDERBUFFER, Dt);
    }
    e.bindFramebuffer(n.FRAMEBUFFER, null);
  }
  function _t(tt, W, mt) {
    const Et = r.get(tt);
    W !== void 0 && $(Et.__webglFramebuffer, tt, tt.texture, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, 0), mt !== void 0 && st(tt);
  }
  function Mt(tt) {
    const W = tt.texture, mt = r.get(tt), Et = r.get(W);
    tt.addEventListener("dispose", N);
    const Dt = tt.textures, wt = tt.isWebGLCubeRenderTarget === !0, Zt = Dt.length > 1;
    if (Zt || (Et.__webglTexture === void 0 && (Et.__webglTexture = n.createTexture()), Et.__version = W.version, c.memory.textures++), wt) {
      mt.__webglFramebuffer = [];
      for (let Pt = 0; Pt < 6; Pt++)
        if (W.mipmaps && W.mipmaps.length > 0) {
          mt.__webglFramebuffer[Pt] = [];
          for (let Wt = 0; Wt < W.mipmaps.length; Wt++)
            mt.__webglFramebuffer[Pt][Wt] = n.createFramebuffer();
        } else
          mt.__webglFramebuffer[Pt] = n.createFramebuffer();
    } else {
      if (W.mipmaps && W.mipmaps.length > 0) {
        mt.__webglFramebuffer = [];
        for (let Pt = 0; Pt < W.mipmaps.length; Pt++)
          mt.__webglFramebuffer[Pt] = n.createFramebuffer();
      } else
        mt.__webglFramebuffer = n.createFramebuffer();
      if (Zt)
        for (let Pt = 0, Wt = Dt.length; Pt < Wt; Pt++) {
          const _e = r.get(Dt[Pt]);
          _e.__webglTexture === void 0 && (_e.__webglTexture = n.createTexture(), c.memory.textures++);
        }
      if (tt.samples > 0 && ne(tt) === !1) {
        mt.__webglMultisampledFramebuffer = n.createFramebuffer(), mt.__webglColorRenderbuffer = [], e.bindFramebuffer(n.FRAMEBUFFER, mt.__webglMultisampledFramebuffer);
        for (let Pt = 0; Pt < Dt.length; Pt++) {
          const Wt = Dt[Pt];
          mt.__webglColorRenderbuffer[Pt] = n.createRenderbuffer(), n.bindRenderbuffer(n.RENDERBUFFER, mt.__webglColorRenderbuffer[Pt]);
          const _e = o.convert(Wt.format, Wt.colorSpace), Ut = o.convert(Wt.type), Yt = w(Wt.internalFormat, _e, Ut, Wt.colorSpace, tt.isXRRenderTarget === !0), te = Ft(tt);
          n.renderbufferStorageMultisample(n.RENDERBUFFER, te, Yt, tt.width, tt.height), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Pt, n.RENDERBUFFER, mt.__webglColorRenderbuffer[Pt]);
        }
        n.bindRenderbuffer(n.RENDERBUFFER, null), tt.depthBuffer && (mt.__webglDepthRenderbuffer = n.createRenderbuffer(), Q(mt.__webglDepthRenderbuffer, tt, !0)), e.bindFramebuffer(n.FRAMEBUFFER, null);
      }
    }
    if (wt) {
      e.bindTexture(n.TEXTURE_CUBE_MAP, Et.__webglTexture), q(n.TEXTURE_CUBE_MAP, W);
      for (let Pt = 0; Pt < 6; Pt++)
        if (W.mipmaps && W.mipmaps.length > 0)
          for (let Wt = 0; Wt < W.mipmaps.length; Wt++)
            $(mt.__webglFramebuffer[Pt][Wt], tt, W, n.COLOR_ATTACHMENT0, n.TEXTURE_CUBE_MAP_POSITIVE_X + Pt, Wt);
        else
          $(mt.__webglFramebuffer[Pt], tt, W, n.COLOR_ATTACHMENT0, n.TEXTURE_CUBE_MAP_POSITIVE_X + Pt, 0);
      S(W) && y(n.TEXTURE_CUBE_MAP), e.unbindTexture();
    } else if (Zt) {
      for (let Pt = 0, Wt = Dt.length; Pt < Wt; Pt++) {
        const _e = Dt[Pt], Ut = r.get(_e);
        e.bindTexture(n.TEXTURE_2D, Ut.__webglTexture), q(n.TEXTURE_2D, _e), $(mt.__webglFramebuffer, tt, _e, n.COLOR_ATTACHMENT0 + Pt, n.TEXTURE_2D, 0), S(_e) && y(n.TEXTURE_2D);
      }
      e.unbindTexture();
    } else {
      let Pt = n.TEXTURE_2D;
      if ((tt.isWebGL3DRenderTarget || tt.isWebGLArrayRenderTarget) && (Pt = tt.isWebGL3DRenderTarget ? n.TEXTURE_3D : n.TEXTURE_2D_ARRAY), e.bindTexture(Pt, Et.__webglTexture), q(Pt, W), W.mipmaps && W.mipmaps.length > 0)
        for (let Wt = 0; Wt < W.mipmaps.length; Wt++)
          $(mt.__webglFramebuffer[Wt], tt, W, n.COLOR_ATTACHMENT0, Pt, Wt);
      else
        $(mt.__webglFramebuffer, tt, W, n.COLOR_ATTACHMENT0, Pt, 0);
      S(W) && y(Pt), e.unbindTexture();
    }
    tt.depthBuffer && st(tt);
  }
  function Rt(tt) {
    const W = tt.textures;
    for (let mt = 0, Et = W.length; mt < Et; mt++) {
      const Dt = W[mt];
      if (S(Dt)) {
        const wt = A(tt), Zt = r.get(Dt).__webglTexture;
        e.bindTexture(wt, Zt), y(wt), e.unbindTexture();
      }
    }
  }
  const Ot = [], nt = [];
  function Jt(tt) {
    if (tt.samples > 0) {
      if (ne(tt) === !1) {
        const W = tt.textures, mt = tt.width, Et = tt.height;
        let Dt = n.COLOR_BUFFER_BIT;
        const wt = tt.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, Zt = r.get(tt), Pt = W.length > 1;
        if (Pt)
          for (let Wt = 0; Wt < W.length; Wt++)
            e.bindFramebuffer(n.FRAMEBUFFER, Zt.__webglMultisampledFramebuffer), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Wt, n.RENDERBUFFER, null), e.bindFramebuffer(n.FRAMEBUFFER, Zt.__webglFramebuffer), n.framebufferTexture2D(n.DRAW_FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Wt, n.TEXTURE_2D, null, 0);
        e.bindFramebuffer(n.READ_FRAMEBUFFER, Zt.__webglMultisampledFramebuffer), e.bindFramebuffer(n.DRAW_FRAMEBUFFER, Zt.__webglFramebuffer);
        for (let Wt = 0; Wt < W.length; Wt++) {
          if (tt.resolveDepthBuffer && (tt.depthBuffer && (Dt |= n.DEPTH_BUFFER_BIT), tt.stencilBuffer && tt.resolveStencilBuffer && (Dt |= n.STENCIL_BUFFER_BIT)), Pt) {
            n.framebufferRenderbuffer(n.READ_FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.RENDERBUFFER, Zt.__webglColorRenderbuffer[Wt]);
            const _e = r.get(W[Wt]).__webglTexture;
            n.framebufferTexture2D(n.DRAW_FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, _e, 0);
          }
          n.blitFramebuffer(0, 0, mt, Et, 0, 0, mt, Et, Dt, n.NEAREST), d === !0 && (Ot.length = 0, nt.length = 0, Ot.push(n.COLOR_ATTACHMENT0 + Wt), tt.depthBuffer && tt.resolveDepthBuffer === !1 && (Ot.push(wt), nt.push(wt), n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER, nt)), n.invalidateFramebuffer(n.READ_FRAMEBUFFER, Ot));
        }
        if (e.bindFramebuffer(n.READ_FRAMEBUFFER, null), e.bindFramebuffer(n.DRAW_FRAMEBUFFER, null), Pt)
          for (let Wt = 0; Wt < W.length; Wt++) {
            e.bindFramebuffer(n.FRAMEBUFFER, Zt.__webglMultisampledFramebuffer), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Wt, n.RENDERBUFFER, Zt.__webglColorRenderbuffer[Wt]);
            const _e = r.get(W[Wt]).__webglTexture;
            e.bindFramebuffer(n.FRAMEBUFFER, Zt.__webglFramebuffer), n.framebufferTexture2D(n.DRAW_FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Wt, n.TEXTURE_2D, _e, 0);
          }
        e.bindFramebuffer(n.DRAW_FRAMEBUFFER, Zt.__webglMultisampledFramebuffer);
      } else if (tt.depthBuffer && tt.resolveDepthBuffer === !1 && d) {
        const W = tt.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT;
        n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER, [W]);
      }
    }
  }
  function Ft(tt) {
    return Math.min(a.maxSamples, tt.samples);
  }
  function ne(tt) {
    const W = r.get(tt);
    return tt.samples > 0 && t.has("WEBGL_multisampled_render_to_texture") === !0 && W.__useRenderToTexture !== !1;
  }
  function jt(tt) {
    const W = c.render.frame;
    p.get(tt) !== W && (p.set(tt, W), tt.update());
  }
  function xe(tt, W) {
    const mt = tt.colorSpace, Et = tt.format, Dt = tt.type;
    return tt.isCompressedTexture === !0 || tt.isVideoTexture === !0 || mt !== sl && mt !== Fs && (Ie.getTransfer(mt) === qe ? (Et !== Ci || Dt !== es) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", mt)), W;
  }
  function qt(tt) {
    return typeof HTMLImageElement < "u" && tt instanceof HTMLImageElement ? (h.width = tt.naturalWidth || tt.width, h.height = tt.naturalHeight || tt.height) : typeof VideoFrame < "u" && tt instanceof VideoFrame ? (h.width = tt.displayWidth, h.height = tt.displayHeight) : (h.width = tt.width, h.height = tt.height), h;
  }
  this.allocateTextureUnit = I, this.resetTextureUnits = B, this.setTexture2D = X, this.setTexture2DArray = D, this.setTexture3D = V, this.setTextureCube = H, this.rebindTextures = _t, this.setupRenderTarget = Mt, this.updateRenderTargetMipmap = Rt, this.updateMultisampleRenderTarget = Jt, this.setupDepthRenderbuffer = st, this.setupFrameBufferTexture = $, this.useMultisampledRTT = ne;
}
function EL(n, t) {
  function e(r, a = Fs) {
    let o;
    const c = Ie.getTransfer(a);
    if (r === es) return n.UNSIGNED_BYTE;
    if (r === v0) return n.UNSIGNED_SHORT_4_4_4_4;
    if (r === _0) return n.UNSIGNED_SHORT_5_5_5_1;
    if (r === aM) return n.UNSIGNED_INT_5_9_9_9_REV;
    if (r === rM) return n.BYTE;
    if (r === sM) return n.SHORT;
    if (r === Cc) return n.UNSIGNED_SHORT;
    if (r === g0) return n.INT;
    if (r === Na) return n.UNSIGNED_INT;
    if (r === Gi) return n.FLOAT;
    if (r === Xc) return n.HALF_FLOAT;
    if (r === oM) return n.ALPHA;
    if (r === lM) return n.RGB;
    if (r === Ci) return n.RGBA;
    if (r === cM) return n.LUMINANCE;
    if (r === uM) return n.LUMINANCE_ALPHA;
    if (r === $o) return n.DEPTH_COMPONENT;
    if (r === rl) return n.DEPTH_STENCIL;
    if (r === y0) return n.RED;
    if (r === x0) return n.RED_INTEGER;
    if (r === fM) return n.RG;
    if (r === S0) return n.RG_INTEGER;
    if (r === b0) return n.RGBA_INTEGER;
    if (r === Jf || r === td || r === ed || r === nd)
      if (c === qe)
        if (o = t.get("WEBGL_compressed_texture_s3tc_srgb"), o !== null) {
          if (r === Jf) return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;
          if (r === td) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
          if (r === ed) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
          if (r === nd) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
        } else
          return null;
      else if (o = t.get("WEBGL_compressed_texture_s3tc"), o !== null) {
        if (r === Jf) return o.COMPRESSED_RGB_S3TC_DXT1_EXT;
        if (r === td) return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;
        if (r === ed) return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;
        if (r === nd) return o.COMPRESSED_RGBA_S3TC_DXT5_EXT;
      } else
        return null;
    if (r === yg || r === xg || r === Sg || r === bg)
      if (o = t.get("WEBGL_compressed_texture_pvrtc"), o !== null) {
        if (r === yg) return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
        if (r === xg) return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
        if (r === Sg) return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
        if (r === bg) return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
      } else
        return null;
    if (r === Mg || r === Eg || r === wg)
      if (o = t.get("WEBGL_compressed_texture_etc"), o !== null) {
        if (r === Mg || r === Eg) return c === qe ? o.COMPRESSED_SRGB8_ETC2 : o.COMPRESSED_RGB8_ETC2;
        if (r === wg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : o.COMPRESSED_RGBA8_ETC2_EAC;
      } else
        return null;
    if (r === Tg || r === Ag || r === Cg || r === Rg || r === Dg || r === Ng || r === Lg || r === Ug || r === Og || r === Pg || r === zg || r === Ig || r === Bg || r === Fg)
      if (o = t.get("WEBGL_compressed_texture_astc"), o !== null) {
        if (r === Tg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : o.COMPRESSED_RGBA_ASTC_4x4_KHR;
        if (r === Ag) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : o.COMPRESSED_RGBA_ASTC_5x4_KHR;
        if (r === Cg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : o.COMPRESSED_RGBA_ASTC_5x5_KHR;
        if (r === Rg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : o.COMPRESSED_RGBA_ASTC_6x5_KHR;
        if (r === Dg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : o.COMPRESSED_RGBA_ASTC_6x6_KHR;
        if (r === Ng) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : o.COMPRESSED_RGBA_ASTC_8x5_KHR;
        if (r === Lg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : o.COMPRESSED_RGBA_ASTC_8x6_KHR;
        if (r === Ug) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : o.COMPRESSED_RGBA_ASTC_8x8_KHR;
        if (r === Og) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : o.COMPRESSED_RGBA_ASTC_10x5_KHR;
        if (r === Pg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : o.COMPRESSED_RGBA_ASTC_10x6_KHR;
        if (r === zg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : o.COMPRESSED_RGBA_ASTC_10x8_KHR;
        if (r === Ig) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : o.COMPRESSED_RGBA_ASTC_10x10_KHR;
        if (r === Bg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : o.COMPRESSED_RGBA_ASTC_12x10_KHR;
        if (r === Fg) return c === qe ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : o.COMPRESSED_RGBA_ASTC_12x12_KHR;
      } else
        return null;
    if (r === id || r === Hg || r === Vg)
      if (o = t.get("EXT_texture_compression_bptc"), o !== null) {
        if (r === id) return c === qe ? o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : o.COMPRESSED_RGBA_BPTC_UNORM_EXT;
        if (r === Hg) return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
        if (r === Vg) return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
      } else
        return null;
    if (r === dM || r === kg || r === Gg || r === Xg)
      if (o = t.get("EXT_texture_compression_rgtc"), o !== null) {
        if (r === id) return o.COMPRESSED_RED_RGTC1_EXT;
        if (r === kg) return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;
        if (r === Gg) return o.COMPRESSED_RED_GREEN_RGTC2_EXT;
        if (r === Xg) return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
      } else
        return null;
    return r === il ? n.UNSIGNED_INT_24_8 : n[r] !== void 0 ? n[r] : null;
  }
  return { convert: e };
}
const wL = { type: "move" };
class Pm {
  constructor() {
    this._targetRay = null, this._grip = null, this._hand = null;
  }
  getHandSpace() {
    return this._hand === null && (this._hand = new Vs(), 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 Vs(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new ot(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new ot()), this._targetRay;
  }
  getGripSpace() {
    return this._grip === null && (this._grip = new Vs(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new ot(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new ot()), this._grip;
  }
  dispatchEvent(t) {
    return this._targetRay !== null && this._targetRay.dispatchEvent(t), this._grip !== null && this._grip.dispatchEvent(t), this._hand !== null && this._hand.dispatchEvent(t), this;
  }
  connect(t) {
    if (t && t.hand) {
      const e = this._hand;
      if (e)
        for (const r of t.hand.values())
          this._getHandJoint(e, r);
    }
    return this.dispatchEvent({ type: "connected", data: t }), this;
  }
  disconnect(t) {
    return this.dispatchEvent({ type: "disconnected", data: t }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this;
  }
  update(t, e, r) {
    let a = null, o = null, c = null;
    const u = this._targetRay, d = this._grip, h = this._hand;
    if (t && e.session.visibilityState !== "visible-blurred") {
      if (h && t.hand) {
        c = !0;
        for (const E of t.hand.values()) {
          const S = e.getJointPose(E, r), y = this._getHandJoint(h, E);
          S !== null && (y.matrix.fromArray(S.transform.matrix), y.matrix.decompose(y.position, y.rotation, y.scale), y.matrixWorldNeedsUpdate = !0, y.jointRadius = S.radius), y.visible = S !== null;
        }
        const p = h.joints["index-finger-tip"], m = h.joints["thumb-tip"], g = p.position.distanceTo(m.position), _ = 0.02, b = 5e-3;
        h.inputState.pinching && g > _ + b ? (h.inputState.pinching = !1, this.dispatchEvent({
          type: "pinchend",
          handedness: t.handedness,
          target: this
        })) : !h.inputState.pinching && g <= _ - b && (h.inputState.pinching = !0, this.dispatchEvent({
          type: "pinchstart",
          handedness: t.handedness,
          target: this
        }));
      } else
        d !== null && t.gripSpace && (o = e.getPose(t.gripSpace, r), o !== null && (d.matrix.fromArray(o.transform.matrix), d.matrix.decompose(d.position, d.rotation, d.scale), d.matrixWorldNeedsUpdate = !0, o.linearVelocity ? (d.hasLinearVelocity = !0, d.linearVelocity.copy(o.linearVelocity)) : d.hasLinearVelocity = !1, o.angularVelocity ? (d.hasAngularVelocity = !0, d.angularVelocity.copy(o.angularVelocity)) : d.hasAngularVelocity = !1));
      u !== null && (a = e.getPose(t.targetRaySpace, r), a === null && o !== null && (a = o), a !== null && (u.matrix.fromArray(a.transform.matrix), u.matrix.decompose(u.position, u.rotation, u.scale), u.matrixWorldNeedsUpdate = !0, a.linearVelocity ? (u.hasLinearVelocity = !0, u.linearVelocity.copy(a.linearVelocity)) : u.hasLinearVelocity = !1, a.angularVelocity ? (u.hasAngularVelocity = !0, u.angularVelocity.copy(a.angularVelocity)) : u.hasAngularVelocity = !1, this.dispatchEvent(wL)));
    }
    return u !== null && (u.visible = a !== null), d !== null && (d.visible = o !== null), h !== null && (h.visible = c !== null), this;
  }
  // private method
  _getHandJoint(t, e) {
    if (t.joints[e.jointName] === void 0) {
      const r = new Vs();
      r.matrixAutoUpdate = !1, r.visible = !1, t.joints[e.jointName] = r, t.add(r);
    }
    return t.joints[e.jointName];
  }
}
const TL = `
void main() {

	gl_Position = vec4( position, 1.0 );

}`, AL = `
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 CL {
  constructor() {
    this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0;
  }
  init(t, e, r) {
    if (this.texture === null) {
      const a = new Jn(), o = t.properties.get(a);
      o.__webglTexture = e.texture, (e.depthNear !== r.depthNear || e.depthFar !== r.depthFar) && (this.depthNear = e.depthNear, this.depthFar = e.depthFar), this.texture = a;
    }
  }
  getMesh(t) {
    if (this.texture !== null && this.mesh === null) {
      const e = t.cameras[0].viewport, r = new gr({
        vertexShader: TL,
        fragmentShader: AL,
        uniforms: {
          depthColor: { value: this.texture },
          depthWidth: { value: e.z },
          depthHeight: { value: e.w }
        }
      });
      this.mesh = new Dn(new Ud(20, 20), r);
    }
    return this.mesh;
  }
  reset() {
    this.texture = null, this.mesh = null;
  }
  getDepthTexture() {
    return this.texture;
  }
}
class RL extends Ia {
  constructor(t, e) {
    super();
    const r = this;
    let a = null, o = 1, c = null, u = "local-floor", d = 1, h = null, p = null, m = null, g = null, _ = null, b = null;
    const E = new CL(), S = e.getContextAttributes();
    let y = null, A = null;
    const w = [], M = [], O = new oe();
    let L = null;
    const N = new Ti();
    N.viewport = new Ke();
    const z = new Ti();
    z.viewport = new Ke();
    const R = [N, z], T = new YC();
    let U = null, B = null;
    this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(G) {
      let k = w[G];
      return k === void 0 && (k = new Pm(), w[G] = k), k.getTargetRaySpace();
    }, this.getControllerGrip = function(G) {
      let k = w[G];
      return k === void 0 && (k = new Pm(), w[G] = k), k.getGripSpace();
    }, this.getHand = function(G) {
      let k = w[G];
      return k === void 0 && (k = new Pm(), w[G] = k), k.getHandSpace();
    };
    function I(G) {
      const k = M.indexOf(G.inputSource);
      if (k === -1)
        return;
      const $ = w[k];
      $ !== void 0 && ($.update(G.inputSource, G.frame, h || c), $.dispatchEvent({ type: G.type, data: G.inputSource }));
    }
    function C() {
      a.removeEventListener("select", I), a.removeEventListener("selectstart", I), a.removeEventListener("selectend", I), a.removeEventListener("squeeze", I), a.removeEventListener("squeezestart", I), a.removeEventListener("squeezeend", I), a.removeEventListener("end", C), a.removeEventListener("inputsourceschange", X);
      for (let G = 0; G < w.length; G++) {
        const k = M[G];
        k !== null && (M[G] = null, w[G].disconnect(k));
      }
      U = null, B = null, E.reset(), t.setRenderTarget(y), _ = null, g = null, m = null, a = null, A = null, it.stop(), r.isPresenting = !1, t.setPixelRatio(L), t.setSize(O.width, O.height, !1), r.dispatchEvent({ type: "sessionend" });
    }
    this.setFramebufferScaleFactor = function(G) {
      o = G, r.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.");
    }, this.setReferenceSpaceType = function(G) {
      u = G, r.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.");
    }, this.getReferenceSpace = function() {
      return h || c;
    }, this.setReferenceSpace = function(G) {
      h = G;
    }, this.getBaseLayer = function() {
      return g !== null ? g : _;
    }, this.getBinding = function() {
      return m;
    }, this.getFrame = function() {
      return b;
    }, this.getSession = function() {
      return a;
    }, this.setSession = async function(G) {
      if (a = G, a !== null) {
        if (y = t.getRenderTarget(), a.addEventListener("select", I), a.addEventListener("selectstart", I), a.addEventListener("selectend", I), a.addEventListener("squeeze", I), a.addEventListener("squeezestart", I), a.addEventListener("squeezeend", I), a.addEventListener("end", C), a.addEventListener("inputsourceschange", X), S.xrCompatible !== !0 && await e.makeXRCompatible(), L = t.getPixelRatio(), t.getSize(O), a.enabledFeatures !== void 0 && a.enabledFeatures.includes("layers")) {
          let $ = null, Q = null, et = null;
          S.depth && (et = S.stencil ? e.DEPTH24_STENCIL8 : e.DEPTH_COMPONENT24, $ = S.stencil ? rl : $o, Q = S.stencil ? il : Na);
          const st = {
            colorFormat: e.RGBA8,
            depthFormat: et,
            scaleFactor: o
          };
          m = new XRWebGLBinding(a, e), g = m.createProjectionLayer(st), a.updateRenderState({ layers: [g] }), t.setPixelRatio(1), t.setSize(g.textureWidth, g.textureHeight, !1), A = new La(
            g.textureWidth,
            g.textureHeight,
            {
              format: Ci,
              type: es,
              depthTexture: new RM(g.textureWidth, g.textureHeight, Q, void 0, void 0, void 0, void 0, void 0, void 0, $),
              stencilBuffer: S.stencil,
              colorSpace: t.outputColorSpace,
              samples: S.antialias ? 4 : 0,
              resolveDepthBuffer: g.ignoreDepthValues === !1
            }
          );
        } else {
          const $ = {
            antialias: S.antialias,
            alpha: !0,
            depth: S.depth,
            stencil: S.stencil,
            framebufferScaleFactor: o
          };
          _ = new XRWebGLLayer(a, e, $), a.updateRenderState({ baseLayer: _ }), t.setPixelRatio(1), t.setSize(_.framebufferWidth, _.framebufferHeight, !1), A = new La(
            _.framebufferWidth,
            _.framebufferHeight,
            {
              format: Ci,
              type: es,
              colorSpace: t.outputColorSpace,
              stencilBuffer: S.stencil
            }
          );
        }
        A.isXRRenderTarget = !0, this.setFoveation(d), h = null, c = await a.requestReferenceSpace(u), it.setContext(a), it.start(), r.isPresenting = !0, r.dispatchEvent({ type: "sessionstart" });
      }
    }, this.getEnvironmentBlendMode = function() {
      if (a !== null)
        return a.environmentBlendMode;
    }, this.getDepthTexture = function() {
      return E.getDepthTexture();
    };
    function X(G) {
      for (let k = 0; k < G.removed.length; k++) {
        const $ = G.removed[k], Q = M.indexOf($);
        Q >= 0 && (M[Q] = null, w[Q].disconnect($));
      }
      for (let k = 0; k < G.added.length; k++) {
        const $ = G.added[k];
        let Q = M.indexOf($);
        if (Q === -1) {
          for (let st = 0; st < w.length; st++)
            if (st >= M.length) {
              M.push($), Q = st;
              break;
            } else if (M[st] === null) {
              M[st] = $, Q = st;
              break;
            }
          if (Q === -1) break;
        }
        const et = w[Q];
        et && et.connect($);
      }
    }
    const D = new ot(), V = new ot();
    function H(G, k, $) {
      D.setFromMatrixPosition(k.matrixWorld), V.setFromMatrixPosition($.matrixWorld);
      const Q = D.distanceTo(V), et = k.projectionMatrix.elements, st = $.projectionMatrix.elements, _t = et[14] / (et[10] - 1), Mt = et[14] / (et[10] + 1), Rt = (et[9] + 1) / et[5], Ot = (et[9] - 1) / et[5], nt = (et[8] - 1) / et[0], Jt = (st[8] + 1) / st[0], Ft = _t * nt, ne = _t * Jt, jt = Q / (-nt + Jt), xe = jt * -nt;
      if (k.matrixWorld.decompose(G.position, G.quaternion, G.scale), G.translateX(xe), G.translateZ(jt), G.matrixWorld.compose(G.position, G.quaternion, G.scale), G.matrixWorldInverse.copy(G.matrixWorld).invert(), et[10] === -1)
        G.projectionMatrix.copy(k.projectionMatrix), G.projectionMatrixInverse.copy(k.projectionMatrixInverse);
      else {
        const qt = _t + jt, tt = Mt + jt, W = Ft - xe, mt = ne + (Q - xe), Et = Rt * Mt / tt * qt, Dt = Ot * Mt / tt * qt;
        G.projectionMatrix.makePerspective(W, mt, Et, Dt, qt, tt), G.projectionMatrixInverse.copy(G.projectionMatrix).invert();
      }
    }
    function j(G, k) {
      k === null ? G.matrixWorld.copy(G.matrix) : G.matrixWorld.multiplyMatrices(k.matrixWorld, G.matrix), G.matrixWorldInverse.copy(G.matrixWorld).invert();
    }
    this.updateCamera = function(G) {
      if (a === null) return;
      let k = G.near, $ = G.far;
      E.texture !== null && (E.depthNear > 0 && (k = E.depthNear), E.depthFar > 0 && ($ = E.depthFar)), T.near = z.near = N.near = k, T.far = z.far = N.far = $, (U !== T.near || B !== T.far) && (a.updateRenderState({
        depthNear: T.near,
        depthFar: T.far
      }), U = T.near, B = T.far), N.layers.mask = G.layers.mask | 2, z.layers.mask = G.layers.mask | 4, T.layers.mask = N.layers.mask | z.layers.mask;
      const Q = G.parent, et = T.cameras;
      j(T, Q);
      for (let st = 0; st < et.length; st++)
        j(et[st], Q);
      et.length === 2 ? H(T, N, z) : T.projectionMatrix.copy(N.projectionMatrix), K(G, T, Q);
    };
    function K(G, k, $) {
      $ === null ? G.matrix.copy(k.matrixWorld) : (G.matrix.copy($.matrixWorld), G.matrix.invert(), G.matrix.multiply(k.matrixWorld)), G.matrix.decompose(G.position, G.quaternion, G.scale), G.updateMatrixWorld(!0), G.projectionMatrix.copy(k.projectionMatrix), G.projectionMatrixInverse.copy(k.projectionMatrixInverse), G.isPerspectiveCamera && (G.fov = Rc * 2 * Math.atan(1 / G.projectionMatrix.elements[5]), G.zoom = 1);
    }
    this.getCamera = function() {
      return T;
    }, this.getFoveation = function() {
      if (!(g === null && _ === null))
        return d;
    }, this.setFoveation = function(G) {
      d = G, g !== null && (g.fixedFoveation = G), _ !== null && _.fixedFoveation !== void 0 && (_.fixedFoveation = G);
    }, this.hasDepthSensing = function() {
      return E.texture !== null;
    }, this.getDepthSensingMesh = function() {
      return E.getMesh(T);
    };
    let F = null;
    function q(G, k) {
      if (p = k.getViewerPose(h || c), b = k, p !== null) {
        const $ = p.views;
        _ !== null && (t.setRenderTargetFramebuffer(A, _.framebuffer), t.setRenderTarget(A));
        let Q = !1;
        $.length !== T.cameras.length && (T.cameras.length = 0, Q = !0);
        for (let st = 0; st < $.length; st++) {
          const _t = $[st];
          let Mt = null;
          if (_ !== null)
            Mt = _.getViewport(_t);
          else {
            const Ot = m.getViewSubImage(g, _t);
            Mt = Ot.viewport, st === 0 && (t.setRenderTargetTextures(
              A,
              Ot.colorTexture,
              g.ignoreDepthValues ? void 0 : Ot.depthStencilTexture
            ), t.setRenderTarget(A));
          }
          let Rt = R[st];
          Rt === void 0 && (Rt = new Ti(), Rt.layers.enable(st), Rt.viewport = new Ke(), R[st] = Rt), Rt.matrix.fromArray(_t.transform.matrix), Rt.matrix.decompose(Rt.position, Rt.quaternion, Rt.scale), Rt.projectionMatrix.fromArray(_t.projectionMatrix), Rt.projectionMatrixInverse.copy(Rt.projectionMatrix).invert(), Rt.viewport.set(Mt.x, Mt.y, Mt.width, Mt.height), st === 0 && (T.matrix.copy(Rt.matrix), T.matrix.decompose(T.position, T.quaternion, T.scale)), Q === !0 && T.cameras.push(Rt);
        }
        const et = a.enabledFeatures;
        if (et && et.includes("depth-sensing")) {
          const st = m.getDepthInformation($[0]);
          st && st.isValid && st.texture && E.init(t, st, a.renderState);
        }
      }
      for (let $ = 0; $ < w.length; $++) {
        const Q = M[$], et = w[$];
        Q !== null && et !== void 0 && et.update(Q, k, h || c);
      }
      F && F(G, k), k.detectedPlanes && r.dispatchEvent({ type: "planesdetected", data: k }), b = null;
    }
    const it = new NM();
    it.setAnimationLoop(q), this.setAnimationLoop = function(G) {
      F = G;
    }, this.dispose = function() {
    };
  }
}
const _a = /* @__PURE__ */ new mr(), DL = /* @__PURE__ */ new Ge();
function NL(n, t) {
  function e(S, y) {
    S.matrixAutoUpdate === !0 && S.updateMatrix(), y.value.copy(S.matrix);
  }
  function r(S, y) {
    y.color.getRGB(S.fogColor.value, MM(n)), y.isFog ? (S.fogNear.value = y.near, S.fogFar.value = y.far) : y.isFogExp2 && (S.fogDensity.value = y.density);
  }
  function a(S, y, A, w, M) {
    y.isMeshBasicMaterial || y.isMeshLambertMaterial ? o(S, y) : y.isMeshToonMaterial ? (o(S, y), m(S, y)) : y.isMeshPhongMaterial ? (o(S, y), p(S, y)) : y.isMeshStandardMaterial ? (o(S, y), g(S, y), y.isMeshPhysicalMaterial && _(S, y, M)) : y.isMeshMatcapMaterial ? (o(S, y), b(S, y)) : y.isMeshDepthMaterial ? o(S, y) : y.isMeshDistanceMaterial ? (o(S, y), E(S, y)) : y.isMeshNormalMaterial ? o(S, y) : y.isLineBasicMaterial ? (c(S, y), y.isLineDashedMaterial && u(S, y)) : y.isPointsMaterial ? d(S, y, A, w) : y.isSpriteMaterial ? h(S, y) : y.isShadowMaterial ? (S.color.value.copy(y.color), S.opacity.value = y.opacity) : y.isShaderMaterial && (y.uniformsNeedUpdate = !1);
  }
  function o(S, y) {
    S.opacity.value = y.opacity, y.color && S.diffuse.value.copy(y.color), y.emissive && S.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity), y.map && (S.map.value = y.map, e(y.map, S.mapTransform)), y.alphaMap && (S.alphaMap.value = y.alphaMap, e(y.alphaMap, S.alphaMapTransform)), y.bumpMap && (S.bumpMap.value = y.bumpMap, e(y.bumpMap, S.bumpMapTransform), S.bumpScale.value = y.bumpScale, y.side === pi && (S.bumpScale.value *= -1)), y.normalMap && (S.normalMap.value = y.normalMap, e(y.normalMap, S.normalMapTransform), S.normalScale.value.copy(y.normalScale), y.side === pi && S.normalScale.value.negate()), y.displacementMap && (S.displacementMap.value = y.displacementMap, e(y.displacementMap, S.displacementMapTransform), S.displacementScale.value = y.displacementScale, S.displacementBias.value = y.displacementBias), y.emissiveMap && (S.emissiveMap.value = y.emissiveMap, e(y.emissiveMap, S.emissiveMapTransform)), y.specularMap && (S.specularMap.value = y.specularMap, e(y.specularMap, S.specularMapTransform)), y.alphaTest > 0 && (S.alphaTest.value = y.alphaTest);
    const A = t.get(y), w = A.envMap, M = A.envMapRotation;
    w && (S.envMap.value = w, _a.copy(M), _a.x *= -1, _a.y *= -1, _a.z *= -1, w.isCubeTexture && w.isRenderTargetTexture === !1 && (_a.y *= -1, _a.z *= -1), S.envMapRotation.value.setFromMatrix4(DL.makeRotationFromEuler(_a)), S.flipEnvMap.value = w.isCubeTexture && w.isRenderTargetTexture === !1 ? -1 : 1, S.reflectivity.value = y.reflectivity, S.ior.value = y.ior, S.refractionRatio.value = y.refractionRatio), y.lightMap && (S.lightMap.value = y.lightMap, S.lightMapIntensity.value = y.lightMapIntensity, e(y.lightMap, S.lightMapTransform)), y.aoMap && (S.aoMap.value = y.aoMap, S.aoMapIntensity.value = y.aoMapIntensity, e(y.aoMap, S.aoMapTransform));
  }
  function c(S, y) {
    S.diffuse.value.copy(y.color), S.opacity.value = y.opacity, y.map && (S.map.value = y.map, e(y.map, S.mapTransform));
  }
  function u(S, y) {
    S.dashSize.value = y.dashSize, S.totalSize.value = y.dashSize + y.gapSize, S.scale.value = y.scale;
  }
  function d(S, y, A, w) {
    S.diffuse.value.copy(y.color), S.opacity.value = y.opacity, S.size.value = y.size * A, S.scale.value = w * 0.5, y.map && (S.map.value = y.map, e(y.map, S.uvTransform)), y.alphaMap && (S.alphaMap.value = y.alphaMap, e(y.alphaMap, S.alphaMapTransform)), y.alphaTest > 0 && (S.alphaTest.value = y.alphaTest);
  }
  function h(S, y) {
    S.diffuse.value.copy(y.color), S.opacity.value = y.opacity, S.rotation.value = y.rotation, y.map && (S.map.value = y.map, e(y.map, S.mapTransform)), y.alphaMap && (S.alphaMap.value = y.alphaMap, e(y.alphaMap, S.alphaMapTransform)), y.alphaTest > 0 && (S.alphaTest.value = y.alphaTest);
  }
  function p(S, y) {
    S.specular.value.copy(y.specular), S.shininess.value = Math.max(y.shininess, 1e-4);
  }
  function m(S, y) {
    y.gradientMap && (S.gradientMap.value = y.gradientMap);
  }
  function g(S, y) {
    S.metalness.value = y.metalness, y.metalnessMap && (S.metalnessMap.value = y.metalnessMap, e(y.metalnessMap, S.metalnessMapTransform)), S.roughness.value = y.roughness, y.roughnessMap && (S.roughnessMap.value = y.roughnessMap, e(y.roughnessMap, S.roughnessMapTransform)), y.envMap && (S.envMapIntensity.value = y.envMapIntensity);
  }
  function _(S, y, A) {
    S.ior.value = y.ior, y.sheen > 0 && (S.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen), S.sheenRoughness.value = y.sheenRoughness, y.sheenColorMap && (S.sheenColorMap.value = y.sheenColorMap, e(y.sheenColorMap, S.sheenColorMapTransform)), y.sheenRoughnessMap && (S.sheenRoughnessMap.value = y.sheenRoughnessMap, e(y.sheenRoughnessMap, S.sheenRoughnessMapTransform))), y.clearcoat > 0 && (S.clearcoat.value = y.clearcoat, S.clearcoatRoughness.value = y.clearcoatRoughness, y.clearcoatMap && (S.clearcoatMap.value = y.clearcoatMap, e(y.clearcoatMap, S.clearcoatMapTransform)), y.clearcoatRoughnessMap && (S.clearcoatRoughnessMap.value = y.clearcoatRoughnessMap, e(y.clearcoatRoughnessMap, S.clearcoatRoughnessMapTransform)), y.clearcoatNormalMap && (S.clearcoatNormalMap.value = y.clearcoatNormalMap, e(y.clearcoatNormalMap, S.clearcoatNormalMapTransform), S.clearcoatNormalScale.value.copy(y.clearcoatNormalScale), y.side === pi && S.clearcoatNormalScale.value.negate())), y.dispersion > 0 && (S.dispersion.value = y.dispersion), y.iridescence > 0 && (S.iridescence.value = y.iridescence, S.iridescenceIOR.value = y.iridescenceIOR, S.iridescenceThicknessMinimum.value = y.iridescenceThicknessRange[0], S.iridescenceThicknessMaximum.value = y.iridescenceThicknessRange[1], y.iridescenceMap && (S.iridescenceMap.value = y.iridescenceMap, e(y.iridescenceMap, S.iridescenceMapTransform)), y.iridescenceThicknessMap && (S.iridescenceThicknessMap.value = y.iridescenceThicknessMap, e(y.iridescenceThicknessMap, S.iridescenceThicknessMapTransform))), y.transmission > 0 && (S.transmission.value = y.transmission, S.transmissionSamplerMap.value = A.texture, S.transmissionSamplerSize.value.set(A.width, A.height), y.transmissionMap && (S.transmissionMap.value = y.transmissionMap, e(y.transmissionMap, S.transmissionMapTransform)), S.thickness.value = y.thickness, y.thicknessMap && (S.thicknessMap.value = y.thicknessMap, e(y.thicknessMap, S.thicknessMapTransform)), S.attenuationDistance.value = y.attenuationDistance, S.attenuationColor.value.copy(y.attenuationColor)), y.anisotropy > 0 && (S.anisotropyVector.value.set(y.anisotropy * Math.cos(y.anisotropyRotation), y.anisotropy * Math.sin(y.anisotropyRotation)), y.anisotropyMap && (S.anisotropyMap.value = y.anisotropyMap, e(y.anisotropyMap, S.anisotropyMapTransform))), S.specularIntensity.value = y.specularIntensity, S.specularColor.value.copy(y.specularColor), y.specularColorMap && (S.specularColorMap.value = y.specularColorMap, e(y.specularColorMap, S.specularColorMapTransform)), y.specularIntensityMap && (S.specularIntensityMap.value = y.specularIntensityMap, e(y.specularIntensityMap, S.specularIntensityMapTransform));
  }
  function b(S, y) {
    y.matcap && (S.matcap.value = y.matcap);
  }
  function E(S, y) {
    const A = t.get(y).light;
    S.referencePosition.value.setFromMatrixPosition(A.matrixWorld), S.nearDistance.value = A.shadow.camera.near, S.farDistance.value = A.shadow.camera.far;
  }
  return {
    refreshFogUniforms: r,
    refreshMaterialUniforms: a
  };
}
function LL(n, t, e, r) {
  let a = {}, o = {}, c = [];
  const u = n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);
  function d(A, w) {
    const M = w.program;
    r.uniformBlockBinding(A, M);
  }
  function h(A, w) {
    let M = a[A.id];
    M === void 0 && (b(A), M = p(A), a[A.id] = M, A.addEventListener("dispose", S));
    const O = w.program;
    r.updateUBOMapping(A, O);
    const L = t.render.frame;
    o[A.id] !== L && (g(A), o[A.id] = L);
  }
  function p(A) {
    const w = m();
    A.__bindingPointIndex = w;
    const M = n.createBuffer(), O = A.__size, L = A.usage;
    return n.bindBuffer(n.UNIFORM_BUFFER, M), n.bufferData(n.UNIFORM_BUFFER, O, L), n.bindBuffer(n.UNIFORM_BUFFER, null), n.bindBufferBase(n.UNIFORM_BUFFER, w, M), M;
  }
  function m() {
    for (let A = 0; A < u; A++)
      if (c.indexOf(A) === -1)
        return c.push(A), A;
    return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0;
  }
  function g(A) {
    const w = a[A.id], M = A.uniforms, O = A.__cache;
    n.bindBuffer(n.UNIFORM_BUFFER, w);
    for (let L = 0, N = M.length; L < N; L++) {
      const z = Array.isArray(M[L]) ? M[L] : [M[L]];
      for (let R = 0, T = z.length; R < T; R++) {
        const U = z[R];
        if (_(U, L, R, O) === !0) {
          const B = U.__offset, I = Array.isArray(U.value) ? U.value : [U.value];
          let C = 0;
          for (let X = 0; X < I.length; X++) {
            const D = I[X], V = E(D);
            typeof D == "number" || typeof D == "boolean" ? (U.__data[0] = D, n.bufferSubData(n.UNIFORM_BUFFER, B + C, U.__data)) : D.isMatrix3 ? (U.__data[0] = D.elements[0], U.__data[1] = D.elements[1], U.__data[2] = D.elements[2], U.__data[3] = 0, U.__data[4] = D.elements[3], U.__data[5] = D.elements[4], U.__data[6] = D.elements[5], U.__data[7] = 0, U.__data[8] = D.elements[6], U.__data[9] = D.elements[7], U.__data[10] = D.elements[8], U.__data[11] = 0) : (D.toArray(U.__data, C), C += V.storage / Float32Array.BYTES_PER_ELEMENT);
          }
          n.bufferSubData(n.UNIFORM_BUFFER, B, U.__data);
        }
      }
    }
    n.bindBuffer(n.UNIFORM_BUFFER, null);
  }
  function _(A, w, M, O) {
    const L = A.value, N = w + "_" + M;
    if (O[N] === void 0)
      return typeof L == "number" || typeof L == "boolean" ? O[N] = L : O[N] = L.clone(), !0;
    {
      const z = O[N];
      if (typeof L == "number" || typeof L == "boolean") {
        if (z !== L)
          return O[N] = L, !0;
      } else if (z.equals(L) === !1)
        return z.copy(L), !0;
    }
    return !1;
  }
  function b(A) {
    const w = A.uniforms;
    let M = 0;
    const O = 16;
    for (let N = 0, z = w.length; N < z; N++) {
      const R = Array.isArray(w[N]) ? w[N] : [w[N]];
      for (let T = 0, U = R.length; T < U; T++) {
        const B = R[T], I = Array.isArray(B.value) ? B.value : [B.value];
        for (let C = 0, X = I.length; C < X; C++) {
          const D = I[C], V = E(D), H = M % O, j = H % V.boundary, K = H + j;
          M += j, K !== 0 && O - K < V.storage && (M += O - K), B.__data = new Float32Array(V.storage / Float32Array.BYTES_PER_ELEMENT), B.__offset = M, M += V.storage;
        }
      }
    }
    const L = M % O;
    return L > 0 && (M += O - L), A.__size = M, A.__cache = {}, this;
  }
  function E(A) {
    const w = {
      boundary: 0,
      // bytes
      storage: 0
      // bytes
    };
    return typeof A == "number" || typeof A == "boolean" ? (w.boundary = 4, w.storage = 4) : A.isVector2 ? (w.boundary = 8, w.storage = 8) : A.isVector3 || A.isColor ? (w.boundary = 16, w.storage = 12) : A.isVector4 ? (w.boundary = 16, w.storage = 16) : A.isMatrix3 ? (w.boundary = 48, w.storage = 48) : A.isMatrix4 ? (w.boundary = 64, w.storage = 64) : A.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", A), w;
  }
  function S(A) {
    const w = A.target;
    w.removeEventListener("dispose", S);
    const M = c.indexOf(w.__bindingPointIndex);
    c.splice(M, 1), n.deleteBuffer(a[w.id]), delete a[w.id], delete o[w.id];
  }
  function y() {
    for (const A in a)
      n.deleteBuffer(a[A]);
    c = [], a = {}, o = {};
  }
  return {
    bind: d,
    update: h,
    dispose: y
  };
}
class UL {
  constructor(t = {}) {
    const {
      canvas: e = uC(),
      context: r = null,
      depth: a = !0,
      stencil: o = !1,
      alpha: c = !1,
      antialias: u = !1,
      premultipliedAlpha: d = !0,
      preserveDrawingBuffer: h = !1,
      powerPreference: p = "default",
      failIfMajorPerformanceCaveat: m = !1,
      reverseDepthBuffer: g = !1
    } = t;
    this.isWebGLRenderer = !0;
    let _;
    if (r !== null) {
      if (typeof WebGLRenderingContext < "u" && r instanceof WebGLRenderingContext)
        throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");
      _ = r.getContextAttributes().alpha;
    } else
      _ = c;
    const b = new Uint32Array(4), E = new Int32Array(4);
    let S = null, y = null;
    const A = [], w = [];
    this.domElement = e, 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 = Vi, this.toneMapping = Gs, this.toneMappingExposure = 1;
    const M = this;
    let O = !1, L = 0, N = 0, z = null, R = -1, T = null;
    const U = new Ke(), B = new Ke();
    let I = null;
    const C = new Me(0);
    let X = 0, D = e.width, V = e.height, H = 1, j = null, K = null;
    const F = new Ke(0, 0, D, V), q = new Ke(0, 0, D, V);
    let it = !1;
    const G = new T0();
    let k = !1, $ = !1;
    this.transmissionResolutionScale = 1;
    const Q = new Ge(), et = new Ge(), st = new ot(), _t = new Ke(), Mt = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 };
    let Rt = !1;
    function Ot() {
      return z === null ? H : 1;
    }
    let nt = r;
    function Jt(Z, ft) {
      return e.getContext(Z, ft);
    }
    try {
      const Z = {
        alpha: !0,
        depth: a,
        stencil: o,
        antialias: u,
        premultipliedAlpha: d,
        preserveDrawingBuffer: h,
        powerPreference: p,
        failIfMajorPerformanceCaveat: m
      };
      if ("setAttribute" in e && e.setAttribute("data-engine", `three.js r${p0}`), e.addEventListener("webglcontextlost", Ct, !1), e.addEventListener("webglcontextrestored", It, !1), e.addEventListener("webglcontextcreationerror", Ht, !1), nt === null) {
        const ft = "webgl2";
        if (nt = Jt(ft, Z), nt === null)
          throw Jt(ft) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context.");
      }
    } catch (Z) {
      throw console.error("THREE.WebGLRenderer: " + Z.message), Z;
    }
    let Ft, ne, jt, xe, qt, tt, W, mt, Et, Dt, wt, Zt, Pt, Wt, _e, Ut, Yt, te, Kt, Gt, le, he, Fe, ut;
    function zt() {
      Ft = new kD(nt), Ft.init(), he = new EL(nt, Ft), ne = new zD(nt, Ft, t, he), jt = new bL(nt, Ft), ne.reverseDepthBuffer && g && jt.buffers.depth.setReversed(!0), xe = new jD(nt), qt = new cL(), tt = new ML(nt, Ft, jt, qt, ne, he, xe), W = new BD(M), mt = new VD(M), Et = new QC(nt), Fe = new OD(nt, Et), Dt = new GD(nt, Et, xe, Fe), wt = new YD(nt, Dt, Et, xe), Kt = new WD(nt, ne, tt), Ut = new ID(qt), Zt = new lL(M, W, mt, Ft, ne, Fe, Ut), Pt = new NL(M, qt), Wt = new fL(), _e = new vL(Ft), te = new UD(M, W, mt, jt, wt, _, d), Yt = new xL(M, wt, ne), ut = new LL(nt, xe, ne, jt), Gt = new PD(nt, Ft, xe), le = new XD(nt, Ft, xe), xe.programs = Zt.programs, M.capabilities = ne, M.extensions = Ft, M.properties = qt, M.renderLists = Wt, M.shadowMap = Yt, M.state = jt, M.info = xe;
    }
    zt();
    const St = new RL(M, nt);
    this.xr = St, this.getContext = function() {
      return nt;
    }, this.getContextAttributes = function() {
      return nt.getContextAttributes();
    }, this.forceContextLoss = function() {
      const Z = Ft.get("WEBGL_lose_context");
      Z && Z.loseContext();
    }, this.forceContextRestore = function() {
      const Z = Ft.get("WEBGL_lose_context");
      Z && Z.restoreContext();
    }, this.getPixelRatio = function() {
      return H;
    }, this.setPixelRatio = function(Z) {
      Z !== void 0 && (H = Z, this.setSize(D, V, !1));
    }, this.getSize = function(Z) {
      return Z.set(D, V);
    }, this.setSize = function(Z, ft, gt = !0) {
      if (St.isPresenting) {
        console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
        return;
      }
      D = Z, V = ft, e.width = Math.floor(Z * H), e.height = Math.floor(ft * H), gt === !0 && (e.style.width = Z + "px", e.style.height = ft + "px"), this.setViewport(0, 0, Z, ft);
    }, this.getDrawingBufferSize = function(Z) {
      return Z.set(D * H, V * H).floor();
    }, this.setDrawingBufferSize = function(Z, ft, gt) {
      D = Z, V = ft, H = gt, e.width = Math.floor(Z * gt), e.height = Math.floor(ft * gt), this.setViewport(0, 0, Z, ft);
    }, this.getCurrentViewport = function(Z) {
      return Z.copy(U);
    }, this.getViewport = function(Z) {
      return Z.copy(F);
    }, this.setViewport = function(Z, ft, gt, yt) {
      Z.isVector4 ? F.set(Z.x, Z.y, Z.z, Z.w) : F.set(Z, ft, gt, yt), jt.viewport(U.copy(F).multiplyScalar(H).round());
    }, this.getScissor = function(Z) {
      return Z.copy(q);
    }, this.setScissor = function(Z, ft, gt, yt) {
      Z.isVector4 ? q.set(Z.x, Z.y, Z.z, Z.w) : q.set(Z, ft, gt, yt), jt.scissor(B.copy(q).multiplyScalar(H).round());
    }, this.getScissorTest = function() {
      return it;
    }, this.setScissorTest = function(Z) {
      jt.setScissorTest(it = Z);
    }, this.setOpaqueSort = function(Z) {
      j = Z;
    }, this.setTransparentSort = function(Z) {
      K = Z;
    }, this.getClearColor = function(Z) {
      return Z.copy(te.getClearColor());
    }, this.setClearColor = function() {
      te.setClearColor.apply(te, arguments);
    }, this.getClearAlpha = function() {
      return te.getClearAlpha();
    }, this.setClearAlpha = function() {
      te.setClearAlpha.apply(te, arguments);
    }, this.clear = function(Z = !0, ft = !0, gt = !0) {
      let yt = 0;
      if (Z) {
        let lt = !1;
        if (z !== null) {
          const Lt = z.texture.format;
          lt = Lt === b0 || Lt === S0 || Lt === x0;
        }
        if (lt) {
          const Lt = z.texture.type, Vt = Lt === es || Lt === Na || Lt === Cc || Lt === il || Lt === v0 || Lt === _0, kt = te.getClearColor(), Xt = te.getClearAlpha(), fe = kt.r, ce = kt.g, ee = kt.b;
          Vt ? (b[0] = fe, b[1] = ce, b[2] = ee, b[3] = Xt, nt.clearBufferuiv(nt.COLOR, 0, b)) : (E[0] = fe, E[1] = ce, E[2] = ee, E[3] = Xt, nt.clearBufferiv(nt.COLOR, 0, E));
        } else
          yt |= nt.COLOR_BUFFER_BIT;
      }
      ft && (yt |= nt.DEPTH_BUFFER_BIT), gt && (yt |= nt.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), nt.clear(yt);
    }, 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() {
      e.removeEventListener("webglcontextlost", Ct, !1), e.removeEventListener("webglcontextrestored", It, !1), e.removeEventListener("webglcontextcreationerror", Ht, !1), te.dispose(), Wt.dispose(), _e.dispose(), qt.dispose(), W.dispose(), mt.dispose(), wt.dispose(), Fe.dispose(), ut.dispose(), Zt.dispose(), St.dispose(), St.removeEventListener("sessionstart", Ys), St.removeEventListener("sessionend", qs), Di.stop();
    };
    function Ct(Z) {
      Z.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), O = !0;
    }
    function It() {
      console.log("THREE.WebGLRenderer: Context Restored."), O = !1;
      const Z = xe.autoReset, ft = Yt.enabled, gt = Yt.autoUpdate, yt = Yt.needsUpdate, lt = Yt.type;
      zt(), xe.autoReset = Z, Yt.enabled = ft, Yt.autoUpdate = gt, Yt.needsUpdate = yt, Yt.type = lt;
    }
    function Ht(Z) {
      console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", Z.statusMessage);
    }
    function ue(Z) {
      const ft = Z.target;
      ft.removeEventListener("dispose", ue), tn(ft);
    }
    function tn(Z) {
      dn(Z), qt.remove(Z);
    }
    function dn(Z) {
      const ft = qt.get(Z).programs;
      ft !== void 0 && (ft.forEach(function(gt) {
        Zt.releaseProgram(gt);
      }), Z.isShaderMaterial && Zt.releaseShaderCache(Z));
    }
    this.renderBufferDirect = function(Z, ft, gt, yt, lt, Lt) {
      ft === null && (ft = Mt);
      const Vt = lt.isMesh && lt.matrixWorld.determinant() < 0, kt = ss(Z, ft, gt, yt, lt);
      jt.setMaterial(yt, Vt);
      let Xt = gt.index, fe = 1;
      if (yt.wireframe === !0) {
        if (Xt = Dt.getWireframeAttribute(gt), Xt === void 0) return;
        fe = 2;
      }
      const ce = gt.drawRange, ee = gt.attributes.position;
      let Ee = ce.start * fe, we = (ce.start + ce.count) * fe;
      Lt !== null && (Ee = Math.max(Ee, Lt.start * fe), we = Math.min(we, (Lt.start + Lt.count) * fe)), Xt !== null ? (Ee = Math.max(Ee, 0), we = Math.min(we, Xt.count)) : ee != null && (Ee = Math.max(Ee, 0), we = Math.min(we, ee.count));
      const Qe = we - Ee;
      if (Qe < 0 || Qe === 1 / 0) return;
      Fe.setup(lt, yt, kt, gt, Xt);
      let Le, de = Gt;
      if (Xt !== null && (Le = Et.get(Xt), de = le, de.setIndex(Le)), lt.isMesh)
        yt.wireframe === !0 ? (jt.setLineWidth(yt.wireframeLinewidth * Ot()), de.setMode(nt.LINES)) : de.setMode(nt.TRIANGLES);
      else if (lt.isLine) {
        let ie = yt.linewidth;
        ie === void 0 && (ie = 1), jt.setLineWidth(ie * Ot()), lt.isLineSegments ? de.setMode(nt.LINES) : lt.isLineLoop ? de.setMode(nt.LINE_LOOP) : de.setMode(nt.LINE_STRIP);
      } else lt.isPoints ? de.setMode(nt.POINTS) : lt.isSprite && de.setMode(nt.TRIANGLES);
      if (lt.isBatchedMesh)
        if (lt._multiDrawInstances !== null)
          de.renderMultiDrawInstances(lt._multiDrawStarts, lt._multiDrawCounts, lt._multiDrawCount, lt._multiDrawInstances);
        else if (Ft.get("WEBGL_multi_draw"))
          de.renderMultiDraw(lt._multiDrawStarts, lt._multiDrawCounts, lt._multiDrawCount);
        else {
          const ie = lt._multiDrawStarts, hn = lt._multiDrawCounts, Se = lt._multiDrawCount, Zn = Xt ? Et.get(Xt).bytesPerElement : 1, ii = qt.get(yt).currentProgram.getUniforms();
          for (let In = 0; In < Se; In++)
            ii.setValue(nt, "_gl_DrawID", In), de.render(ie[In] / Zn, hn[In]);
        }
      else if (lt.isInstancedMesh)
        de.renderInstances(Ee, Qe, lt.count);
      else if (gt.isInstancedBufferGeometry) {
        const ie = gt._maxInstanceCount !== void 0 ? gt._maxInstanceCount : 1 / 0, hn = Math.min(gt.instanceCount, ie);
        de.renderInstances(Ee, Qe, hn);
      } else
        de.render(Ee, Qe);
    };
    function De(Z, ft, gt) {
      Z.transparent === !0 && Z.side === ur && Z.forceSinglePass === !1 ? (Z.side = pi, Z.needsUpdate = !0, sn(Z, ft, gt), Z.side = Xs, Z.needsUpdate = !0, sn(Z, ft, gt), Z.side = ur) : sn(Z, ft, gt);
    }
    this.compile = function(Z, ft, gt = null) {
      gt === null && (gt = Z), y = _e.get(gt), y.init(ft), w.push(y), gt.traverseVisible(function(lt) {
        lt.isLight && lt.layers.test(ft.layers) && (y.pushLight(lt), lt.castShadow && y.pushShadow(lt));
      }), Z !== gt && Z.traverseVisible(function(lt) {
        lt.isLight && lt.layers.test(ft.layers) && (y.pushLight(lt), lt.castShadow && y.pushShadow(lt));
      }), y.setupLights();
      const yt = /* @__PURE__ */ new Set();
      return Z.traverse(function(lt) {
        if (!(lt.isMesh || lt.isPoints || lt.isLine || lt.isSprite))
          return;
        const Lt = lt.material;
        if (Lt)
          if (Array.isArray(Lt))
            for (let Vt = 0; Vt < Lt.length; Vt++) {
              const kt = Lt[Vt];
              De(kt, gt, lt), yt.add(kt);
            }
          else
            De(Lt, gt, lt), yt.add(Lt);
      }), w.pop(), y = null, yt;
    }, this.compileAsync = function(Z, ft, gt = null) {
      const yt = this.compile(Z, ft, gt);
      return new Promise((lt) => {
        function Lt() {
          if (yt.forEach(function(Vt) {
            qt.get(Vt).currentProgram.isReady() && yt.delete(Vt);
          }), yt.size === 0) {
            lt(Z);
            return;
          }
          setTimeout(Lt, 10);
        }
        Ft.get("KHR_parallel_shader_compile") !== null ? Lt() : setTimeout(Lt, 10);
      });
    };
    let wn = null;
    function mi(Z) {
      wn && wn(Z);
    }
    function Ys() {
      Di.stop();
    }
    function qs() {
      Di.start();
    }
    const Di = new NM();
    Di.setAnimationLoop(mi), typeof self < "u" && Di.setContext(self), this.setAnimationLoop = function(Z) {
      wn = Z, St.setAnimationLoop(Z), Z === null ? Di.stop() : Di.start();
    }, St.addEventListener("sessionstart", Ys), St.addEventListener("sessionend", qs), this.render = function(Z, ft) {
      if (ft !== void 0 && ft.isCamera !== !0) {
        console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
        return;
      }
      if (O === !0) return;
      if (Z.matrixWorldAutoUpdate === !0 && Z.updateMatrixWorld(), ft.parent === null && ft.matrixWorldAutoUpdate === !0 && ft.updateMatrixWorld(), St.enabled === !0 && St.isPresenting === !0 && (St.cameraAutoUpdate === !0 && St.updateCamera(ft), ft = St.getCamera()), Z.isScene === !0 && Z.onBeforeRender(M, Z, ft, z), y = _e.get(Z, w.length), y.init(ft), w.push(y), et.multiplyMatrices(ft.projectionMatrix, ft.matrixWorldInverse), G.setFromProjectionMatrix(et), $ = this.localClippingEnabled, k = Ut.init(this.clippingPlanes, $), S = Wt.get(Z, A.length), S.init(), A.push(S), St.enabled === !0 && St.isPresenting === !0) {
        const Lt = M.xr.getDepthSensingMesh();
        Lt !== null && Sr(Lt, ft, -1 / 0, M.sortObjects);
      }
      Sr(Z, ft, 0, M.sortObjects), S.finish(), M.sortObjects === !0 && S.sort(j, K), Rt = St.enabled === !1 || St.isPresenting === !1 || St.hasDepthSensing() === !1, Rt && te.addToRenderList(S, Z), this.info.render.frame++, k === !0 && Ut.beginShadows();
      const gt = y.state.shadowsArray;
      Yt.render(gt, Z, ft), k === !0 && Ut.endShadows(), this.info.autoReset === !0 && this.info.reset();
      const yt = S.opaque, lt = S.transmissive;
      if (y.setupLights(), ft.isArrayCamera) {
        const Lt = ft.cameras;
        if (lt.length > 0)
          for (let Vt = 0, kt = Lt.length; Vt < kt; Vt++) {
            const Xt = Lt[Vt];
            Zs(yt, lt, Z, Xt);
          }
        Rt && te.render(Z);
        for (let Vt = 0, kt = Lt.length; Vt < kt; Vt++) {
          const Xt = Lt[Vt];
          rs(S, Z, Xt, Xt.viewport);
        }
      } else
        lt.length > 0 && Zs(yt, lt, Z, ft), Rt && te.render(Z), rs(S, Z, ft);
      z !== null && N === 0 && (tt.updateMultisampleRenderTarget(z), tt.updateRenderTargetMipmap(z)), Z.isScene === !0 && Z.onAfterRender(M, Z, ft), Fe.resetDefaultState(), R = -1, T = null, w.pop(), w.length > 0 ? (y = w[w.length - 1], k === !0 && Ut.setGlobalState(M.clippingPlanes, y.state.camera)) : y = null, A.pop(), A.length > 0 ? S = A[A.length - 1] : S = null;
    };
    function Sr(Z, ft, gt, yt) {
      if (Z.visible === !1) return;
      if (Z.layers.test(ft.layers)) {
        if (Z.isGroup)
          gt = Z.renderOrder;
        else if (Z.isLOD)
          Z.autoUpdate === !0 && Z.update(ft);
        else if (Z.isLight)
          y.pushLight(Z), Z.castShadow && y.pushShadow(Z);
        else if (Z.isSprite) {
          if (!Z.frustumCulled || G.intersectsSprite(Z)) {
            yt && _t.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(et);
            const Vt = wt.update(Z), kt = Z.material;
            kt.visible && S.push(Z, Vt, kt, gt, _t.z, null);
          }
        } else if ((Z.isMesh || Z.isLine || Z.isPoints) && (!Z.frustumCulled || G.intersectsObject(Z))) {
          const Vt = wt.update(Z), kt = Z.material;
          if (yt && (Z.boundingSphere !== void 0 ? (Z.boundingSphere === null && Z.computeBoundingSphere(), _t.copy(Z.boundingSphere.center)) : (Vt.boundingSphere === null && Vt.computeBoundingSphere(), _t.copy(Vt.boundingSphere.center)), _t.applyMatrix4(Z.matrixWorld).applyMatrix4(et)), Array.isArray(kt)) {
            const Xt = Vt.groups;
            for (let fe = 0, ce = Xt.length; fe < ce; fe++) {
              const ee = Xt[fe], Ee = kt[ee.materialIndex];
              Ee && Ee.visible && S.push(Z, Vt, Ee, gt, _t.z, ee);
            }
          } else kt.visible && S.push(Z, Vt, kt, gt, _t.z, null);
        }
      }
      const Lt = Z.children;
      for (let Vt = 0, kt = Lt.length; Vt < kt; Vt++)
        Sr(Lt[Vt], ft, gt, yt);
    }
    function rs(Z, ft, gt, yt) {
      const lt = Z.opaque, Lt = Z.transmissive, Vt = Z.transparent;
      y.setupLightsView(gt), k === !0 && Ut.setGlobalState(M.clippingPlanes, gt), yt && jt.viewport(U.copy(yt)), lt.length > 0 && br(lt, ft, gt), Lt.length > 0 && br(Lt, ft, gt), Vt.length > 0 && br(Vt, ft, gt), jt.buffers.depth.setTest(!0), jt.buffers.depth.setMask(!0), jt.buffers.color.setMask(!0), jt.setPolygonOffset(!1);
    }
    function Zs(Z, ft, gt, yt) {
      if ((gt.isScene === !0 ? gt.overrideMaterial : null) !== null)
        return;
      y.state.transmissionRenderTarget[yt.id] === void 0 && (y.state.transmissionRenderTarget[yt.id] = new La(1, 1, {
        generateMipmaps: !0,
        type: Ft.has("EXT_color_buffer_half_float") || Ft.has("EXT_color_buffer_float") ? Xc : es,
        minFilter: wa,
        samples: 4,
        stencilBuffer: o,
        resolveDepthBuffer: !1,
        resolveStencilBuffer: !1,
        colorSpace: Ie.workingColorSpace
      }));
      const Lt = y.state.transmissionRenderTarget[yt.id], Vt = yt.viewport || U;
      Lt.setSize(Vt.z * M.transmissionResolutionScale, Vt.w * M.transmissionResolutionScale);
      const kt = M.getRenderTarget();
      M.setRenderTarget(Lt), M.getClearColor(C), X = M.getClearAlpha(), X < 1 && M.setClearColor(16777215, 0.5), M.clear(), Rt && te.render(gt);
      const Xt = M.toneMapping;
      M.toneMapping = Gs;
      const fe = yt.viewport;
      if (yt.viewport !== void 0 && (yt.viewport = void 0), y.setupLightsView(yt), k === !0 && Ut.setGlobalState(M.clippingPlanes, yt), br(Z, gt, yt), tt.updateMultisampleRenderTarget(Lt), tt.updateRenderTargetMipmap(Lt), Ft.has("WEBGL_multisampled_render_to_texture") === !1) {
        let ce = !1;
        for (let ee = 0, Ee = ft.length; ee < Ee; ee++) {
          const we = ft[ee], Qe = we.object, Le = we.geometry, de = we.material, ie = we.group;
          if (de.side === ur && Qe.layers.test(yt.layers)) {
            const hn = de.side;
            de.side = pi, de.needsUpdate = !0, gi(Qe, gt, yt, Le, de, ie), de.side = hn, de.needsUpdate = !0, ce = !0;
          }
        }
        ce === !0 && (tt.updateMultisampleRenderTarget(Lt), tt.updateRenderTargetMipmap(Lt));
      }
      M.setRenderTarget(kt), M.setClearColor(C, X), fe !== void 0 && (yt.viewport = fe), M.toneMapping = Xt;
    }
    function br(Z, ft, gt) {
      const yt = ft.isScene === !0 ? ft.overrideMaterial : null;
      for (let lt = 0, Lt = Z.length; lt < Lt; lt++) {
        const Vt = Z[lt], kt = Vt.object, Xt = Vt.geometry, fe = yt === null ? Vt.material : yt, ce = Vt.group;
        kt.layers.test(gt.layers) && gi(kt, ft, gt, Xt, fe, ce);
      }
    }
    function gi(Z, ft, gt, yt, lt, Lt) {
      Z.onBeforeRender(M, ft, gt, yt, lt, Lt), Z.modelViewMatrix.multiplyMatrices(gt.matrixWorldInverse, Z.matrixWorld), Z.normalMatrix.getNormalMatrix(Z.modelViewMatrix), lt.onBeforeRender(M, ft, gt, yt, Z, Lt), lt.transparent === !0 && lt.side === ur && lt.forceSinglePass === !1 ? (lt.side = pi, lt.needsUpdate = !0, M.renderBufferDirect(gt, ft, yt, lt, Z, Lt), lt.side = Xs, lt.needsUpdate = !0, M.renderBufferDirect(gt, ft, yt, lt, Z, Lt), lt.side = ur) : M.renderBufferDirect(gt, ft, yt, lt, Z, Lt), Z.onAfterRender(M, ft, gt, yt, lt, Lt);
    }
    function sn(Z, ft, gt) {
      ft.isScene !== !0 && (ft = Mt);
      const yt = qt.get(Z), lt = y.state.lights, Lt = y.state.shadowsArray, Vt = lt.state.version, kt = Zt.getParameters(Z, lt.state, Lt, ft, gt), Xt = Zt.getProgramCacheKey(kt);
      let fe = yt.programs;
      yt.environment = Z.isMeshStandardMaterial ? ft.environment : null, yt.fog = ft.fog, yt.envMap = (Z.isMeshStandardMaterial ? mt : W).get(Z.envMap || yt.environment), yt.envMapRotation = yt.environment !== null && Z.envMap === null ? ft.environmentRotation : Z.envMapRotation, fe === void 0 && (Z.addEventListener("dispose", ue), fe = /* @__PURE__ */ new Map(), yt.programs = fe);
      let ce = fe.get(Xt);
      if (ce !== void 0) {
        if (yt.currentProgram === ce && yt.lightsStateVersion === Vt)
          return Ni(Z, kt), ce;
      } else
        kt.uniforms = Zt.getUniforms(Z), Z.onBeforeCompile(kt, M), ce = Zt.acquireProgram(kt, Xt), fe.set(Xt, ce), yt.uniforms = kt.uniforms;
      const ee = yt.uniforms;
      return (!Z.isShaderMaterial && !Z.isRawShaderMaterial || Z.clipping === !0) && (ee.clippingPlanes = Ut.uniform), Ni(Z, kt), yt.needsLights = gl(Z), yt.lightsStateVersion = Vt, yt.needsLights && (ee.ambientLightColor.value = lt.state.ambient, ee.lightProbe.value = lt.state.probe, ee.directionalLights.value = lt.state.directional, ee.directionalLightShadows.value = lt.state.directionalShadow, ee.spotLights.value = lt.state.spot, ee.spotLightShadows.value = lt.state.spotShadow, ee.rectAreaLights.value = lt.state.rectArea, ee.ltc_1.value = lt.state.rectAreaLTC1, ee.ltc_2.value = lt.state.rectAreaLTC2, ee.pointLights.value = lt.state.point, ee.pointLightShadows.value = lt.state.pointShadow, ee.hemisphereLights.value = lt.state.hemi, ee.directionalShadowMap.value = lt.state.directionalShadowMap, ee.directionalShadowMatrix.value = lt.state.directionalShadowMatrix, ee.spotShadowMap.value = lt.state.spotShadowMap, ee.spotLightMatrix.value = lt.state.spotLightMatrix, ee.spotLightMap.value = lt.state.spotLightMap, ee.pointShadowMap.value = lt.state.pointShadowMap, ee.pointShadowMatrix.value = lt.state.pointShadowMatrix), yt.currentProgram = ce, yt.uniformsList = null, ce;
    }
    function Tn(Z) {
      if (Z.uniformsList === null) {
        const ft = Z.currentProgram.getUniforms();
        Z.uniformsList = sd.seqWithValue(ft.seq, Z.uniforms);
      }
      return Z.uniformsList;
    }
    function Ni(Z, ft) {
      const gt = qt.get(Z);
      gt.outputColorSpace = ft.outputColorSpace, gt.batching = ft.batching, gt.batchingColor = ft.batchingColor, gt.instancing = ft.instancing, gt.instancingColor = ft.instancingColor, gt.instancingMorph = ft.instancingMorph, gt.skinning = ft.skinning, gt.morphTargets = ft.morphTargets, gt.morphNormals = ft.morphNormals, gt.morphColors = ft.morphColors, gt.morphTargetsCount = ft.morphTargetsCount, gt.numClippingPlanes = ft.numClippingPlanes, gt.numIntersection = ft.numClipIntersection, gt.vertexAlphas = ft.vertexAlphas, gt.vertexTangents = ft.vertexTangents, gt.toneMapping = ft.toneMapping;
    }
    function ss(Z, ft, gt, yt, lt) {
      ft.isScene !== !0 && (ft = Mt), tt.resetTextureUnits();
      const Lt = ft.fog, Vt = yt.isMeshStandardMaterial ? ft.environment : null, kt = z === null ? M.outputColorSpace : z.isXRRenderTarget === !0 ? z.texture.colorSpace : sl, Xt = (yt.isMeshStandardMaterial ? mt : W).get(yt.envMap || Vt), fe = yt.vertexColors === !0 && !!gt.attributes.color && gt.attributes.color.itemSize === 4, ce = !!gt.attributes.tangent && (!!yt.normalMap || yt.anisotropy > 0), ee = !!gt.morphAttributes.position, Ee = !!gt.morphAttributes.normal, we = !!gt.morphAttributes.color;
      let Qe = Gs;
      yt.toneMapped && (z === null || z.isXRRenderTarget === !0) && (Qe = M.toneMapping);
      const Le = gt.morphAttributes.position || gt.morphAttributes.normal || gt.morphAttributes.color, de = Le !== void 0 ? Le.length : 0, ie = qt.get(yt), hn = y.state.lights;
      if (k === !0 && ($ === !0 || Z !== T)) {
        const en = Z === T && yt.id === R;
        Ut.setState(yt, Z, en);
      }
      let Se = !1;
      yt.version === ie.__version ? (ie.needsLights && ie.lightsStateVersion !== hn.state.version || ie.outputColorSpace !== kt || lt.isBatchedMesh && ie.batching === !1 || !lt.isBatchedMesh && ie.batching === !0 || lt.isBatchedMesh && ie.batchingColor === !0 && lt.colorTexture === null || lt.isBatchedMesh && ie.batchingColor === !1 && lt.colorTexture !== null || lt.isInstancedMesh && ie.instancing === !1 || !lt.isInstancedMesh && ie.instancing === !0 || lt.isSkinnedMesh && ie.skinning === !1 || !lt.isSkinnedMesh && ie.skinning === !0 || lt.isInstancedMesh && ie.instancingColor === !0 && lt.instanceColor === null || lt.isInstancedMesh && ie.instancingColor === !1 && lt.instanceColor !== null || lt.isInstancedMesh && ie.instancingMorph === !0 && lt.morphTexture === null || lt.isInstancedMesh && ie.instancingMorph === !1 && lt.morphTexture !== null || ie.envMap !== Xt || yt.fog === !0 && ie.fog !== Lt || ie.numClippingPlanes !== void 0 && (ie.numClippingPlanes !== Ut.numPlanes || ie.numIntersection !== Ut.numIntersection) || ie.vertexAlphas !== fe || ie.vertexTangents !== ce || ie.morphTargets !== ee || ie.morphNormals !== Ee || ie.morphColors !== we || ie.toneMapping !== Qe || ie.morphTargetsCount !== de) && (Se = !0) : (Se = !0, ie.__version = yt.version);
      let Zn = ie.currentProgram;
      Se === !0 && (Zn = sn(yt, ft, lt));
      let ii = !1, In = !1, gn = !1;
      const Oe = Zn.getUniforms(), Bn = ie.uniforms;
      if (jt.useProgram(Zn.program) && (ii = !0, In = !0, gn = !0), yt.id !== R && (R = yt.id, In = !0), ii || T !== Z) {
        jt.buffers.depth.getReversed() ? (Q.copy(Z.projectionMatrix), dC(Q), hC(Q), Oe.setValue(nt, "projectionMatrix", Q)) : Oe.setValue(nt, "projectionMatrix", Z.projectionMatrix), Oe.setValue(nt, "viewMatrix", Z.matrixWorldInverse);
        const Fn = Oe.map.cameraPosition;
        Fn !== void 0 && Fn.setValue(nt, st.setFromMatrixPosition(Z.matrixWorld)), ne.logarithmicDepthBuffer && Oe.setValue(
          nt,
          "logDepthBufFC",
          2 / (Math.log(Z.far + 1) / Math.LN2)
        ), (yt.isMeshPhongMaterial || yt.isMeshToonMaterial || yt.isMeshLambertMaterial || yt.isMeshBasicMaterial || yt.isMeshStandardMaterial || yt.isShaderMaterial) && Oe.setValue(nt, "isOrthographic", Z.isOrthographicCamera === !0), T !== Z && (T = Z, In = !0, gn = !0);
      }
      if (lt.isSkinnedMesh) {
        Oe.setOptional(nt, lt, "bindMatrix"), Oe.setOptional(nt, lt, "bindMatrixInverse");
        const en = lt.skeleton;
        en && (en.boneTexture === null && en.computeBoneTexture(), Oe.setValue(nt, "boneTexture", en.boneTexture, tt));
      }
      lt.isBatchedMesh && (Oe.setOptional(nt, lt, "batchingTexture"), Oe.setValue(nt, "batchingTexture", lt._matricesTexture, tt), Oe.setOptional(nt, lt, "batchingIdTexture"), Oe.setValue(nt, "batchingIdTexture", lt._indirectTexture, tt), Oe.setOptional(nt, lt, "batchingColorTexture"), lt._colorsTexture !== null && Oe.setValue(nt, "batchingColorTexture", lt._colorsTexture, tt));
      const On = gt.morphAttributes;
      if ((On.position !== void 0 || On.normal !== void 0 || On.color !== void 0) && Kt.update(lt, gt, Zn), (In || ie.receiveShadow !== lt.receiveShadow) && (ie.receiveShadow = lt.receiveShadow, Oe.setValue(nt, "receiveShadow", lt.receiveShadow)), yt.isMeshGouraudMaterial && yt.envMap !== null && (Bn.envMap.value = Xt, Bn.flipEnvMap.value = Xt.isCubeTexture && Xt.isRenderTargetTexture === !1 ? -1 : 1), yt.isMeshStandardMaterial && yt.envMap === null && ft.environment !== null && (Bn.envMapIntensity.value = ft.environmentIntensity), In && (Oe.setValue(nt, "toneMappingExposure", M.toneMappingExposure), ie.needsLights && Fa(Bn, gn), Lt && yt.fog === !0 && Pt.refreshFogUniforms(Bn, Lt), Pt.refreshMaterialUniforms(Bn, yt, H, V, y.state.transmissionRenderTarget[Z.id]), sd.upload(nt, Tn(ie), Bn, tt)), yt.isShaderMaterial && yt.uniformsNeedUpdate === !0 && (sd.upload(nt, Tn(ie), Bn, tt), yt.uniformsNeedUpdate = !1), yt.isSpriteMaterial && Oe.setValue(nt, "center", lt.center), Oe.setValue(nt, "modelViewMatrix", lt.modelViewMatrix), Oe.setValue(nt, "normalMatrix", lt.normalMatrix), Oe.setValue(nt, "modelMatrix", lt.matrixWorld), yt.isShaderMaterial || yt.isRawShaderMaterial) {
        const en = yt.uniformsGroups;
        for (let Fn = 0, Va = en.length; Fn < Va; Fn++) {
          const ri = en[Fn];
          ut.update(ri, Zn), ut.bind(ri, Zn);
        }
      }
      return Zn;
    }
    function Fa(Z, ft) {
      Z.ambientLightColor.needsUpdate = ft, Z.lightProbe.needsUpdate = ft, Z.directionalLights.needsUpdate = ft, Z.directionalLightShadows.needsUpdate = ft, Z.pointLights.needsUpdate = ft, Z.pointLightShadows.needsUpdate = ft, Z.spotLights.needsUpdate = ft, Z.spotLightShadows.needsUpdate = ft, Z.rectAreaLights.needsUpdate = ft, Z.hemisphereLights.needsUpdate = ft;
    }
    function gl(Z) {
      return Z.isMeshLambertMaterial || Z.isMeshToonMaterial || Z.isMeshPhongMaterial || Z.isMeshStandardMaterial || Z.isShadowMaterial || Z.isShaderMaterial && Z.lights === !0;
    }
    this.getActiveCubeFace = function() {
      return L;
    }, this.getActiveMipmapLevel = function() {
      return N;
    }, this.getRenderTarget = function() {
      return z;
    }, this.setRenderTargetTextures = function(Z, ft, gt) {
      qt.get(Z.texture).__webglTexture = ft, qt.get(Z.depthTexture).__webglTexture = gt;
      const yt = qt.get(Z);
      yt.__hasExternalTextures = !0, yt.__autoAllocateDepthBuffer = gt === void 0, yt.__autoAllocateDepthBuffer || Ft.has("WEBGL_multisampled_render_to_texture") === !0 && (console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"), yt.__useRenderToTexture = !1);
    }, this.setRenderTargetFramebuffer = function(Z, ft) {
      const gt = qt.get(Z);
      gt.__webglFramebuffer = ft, gt.__useDefaultFramebuffer = ft === void 0;
    };
    const Ha = nt.createFramebuffer();
    this.setRenderTarget = function(Z, ft = 0, gt = 0) {
      z = Z, L = ft, N = gt;
      let yt = !0, lt = null, Lt = !1, Vt = !1;
      if (Z) {
        const Xt = qt.get(Z);
        if (Xt.__useDefaultFramebuffer !== void 0)
          jt.bindFramebuffer(nt.FRAMEBUFFER, null), yt = !1;
        else if (Xt.__webglFramebuffer === void 0)
          tt.setupRenderTarget(Z);
        else if (Xt.__hasExternalTextures)
          tt.rebindTextures(Z, qt.get(Z.texture).__webglTexture, qt.get(Z.depthTexture).__webglTexture);
        else if (Z.depthBuffer) {
          const ee = Z.depthTexture;
          if (Xt.__boundDepthTexture !== ee) {
            if (ee !== null && qt.has(ee) && (Z.width !== ee.image.width || Z.height !== ee.image.height))
              throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");
            tt.setupDepthRenderbuffer(Z);
          }
        }
        const fe = Z.texture;
        (fe.isData3DTexture || fe.isDataArrayTexture || fe.isCompressedArrayTexture) && (Vt = !0);
        const ce = qt.get(Z).__webglFramebuffer;
        Z.isWebGLCubeRenderTarget ? (Array.isArray(ce[ft]) ? lt = ce[ft][gt] : lt = ce[ft], Lt = !0) : Z.samples > 0 && tt.useMultisampledRTT(Z) === !1 ? lt = qt.get(Z).__webglMultisampledFramebuffer : Array.isArray(ce) ? lt = ce[gt] : lt = ce, U.copy(Z.viewport), B.copy(Z.scissor), I = Z.scissorTest;
      } else
        U.copy(F).multiplyScalar(H).floor(), B.copy(q).multiplyScalar(H).floor(), I = it;
      if (gt !== 0 && (lt = Ha), jt.bindFramebuffer(nt.FRAMEBUFFER, lt) && yt && jt.drawBuffers(Z, lt), jt.viewport(U), jt.scissor(B), jt.setScissorTest(I), Lt) {
        const Xt = qt.get(Z.texture);
        nt.framebufferTexture2D(nt.FRAMEBUFFER, nt.COLOR_ATTACHMENT0, nt.TEXTURE_CUBE_MAP_POSITIVE_X + ft, Xt.__webglTexture, gt);
      } else if (Vt) {
        const Xt = qt.get(Z.texture), fe = ft;
        nt.framebufferTextureLayer(nt.FRAMEBUFFER, nt.COLOR_ATTACHMENT0, Xt.__webglTexture, gt, fe);
      } else if (Z !== null && gt !== 0) {
        const Xt = qt.get(Z.texture);
        nt.framebufferTexture2D(nt.FRAMEBUFFER, nt.COLOR_ATTACHMENT0, nt.TEXTURE_2D, Xt.__webglTexture, gt);
      }
      R = -1;
    }, this.readRenderTargetPixels = function(Z, ft, gt, yt, lt, Lt, Vt) {
      if (!(Z && Z.isWebGLRenderTarget)) {
        console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
        return;
      }
      let kt = qt.get(Z).__webglFramebuffer;
      if (Z.isWebGLCubeRenderTarget && Vt !== void 0 && (kt = kt[Vt]), kt) {
        jt.bindFramebuffer(nt.FRAMEBUFFER, kt);
        try {
          const Xt = Z.texture, fe = Xt.format, ce = Xt.type;
          if (!ne.textureFormatReadable(fe)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
            return;
          }
          if (!ne.textureTypeReadable(ce)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
            return;
          }
          ft >= 0 && ft <= Z.width - yt && gt >= 0 && gt <= Z.height - lt && nt.readPixels(ft, gt, yt, lt, he.convert(fe), he.convert(ce), Lt);
        } finally {
          const Xt = z !== null ? qt.get(z).__webglFramebuffer : null;
          jt.bindFramebuffer(nt.FRAMEBUFFER, Xt);
        }
      }
    }, this.readRenderTargetPixelsAsync = async function(Z, ft, gt, yt, lt, Lt, Vt) {
      if (!(Z && Z.isWebGLRenderTarget))
        throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
      let kt = qt.get(Z).__webglFramebuffer;
      if (Z.isWebGLCubeRenderTarget && Vt !== void 0 && (kt = kt[Vt]), kt) {
        const Xt = Z.texture, fe = Xt.format, ce = Xt.type;
        if (!ne.textureFormatReadable(fe))
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");
        if (!ne.textureTypeReadable(ce))
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");
        if (ft >= 0 && ft <= Z.width - yt && gt >= 0 && gt <= Z.height - lt) {
          jt.bindFramebuffer(nt.FRAMEBUFFER, kt);
          const ee = nt.createBuffer();
          nt.bindBuffer(nt.PIXEL_PACK_BUFFER, ee), nt.bufferData(nt.PIXEL_PACK_BUFFER, Lt.byteLength, nt.STREAM_READ), nt.readPixels(ft, gt, yt, lt, he.convert(fe), he.convert(ce), 0);
          const Ee = z !== null ? qt.get(z).__webglFramebuffer : null;
          jt.bindFramebuffer(nt.FRAMEBUFFER, Ee);
          const we = nt.fenceSync(nt.SYNC_GPU_COMMANDS_COMPLETE, 0);
          return nt.flush(), await fC(nt, we, 4), nt.bindBuffer(nt.PIXEL_PACK_BUFFER, ee), nt.getBufferSubData(nt.PIXEL_PACK_BUFFER, 0, Lt), nt.deleteBuffer(ee), nt.deleteSync(we), Lt;
        } else
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");
      }
    }, this.copyFramebufferToTexture = function(Z, ft = null, gt = 0) {
      Z.isTexture !== !0 && (ko("WebGLRenderer: copyFramebufferToTexture function signature has changed."), ft = arguments[0] || null, Z = arguments[1]);
      const yt = Math.pow(2, -gt), lt = Math.floor(Z.image.width * yt), Lt = Math.floor(Z.image.height * yt), Vt = ft !== null ? ft.x : 0, kt = ft !== null ? ft.y : 0;
      tt.setTexture2D(Z, 0), nt.copyTexSubImage2D(nt.TEXTURE_2D, gt, 0, 0, Vt, kt, lt, Lt), jt.unbindTexture();
    };
    const Mr = nt.createFramebuffer(), $s = nt.createFramebuffer();
    this.copyTextureToTexture = function(Z, ft, gt = null, yt = null, lt = 0, Lt = null) {
      Z.isTexture !== !0 && (ko("WebGLRenderer: copyTextureToTexture function signature has changed."), yt = arguments[0] || null, Z = arguments[1], ft = arguments[2], Lt = arguments[3] || 0, gt = null), Lt === null && (lt !== 0 ? (ko("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."), Lt = lt, lt = 0) : Lt = 0);
      let Vt, kt, Xt, fe, ce, ee, Ee, we, Qe;
      const Le = Z.isCompressedTexture ? Z.mipmaps[Lt] : Z.image;
      if (gt !== null)
        Vt = gt.max.x - gt.min.x, kt = gt.max.y - gt.min.y, Xt = gt.isBox3 ? gt.max.z - gt.min.z : 1, fe = gt.min.x, ce = gt.min.y, ee = gt.isBox3 ? gt.min.z : 0;
      else {
        const On = Math.pow(2, -lt);
        Vt = Math.floor(Le.width * On), kt = Math.floor(Le.height * On), Z.isDataArrayTexture ? Xt = Le.depth : Z.isData3DTexture ? Xt = Math.floor(Le.depth * On) : Xt = 1, fe = 0, ce = 0, ee = 0;
      }
      yt !== null ? (Ee = yt.x, we = yt.y, Qe = yt.z) : (Ee = 0, we = 0, Qe = 0);
      const de = he.convert(ft.format), ie = he.convert(ft.type);
      let hn;
      ft.isData3DTexture ? (tt.setTexture3D(ft, 0), hn = nt.TEXTURE_3D) : ft.isDataArrayTexture || ft.isCompressedArrayTexture ? (tt.setTexture2DArray(ft, 0), hn = nt.TEXTURE_2D_ARRAY) : (tt.setTexture2D(ft, 0), hn = nt.TEXTURE_2D), nt.pixelStorei(nt.UNPACK_FLIP_Y_WEBGL, ft.flipY), nt.pixelStorei(nt.UNPACK_PREMULTIPLY_ALPHA_WEBGL, ft.premultiplyAlpha), nt.pixelStorei(nt.UNPACK_ALIGNMENT, ft.unpackAlignment);
      const Se = nt.getParameter(nt.UNPACK_ROW_LENGTH), Zn = nt.getParameter(nt.UNPACK_IMAGE_HEIGHT), ii = nt.getParameter(nt.UNPACK_SKIP_PIXELS), In = nt.getParameter(nt.UNPACK_SKIP_ROWS), gn = nt.getParameter(nt.UNPACK_SKIP_IMAGES);
      nt.pixelStorei(nt.UNPACK_ROW_LENGTH, Le.width), nt.pixelStorei(nt.UNPACK_IMAGE_HEIGHT, Le.height), nt.pixelStorei(nt.UNPACK_SKIP_PIXELS, fe), nt.pixelStorei(nt.UNPACK_SKIP_ROWS, ce), nt.pixelStorei(nt.UNPACK_SKIP_IMAGES, ee);
      const Oe = Z.isDataArrayTexture || Z.isData3DTexture, Bn = ft.isDataArrayTexture || ft.isData3DTexture;
      if (Z.isDepthTexture) {
        const On = qt.get(Z), en = qt.get(ft), Fn = qt.get(On.__renderTarget), Va = qt.get(en.__renderTarget);
        jt.bindFramebuffer(nt.READ_FRAMEBUFFER, Fn.__webglFramebuffer), jt.bindFramebuffer(nt.DRAW_FRAMEBUFFER, Va.__webglFramebuffer);
        for (let ri = 0; ri < Xt; ri++)
          Oe && (nt.framebufferTextureLayer(nt.READ_FRAMEBUFFER, nt.COLOR_ATTACHMENT0, qt.get(Z).__webglTexture, lt, ee + ri), nt.framebufferTextureLayer(nt.DRAW_FRAMEBUFFER, nt.COLOR_ATTACHMENT0, qt.get(ft).__webglTexture, Lt, Qe + ri)), nt.blitFramebuffer(fe, ce, Vt, kt, Ee, we, Vt, kt, nt.DEPTH_BUFFER_BIT, nt.NEAREST);
        jt.bindFramebuffer(nt.READ_FRAMEBUFFER, null), jt.bindFramebuffer(nt.DRAW_FRAMEBUFFER, null);
      } else if (lt !== 0 || Z.isRenderTargetTexture || qt.has(Z)) {
        const On = qt.get(Z), en = qt.get(ft);
        jt.bindFramebuffer(nt.READ_FRAMEBUFFER, Mr), jt.bindFramebuffer(nt.DRAW_FRAMEBUFFER, $s);
        for (let Fn = 0; Fn < Xt; Fn++)
          Oe ? nt.framebufferTextureLayer(nt.READ_FRAMEBUFFER, nt.COLOR_ATTACHMENT0, On.__webglTexture, lt, ee + Fn) : nt.framebufferTexture2D(nt.READ_FRAMEBUFFER, nt.COLOR_ATTACHMENT0, nt.TEXTURE_2D, On.__webglTexture, lt), Bn ? nt.framebufferTextureLayer(nt.DRAW_FRAMEBUFFER, nt.COLOR_ATTACHMENT0, en.__webglTexture, Lt, Qe + Fn) : nt.framebufferTexture2D(nt.DRAW_FRAMEBUFFER, nt.COLOR_ATTACHMENT0, nt.TEXTURE_2D, en.__webglTexture, Lt), lt !== 0 ? nt.blitFramebuffer(fe, ce, Vt, kt, Ee, we, Vt, kt, nt.COLOR_BUFFER_BIT, nt.NEAREST) : Bn ? nt.copyTexSubImage3D(hn, Lt, Ee, we, Qe + Fn, fe, ce, Vt, kt) : nt.copyTexSubImage2D(hn, Lt, Ee, we, fe, ce, Vt, kt);
        jt.bindFramebuffer(nt.READ_FRAMEBUFFER, null), jt.bindFramebuffer(nt.DRAW_FRAMEBUFFER, null);
      } else
        Bn ? Z.isDataTexture || Z.isData3DTexture ? nt.texSubImage3D(hn, Lt, Ee, we, Qe, Vt, kt, Xt, de, ie, Le.data) : ft.isCompressedArrayTexture ? nt.compressedTexSubImage3D(hn, Lt, Ee, we, Qe, Vt, kt, Xt, de, Le.data) : nt.texSubImage3D(hn, Lt, Ee, we, Qe, Vt, kt, Xt, de, ie, Le) : Z.isDataTexture ? nt.texSubImage2D(nt.TEXTURE_2D, Lt, Ee, we, Vt, kt, de, ie, Le.data) : Z.isCompressedTexture ? nt.compressedTexSubImage2D(nt.TEXTURE_2D, Lt, Ee, we, Le.width, Le.height, de, Le.data) : nt.texSubImage2D(nt.TEXTURE_2D, Lt, Ee, we, Vt, kt, de, ie, Le);
      nt.pixelStorei(nt.UNPACK_ROW_LENGTH, Se), nt.pixelStorei(nt.UNPACK_IMAGE_HEIGHT, Zn), nt.pixelStorei(nt.UNPACK_SKIP_PIXELS, ii), nt.pixelStorei(nt.UNPACK_SKIP_ROWS, In), nt.pixelStorei(nt.UNPACK_SKIP_IMAGES, gn), Lt === 0 && ft.generateMipmaps && nt.generateMipmap(hn), jt.unbindTexture();
    }, this.copyTextureToTexture3D = function(Z, ft, gt = null, yt = null, lt = 0) {
      return Z.isTexture !== !0 && (ko("WebGLRenderer: copyTextureToTexture3D function signature has changed."), gt = arguments[0] || null, yt = arguments[1] || null, Z = arguments[2], ft = arguments[3], lt = arguments[4] || 0), ko('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'), this.copyTextureToTexture(Z, ft, gt, yt, lt);
    }, this.initRenderTarget = function(Z) {
      qt.get(Z).__webglFramebuffer === void 0 && tt.setupRenderTarget(Z);
    }, this.initTexture = function(Z) {
      Z.isCubeTexture ? tt.setTextureCube(Z, 0) : Z.isData3DTexture ? tt.setTexture3D(Z, 0) : Z.isDataArrayTexture || Z.isCompressedArrayTexture ? tt.setTexture2DArray(Z, 0) : tt.setTexture2D(Z, 0), jt.unbindTexture();
    }, this.resetState = function() {
      L = 0, N = 0, z = null, jt.reset(), Fe.reset();
    }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  get coordinateSystem() {
    return Zr;
  }
  get outputColorSpace() {
    return this._outputColorSpace;
  }
  set outputColorSpace(t) {
    this._outputColorSpace = t;
    const e = this.getContext();
    e.drawingBufferColorspace = Ie._getDrawingBufferColorSpace(t), e.unpackColorSpace = Ie._getUnpackColorSpace();
  }
}
const eb = { type: "change" }, L0 = { type: "start" }, zM = { type: "end" }, Bf = new E0(), nb = new Bs(), OL = Math.cos(70 * mM.DEG2RAD), Cn = new ot(), fi = 2 * Math.PI, Ze = {
  NONE: -1,
  ROTATE: 0,
  DOLLY: 1,
  PAN: 2,
  TOUCH_ROTATE: 3,
  TOUCH_PAN: 4,
  TOUCH_DOLLY_PAN: 5,
  TOUCH_DOLLY_ROTATE: 6
}, zm = 1e-6;
class ib extends $C {
  constructor(t, e = null) {
    super(t, e), this.state = Ze.NONE, this.enabled = !0, this.target = new ot(), this.cursor = new ot(), 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.keyRotateSpeed = 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: qo.ROTATE, MIDDLE: qo.DOLLY, RIGHT: qo.PAN }, this.touches = { ONE: Xo.ROTATE, TWO: Xo.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new ot(), this._lastQuaternion = new js(), this._lastTargetPosition = new ot(), this._quat = new js().setFromUnitVectors(t.up, new ot(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new AS(), this._sphericalDelta = new AS(), this._scale = 1, this._panOffset = new ot(), this._rotateStart = new oe(), this._rotateEnd = new oe(), this._rotateDelta = new oe(), this._panStart = new oe(), this._panEnd = new oe(), this._panDelta = new oe(), this._dollyStart = new oe(), this._dollyEnd = new oe(), this._dollyDelta = new oe(), this._dollyDirection = new ot(), this._mouse = new oe(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = zL.bind(this), this._onPointerDown = PL.bind(this), this._onPointerUp = IL.bind(this), this._onContextMenu = XL.bind(this), this._onMouseWheel = HL.bind(this), this._onKeyDown = VL.bind(this), this._onTouchStart = kL.bind(this), this._onTouchMove = GL.bind(this), this._onMouseDown = BL.bind(this), this._onMouseMove = FL.bind(this), this._interceptControlDown = jL.bind(this), this._interceptControlUp = WL.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(t) {
    t.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = t;
  }
  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(eb), this.update(), this.state = Ze.NONE;
  }
  update(t = null) {
    const e = this.object.position;
    Cn.copy(e).sub(this.target), Cn.applyQuaternion(this._quat), this._spherical.setFromVector3(Cn), this.autoRotate && this.state === Ze.NONE && this._rotateLeft(this._getAutoRotationAngle(t)), 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 r = this.minAzimuthAngle, a = this.maxAzimuthAngle;
    isFinite(r) && isFinite(a) && (r < -Math.PI ? r += fi : r > Math.PI && (r -= fi), a < -Math.PI ? a += fi : a > Math.PI && (a -= fi), r <= a ? this._spherical.theta = Math.max(r, Math.min(a, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (r + a) / 2 ? Math.max(r, this._spherical.theta) : Math.min(a, 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 o = !1;
    if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
      this._spherical.radius = this._clampDistance(this._spherical.radius);
    else {
      const c = this._spherical.radius;
      this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), o = c != this._spherical.radius;
    }
    if (Cn.setFromSpherical(this._spherical), Cn.applyQuaternion(this._quatInverse), e.copy(this.target).add(Cn), 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 c = null;
      if (this.object.isPerspectiveCamera) {
        const u = Cn.length();
        c = this._clampDistance(u * this._scale);
        const d = u - c;
        this.object.position.addScaledVector(this._dollyDirection, d), this.object.updateMatrixWorld(), o = !!d;
      } else if (this.object.isOrthographicCamera) {
        const u = new ot(this._mouse.x, this._mouse.y, 0);
        u.unproject(this.object);
        const d = this.object.zoom;
        this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), o = d !== this.object.zoom;
        const h = new ot(this._mouse.x, this._mouse.y, 0);
        h.unproject(this.object), this.object.position.sub(h).add(u), this.object.updateMatrixWorld(), c = Cn.length();
      } else
        console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
      c !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(c).add(this.object.position) : (Bf.origin.copy(this.object.position), Bf.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(Bf.direction)) < OL ? this.object.lookAt(this.target) : (nb.setFromNormalAndCoplanarPoint(this.object.up, this.target), Bf.intersectPlane(nb, this.target))));
    } else if (this.object.isOrthographicCamera) {
      const c = this.object.zoom;
      this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), c !== this.object.zoom && (this.object.updateProjectionMatrix(), o = !0);
    }
    return this._scale = 1, this._performCursorZoom = !1, o || this._lastPosition.distanceToSquared(this.object.position) > zm || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > zm || this._lastTargetPosition.distanceToSquared(this.target) > zm ? (this.dispatchEvent(eb), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
  }
  _getAutoRotationAngle(t) {
    return t !== null ? fi / 60 * this.autoRotateSpeed * t : fi / 60 / 60 * this.autoRotateSpeed;
  }
  _getZoomScale(t) {
    const e = Math.abs(t * 0.01);
    return Math.pow(0.95, this.zoomSpeed * e);
  }
  _rotateLeft(t) {
    this._sphericalDelta.theta -= t;
  }
  _rotateUp(t) {
    this._sphericalDelta.phi -= t;
  }
  _panLeft(t, e) {
    Cn.setFromMatrixColumn(e, 0), Cn.multiplyScalar(-t), this._panOffset.add(Cn);
  }
  _panUp(t, e) {
    this.screenSpacePanning === !0 ? Cn.setFromMatrixColumn(e, 1) : (Cn.setFromMatrixColumn(e, 0), Cn.crossVectors(this.object.up, Cn)), Cn.multiplyScalar(t), this._panOffset.add(Cn);
  }
  // deltaX and deltaY are in pixels; right and down are positive
  _pan(t, e) {
    const r = this.domElement;
    if (this.object.isPerspectiveCamera) {
      const a = this.object.position;
      Cn.copy(a).sub(this.target);
      let o = Cn.length();
      o *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * t * o / r.clientHeight, this.object.matrix), this._panUp(2 * e * o / r.clientHeight, this.object.matrix);
    } else this.object.isOrthographicCamera ? (this._panLeft(t * (this.object.right - this.object.left) / this.object.zoom / r.clientWidth, this.object.matrix), this._panUp(e * (this.object.top - this.object.bottom) / this.object.zoom / r.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
  }
  _dollyOut(t) {
    this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
  }
  _dollyIn(t) {
    this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
  }
  _updateZoomParameters(t, e) {
    if (!this.zoomToCursor)
      return;
    this._performCursorZoom = !0;
    const r = this.domElement.getBoundingClientRect(), a = t - r.left, o = e - r.top, c = r.width, u = r.height;
    this._mouse.x = a / c * 2 - 1, this._mouse.y = -(o / u) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
  }
  _clampDistance(t) {
    return Math.max(this.minDistance, Math.min(this.maxDistance, t));
  }
  //
  // event callbacks - update the object state
  //
  _handleMouseDownRotate(t) {
    this._rotateStart.set(t.clientX, t.clientY);
  }
  _handleMouseDownDolly(t) {
    this._updateZoomParameters(t.clientX, t.clientX), this._dollyStart.set(t.clientX, t.clientY);
  }
  _handleMouseDownPan(t) {
    this._panStart.set(t.clientX, t.clientY);
  }
  _handleMouseMoveRotate(t) {
    this._rotateEnd.set(t.clientX, t.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
    const e = this.domElement;
    this._rotateLeft(fi * this._rotateDelta.x / e.clientHeight), this._rotateUp(fi * this._rotateDelta.y / e.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
  }
  _handleMouseMoveDolly(t) {
    this._dollyEnd.set(t.clientX, t.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(t) {
    this._panEnd.set(t.clientX, t.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(t) {
    this._updateZoomParameters(t.clientX, t.clientY), t.deltaY < 0 ? this._dollyIn(this._getZoomScale(t.deltaY)) : t.deltaY > 0 && this._dollyOut(this._getZoomScale(t.deltaY)), this.update();
  }
  _handleKeyDown(t) {
    let e = !1;
    switch (t.code) {
      case this.keys.UP:
        t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(fi * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), e = !0;
        break;
      case this.keys.BOTTOM:
        t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-fi * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), e = !0;
        break;
      case this.keys.LEFT:
        t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(fi * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), e = !0;
        break;
      case this.keys.RIGHT:
        t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-fi * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), e = !0;
        break;
    }
    e && (t.preventDefault(), this.update());
  }
  _handleTouchStartRotate(t) {
    if (this._pointers.length === 1)
      this._rotateStart.set(t.pageX, t.pageY);
    else {
      const e = this._getSecondPointerPosition(t), r = 0.5 * (t.pageX + e.x), a = 0.5 * (t.pageY + e.y);
      this._rotateStart.set(r, a);
    }
  }
  _handleTouchStartPan(t) {
    if (this._pointers.length === 1)
      this._panStart.set(t.pageX, t.pageY);
    else {
      const e = this._getSecondPointerPosition(t), r = 0.5 * (t.pageX + e.x), a = 0.5 * (t.pageY + e.y);
      this._panStart.set(r, a);
    }
  }
  _handleTouchStartDolly(t) {
    const e = this._getSecondPointerPosition(t), r = t.pageX - e.x, a = t.pageY - e.y, o = Math.sqrt(r * r + a * a);
    this._dollyStart.set(0, o);
  }
  _handleTouchStartDollyPan(t) {
    this.enableZoom && this._handleTouchStartDolly(t), this.enablePan && this._handleTouchStartPan(t);
  }
  _handleTouchStartDollyRotate(t) {
    this.enableZoom && this._handleTouchStartDolly(t), this.enableRotate && this._handleTouchStartRotate(t);
  }
  _handleTouchMoveRotate(t) {
    if (this._pointers.length == 1)
      this._rotateEnd.set(t.pageX, t.pageY);
    else {
      const r = this._getSecondPointerPosition(t), a = 0.5 * (t.pageX + r.x), o = 0.5 * (t.pageY + r.y);
      this._rotateEnd.set(a, o);
    }
    this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
    const e = this.domElement;
    this._rotateLeft(fi * this._rotateDelta.x / e.clientHeight), this._rotateUp(fi * this._rotateDelta.y / e.clientHeight), this._rotateStart.copy(this._rotateEnd);
  }
  _handleTouchMovePan(t) {
    if (this._pointers.length === 1)
      this._panEnd.set(t.pageX, t.pageY);
    else {
      const e = this._getSecondPointerPosition(t), r = 0.5 * (t.pageX + e.x), a = 0.5 * (t.pageY + e.y);
      this._panEnd.set(r, a);
    }
    this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
  }
  _handleTouchMoveDolly(t) {
    const e = this._getSecondPointerPosition(t), r = t.pageX - e.x, a = t.pageY - e.y, o = Math.sqrt(r * r + a * a);
    this._dollyEnd.set(0, o), 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 c = (t.pageX + e.x) * 0.5, u = (t.pageY + e.y) * 0.5;
    this._updateZoomParameters(c, u);
  }
  _handleTouchMoveDollyPan(t) {
    this.enableZoom && this._handleTouchMoveDolly(t), this.enablePan && this._handleTouchMovePan(t);
  }
  _handleTouchMoveDollyRotate(t) {
    this.enableZoom && this._handleTouchMoveDolly(t), this.enableRotate && this._handleTouchMoveRotate(t);
  }
  // pointers
  _addPointer(t) {
    this._pointers.push(t.pointerId);
  }
  _removePointer(t) {
    delete this._pointerPositions[t.pointerId];
    for (let e = 0; e < this._pointers.length; e++)
      if (this._pointers[e] == t.pointerId) {
        this._pointers.splice(e, 1);
        return;
      }
  }
  _isTrackingPointer(t) {
    for (let e = 0; e < this._pointers.length; e++)
      if (this._pointers[e] == t.pointerId) return !0;
    return !1;
  }
  _trackPointer(t) {
    let e = this._pointerPositions[t.pointerId];
    e === void 0 && (e = new oe(), this._pointerPositions[t.pointerId] = e), e.set(t.pageX, t.pageY);
  }
  _getSecondPointerPosition(t) {
    const e = t.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
    return this._pointerPositions[e];
  }
  //
  _customWheelEvent(t) {
    const e = t.deltaMode, r = {
      clientX: t.clientX,
      clientY: t.clientY,
      deltaY: t.deltaY
    };
    switch (e) {
      case 1:
        r.deltaY *= 16;
        break;
      case 2:
        r.deltaY *= 100;
        break;
    }
    return t.ctrlKey && !this._controlActive && (r.deltaY *= 10), r;
  }
}
function PL(n) {
  this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(n.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(n) && (this._addPointer(n), n.pointerType === "touch" ? this._onTouchStart(n) : this._onMouseDown(n)));
}
function zL(n) {
  this.enabled !== !1 && (n.pointerType === "touch" ? this._onTouchMove(n) : this._onMouseMove(n));
}
function IL(n) {
  switch (this._removePointer(n), this._pointers.length) {
    case 0:
      this.domElement.releasePointerCapture(n.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(zM), this.state = Ze.NONE;
      break;
    case 1:
      const t = this._pointers[0], e = this._pointerPositions[t];
      this._onTouchStart({ pointerId: t, pageX: e.x, pageY: e.y });
      break;
  }
}
function BL(n) {
  let t;
  switch (n.button) {
    case 0:
      t = this.mouseButtons.LEFT;
      break;
    case 1:
      t = this.mouseButtons.MIDDLE;
      break;
    case 2:
      t = this.mouseButtons.RIGHT;
      break;
    default:
      t = -1;
  }
  switch (t) {
    case qo.DOLLY:
      if (this.enableZoom === !1) return;
      this._handleMouseDownDolly(n), this.state = Ze.DOLLY;
      break;
    case qo.ROTATE:
      if (n.ctrlKey || n.metaKey || n.shiftKey) {
        if (this.enablePan === !1) return;
        this._handleMouseDownPan(n), this.state = Ze.PAN;
      } else {
        if (this.enableRotate === !1) return;
        this._handleMouseDownRotate(n), this.state = Ze.ROTATE;
      }
      break;
    case qo.PAN:
      if (n.ctrlKey || n.metaKey || n.shiftKey) {
        if (this.enableRotate === !1) return;
        this._handleMouseDownRotate(n), this.state = Ze.ROTATE;
      } else {
        if (this.enablePan === !1) return;
        this._handleMouseDownPan(n), this.state = Ze.PAN;
      }
      break;
    default:
      this.state = Ze.NONE;
  }
  this.state !== Ze.NONE && this.dispatchEvent(L0);
}
function FL(n) {
  switch (this.state) {
    case Ze.ROTATE:
      if (this.enableRotate === !1) return;
      this._handleMouseMoveRotate(n);
      break;
    case Ze.DOLLY:
      if (this.enableZoom === !1) return;
      this._handleMouseMoveDolly(n);
      break;
    case Ze.PAN:
      if (this.enablePan === !1) return;
      this._handleMouseMovePan(n);
      break;
  }
}
function HL(n) {
  this.enabled === !1 || this.enableZoom === !1 || this.state !== Ze.NONE || (n.preventDefault(), this.dispatchEvent(L0), this._handleMouseWheel(this._customWheelEvent(n)), this.dispatchEvent(zM));
}
function VL(n) {
  this.enabled !== !1 && this._handleKeyDown(n);
}
function kL(n) {
  switch (this._trackPointer(n), this._pointers.length) {
    case 1:
      switch (this.touches.ONE) {
        case Xo.ROTATE:
          if (this.enableRotate === !1) return;
          this._handleTouchStartRotate(n), this.state = Ze.TOUCH_ROTATE;
          break;
        case Xo.PAN:
          if (this.enablePan === !1) return;
          this._handleTouchStartPan(n), this.state = Ze.TOUCH_PAN;
          break;
        default:
          this.state = Ze.NONE;
      }
      break;
    case 2:
      switch (this.touches.TWO) {
        case Xo.DOLLY_PAN:
          if (this.enableZoom === !1 && this.enablePan === !1) return;
          this._handleTouchStartDollyPan(n), this.state = Ze.TOUCH_DOLLY_PAN;
          break;
        case Xo.DOLLY_ROTATE:
          if (this.enableZoom === !1 && this.enableRotate === !1) return;
          this._handleTouchStartDollyRotate(n), this.state = Ze.TOUCH_DOLLY_ROTATE;
          break;
        default:
          this.state = Ze.NONE;
      }
      break;
    default:
      this.state = Ze.NONE;
  }
  this.state !== Ze.NONE && this.dispatchEvent(L0);
}
function GL(n) {
  switch (this._trackPointer(n), this.state) {
    case Ze.TOUCH_ROTATE:
      if (this.enableRotate === !1) return;
      this._handleTouchMoveRotate(n), this.update();
      break;
    case Ze.TOUCH_PAN:
      if (this.enablePan === !1) return;
      this._handleTouchMovePan(n), this.update();
      break;
    case Ze.TOUCH_DOLLY_PAN:
      if (this.enableZoom === !1 && this.enablePan === !1) return;
      this._handleTouchMoveDollyPan(n), this.update();
      break;
    case Ze.TOUCH_DOLLY_ROTATE:
      if (this.enableZoom === !1 && this.enableRotate === !1) return;
      this._handleTouchMoveDollyRotate(n), this.update();
      break;
    default:
      this.state = Ze.NONE;
  }
}
function XL(n) {
  this.enabled !== !1 && n.preventDefault();
}
function jL(n) {
  n.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
function WL(n) {
  n.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
const YL = {
  1: [1, 1, 1],
  // H  - white (CPK)
  2: [0.851, 1, 1],
  // He - light cyan (CPK)
  3: [0.527, 0.88, 0.457],
  // Li (VESTA)
  4: [0.371, 0.846, 0.483],
  // Be (VESTA)
  5: [1, 0.71, 0.71],
  // B  - pink (CPK)
  6: [0.565, 0.565, 0.565],
  // C  - gray (CPK)
  7: [0.188, 0.314, 0.973],
  // N  - blue (CPK)
  8: [1, 0.051, 0.051],
  // O  - red (CPK)
  9: [0.565, 0.878, 0.314],
  // F  - green (CPK)
  10: [1, 0.218, 0.71],
  // Ne (VESTA)
  11: [0.671, 0.361, 0.949],
  // Na - purple (CPK)
  12: [0.541, 1, 0],
  // Mg - green (CPK)
  13: [0.749, 0.651, 0.651],
  // Al - gray-pink (CPK)
  14: [0.941, 0.784, 0.627],
  // Si - tan (CPK)
  15: [1, 0.502, 0],
  // P  - orange (CPK)
  16: [1, 1, 0.188],
  // S  - yellow (CPK)
  17: [0.122, 0.941, 0.122],
  // Cl - green (CPK)
  18: [0.502, 0.82, 0.89],
  // Ar - light blue (CPK)
  19: [0.561, 0.251, 0.831],
  // K  - purple (CPK)
  20: [0.239, 1, 0],
  // Ca - green (CPK)
  21: [0.712, 0.389, 0.673],
  // Sc (VESTA)
  22: [0.472, 0.794, 1],
  // Ti (VESTA)
  23: [0.9, 0.1, 0],
  // V  (VESTA)
  24: [0, 0, 0.62],
  // Cr (VESTA)
  25: [0.661, 0.034, 0.62],
  // Mn (VESTA)
  26: [0.878, 0.4, 0.2],
  // Fe - orange (CPK)
  27: [0, 0, 0.687],
  // Co (VESTA)
  28: [0.72, 0.736, 0.743],
  // Ni (VESTA)
  29: [0.784, 0.502, 0.2],
  // Cu - copper (CPK)
  30: [0.49, 0.502, 0.69],
  // Zn - slate (CPK)
  31: [0.623, 0.893, 0.455],
  // Ga (VESTA)
  32: [0.496, 0.435, 0.652],
  // Ge (VESTA)
  33: [0.458, 0.817, 0.342],
  // As (VESTA)
  34: [1, 0.631, 0],
  // Se - orange (CPK)
  35: [0.651, 0.161, 0.161],
  // Br - dark red (CPK)
  36: [0.981, 0.758, 0.954],
  // Kr (VESTA)
  37: [1, 0, 0.6],
  // Rb (VESTA)
  38: [0, 1, 0.153],
  // Sr (VESTA)
  39: [0.403, 0.597, 0.558],
  // Y  (VESTA)
  40: [0, 1, 0],
  // Zr (VESTA)
  41: [0.3, 0.7, 0.465],
  // Nb (VESTA)
  42: [0.706, 0.526, 0.689],
  // Mo (VESTA)
  43: [0.806, 0.687, 0.795],
  // Tc (VESTA)
  44: [0.812, 0.721, 0.681],
  // Ru (VESTA)
  45: [0.807, 0.822, 0.671],
  // Rh (VESTA)
  46: [0.76, 0.768, 0.725],
  // Pd (VESTA)
  47: [0.753, 0.753, 0.753],
  // Ag - silver
  48: [0.951, 0.121, 0.864],
  // Cd (VESTA)
  49: [0.844, 0.504, 0.735],
  // In (VESTA)
  50: [0.608, 0.561, 0.729],
  // Sn (VESTA)
  51: [0.846, 0.515, 0.313],
  // Sb (VESTA)
  52: [0.68, 0.636, 0.32],
  // Te (VESTA)
  53: [0.58, 0, 0.58],
  // I  - purple (CPK)
  54: [0.607, 0.632, 0.973],
  // Xe (VESTA)
  55: [0.059, 0.999, 0.726],
  // Cs (VESTA)
  56: [0.118, 0.94, 0.176],
  // Ba (VESTA)
  57: [0.353, 0.771, 0.287],
  // La (VESTA)
  58: [0.821, 0.991, 0.024],
  // Ce (VESTA)
  59: [0.991, 0.886, 0.023],
  // Pr (VESTA)
  60: [0.987, 0.556, 0.027],
  // Nd (VESTA)
  61: [0, 0, 0.96],
  // Pm (VESTA)
  62: [0.99, 0.024, 0.492],
  // Sm (VESTA)
  63: [0.984, 0.031, 0.836],
  // Eu (VESTA)
  64: [0.753, 0.014, 1],
  // Gd (VESTA)
  65: [0.443, 0.017, 0.998],
  // Tb (VESTA)
  66: [0.194, 0.024, 0.991],
  // Dy (VESTA)
  67: [0.028, 0.259, 0.986],
  // Ho (VESTA)
  68: [0.287, 0.451, 0.23],
  // Er (VESTA)
  69: [0, 0, 0.88],
  // Tm (VESTA)
  70: [0.153, 0.992, 0.958],
  // Yb (VESTA)
  71: [0.151, 0.994, 0.71],
  // Lu (VESTA)
  72: [0.707, 0.706, 0.351],
  // Hf (VESTA)
  73: [0.72, 0.607, 0.338],
  // Ta (VESTA)
  74: [0.556, 0.543, 0.502],
  // W  (VESTA)
  75: [0.703, 0.694, 0.558],
  // Re (VESTA)
  76: [0.787, 0.695, 0.474],
  // Os (VESTA)
  77: [0.79, 0.81, 0.45],
  // Ir (VESTA)
  78: [0.8, 0.775, 0.751],
  // Pt (VESTA)
  79: [0.996, 0.701, 0.221],
  // Au (VESTA)
  80: [0.829, 0.721, 0.798],
  // Hg (VESTA)
  81: [0.588, 0.539, 0.426],
  // Tl (VESTA)
  82: [0.324, 0.326, 0.357],
  // Pb (VESTA)
  83: [0.824, 0.187, 0.972],
  // Bi (VESTA)
  84: [0, 0, 1],
  // Po (VESTA)
  85: [0.3, 0.2, 0.8],
  // At (adjusted from VESTA to avoid Po duplicate)
  86: [1, 1, 0],
  // Rn (VESTA)
  87: [0, 0, 0],
  // Fr (VESTA)
  88: [0.43, 0.667, 0.348],
  // Ra (VESTA)
  89: [0.393, 0.621, 0.45],
  // Ac (VESTA)
  90: [0.149, 0.996, 0.471],
  // Th (VESTA)
  91: [0.161, 0.984, 0.209],
  // Pa (VESTA)
  92: [0.478, 0.634, 0.667]
  // U  (VESTA)
}, qL = [0.75, 0.4, 0.75], $g = {
  1: 1.2,
  2: 1.4,
  3: 1.4,
  4: 1.4,
  5: 1.4,
  6: 1.7,
  7: 1.55,
  8: 1.52,
  9: 1.47,
  10: 1.54,
  11: 1.54,
  12: 1.54,
  13: 1.54,
  14: 2.1,
  15: 1.8,
  16: 1.8,
  17: 1.75,
  18: 1.88,
  19: 1.88,
  20: 1.88,
  21: 1.88,
  22: 1.88,
  23: 1.88,
  24: 1.88,
  25: 1.88,
  26: 1.88,
  27: 1.88,
  28: 1.88,
  29: 1.88,
  30: 1.88,
  31: 1.88,
  32: 1.88,
  33: 1.85,
  34: 1.9,
  35: 1.85,
  36: 2.02,
  37: 2.02,
  38: 2.02,
  39: 2.02,
  40: 2.02,
  41: 2.02,
  42: 2.02,
  43: 2.02,
  44: 2.02,
  45: 2.02,
  46: 2.02,
  47: 2.02,
  48: 2.02,
  49: 2.02,
  50: 2.02,
  51: 2,
  52: 2.06,
  53: 1.98,
  54: 2.16,
  55: 2.16,
  56: 2.16,
  57: 2.16,
  58: 2.16,
  59: 2.16,
  60: 2.16,
  61: 2.16,
  62: 2.16,
  63: 2.16,
  64: 2.16,
  65: 2.16,
  66: 2.16,
  67: 2.16,
  68: 2.16,
  69: 2.16,
  70: 2.16,
  71: 2.16,
  72: 2.16,
  73: 2.16,
  74: 2.16,
  75: 2.16,
  76: 2.16,
  77: 2.16,
  78: 2.16,
  79: 2.16,
  80: 2.16,
  81: 2.16,
  82: 2.16,
  83: 2.16,
  84: 2.16,
  85: 2.16,
  86: 2.16,
  87: 2.16,
  88: 2.16,
  89: 2.16,
  90: 2.16,
  91: 2.16,
  92: 2.16
}, Kg = 1.5, U0 = 0.3, ZL = 0.15, rb = 1, sb = 2, ab = 3, ob = 4, lb = 0.18, $L = 0.1, cb = 0.2, KL = 0.08, QL = 0.1, JL = 0.06, tU = {
  1: "H",
  2: "He",
  3: "Li",
  4: "Be",
  5: "B",
  6: "C",
  7: "N",
  8: "O",
  9: "F",
  10: "Ne",
  11: "Na",
  12: "Mg",
  13: "Al",
  14: "Si",
  15: "P",
  16: "S",
  17: "Cl",
  18: "Ar",
  19: "K",
  20: "Ca",
  21: "Sc",
  22: "Ti",
  23: "V",
  24: "Cr",
  25: "Mn",
  26: "Fe",
  27: "Co",
  28: "Ni",
  29: "Cu",
  30: "Zn",
  31: "Ga",
  32: "Ge",
  33: "As",
  34: "Se",
  35: "Br",
  36: "Kr",
  37: "Rb",
  38: "Sr",
  39: "Y",
  40: "Zr",
  41: "Nb",
  42: "Mo",
  43: "Tc",
  44: "Ru",
  45: "Rh",
  46: "Pd",
  47: "Ag",
  48: "Cd",
  49: "In",
  50: "Sn",
  51: "Sb",
  52: "Te",
  53: "I",
  54: "Xe",
  55: "Cs",
  56: "Ba",
  57: "La",
  58: "Ce",
  59: "Pr",
  60: "Nd",
  61: "Pm",
  62: "Sm",
  63: "Eu",
  64: "Gd",
  65: "Tb",
  66: "Dy",
  67: "Ho",
  68: "Er",
  69: "Tm",
  70: "Yb",
  71: "Lu",
  72: "Hf",
  73: "Ta",
  74: "W",
  75: "Re",
  76: "Os",
  77: "Ir",
  78: "Pt",
  79: "Au",
  80: "Hg",
  81: "Tl",
  82: "Pb",
  83: "Bi",
  84: "Po",
  85: "At",
  86: "Rn",
  87: "Fr",
  88: "Ra",
  89: "Ac",
  90: "Th",
  91: "Pa",
  92: "U"
};
function Nc(n) {
  return YL[n] ?? qL;
}
function O0(n) {
  return $g[n] ?? Kg;
}
const eU = {
  1: 1.008,
  2: 4.003,
  3: 6.941,
  4: 9.012,
  5: 10.81,
  6: 12.011,
  7: 14.007,
  8: 15.999,
  9: 18.998,
  10: 20.18,
  11: 22.99,
  12: 24.305,
  13: 26.982,
  14: 28.086,
  15: 30.974,
  16: 32.06,
  17: 35.45,
  18: 39.948,
  19: 39.098,
  20: 40.078,
  21: 44.956,
  22: 47.867,
  23: 50.942,
  24: 51.996,
  25: 54.938,
  26: 55.845,
  27: 58.933,
  28: 58.693,
  29: 63.546,
  30: 65.38,
  31: 69.723,
  32: 72.63,
  33: 74.922,
  34: 78.96,
  35: 79.904,
  36: 83.798,
  37: 85.468,
  38: 87.62,
  39: 88.906,
  40: 91.224,
  41: 92.906,
  42: 95.95,
  43: 98,
  44: 101.07,
  45: 102.906,
  46: 106.42,
  47: 107.868,
  48: 112.411,
  49: 114.818,
  50: 118.71,
  51: 121.76,
  52: 127.6,
  53: 126.904,
  54: 131.293,
  55: 132.905,
  56: 137.327,
  57: 138.905,
  58: 140.116,
  59: 140.908,
  60: 144.242,
  61: 145,
  62: 150.36,
  63: 151.964,
  64: 157.25,
  65: 158.925,
  66: 162.5,
  67: 164.93,
  68: 167.259,
  69: 168.934,
  70: 173.045,
  71: 174.967,
  72: 178.49,
  73: 180.948,
  74: 183.84,
  75: 186.207,
  76: 190.23,
  77: 192.217,
  78: 195.084,
  79: 196.967,
  80: 200.592,
  81: 204.38,
  82: 207.2,
  83: 208.98,
  84: 209,
  85: 210,
  86: 222,
  87: 223,
  88: 226,
  89: 227,
  90: 232.038,
  91: 231.036,
  92: 238.029
};
function P0(n) {
  return tU[n] ?? `#${n}`;
}
function nU(n) {
  return eU[n] ?? 0;
}
const iU = (
  /* glsl */
  `precision highp float;
  precision highp int;

  // Three.js built-in uniforms (must declare explicitly for RawShaderMaterial)
  uniform mat4 modelViewMatrix;
  uniform mat4 projectionMatrix;
  uniform float uScaleMultiplier;
  uniform int uUsePerAtomOverrides;

  // Per-vertex (quad corners)
  in vec3 position;

  // Per-instance
  in vec3 instanceCenter;
  in float instanceRadius;
  in vec3 instanceColor;
  in float instanceScaleOverride;
  in float instanceOpacityOverride;

  out vec3 vColor;
  out vec2 vUv;
  out float vRadius;
  out vec3 vViewCenter;
  out float vOpacityOverride;

  void main() {
    vColor = instanceColor;
    vUv = position.xy;
    vOpacityOverride = instanceOpacityOverride;
    float effectiveScale = uScaleMultiplier;
    if (uUsePerAtomOverrides == 1) {
      effectiveScale *= instanceScaleOverride;
    }
    float scaledRadius = instanceRadius * effectiveScale;
    vRadius = scaledRadius;

    vec4 viewCenter = modelViewMatrix * vec4(instanceCenter, 1.0);
    vViewCenter = viewCenter.xyz;

    vec3 viewPos = viewCenter.xyz;
    viewPos.xy += position.xy * scaledRadius;

    gl_Position = projectionMatrix * vec4(viewPos, 1.0);
  }
`
), rU = (
  /* glsl */
  `precision highp float;
  precision highp int;

  in vec3 vColor;
  in vec2 vUv;
  in float vRadius;
  in vec3 vViewCenter;
  in float vOpacityOverride;

  uniform mat4 projectionMatrix;
  uniform float uOpacity;
  uniform int uUsePerAtomOverrides;

  out vec4 fragColor;

  void main() {
    float dist2 = dot(vUv, vUv);
    if (dist2 > 1.0) discard;

    float z = sqrt(1.0 - dist2);
    vec3 normal = vec3(vUv, z);

    // Correct depth
    vec3 fragViewPos = vViewCenter + normal * vRadius;
    vec4 clipPos = projectionMatrix * vec4(fragViewPos, 1.0);
    float ndcDepth = clipPos.z / clipPos.w;
    gl_FragDepth = ndcDepth * 0.5 + 0.5;

    // Hemisphere ambient: sky blue on top, warm brown on bottom
    vec3 skyColor = vec3(0.87, 0.92, 1.0);
    vec3 groundColor = vec3(0.6, 0.47, 0.27);
    float hemiMix = normal.y * 0.5 + 0.5;
    vec3 ambient = mix(groundColor, skyColor, hemiMix) * 0.35;

    // Dual-light diffuse
    vec3 lightDir1 = normalize(vec3(0.5, 0.5, 1.0));
    vec3 lightDir2 = normalize(vec3(-0.3, 0.3, 0.8));
    float diffuse1 = max(dot(normal, lightDir1), 0.0);
    float diffuse2 = max(dot(normal, lightDir2), 0.0);
    float diffuse = diffuse1 * 0.55 + diffuse2 * 0.2;

    // Specular (Blinn-Phong)
    vec3 viewDir = vec3(0.0, 0.0, 1.0);
    vec3 halfDir = normalize(lightDir1 + viewDir);
    float spec = pow(max(dot(normal, halfDir), 0.0), 64.0);

    // Fresnel rim
    float fresnel = pow(1.0 - z, 3.0) * 0.15;

    // Edge darkening
    float edgeFactor = mix(0.7, 1.0, z);

    vec3 color = vColor * (ambient + diffuse) * edgeFactor
               + vec3(1.0) * spec * 0.3
               + vec3(0.15) * fresnel;
    float finalOpacity = uOpacity;
    if (uUsePerAtomOverrides == 1) {
      finalOpacity *= vOpacityOverride;
    }
    fragColor = vec4(color, finalOpacity);
  }
`
), sU = (
  /* glsl */
  `precision highp float;

  uniform mat4 modelViewMatrix;
  uniform mat4 projectionMatrix;
  uniform float uBondScaleMultiplier;
  uniform sampler2D uPositionTex;
  uniform int uPositionTexWidth;

  in vec3 position;
  in vec2 uv;

  in float instanceAtomA;
  in float instanceAtomB;
  in float instanceOffsetX;
  in float instanceOffsetY;
  in vec3 instanceColor;
  in float instanceRadius;
  in float instanceDashed;

  out vec3 vColor;
  out vec2 vCylUv;
  out float vDashed;

  vec3 getAtomPos(int idx) {
    int tx = idx % uPositionTexWidth;
    int ty = idx / uPositionTexWidth;
    return texelFetch(uPositionTex, ivec2(tx, ty), 0).rgb;
  }

  void main() {
    vColor = instanceColor;
    vCylUv = uv;
    vDashed = instanceDashed;

    int atomA = int(instanceAtomA + 0.5);
    int atomB = int(instanceAtomB + 0.5);
    vec3 posA = getAtomPos(atomA);
    vec3 posB = getAtomPos(atomB);

    vec3 start = posA;
    vec3 end = posB;

    // Apply perpendicular offset for double/triple/aromatic bonds
    if (instanceOffsetX != 0.0 || instanceOffsetY != 0.0) {
      vec3 bdir = normalize(posB - posA);
      vec3 perpX = cross(bdir, vec3(0.0, 1.0, 0.0));
      if (dot(perpX, perpX) < 0.001) {
        perpX = cross(bdir, vec3(1.0, 0.0, 0.0));
      }
      perpX = normalize(perpX);
      vec3 perpY = normalize(cross(bdir, perpX));
      vec3 offset = perpX * instanceOffsetX + perpY * instanceOffsetY;
      start += offset;
      end += offset;
    }

    vec4 viewStart = modelViewMatrix * vec4(start, 1.0);
    vec4 viewEnd = modelViewMatrix * vec4(end, 1.0);

    vec3 viewMid = (viewStart.xyz + viewEnd.xyz) * 0.5;
    vec3 axis = viewEnd.xyz - viewStart.xyz;
    float len = length(axis);
    vec3 dir = axis / max(len, 0.0001);

    vec3 side = normalize(cross(dir, vec3(0.0, 0.0, 1.0)));

    vec3 viewPos = viewMid
      + dir * (position.y * len * 0.5)
      + side * (position.x * instanceRadius * uBondScaleMultiplier);

    gl_Position = projectionMatrix * vec4(viewPos, 1.0);
  }
`
), aU = (
  /* glsl */
  `precision highp float;

  in vec3 vColor;
  in vec2 vCylUv;
  in float vDashed;

  uniform float uOpacity;

  out vec4 fragColor;

  void main() {
    // Dashed bond: discard alternate segments along bond length
    if (vDashed > 0.5) {
      if (sin(vCylUv.y * 30.0) < 0.0) discard;
    }

    float nx = vCylUv.x;
    float nz = sqrt(max(0.0, 1.0 - nx * nx));
    vec3 normal = vec3(nx, 0.0, nz);

    // Hemisphere ambient
    vec3 skyColor = vec3(0.87, 0.92, 1.0);
    vec3 groundColor = vec3(0.6, 0.47, 0.27);
    float hemiMix = normal.y * 0.5 + 0.5;
    vec3 ambient = mix(groundColor, skyColor, hemiMix) * 0.35;

    // Dual-light diffuse
    vec3 lightDir1 = normalize(vec3(0.5, 0.5, 1.0));
    vec3 lightDir2 = normalize(vec3(-0.3, 0.3, 0.8));
    float diffuse1 = max(dot(normal, lightDir1), 0.0);
    float diffuse2 = max(dot(normal, lightDir2), 0.0);
    float diffuse = diffuse1 * 0.55 + diffuse2 * 0.2;

    // Specular
    vec3 viewDir = vec3(0.0, 0.0, 1.0);
    vec3 halfDir = normalize(lightDir1 + viewDir);
    float spec = pow(max(dot(normal, halfDir), 0.0), 64.0);

    // Fresnel rim
    float fresnel = pow(1.0 - nz, 3.0) * 0.1;

    vec3 color = vColor * (ambient + diffuse)
               + vec3(1.0) * spec * 0.2
               + vec3(0.1) * fresnel;
    fragColor = vec4(color, uOpacity);
  }
`
);
class oU {
  constructor(t = 1e6) {
    Nt(this, "mesh");
    Nt(this, "geo");
    Nt(this, "material");
    Nt(this, "centerAttr");
    Nt(this, "radiusAttr");
    Nt(this, "colorAttr");
    Nt(this, "scaleOverrideAttr");
    Nt(this, "opacityOverrideAttr");
    Nt(this, "centerBuf");
    Nt(this, "radiusBuf");
    Nt(this, "colorBuf");
    Nt(this, "scaleOverrideBuf");
    Nt(this, "opacityOverrideBuf");
    Nt(this, "nAtoms", 0);
    Nt(this, "capacity");
    this.capacity = t, this.geo = new D0();
    const e = new Float32Array([
      -1,
      -1,
      0,
      1,
      -1,
      0,
      1,
      1,
      0,
      -1,
      1,
      0
    ]), r = new Uint16Array([0, 1, 2, 0, 2, 3]);
    this.geo.setAttribute("position", new fn(e, 3)), this.geo.setIndex(new fn(r, 1)), this.geo.instanceCount = 0, this.centerBuf = new Float32Array(t * 3), this.radiusBuf = new Float32Array(t), this.colorBuf = new Float32Array(t * 3), this.scaleOverrideBuf = new Float32Array(t).fill(1), this.opacityOverrideBuf = new Float32Array(t).fill(1), this.centerAttr = new Rn(this.centerBuf, 3), this.radiusAttr = new Rn(this.radiusBuf, 1), this.colorAttr = new Rn(this.colorBuf, 3), this.scaleOverrideAttr = new Rn(this.scaleOverrideBuf, 1), this.opacityOverrideAttr = new Rn(this.opacityOverrideBuf, 1), this.centerAttr.setUsage(So), this.radiusAttr.setUsage(Ta), this.colorAttr.setUsage(Ta), this.scaleOverrideAttr.setUsage(So), this.opacityOverrideAttr.setUsage(So), this.geo.setAttribute("instanceCenter", this.centerAttr), this.geo.setAttribute("instanceRadius", this.radiusAttr), this.geo.setAttribute("instanceColor", this.colorAttr), this.geo.setAttribute("instanceScaleOverride", this.scaleOverrideAttr), this.geo.setAttribute("instanceOpacityOverride", this.opacityOverrideAttr), this.material = new DM({
      glslVersion: hd,
      vertexShader: iU,
      fragmentShader: rU,
      uniforms: {
        uScaleMultiplier: { value: 1 },
        uOpacity: { value: 1 },
        uUsePerAtomOverrides: { value: 0 }
      },
      depthWrite: !0,
      depthTest: !0
    }), this.mesh = new Dn(this.geo, this.material), this.mesh.frustumCulled = !1;
  }
  loadSnapshot(t) {
    const { nAtoms: e, positions: r, elements: a } = t;
    this.nAtoms = e, e > this.capacity && this.grow(e);
    for (let o = 0; o < e; o++) {
      const c = o * 3;
      this.centerBuf[c] = r[c], this.centerBuf[c + 1] = r[c + 1], this.centerBuf[c + 2] = r[c + 2], this.radiusBuf[o] = O0(a[o]) * U0;
      const [u, d, h] = Nc(a[o]);
      this.colorBuf[c] = u, this.colorBuf[c + 1] = d, this.colorBuf[c + 2] = h;
    }
    this.scaleOverrideBuf.fill(1, 0, e), this.opacityOverrideBuf.fill(1, 0, e), this.centerAttr.needsUpdate = !0, this.radiusAttr.needsUpdate = !0, this.colorAttr.needsUpdate = !0, this.scaleOverrideAttr.needsUpdate = !0, this.opacityOverrideAttr.needsUpdate = !0, this.geo.instanceCount = e;
  }
  updatePositions(t) {
    this.centerBuf.set(t.subarray(0, this.nAtoms * 3)), this.centerAttr.needsUpdate = !0;
  }
  /** Update atom radius scale (O(1) via shader uniform). */
  setScale(t, e) {
    this.material.uniforms.uScaleMultiplier.value = t;
  }
  /** Set global atom opacity. */
  setOpacity(t) {
    this.material.uniforms.uOpacity.value = t, this.material.transparent = t < 1, this.material.depthWrite = t >= 1, this.material.needsUpdate = !0;
  }
  /** Set per-atom scale overrides. */
  setScaleOverrides(t) {
    this.scaleOverrideBuf.set(t.subarray(0, this.nAtoms)), this.scaleOverrideAttr.needsUpdate = !0, this.material.uniforms.uUsePerAtomOverrides.value = 1;
  }
  /** Set per-atom opacity overrides. */
  setOpacityOverrides(t) {
    this.opacityOverrideBuf.set(t.subarray(0, this.nAtoms)), this.opacityOverrideAttr.needsUpdate = !0, this.material.uniforms.uUsePerAtomOverrides.value = 1;
    let e = !1;
    for (let r = 0; r < this.nAtoms; r++)
      if (this.opacityOverrideBuf[r] < 1) {
        e = !0;
        break;
      }
    e && (this.material.transparent = !0, this.material.depthWrite = !1, this.material.needsUpdate = !0);
  }
  /** Clear all per-atom overrides, reverting to global uniforms. */
  clearOverrides() {
    this.scaleOverrideBuf.fill(1, 0, this.nAtoms), this.opacityOverrideBuf.fill(1, 0, this.nAtoms), this.scaleOverrideAttr.needsUpdate = !0, this.opacityOverrideAttr.needsUpdate = !0, this.material.uniforms.uUsePerAtomOverrides.value = 0;
  }
  grow(t) {
    this.capacity = Math.max(t, this.capacity * 2);
    const e = new Float32Array(this.capacity * 3), r = new Float32Array(this.capacity), a = new Float32Array(this.capacity * 3), o = new Float32Array(this.capacity).fill(1), c = new Float32Array(this.capacity).fill(1);
    e.set(this.centerBuf), r.set(this.radiusBuf), a.set(this.colorBuf), o.set(this.scaleOverrideBuf), c.set(this.opacityOverrideBuf), this.centerBuf = e, this.radiusBuf = r, this.colorBuf = a, this.scaleOverrideBuf = o, this.opacityOverrideBuf = c, this.centerAttr = new Rn(this.centerBuf, 3), this.radiusAttr = new Rn(this.radiusBuf, 1), this.colorAttr = new Rn(this.colorBuf, 3), this.scaleOverrideAttr = new Rn(this.scaleOverrideBuf, 1), this.opacityOverrideAttr = new Rn(this.opacityOverrideBuf, 1), this.centerAttr.setUsage(So), this.radiusAttr.setUsage(Ta), this.colorAttr.setUsage(Ta), this.scaleOverrideAttr.setUsage(So), this.opacityOverrideAttr.setUsage(So), this.geo.setAttribute("instanceCenter", this.centerAttr), this.geo.setAttribute("instanceRadius", this.radiusAttr), this.geo.setAttribute("instanceColor", this.colorAttr), this.geo.setAttribute("instanceScaleOverride", this.scaleOverrideAttr), this.geo.setAttribute("instanceOpacityOverride", this.opacityOverrideAttr);
  }
  dispose() {
    this.geo.dispose(), this.material.dispose();
  }
}
const lU = 4096;
class cU {
  constructor(t = 3e6) {
    Nt(this, "mesh");
    Nt(this, "geo");
    Nt(this, "bondMaterial");
    // Topology buffers (set at loadSnapshot, static per snapshot)
    Nt(this, "atomABuf");
    Nt(this, "atomBBuf");
    Nt(this, "offsetXBuf");
    Nt(this, "offsetYBuf");
    Nt(this, "colorBuf");
    Nt(this, "radiusBuf");
    Nt(this, "dashedBuf");
    // Position DataTexture (updated per frame)
    Nt(this, "positionTex");
    Nt(this, "positionTexData");
    Nt(this, "positionTexWidth", 1);
    Nt(this, "positionTexHeight", 1);
    Nt(this, "nAtoms", 0);
    Nt(this, "capacity");
    this.capacity = t, this.geo = new D0();
    const e = new Float32Array([
      -1,
      -1,
      0,
      1,
      -1,
      0,
      1,
      1,
      0,
      -1,
      1,
      0
    ]), r = new Float32Array([
      -1,
      -1,
      1,
      -1,
      1,
      1,
      -1,
      1
    ]), a = new Uint16Array([0, 1, 2, 0, 2, 3]);
    this.geo.setAttribute("position", new fn(e, 3)), this.geo.setAttribute("uv", new fn(r, 2)), this.geo.setIndex(new fn(a, 1)), this.geo.instanceCount = 0, this.atomABuf = new Float32Array(t), this.atomBBuf = new Float32Array(t), this.offsetXBuf = new Float32Array(t), this.offsetYBuf = new Float32Array(t), this.colorBuf = new Float32Array(t * 3), this.radiusBuf = new Float32Array(t), this.dashedBuf = new Float32Array(t), this.positionTexData = new Float32Array(4), this.positionTex = new Wg(
      this.positionTexData,
      1,
      1,
      Ci,
      Gi
    ), this.positionTex.minFilter = Yn, this.positionTex.magFilter = Yn, this.positionTex.generateMipmaps = !1, this.positionTex.needsUpdate = !0, this.registerAttributes(), this.bondMaterial = new DM({
      glslVersion: hd,
      vertexShader: sU,
      fragmentShader: aU,
      uniforms: {
        uOpacity: { value: 1 },
        uBondScaleMultiplier: { value: 1 },
        uPositionTex: { value: this.positionTex },
        uPositionTexWidth: { value: 1 }
      },
      depthWrite: !0,
      depthTest: !0
    }), this.mesh = new Dn(this.geo, this.bondMaterial), this.mesh.frustumCulled = !1;
  }
  loadSnapshot(t) {
    const { nAtoms: e, nBonds: r, positions: a, elements: o, bonds: c, bondOrders: u } = t;
    this.nAtoms = e, this.positionTexWidth = Math.min(e, lU), this.positionTexHeight = Math.max(1, Math.ceil(e / this.positionTexWidth)), this.positionTexData = new Float32Array(this.positionTexWidth * this.positionTexHeight * 4), this.copyPositionsToTexData(a), this.positionTex.dispose(), this.positionTex = new Wg(
      this.positionTexData,
      this.positionTexWidth,
      this.positionTexHeight,
      Ci,
      Gi
    ), this.positionTex.minFilter = Yn, this.positionTex.magFilter = Yn, this.positionTex.generateMipmaps = !1, this.positionTex.needsUpdate = !0, this.bondMaterial.uniforms.uPositionTex.value = this.positionTex, this.bondMaterial.uniforms.uPositionTexWidth.value = this.positionTexWidth;
    let d = 0;
    for (let p = 0; p < r; p++) {
      const m = u ? u[p] : rb;
      m === sb ? d += 2 : m === ab ? d += 3 : m === ob ? d += 2 : d += 1;
    }
    d > this.capacity && this.grow(d);
    let h = 0;
    for (let p = 0; p < r; p++) {
      const m = c[p * 2], g = c[p * 2 + 1], _ = u ? u[p] : rb, [b, E, S] = Nc(o[m]), [y, A, w] = Nc(o[g]), M = (b + y) * 0.5, O = (E + A) * 0.5, L = (S + w) * 0.5;
      if (_ === sb)
        for (const N of [-1, 1])
          this.setTopology(
            h,
            m,
            g,
            N * lb,
            0,
            $L,
            M,
            O,
            L,
            0
          ), h++;
      else if (_ === ab) {
        const N = [0, 2 * Math.PI / 3, 4 * Math.PI / 3];
        for (const z of N) {
          const R = Math.cos(z) * cb, T = Math.sin(z) * cb;
          this.setTopology(
            h,
            m,
            g,
            R,
            T,
            KL,
            M,
            O,
            L,
            0
          ), h++;
        }
      } else _ === ob ? (this.setTopology(
        h,
        m,
        g,
        0,
        0,
        QL,
        M,
        O,
        L,
        0
      ), h++, this.setTopology(
        h,
        m,
        g,
        lb,
        0,
        JL,
        M,
        O,
        L,
        1
      ), h++) : (this.setTopology(
        h,
        m,
        g,
        0,
        0,
        ZL,
        M,
        O,
        L,
        0
      ), h++);
    }
    this.registerAttributes(), this.geo.instanceCount = h;
  }
  updatePositions(t, e, r) {
    this.copyPositionsToTexData(t), this.positionTex.needsUpdate = !0;
  }
  setTopology(t, e, r, a, o, c, u, d, h, p) {
    this.atomABuf[t] = e, this.atomBBuf[t] = r, this.offsetXBuf[t] = a, this.offsetYBuf[t] = o;
    const m = t * 3;
    this.colorBuf[m] = u, this.colorBuf[m + 1] = d, this.colorBuf[m + 2] = h, this.radiusBuf[t] = c, this.dashedBuf[t] = p;
  }
  copyPositionsToTexData(t) {
    const e = this.positionTexData, r = this.nAtoms;
    for (let a = 0; a < r; a++) {
      const o = a * 3, c = a * 4;
      e[c] = t[o], e[c + 1] = t[o + 1], e[c + 2] = t[o + 2];
    }
  }
  /** Recreate all instance attributes and re-register with geometry. */
  registerAttributes() {
    const t = new Rn(this.atomABuf, 1), e = new Rn(this.atomBBuf, 1), r = new Rn(this.offsetXBuf, 1), a = new Rn(this.offsetYBuf, 1), o = new Rn(this.colorBuf, 3), c = new Rn(this.radiusBuf, 1), u = new Rn(this.dashedBuf, 1);
    this.geo.setAttribute("instanceAtomA", t), this.geo.setAttribute("instanceAtomB", e), this.geo.setAttribute("instanceOffsetX", r), this.geo.setAttribute("instanceOffsetY", a), this.geo.setAttribute("instanceColor", o), this.geo.setAttribute("instanceRadius", c), this.geo.setAttribute("instanceDashed", u);
  }
  grow(t) {
    this.capacity = Math.max(t, this.capacity * 2);
    const e = new Float32Array(this.capacity), r = new Float32Array(this.capacity), a = new Float32Array(this.capacity), o = new Float32Array(this.capacity), c = new Float32Array(this.capacity * 3), u = new Float32Array(this.capacity), d = new Float32Array(this.capacity);
    e.set(this.atomABuf), r.set(this.atomBBuf), a.set(this.offsetXBuf), o.set(this.offsetYBuf), c.set(this.colorBuf), u.set(this.radiusBuf), d.set(this.dashedBuf), this.atomABuf = e, this.atomBBuf = r, this.offsetXBuf = a, this.offsetYBuf = o, this.colorBuf = c, this.radiusBuf = u, this.dashedBuf = d, this.registerAttributes();
  }
  /** Set global bond opacity. */
  setOpacity(t) {
    this.bondMaterial.uniforms.uOpacity.value = t, this.bondMaterial.transparent = t < 1, this.bondMaterial.depthWrite = t >= 1, this.bondMaterial.needsUpdate = !0;
  }
  /** Set bond radius scale multiplier (O(1) via shader uniform). */
  setScale(t, e) {
    this.bondMaterial.uniforms.uBondScaleMultiplier.value = t;
  }
  dispose() {
    this.geo.dispose(), this.bondMaterial.dispose(), this.positionTex.dispose();
  }
}
class uU {
  constructor() {
    Nt(this, "mesh");
    Nt(this, "geometry");
    this.geometry = new qn();
    const t = new Float32Array(72);
    this.geometry.setAttribute(
      "position",
      new fn(t, 3)
    );
    const e = new Ld({
      color: 6710886,
      transparent: !0,
      opacity: 0.5
    });
    this.mesh = new BC(this.geometry, e), this.mesh.frustumCulled = !1, this.mesh.visible = !1;
  }
  /**
   * Update the cell box from a 3x3 matrix (row-major Float32Array of length 9).
   * Cell vectors: va = box[0..2], vb = box[3..5], vc = box[6..8].
   */
  loadBox(t) {
    const e = new ot(t[0], t[1], t[2]), r = new ot(t[3], t[4], t[5]), a = new ot(t[6], t[7], t[8]), o = new ot(0, 0, 0), c = e.clone(), u = r.clone(), d = a.clone(), h = e.clone().add(r), p = e.clone().add(a), m = r.clone().add(a), g = e.clone().add(r).add(a), _ = [
      // Bottom face
      [o, c],
      [o, u],
      [c, h],
      [u, h],
      // Top face
      [d, p],
      [d, m],
      [p, g],
      [m, g],
      // Vertical edges
      [o, d],
      [c, p],
      [u, m],
      [h, g]
    ], b = this.geometry.getAttribute(
      "position"
    ), E = b.array;
    for (let S = 0; S < 12; S++) {
      const [y, A] = _[S];
      E[S * 6] = y.x, E[S * 6 + 1] = y.y, E[S * 6 + 2] = y.z, E[S * 6 + 3] = A.x, E[S * 6 + 4] = A.y, E[S * 6 + 5] = A.z;
    }
    b.needsUpdate = !0, this.geometry.computeBoundingSphere(), this.mesh.visible = !0;
  }
  setVisible(t) {
    this.mesh.visible = t;
  }
  dispose() {
    this.geometry.dispose(), this.mesh.material.dispose();
  }
}
const ub = 8, fb = [14496563, 3385907, 3368669], Im = 1e-4;
class fU {
  constructor() {
    Nt(this, "axesScene");
    Nt(this, "axesCamera");
    Nt(this, "arrowGroup");
    Nt(this, "visible", !0);
    /** Inset position in CSS pixels (bottom-left corner of the inset). */
    Nt(this, "posX", ub);
    Nt(this, "posY", ub);
    /** Last computed inset size (CSS pixels), cached for hit-testing. */
    Nt(this, "lastInsetSize", 60);
    this.axesScene = new TM(), this.axesCamera = new Ti(50, 1, 0.1, 100), this.axesCamera.position.set(0, 0, 3);
    const t = new WC(16777215, 0.6);
    this.axesScene.add(t);
    const e = new rd(16777215, 0.8);
    e.position.set(2, 2, 2), this.axesScene.add(e), this.arrowGroup = new Vs(), this.axesScene.add(this.arrowGroup);
  }
  /**
   * Update from the 3x3 cell matrix (row-major Float32Array of length 9).
   */
  loadBox(t) {
    const e = new ot(t[0], t[1], t[2]), r = new ot(t[3], t[4], t[5]), a = new ot(t[6], t[7], t[8]), o = e.length(), c = r.length(), u = a.length(), h = Math.abs(e.dot(r)) < Im * o * c && Math.abs(e.dot(a)) < Im * o * u && Math.abs(r.dot(a)) < Im * c * u ? ["x", "y", "z"] : ["a", "b", "c"], p = [e.normalize(), r.normalize(), a.normalize()];
    this.buildArrows(p, h);
  }
  buildArrows(t, e) {
    for (; this.arrowGroup.children.length > 0; ) {
      const r = this.arrowGroup.children[0];
      this.arrowGroup.remove(r), this.disposeObject(r);
    }
    for (let r = 0; r < 3; r++) {
      const a = new ZC(
        t[r],
        new ot(0, 0, 0),
        1,
        fb[r],
        0.25,
        0.1
      );
      this.arrowGroup.add(a);
      const o = this.makeTextSprite(e[r], fb[r]);
      o.position.copy(t[r]).multiplyScalar(1.25), o.scale.set(0.3, 0.3, 1), this.arrowGroup.add(o);
    }
  }
  makeTextSprite(t, e) {
    const a = document.createElement("canvas");
    a.width = 64, a.height = 64;
    const o = a.getContext("2d");
    if (!o)
      return new Em(new jg({ transparent: !0 }));
    o.clearRect(0, 0, 64, 64);
    const c = new Me(e);
    o.fillStyle = `rgb(${c.r * 255 | 0},${c.g * 255 | 0},${c.b * 255 | 0})`, o.font = "bold 48px Arial, sans-serif", o.textAlign = "center", o.textBaseline = "middle", o.fillText(t, 64 / 2, 64 / 2);
    const u = new FC(a), d = new jg({
      map: u,
      depthTest: !1,
      transparent: !0
    });
    return new Em(d);
  }
  // ── Hit-testing & drag ──────────────────────────────────────
  /**
   * Test whether a CSS-pixel coordinate (origin = top-left of container)
   * lies inside the axes inset.
   */
  hitTest(t, e, r) {
    if (!this.visible || this.arrowGroup.children.length === 0) return !1;
    const a = r - e;
    return t >= this.posX && t <= this.posX + this.lastInsetSize && a >= this.posY && a <= this.posY + this.lastInsetSize;
  }
  /**
   * Move the inset by a delta (CSS pixels), clamped to container bounds.
   */
  moveBy(t, e, r, a) {
    this.posX += t, this.posY -= e, this.clampPosition(r, a);
  }
  clampPosition(t, e) {
    const r = this.lastInsetSize, a = 4;
    this.posX = Math.max(a, Math.min(t - r - a, this.posX)), this.posY = Math.max(a, Math.min(e - r - a, this.posY));
  }
  // ── Rendering ───────────────────────────────────────────────
  /**
   * Render the axes inset.
   * Must be called AFTER the main scene render.
   */
  render(t, e, r, a) {
    if (!this.visible || this.arrowGroup.children.length === 0) return;
    this.axesCamera.quaternion.copy(e.quaternion), this.axesCamera.position.set(0, 0, 3).applyQuaternion(e.quaternion);
    const o = Math.min(r, a), c = Math.max(60, Math.min(140, Math.round(o * 0.12)));
    this.lastInsetSize = c, this.clampPosition(r, a);
    const u = t.autoClear;
    t.autoClear = !1, t.setViewport(this.posX, this.posY, c, c), t.setScissor(this.posX, this.posY, c, c), t.setScissorTest(!0), t.clearDepth(), t.render(this.axesScene, this.axesCamera), t.autoClear = u, t.setViewport(0, 0, r, a), t.setScissorTest(!1);
  }
  setVisible(t) {
    this.visible = t;
  }
  isVisible() {
    return this.visible;
  }
  disposeObject(t) {
    t.traverse((e) => {
      var r, a, o;
      (e instanceof Dn || e instanceof Dc) && ((r = e.geometry) == null || r.dispose(), Array.isArray(e.material) ? e.material.forEach((c) => c.dispose()) : (a = e.material) == null || a.dispose()), e instanceof Em && ((o = e.material.map) == null || o.dispose(), e.material.dispose());
    });
  }
  dispose() {
    for (; this.arrowGroup.children.length > 0; ) {
      const t = this.arrowGroup.children[0];
      this.arrowGroup.remove(t), this.disposeObject(t);
    }
  }
}
const dU = 500, hU = "bold 11px sans-serif", db = -8;
class pU {
  constructor() {
    Nt(this, "canvas");
    Nt(this, "ctx");
    Nt(this, "labels", null);
    Nt(this, "elements", null);
    Nt(this, "nAtoms", 0);
    Nt(this, "positions", null);
    Nt(this, "tmpVec", new ot());
    Nt(this, "lastWidth", 0);
    Nt(this, "lastHeight", 0);
    Nt(this, "lastPixelRatio", 1);
    this.canvas = document.createElement("canvas"), this.canvas.style.position = "absolute", this.canvas.style.top = "0", this.canvas.style.left = "0", this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.pointerEvents = "none", this.ctx = this.canvas.getContext("2d");
  }
  getCanvas() {
    return this.canvas;
  }
  setLabels(t) {
    this.labels = t;
  }
  setAtomData(t, e) {
    this.elements = t, this.nAtoms = e;
  }
  setPositions(t) {
    this.positions = t;
  }
  resize(t, e, r) {
    this.lastWidth = t, this.lastHeight = e, this.lastPixelRatio = r, this.canvas.width = Math.round(t * r), this.canvas.height = Math.round(e * r), this.ctx.setTransform(r, 0, 0, r, 0, 0);
  }
  render(t, e, r, a = 1) {
    if ((this.lastWidth !== e || this.lastHeight !== r || this.lastPixelRatio !== a) && this.resize(e, r, a), this.ctx.clearRect(0, 0, e, r), !this.labels || !this.positions || !this.elements || this.nAtoms === 0)
      return;
    const o = e / 2, c = r / 2, u = [];
    for (let h = 0; h < this.nAtoms; h++) {
      if (!this.labels[h] || (this.tmpVec.set(
        this.positions[h * 3],
        this.positions[h * 3 + 1],
        this.positions[h * 3 + 2]
      ), this.tmpVec.project(t), this.tmpVec.z < -1 || this.tmpVec.z > 1)) continue;
      const m = this.tmpVec.x * o + o, g = -(this.tmpVec.y * c) + c;
      m < -50 || m > e + 50 || g < -20 || g > r + 20 || u.push({ sx: m, sy: g, z: this.tmpVec.z, idx: h });
    }
    u.sort((h, p) => h.z - p.z);
    const d = Math.min(u.length, dU);
    this.ctx.font = hU, this.ctx.textAlign = "center", this.ctx.textBaseline = "bottom";
    for (let h = 0; h < d; h++) {
      const { sx: p, sy: m, idx: g } = u[h], _ = this.labels[g], b = this.elements[g], [E, S, y] = Nc(b), A = 0.299 * E + 0.587 * S + 0.114 * y, w = A > 0.5 ? "#000000" : "#ffffff", M = A > 0.5 ? "#ffffff" : "#000000";
      this.ctx.strokeStyle = M, this.ctx.lineWidth = 2.5, this.ctx.lineJoin = "round", this.ctx.strokeText(_, p, m + db), this.ctx.fillStyle = w, this.ctx.fillText(_, p, m + db);
    }
  }
  dispose() {
    this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
  }
}
const hb = 15158332, pb = 0.04, mU = 0.1, Bm = 0.2, gU = 6, vU = 8, _U = 1e-6, gc = new ot(), yU = new ot(0, 1, 0), Fm = new js(), Ff = new ot(), Hf = new ot(), ya = new Ge();
class xU {
  constructor(t = 1e5) {
    Nt(this, "mesh");
    Nt(this, "shaftMesh");
    Nt(this, "headMesh");
    Nt(this, "nAtoms", 0);
    Nt(this, "positions", null);
    Nt(this, "vectors", null);
    Nt(this, "arrowScale", 1);
    Nt(this, "capacity");
    this.capacity = t, this.mesh = new Vs(), this.mesh.visible = !1;
    const e = new Wc(
      pb,
      pb,
      1,
      gU
    );
    e.translate(0, 0.5, 0);
    const r = new A0(mU, Bm, vU);
    r.translate(0, Bm / 2, 0);
    const a = new Yg({
      color: hb,
      transparent: !0,
      opacity: 0.85
    }), o = new Yg({
      color: hb,
      transparent: !0,
      opacity: 0.85
    });
    this.shaftMesh = new yS(e, a, t), this.headMesh = new yS(r, o, t), this.shaftMesh.count = 0, this.headMesh.count = 0, this.mesh.add(this.shaftMesh), this.mesh.add(this.headMesh);
  }
  setAtomPositions(t, e) {
    this.positions = t, this.nAtoms = e, this.vectors && this.update();
  }
  setVectors(t) {
    this.vectors = t, t ? (this.mesh.visible = !0, this.update()) : (this.mesh.visible = !1, this.shaftMesh.count = 0, this.headMesh.count = 0);
  }
  setScale(t) {
    this.arrowScale = t, this.vectors && this.update();
  }
  update() {
    if (!this.positions || !this.vectors) return;
    const t = Math.min(this.nAtoms, this.capacity);
    this.shaftMesh.count = t, this.headMesh.count = t;
    for (let e = 0; e < t; e++) {
      const r = this.positions[e * 3], a = this.positions[e * 3 + 1], o = this.positions[e * 3 + 2], c = this.vectors[e * 3], u = this.vectors[e * 3 + 1], d = this.vectors[e * 3 + 2], h = Math.sqrt(c * c + u * u + d * d);
      if (h < _U) {
        ya.makeScale(0, 0, 0), this.shaftMesh.setMatrixAt(e, ya), this.headMesh.setMatrixAt(e, ya);
        continue;
      }
      gc.set(c / h, u / h, d / h), Fm.setFromUnitVectors(yU, gc);
      const p = h * this.arrowScale, m = Math.max(p - Bm, p * 0.7);
      Ff.set(r, a, o), Hf.set(1, m, 1), ya.compose(Ff, Fm, Hf), this.shaftMesh.setMatrixAt(e, ya), Ff.set(
        r + gc.x * m,
        a + gc.y * m,
        o + gc.z * m
      ), Hf.set(1, 1, 1), ya.compose(Ff, Fm, Hf), this.headMesh.setMatrixAt(e, ya);
    }
    this.shaftMesh.instanceMatrix.needsUpdate = !0, this.headMesh.instanceMatrix.needsUpdate = !0;
  }
  dispose() {
    this.shaftMesh.geometry.dispose(), this.headMesh.geometry.dispose(), this.shaftMesh.material.dispose(), this.headMesh.material.dispose(), this.mesh.remove(this.shaftMesh), this.mesh.remove(this.headMesh);
  }
}
const mb = new _r(), Vf = new ot();
class IM extends D0 {
  constructor() {
    super(), this.isLineSegmentsGeometry = !0, this.type = "LineSegmentsGeometry";
    const t = [-1, 2, 0, 1, 2, 0, -1, 1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, -1, -1, 0, 1, -1, 0], e = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2], r = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5];
    this.setIndex(r), this.setAttribute("position", new Nn(t, 3)), this.setAttribute("uv", new Nn(e, 2));
  }
  applyMatrix4(t) {
    const e = this.attributes.instanceStart, r = this.attributes.instanceEnd;
    return e !== void 0 && (e.applyMatrix4(t), r.applyMatrix4(t), e.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;
  }
  setPositions(t) {
    let e;
    t instanceof Float32Array ? e = t : Array.isArray(t) && (e = new Float32Array(t));
    const r = new qg(e, 6, 1);
    return this.setAttribute("instanceStart", new hr(r, 3, 0)), this.setAttribute("instanceEnd", new hr(r, 3, 3)), this.instanceCount = this.attributes.instanceStart.count, this.computeBoundingBox(), this.computeBoundingSphere(), this;
  }
  setColors(t) {
    let e;
    t instanceof Float32Array ? e = t : Array.isArray(t) && (e = new Float32Array(t));
    const r = new qg(e, 6, 1);
    return this.setAttribute("instanceColorStart", new hr(r, 3, 0)), this.setAttribute("instanceColorEnd", new hr(r, 3, 3)), this;
  }
  fromWireframeGeometry(t) {
    return this.setPositions(t.attributes.position.array), this;
  }
  fromEdgesGeometry(t) {
    return this.setPositions(t.attributes.position.array), this;
  }
  fromMesh(t) {
    return this.fromWireframeGeometry(new HC(t.geometry)), this;
  }
  fromLineSegments(t) {
    const e = t.geometry;
    return this.setPositions(e.attributes.position.array), this;
  }
  computeBoundingBox() {
    this.boundingBox === null && (this.boundingBox = new _r());
    const t = this.attributes.instanceStart, e = this.attributes.instanceEnd;
    t !== void 0 && e !== void 0 && (this.boundingBox.setFromBufferAttribute(t), mb.setFromBufferAttribute(e), this.boundingBox.union(mb));
  }
  computeBoundingSphere() {
    this.boundingSphere === null && (this.boundingSphere = new Ws()), this.boundingBox === null && this.computeBoundingBox();
    const t = this.attributes.instanceStart, e = this.attributes.instanceEnd;
    if (t !== void 0 && e !== void 0) {
      const r = this.boundingSphere.center;
      this.boundingBox.getCenter(r);
      let a = 0;
      for (let o = 0, c = t.count; o < c; o++)
        Vf.fromBufferAttribute(t, o), a = Math.max(a, r.distanceToSquared(Vf)), Vf.fromBufferAttribute(e, o), a = Math.max(a, r.distanceToSquared(Vf));
      this.boundingSphere.radius = Math.sqrt(a), isNaN(this.boundingSphere.radius) && console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.", this);
    }
  }
  toJSON() {
  }
  applyMatrix(t) {
    return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."), this.applyMatrix4(t);
  }
}
Bt.line = {
  worldUnits: { value: 1 },
  linewidth: { value: 1 },
  resolution: { value: new oe(1, 1) },
  dashOffset: { value: 0 },
  dashScale: { value: 1 },
  dashSize: { value: 1 },
  gapSize: { value: 1 }
  // todo FIX - maybe change to totalSize
};
di.line = {
  uniforms: w0.merge([
    Bt.common,
    Bt.fog,
    Bt.line
  ]),
  vertexShader: (
    /* glsl */
    `
		#include <common>
		#include <color_pars_vertex>
		#include <fog_pars_vertex>
		#include <logdepthbuf_pars_vertex>
		#include <clipping_planes_pars_vertex>

		uniform float linewidth;
		uniform vec2 resolution;

		attribute vec3 instanceStart;
		attribute vec3 instanceEnd;

		attribute vec3 instanceColorStart;
		attribute vec3 instanceColorEnd;

		#ifdef WORLD_UNITS

			varying vec4 worldPos;
			varying vec3 worldStart;
			varying vec3 worldEnd;

			#ifdef USE_DASH

				varying vec2 vUv;

			#endif

		#else

			varying vec2 vUv;

		#endif

		#ifdef USE_DASH

			uniform float dashScale;
			attribute float instanceDistanceStart;
			attribute float instanceDistanceEnd;
			varying float vLineDistance;

		#endif

		void trimSegment( const in vec4 start, inout vec4 end ) {

			// trim end segment so it terminates between the camera plane and the near plane

			// conservative estimate of the near plane
			float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
			float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
			float nearEstimate = - 0.5 * b / a;

			float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );

			end.xyz = mix( start.xyz, end.xyz, alpha );

		}

		void main() {

			#ifdef USE_COLOR

				vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;

			#endif

			#ifdef USE_DASH

				vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
				vUv = uv;

			#endif

			float aspect = resolution.x / resolution.y;

			// camera space
			vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
			vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );

			#ifdef WORLD_UNITS

				worldStart = start.xyz;
				worldEnd = end.xyz;

			#else

				vUv = uv;

			#endif

			// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
			// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
			// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
			// perhaps there is a more elegant solution -- WestLangley

			bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column

			if ( perspective ) {

				if ( start.z < 0.0 && end.z >= 0.0 ) {

					trimSegment( start, end );

				} else if ( end.z < 0.0 && start.z >= 0.0 ) {

					trimSegment( end, start );

				}

			}

			// clip space
			vec4 clipStart = projectionMatrix * start;
			vec4 clipEnd = projectionMatrix * end;

			// ndc space
			vec3 ndcStart = clipStart.xyz / clipStart.w;
			vec3 ndcEnd = clipEnd.xyz / clipEnd.w;

			// direction
			vec2 dir = ndcEnd.xy - ndcStart.xy;

			// account for clip-space aspect ratio
			dir.x *= aspect;
			dir = normalize( dir );

			#ifdef WORLD_UNITS

				vec3 worldDir = normalize( end.xyz - start.xyz );
				vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
				vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
				vec3 worldFwd = cross( worldDir, worldUp );
				worldPos = position.y < 0.5 ? start: end;

				// height offset
				float hw = linewidth * 0.5;
				worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;

				// don't extend the line if we're rendering dashes because we
				// won't be rendering the endcaps
				#ifndef USE_DASH

					// cap extension
					worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;

					// add width to the box
					worldPos.xyz += worldFwd * hw;

					// endcaps
					if ( position.y > 1.0 || position.y < 0.0 ) {

						worldPos.xyz -= worldFwd * 2.0 * hw;

					}

				#endif

				// project the worldpos
				vec4 clip = projectionMatrix * worldPos;

				// shift the depth of the projected points so the line
				// segments overlap neatly
				vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
				clip.z = clipPose.z * clip.w;

			#else

				vec2 offset = vec2( dir.y, - dir.x );
				// undo aspect ratio adjustment
				dir.x /= aspect;
				offset.x /= aspect;

				// sign flip
				if ( position.x < 0.0 ) offset *= - 1.0;

				// endcaps
				if ( position.y < 0.0 ) {

					offset += - dir;

				} else if ( position.y > 1.0 ) {

					offset += dir;

				}

				// adjust for linewidth
				offset *= linewidth;

				// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
				offset /= resolution.y;

				// select end
				vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;

				// back to clip space
				offset *= clip.w;

				clip.xy += offset;

			#endif

			gl_Position = clip;

			vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation

			#include <logdepthbuf_vertex>
			#include <clipping_planes_vertex>
			#include <fog_vertex>

		}
		`
  ),
  fragmentShader: (
    /* glsl */
    `
		uniform vec3 diffuse;
		uniform float opacity;
		uniform float linewidth;

		#ifdef USE_DASH

			uniform float dashOffset;
			uniform float dashSize;
			uniform float gapSize;

		#endif

		varying float vLineDistance;

		#ifdef WORLD_UNITS

			varying vec4 worldPos;
			varying vec3 worldStart;
			varying vec3 worldEnd;

			#ifdef USE_DASH

				varying vec2 vUv;

			#endif

		#else

			varying vec2 vUv;

		#endif

		#include <common>
		#include <color_pars_fragment>
		#include <fog_pars_fragment>
		#include <logdepthbuf_pars_fragment>
		#include <clipping_planes_pars_fragment>

		vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {

			float mua;
			float mub;

			vec3 p13 = p1 - p3;
			vec3 p43 = p4 - p3;

			vec3 p21 = p2 - p1;

			float d1343 = dot( p13, p43 );
			float d4321 = dot( p43, p21 );
			float d1321 = dot( p13, p21 );
			float d4343 = dot( p43, p43 );
			float d2121 = dot( p21, p21 );

			float denom = d2121 * d4343 - d4321 * d4321;

			float numer = d1343 * d4321 - d1321 * d4343;

			mua = numer / denom;
			mua = clamp( mua, 0.0, 1.0 );
			mub = ( d1343 + d4321 * ( mua ) ) / d4343;
			mub = clamp( mub, 0.0, 1.0 );

			return vec2( mua, mub );

		}

		void main() {

			#include <clipping_planes_fragment>

			#ifdef USE_DASH

				if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps

				if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX

			#endif

			float alpha = opacity;

			#ifdef WORLD_UNITS

				// Find the closest points on the view ray and the line segment
				vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
				vec3 lineDir = worldEnd - worldStart;
				vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );

				vec3 p1 = worldStart + lineDir * params.x;
				vec3 p2 = rayEnd * params.y;
				vec3 delta = p1 - p2;
				float len = length( delta );
				float norm = len / linewidth;

				#ifndef USE_DASH

					#ifdef USE_ALPHA_TO_COVERAGE

						float dnorm = fwidth( norm );
						alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );

					#else

						if ( norm > 0.5 ) {

							discard;

						}

					#endif

				#endif

			#else

				#ifdef USE_ALPHA_TO_COVERAGE

					// artifacts appear on some hardware if a derivative is taken within a conditional
					float a = vUv.x;
					float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
					float len2 = a * a + b * b;
					float dlen = fwidth( len2 );

					if ( abs( vUv.y ) > 1.0 ) {

						alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );

					}

				#else

					if ( abs( vUv.y ) > 1.0 ) {

						float a = vUv.x;
						float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
						float len2 = a * a + b * b;

						if ( len2 > 1.0 ) discard;

					}

				#endif

			#endif

			vec4 diffuseColor = vec4( diffuse, alpha );

			#include <logdepthbuf_fragment>
			#include <color_fragment>

			gl_FragColor = vec4( diffuseColor.rgb, alpha );

			#include <tonemapping_fragment>
			#include <colorspace_fragment>
			#include <fog_fragment>
			#include <premultiplied_alpha_fragment>

		}
		`
  )
};
class BM extends gr {
  constructor(t) {
    super({
      type: "LineMaterial",
      uniforms: w0.clone(di.line.uniforms),
      vertexShader: di.line.vertexShader,
      fragmentShader: di.line.fragmentShader,
      clipping: !0
      // required for clipping support
    }), this.isLineMaterial = !0, this.setValues(t);
  }
  get color() {
    return this.uniforms.diffuse.value;
  }
  set color(t) {
    this.uniforms.diffuse.value = t;
  }
  get worldUnits() {
    return "WORLD_UNITS" in this.defines;
  }
  set worldUnits(t) {
    t === !0 ? this.defines.WORLD_UNITS = "" : delete this.defines.WORLD_UNITS;
  }
  get linewidth() {
    return this.uniforms.linewidth.value;
  }
  set linewidth(t) {
    this.uniforms.linewidth && (this.uniforms.linewidth.value = t);
  }
  get dashed() {
    return "USE_DASH" in this.defines;
  }
  set dashed(t) {
    t === !0 !== this.dashed && (this.needsUpdate = !0), t === !0 ? this.defines.USE_DASH = "" : delete this.defines.USE_DASH;
  }
  get dashScale() {
    return this.uniforms.dashScale.value;
  }
  set dashScale(t) {
    this.uniforms.dashScale.value = t;
  }
  get dashSize() {
    return this.uniforms.dashSize.value;
  }
  set dashSize(t) {
    this.uniforms.dashSize.value = t;
  }
  get dashOffset() {
    return this.uniforms.dashOffset.value;
  }
  set dashOffset(t) {
    this.uniforms.dashOffset.value = t;
  }
  get gapSize() {
    return this.uniforms.gapSize.value;
  }
  set gapSize(t) {
    this.uniforms.gapSize.value = t;
  }
  get opacity() {
    return this.uniforms.opacity.value;
  }
  set opacity(t) {
    this.uniforms && (this.uniforms.opacity.value = t);
  }
  get resolution() {
    return this.uniforms.resolution.value;
  }
  set resolution(t) {
    this.uniforms.resolution.value.copy(t);
  }
  get alphaToCoverage() {
    return "USE_ALPHA_TO_COVERAGE" in this.defines;
  }
  set alphaToCoverage(t) {
    this.defines && (t === !0 !== this.alphaToCoverage && (this.needsUpdate = !0), t === !0 ? this.defines.USE_ALPHA_TO_COVERAGE = "" : delete this.defines.USE_ALPHA_TO_COVERAGE);
  }
}
const Hm = new Ke(), gb = new ot(), vb = new ot(), Xn = new Ke(), jn = new Ke(), or = new Ke(), Vm = new ot(), km = new Ge(), Wn = new qC(), _b = new ot(), kf = new _r(), Gf = new Ws(), lr = new Ke();
let fr, Ca;
function yb(n, t, e) {
  return lr.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), lr.multiplyScalar(1 / lr.w), lr.x = Ca / e.width, lr.y = Ca / e.height, lr.applyMatrix4(n.projectionMatrixInverse), lr.multiplyScalar(1 / lr.w), Math.abs(Math.max(lr.x, lr.y));
}
function SU(n, t) {
  const e = n.matrixWorld, r = n.geometry, a = r.attributes.instanceStart, o = r.attributes.instanceEnd, c = Math.min(r.instanceCount, a.count);
  for (let u = 0, d = c; u < d; u++) {
    Wn.start.fromBufferAttribute(a, u), Wn.end.fromBufferAttribute(o, u), Wn.applyMatrix4(e);
    const h = new ot(), p = new ot();
    fr.distanceSqToSegment(Wn.start, Wn.end, p, h), p.distanceTo(h) < Ca * 0.5 && t.push({
      point: p,
      pointOnLine: h,
      distance: fr.origin.distanceTo(p),
      object: n,
      face: null,
      faceIndex: u,
      uv: null,
      uv1: null
    });
  }
}
function bU(n, t, e) {
  const r = t.projectionMatrix, o = n.material.resolution, c = n.matrixWorld, u = n.geometry, d = u.attributes.instanceStart, h = u.attributes.instanceEnd, p = Math.min(u.instanceCount, d.count), m = -t.near;
  fr.at(1, or), or.w = 1, or.applyMatrix4(t.matrixWorldInverse), or.applyMatrix4(r), or.multiplyScalar(1 / or.w), or.x *= o.x / 2, or.y *= o.y / 2, or.z = 0, Vm.copy(or), km.multiplyMatrices(t.matrixWorldInverse, c);
  for (let g = 0, _ = p; g < _; g++) {
    if (Xn.fromBufferAttribute(d, g), jn.fromBufferAttribute(h, g), Xn.w = 1, jn.w = 1, Xn.applyMatrix4(km), jn.applyMatrix4(km), Xn.z > m && jn.z > m)
      continue;
    if (Xn.z > m) {
      const w = Xn.z - jn.z, M = (Xn.z - m) / w;
      Xn.lerp(jn, M);
    } else if (jn.z > m) {
      const w = jn.z - Xn.z, M = (jn.z - m) / w;
      jn.lerp(Xn, M);
    }
    Xn.applyMatrix4(r), jn.applyMatrix4(r), Xn.multiplyScalar(1 / Xn.w), jn.multiplyScalar(1 / jn.w), Xn.x *= o.x / 2, Xn.y *= o.y / 2, jn.x *= o.x / 2, jn.y *= o.y / 2, Wn.start.copy(Xn), Wn.start.z = 0, Wn.end.copy(jn), Wn.end.z = 0;
    const E = Wn.closestPointToPointParameter(Vm, !0);
    Wn.at(E, _b);
    const S = mM.lerp(Xn.z, jn.z, E), y = S >= -1 && S <= 1, A = Vm.distanceTo(_b) < Ca * 0.5;
    if (y && A) {
      Wn.start.fromBufferAttribute(d, g), Wn.end.fromBufferAttribute(h, g), Wn.start.applyMatrix4(c), Wn.end.applyMatrix4(c);
      const w = new ot(), M = new ot();
      fr.distanceSqToSegment(Wn.start, Wn.end, M, w), e.push({
        point: M,
        pointOnLine: w,
        distance: fr.origin.distanceTo(M),
        object: n,
        face: null,
        faceIndex: g,
        uv: null,
        uv1: null
      });
    }
  }
}
class MU extends Dn {
  constructor(t = new IM(), e = new BM({ color: Math.random() * 16777215 })) {
    super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
  }
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
  computeLineDistances() {
    const t = this.geometry, e = t.attributes.instanceStart, r = t.attributes.instanceEnd, a = new Float32Array(2 * e.count);
    for (let c = 0, u = 0, d = e.count; c < d; c++, u += 2)
      gb.fromBufferAttribute(e, c), vb.fromBufferAttribute(r, c), a[u] = u === 0 ? 0 : a[u - 1], a[u + 1] = a[u] + gb.distanceTo(vb);
    const o = new qg(a, 2, 1);
    return t.setAttribute("instanceDistanceStart", new hr(o, 1, 0)), t.setAttribute("instanceDistanceEnd", new hr(o, 1, 1)), this;
  }
  raycast(t, e) {
    const r = this.material.worldUnits, a = t.camera;
    a === null && !r && console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');
    const o = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
    fr = t.ray;
    const c = this.matrixWorld, u = this.geometry, d = this.material;
    Ca = d.linewidth + o, u.boundingSphere === null && u.computeBoundingSphere(), Gf.copy(u.boundingSphere).applyMatrix4(c);
    let h;
    if (r)
      h = Ca * 0.5;
    else {
      const m = Math.max(a.near, Gf.distanceToPoint(fr.origin));
      h = yb(a, m, d.resolution);
    }
    if (Gf.radius += h, fr.intersectsSphere(Gf) === !1)
      return;
    u.boundingBox === null && u.computeBoundingBox(), kf.copy(u.boundingBox).applyMatrix4(c);
    let p;
    if (r)
      p = Ca * 0.5;
    else {
      const m = Math.max(a.near, kf.distanceToPoint(fr.origin));
      p = yb(a, m, d.resolution);
    }
    kf.expandByScalar(p), fr.intersectsBox(kf) !== !1 && (r ? SU(this, e) : bU(this, a, e));
  }
  onBeforeRender(t) {
    const e = this.material.uniforms;
    e && e.resolution && (t.getViewport(Hm), this.material.uniforms.resolution.value.set(Hm.z, Hm.w));
  }
}
class EU {
  constructor() {
    Nt(this, "group");
    Nt(this, "faceMesh", null);
    Nt(this, "edgeLines", null);
    Nt(this, "edgeMaterial", null);
    this.group = new Vs(), this.group.frustumCulled = !1;
  }
  loadMeshData(t) {
    this.clear();
    const e = t.positions.length / 3;
    if (e === 0 || t.indices.length === 0) return;
    const r = new qn();
    r.setAttribute("position", new fn(t.positions, 3)), r.setAttribute("normal", new fn(t.normals, 3));
    const a = new Float32Array(e * 3);
    for (let c = 0; c < e; c++)
      a[c * 3] = t.colors[c * 4], a[c * 3 + 1] = t.colors[c * 4 + 1], a[c * 3 + 2] = t.colors[c * 4 + 2];
    r.setAttribute("color", new fn(a, 3)), r.setIndex(new fn(t.indices, 1));
    const o = new Yg({
      vertexColors: !0,
      transparent: !0,
      opacity: t.opacity,
      side: ur,
      depthWrite: !1,
      shininess: 30
    });
    if (this.faceMesh = new Dn(r, o), this.faceMesh.renderOrder = 1, this.group.add(this.faceMesh), t.showEdges && t.edgePositions && t.edgePositions.length > 0) {
      const c = new IM();
      c.setPositions(t.edgePositions);
      const u = new BM({
        color: new Me(t.edgeColor).getHex(),
        linewidth: t.edgeWidth,
        transparent: !0,
        opacity: 0.9,
        depthTest: !0
      });
      this.edgeMaterial = u, this.edgeLines = new MU(c, u), this.edgeLines.renderOrder = 2, this.group.add(this.edgeLines);
    }
  }
  /** Update the resolution uniform required by LineMaterial. */
  updateResolution(t, e) {
    this.edgeMaterial && this.edgeMaterial.resolution.set(t, e);
  }
  clear() {
    this.faceMesh && (this.faceMesh.geometry.dispose(), this.faceMesh.material.dispose(), this.group.remove(this.faceMesh), this.faceMesh = null), this.edgeLines && (this.edgeLines.geometry.dispose(), this.edgeLines.material.dispose(), this.group.remove(this.edgeLines), this.edgeLines = null, this.edgeMaterial = null);
  }
  setVisible(t) {
    this.group.visible = t;
  }
  dispose() {
    this.clear();
  }
}
const Ps = new Ke();
function xb(n, t, e, r, a, o) {
  Ps.set(t, e, r, 1), Ps.applyMatrix4(n.matrixWorldInverse);
  const c = -Ps.z;
  Ps.applyMatrix4(n.projectionMatrix);
  const u = (Ps.x / Ps.w * 0.5 + 0.5) * a, d = (-Ps.y / Ps.w * 0.5 + 0.5) * o;
  return { sx: u, sy: d, depth: c };
}
function wU(n, t, e, r) {
  if (n instanceof $r) {
    const c = (n.top - n.bottom) / n.zoom, u = r / c;
    return t * u;
  }
  const a = n.fov * Math.PI / 180, o = r / (2 * e * Math.tan(a / 2));
  return t * o;
}
function TU(n, t, e, r, a, o, c) {
  const u = t.getBoundingClientRect(), d = o - u.left, h = c - u.top, p = u.width, m = u.height, g = r, _ = e.elements, b = e.nAtoms;
  let E = -1, S = 1 / 0;
  for (let N = 0; N < b; N++) {
    const { sx: z, sy: R, depth: T } = xb(
      n,
      g[N * 3],
      g[N * 3 + 1],
      g[N * 3 + 2],
      p,
      m
    );
    if (T <= 0) continue;
    const U = O0(_[N]) * U0 * a, B = wU(n, U, T, m), I = d - z, C = h - R;
    I * I + C * C <= B * B && T < S && (E = N, S = T);
  }
  if (E >= 0) {
    const N = E, z = _[N];
    return {
      kind: "atom",
      atomIndex: N,
      elementSymbol: P0(z),
      atomicNumber: z,
      position: [g[N * 3], g[N * 3 + 1], g[N * 3 + 2]],
      screenX: o,
      screenY: c
    };
  }
  const y = 8, A = e.bonds, w = e.nBonds, M = e.bondOrders;
  let O = -1, L = 1 / 0;
  for (let N = 0; N < w; N++) {
    const z = A[N * 2], R = A[N * 2 + 1], T = (g[z * 3] + g[R * 3]) * 0.5, U = (g[z * 3 + 1] + g[R * 3 + 1]) * 0.5, B = (g[z * 3 + 2] + g[R * 3 + 2]) * 0.5, { sx: I, sy: C, depth: X } = xb(n, T, U, B, p, m);
    if (X <= 0) continue;
    const D = d - I, V = h - C;
    D * D + V * V <= y * y && X < L && (O = N, L = X);
  }
  if (O >= 0) {
    const N = A[O * 2], z = A[O * 2 + 1], R = g[z * 3] - g[N * 3], T = g[z * 3 + 1] - g[N * 3 + 1], U = g[z * 3 + 2] - g[N * 3 + 2], B = Math.sqrt(R * R + T * T + U * U), I = M ? M[O] : 1;
    return {
      kind: "bond",
      atomA: N,
      atomB: z,
      bondOrder: I,
      bondLength: B,
      screenX: o,
      screenY: c
    };
  }
  return null;
}
function AU(n, t, e) {
  const r = n[e * 3] - n[t * 3], a = n[e * 3 + 1] - n[t * 3 + 1], o = n[e * 3 + 2] - n[t * 3 + 2];
  return Math.sqrt(r * r + a * a + o * o);
}
function CU(n, t, e, r) {
  const a = n[t * 3] - n[e * 3], o = n[t * 3 + 1] - n[e * 3 + 1], c = n[t * 3 + 2] - n[e * 3 + 2], u = n[r * 3] - n[e * 3], d = n[r * 3 + 1] - n[e * 3 + 1], h = n[r * 3 + 2] - n[e * 3 + 2], p = a * u + o * d + c * h, m = Math.sqrt(a * a + o * o + c * c), g = Math.sqrt(u * u + d * d + h * h);
  return Math.acos(Math.max(-1, Math.min(1, p / (m * g)))) * (180 / Math.PI);
}
function RU(n, t, e, r, a) {
  const o = n[e * 3] - n[t * 3], c = n[e * 3 + 1] - n[t * 3 + 1], u = n[e * 3 + 2] - n[t * 3 + 2], d = n[r * 3] - n[e * 3], h = n[r * 3 + 1] - n[e * 3 + 1], p = n[r * 3 + 2] - n[e * 3 + 2], m = n[a * 3] - n[r * 3], g = n[a * 3 + 1] - n[r * 3 + 1], _ = n[a * 3 + 2] - n[r * 3 + 2], b = c * p - u * h, E = u * d - o * p, S = o * h - c * d, y = h * _ - p * g, A = p * m - d * _, w = d * g - h * m, M = Math.sqrt(d * d + h * h + p * p), O = d / M, L = h / M, N = p / M, z = E * N - S * L, R = S * O - b * N, T = b * L - E * O, U = b * y + E * A + S * w, B = z * y + R * A + T * w;
  return Math.atan2(B, U) * (180 / Math.PI);
}
function DU(n, t) {
  if (t.length < 2) return null;
  if (t.length === 2) {
    const e = AU(n, t[0], t[1]);
    return { atoms: [...t], type: "distance", value: e, label: `${e.toFixed(3)} Å` };
  }
  if (t.length === 3) {
    const e = CU(n, t[0], t[1], t[2]);
    return { atoms: [...t], type: "angle", value: e, label: `${e.toFixed(1)}°` };
  }
  if (t.length === 4) {
    const e = RU(n, t[0], t[1], t[2], t[3]);
    return { atoms: [...t], type: "dihedral", value: e, label: `${e.toFixed(1)}°` };
  }
  return null;
}
function NU(n) {
  const { positions: t, nAtoms: e } = n;
  let r = 0, a = 0, o = 0;
  for (let M = 0; M < e; M++)
    r += t[M * 3], a += t[M * 3 + 1], o += t[M * 3 + 2];
  let c, u, d, h = 1 / 0, p = 1 / 0, m = 1 / 0, g = -1 / 0, _ = -1 / 0, b = -1 / 0;
  if (n.box && n.box.some((M) => M !== 0)) {
    const M = n.box;
    c = (M[0] + M[3] + M[6]) / 2, u = (M[1] + M[4] + M[7]) / 2, d = (M[2] + M[5] + M[8]) / 2;
    const O = [M[0], M[1], M[2]], L = [M[3], M[4], M[5]], N = [M[6], M[7], M[8]];
    for (let z = 0; z <= 1; z++)
      for (let R = 0; R <= 1; R++)
        for (let T = 0; T <= 1; T++) {
          const U = z * O[0] + R * L[0] + T * N[0], B = z * O[1] + R * L[1] + T * N[1], I = z * O[2] + R * L[2] + T * N[2];
          h = Math.min(h, U), p = Math.min(p, B), m = Math.min(m, I), g = Math.max(g, U), _ = Math.max(_, B), b = Math.max(b, I);
        }
  } else {
    c = e > 0 ? r / e : 0, u = e > 0 ? a / e : 0, d = e > 0 ? o / e : 0;
    for (let M = 0; M < e; M++) {
      const O = t[M * 3], L = t[M * 3 + 1], N = t[M * 3 + 2];
      h = Math.min(h, O), p = Math.min(p, L), m = Math.min(m, N), g = Math.max(g, O), _ = Math.max(_, L), b = Math.max(b, N);
    }
  }
  const S = g - h, y = _ - p, A = b - m, w = Math.max(S, y, A);
  return {
    center: [c, u, d],
    extent: { maxExtent: w, extentX: S, extentY: y }
  };
}
function LU(n, t, e) {
  const { center: r, extent: a } = NU(e), [o, c, u] = r;
  t.target.set(o, c, u);
  const d = Math.max(a.maxExtent * 1.2, 0.1);
  return n.position.set(o, c - d, u), n instanceof $r ? (n.near = -d * 10, n.far = d * 10, n.zoom = 1) : (n.near = d * 0.01, n.far = d * 10, n.updateProjectionMatrix()), t.update(), a;
}
function UU(n, t, e, r, a, o) {
  if (t === 0 || e === 0) return;
  const c = Math.max(t * 0.3, 100), d = Math.max(t - r - a, c) / e, p = Math.max(o.extentY / 2, o.extentX / (2 * d)) * 1.2, m = Math.max(p * 2, 0.1), g = t / e, _ = m * g / 2;
  n.left = -_, n.right = _, n.top = m / 2, n.bottom = -m / 2;
  const b = 2 * _, E = (r - a) / (2 * t) * b;
  n.left -= E, n.right -= E, n.updateProjectionMatrix();
}
function OU(n, t, e, r) {
  const a = n.position.clone(), o = n.up.clone(), c = e / r;
  let u;
  return t ? u = new Ti(50, c, 0.1, 1e4) : u = new $r(
    -50 * c / 2,
    50 * c / 2,
    50 / 2,
    -50 / 2,
    0.1,
    1e4
  ), u.position.copy(a), u.up.copy(o), u;
}
class PU {
  constructor() {
    Nt(this, "container", null);
    Nt(this, "renderer");
    Nt(this, "scene");
    Nt(this, "camera");
    Nt(this, "controls");
    Nt(this, "perspectiveMode", !1);
    Nt(this, "atomRenderer", null);
    Nt(this, "bondRenderer", null);
    Nt(this, "cellRenderer", null);
    Nt(this, "cellAxesRenderer", null);
    Nt(this, "labelOverlay", null);
    Nt(this, "arrowRenderer", null);
    Nt(this, "polyhedronRenderer", null);
    Nt(this, "useImpostor", !1);
    Nt(this, "animationId", null);
    Nt(this, "snapshot", null);
    Nt(this, "lastExtent", { maxExtent: 1, extentX: 1, extentY: 1 });
    Nt(this, "currentPositions", null);
    /** Axes-inset drag state */
    Nt(this, "axesDragging", !1);
    Nt(this, "axesDragLastX", 0);
    Nt(this, "axesDragLastY", 0);
    Nt(this, "atomScale", 1);
    Nt(this, "atomOpacity", 1);
    Nt(this, "bondScale", 1);
    Nt(this, "bondOpacity", 1);
    Nt(this, "viewInsetLeft", 0);
    Nt(this, "viewInsetRight", 0);
    Nt(this, "dprMediaQuery", null);
    Nt(this, "dprChangeHandler", null);
    // Cached dimensions for frame-synchronous resize detection
    Nt(this, "lastContainerW", 0);
    Nt(this, "lastContainerH", 0);
    Nt(this, "lastDpr", 1);
    // (screen-space picking replaces Three.js raycasting)
    // Atom selection & measurement
    Nt(this, "selectedAtoms", []);
    Nt(this, "selectionGroup", new Vs());
    Nt(this, "animate", () => {
      if (this.animationId = requestAnimationFrame(this.animate), this.container) {
        const r = this.container.clientWidth, a = this.container.clientHeight, o = Math.min(window.devicePixelRatio, 2);
        (r !== this.lastContainerW || a !== this.lastContainerH || o !== this.lastDpr) && (this.lastContainerW = r, this.lastContainerH = a, this.lastDpr = o, this.onResize());
      }
      this.controls.update(), this.polyhedronRenderer && this.container && this.polyhedronRenderer.updateResolution(
        this.container.clientWidth,
        this.container.clientHeight
      ), this.renderer.render(this.scene, this.camera);
      const t = new oe();
      this.renderer.getSize(t);
      const e = this.renderer.getPixelRatio();
      if (this.cellAxesRenderer)
        try {
          this.cellAxesRenderer.render(
            this.renderer,
            this.camera,
            t.x,
            t.y
          );
        } catch (r) {
          console.warn("CellAxesRenderer render error:", r), this.cellAxesRenderer = null;
        }
      this.labelOverlay && this.labelOverlay.render(
        this.camera,
        t.x,
        t.y,
        e
      );
    });
  }
  /** Mount the viewer into a DOM element. */
  mount(t) {
    this.container = t, this.renderer = new UL({
      antialias: !0,
      alpha: !0,
      powerPreference: "high-performance",
      preserveDrawingBuffer: !0
    }), this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)), this.renderer.setSize(t.clientWidth, t.clientHeight, !1), this.renderer.setClearColor(16777215, 1);
    const e = this.renderer.domElement;
    e.style.display = "block", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.width = "100%", e.style.height = "100%", t.appendChild(e), this.labelOverlay = new pU(), t.appendChild(this.labelOverlay.getCanvas()), this.labelOverlay.resize(
      t.clientWidth,
      t.clientHeight,
      Math.min(window.devicePixelRatio, 2)
    ), this.scene = new TM(), this.scene.background = new Me(16777215);
    const r = t.clientWidth / t.clientHeight, a = 50;
    this.camera = new $r(
      -a * r / 2,
      a * r / 2,
      a / 2,
      -a / 2,
      0.1,
      1e4
    ), this.camera.position.set(0, -50, 0), this.camera.up.set(0, 0, 1), this.controls = new ib(this.camera, this.renderer.domElement), this.controls.enableDamping = !0, this.controls.dampingFactor = 0.1, this.controls.rotateSpeed = 0.8, this.controls.zoomSpeed = 1.2;
    const o = new GC(14544639, 10057540, 0.4);
    this.scene.add(o);
    const c = new rd(16777215, 0.8);
    c.position.set(50, 50, 50), this.scene.add(c);
    const u = new rd(16777215, 0.4);
    u.position.set(-30, 20, -20), this.scene.add(u);
    const d = new rd(16777215, 0.3);
    d.position.set(0, -30, -50), this.scene.add(d), this.scene.add(this.selectionGroup), new ResizeObserver(() => this.onResize()).observe(t), this.setupDprListener(), this.animate();
  }
  /** Load a molecular snapshot (topology + positions). */
  loadSnapshot(t) {
    if (this.snapshot = t, this.currentPositions = new Float32Array(t.positions), (this.atomRenderer === null || !this.useImpostor) && this.swapRenderers(!0), this.atomRenderer.loadSnapshot(t), this.atomScale !== 1 && this.atomRenderer.setScale && this.atomRenderer.setScale(this.atomScale, t), this.labelOverlay && (this.labelOverlay.setAtomData(t.elements, t.nAtoms), this.labelOverlay.setPositions(t.positions)), this.arrowRenderer || (this.arrowRenderer = new xU(t.nAtoms), this.scene.add(this.arrowRenderer.mesh)), this.arrowRenderer.setAtomPositions(t.positions, t.nAtoms), t.box) {
      const e = t.box.some((r) => r !== 0);
      if (e && (this.cellRenderer || (this.cellRenderer = new uU(), this.scene.add(this.cellRenderer.mesh)), this.cellRenderer.loadBox(t.box)), e)
        try {
          this.cellAxesRenderer || (this.cellAxesRenderer = new fU()), this.cellAxesRenderer.loadBox(t.box);
        } catch (r) {
          console.warn("CellAxesRenderer init error:", r), this.cellAxesRenderer = null;
        }
    }
    this.fitToView(t);
  }
  /** Update positions from a trajectory frame. */
  updateFrame(t) {
    var e, r;
    !this.snapshot || !this.atomRenderer || !this.bondRenderer || ((!this.currentPositions || this.currentPositions.length < t.positions.length) && (this.currentPositions = new Float32Array(t.positions.length)), this.currentPositions.set(t.positions), this.atomRenderer.updatePositions(t.positions), (e = this.labelOverlay) == null || e.setPositions(t.positions), (r = this.arrowRenderer) == null || r.setAtomPositions(t.positions, t.nAtoms), this.bondRenderer.updatePositions(
      t.positions,
      this.snapshot.bonds,
      this.snapshot.nBonds
    ), this.selectedAtoms.length > 0 && this.updateSelectionVisuals());
  }
  /**
   * Replace bond data and re-render bonds without resetting the camera.
   * Used for per-frame bond recalculation (e.g. distance-based bonds).
   */
  updateBonds(t, e) {
    if (!this.snapshot || !this.bondRenderer) return;
    const r = this.currentPositions ?? this.snapshot.positions, a = {
      ...this.snapshot,
      nBonds: t.length / 2,
      bonds: t,
      bondOrders: e
    };
    this.snapshot = a, this.bondRenderer.loadSnapshot({
      ...a,
      positions: r
    }), this.bondScale !== 1 && this.bondRenderer.setScale && this.bondRenderer.setScale(this.bondScale, a);
  }
  /**
   * Replace bond data with optional extended positions/elements (PBC ghost atoms).
   * When positions/elements are provided, they include ghost atoms appended to
   * the original arrays, and bond indices may reference those ghost atoms.
   */
  updateBondsExt(t, e, r, a, o) {
    if (!this.snapshot || !this.bondRenderer) return;
    const c = r ?? this.currentPositions ?? this.snapshot.positions, u = a ?? this.snapshot.elements, d = o || this.snapshot.nAtoms;
    this.bondRenderer.loadSnapshot({
      ...this.snapshot,
      nAtoms: d,
      nBonds: t.length / 2,
      bonds: t,
      bondOrders: e,
      positions: c,
      elements: u
    }), this.bondScale !== 1 && this.bondRenderer.setScale && this.bondRenderer.setScale(this.bondScale, this.snapshot);
  }
  /** Set per-atom labels for overlay display. */
  setLabels(t) {
    var e;
    (e = this.labelOverlay) == null || e.setLabels(t);
  }
  /** Set per-atom vector data for arrow display. */
  setVectors(t) {
    var e;
    (e = this.arrowRenderer) == null || e.setVectors(t);
  }
  /** Set arrow scale multiplier. */
  setVectorScale(t) {
    var e;
    (e = this.arrowRenderer) == null || e.setScale(t);
  }
  /** Load polyhedra mesh data for rendering. */
  loadPolyhedra(t) {
    this.polyhedronRenderer || (this.polyhedronRenderer = new EU(), this.scene.add(this.polyhedronRenderer.group)), this.polyhedronRenderer.loadMeshData(t);
  }
  /** Clear all polyhedra from the scene. */
  clearPolyhedra() {
    this.polyhedronRenderer && this.polyhedronRenderer.clear();
  }
  /** Set atom radius scale multiplier. */
  setAtomScale(t) {
    var e;
    this.atomScale = t, (e = this.atomRenderer) != null && e.setScale && this.snapshot && this.atomRenderer.setScale(t, this.snapshot);
  }
  /** Set atom opacity (independent of bonds). */
  setAtomOpacity(t) {
    var e, r;
    this.atomOpacity = t, (r = (e = this.atomRenderer) == null ? void 0 : e.setOpacity) == null || r.call(e, t);
  }
  /** Set per-atom scale overrides from selection pipeline. */
  setAtomScaleOverrides(t) {
    var e, r;
    (r = (e = this.atomRenderer) == null ? void 0 : e.setScaleOverrides) == null || r.call(e, t);
  }
  /** Set per-atom opacity overrides from selection pipeline. */
  setAtomOpacityOverrides(t) {
    var e, r;
    (r = (e = this.atomRenderer) == null ? void 0 : e.setOpacityOverrides) == null || r.call(e, t);
  }
  /** Clear all per-atom overrides, reverting to global uniforms. */
  clearAtomOverrides() {
    var t, e;
    (e = (t = this.atomRenderer) == null ? void 0 : t.clearOverrides) == null || e.call(t);
  }
  /** Set bond radius scale multiplier. */
  setBondScale(t) {
    var e;
    this.bondScale = t, (e = this.bondRenderer) != null && e.setScale && this.snapshot && this.bondRenderer.setScale(t, this.snapshot);
  }
  /** Set bond opacity (independent of atoms). */
  setBondOpacity(t) {
    var e, r;
    this.bondOpacity = t, (r = (e = this.bondRenderer) == null ? void 0 : e.setOpacity) == null || r.call(e, t);
  }
  /** Toggle atom visibility. */
  setAtomsVisible(t) {
    this.atomRenderer && (this.atomRenderer.mesh.visible = t);
  }
  /** Toggle bond visibility. */
  setBondsVisible(t) {
    this.bondRenderer && (this.bondRenderer.mesh.visible = t);
  }
  /** Toggle simulation cell visibility. */
  setCellVisible(t) {
    this.cellRenderer && this.cellRenderer.setVisible(t);
  }
  /** Check if cell data exists. */
  hasCell() {
    return this.cellRenderer !== null && this.cellRenderer.mesh.visible;
  }
  /** Toggle cell axes indicator visibility. */
  setCellAxesVisible(t) {
    this.cellAxesRenderer && this.cellAxesRenderer.setVisible(t);
  }
  // ── Axes inset drag API ───────────────────────────────────
  /** Returns true if the CSS-pixel coordinate hits the axes inset. */
  hitTestAxesInset(t, e) {
    return !this.cellAxesRenderer || !this.container ? !1 : this.cellAxesRenderer.hitTest(
      t,
      e,
      this.container.clientHeight
    );
  }
  /** Begin an axes-inset drag at the given CSS coordinates. */
  startAxesDrag(t, e) {
    this.axesDragging = !0, this.axesDragLastX = t, this.axesDragLastY = e, this.controls.enabled = !1;
  }
  /** Continue an axes-inset drag. Returns true if currently dragging. */
  moveAxesDrag(t, e) {
    if (!this.axesDragging || !this.cellAxesRenderer || !this.container)
      return !1;
    const r = t - this.axesDragLastX, a = e - this.axesDragLastY;
    return this.axesDragLastX = t, this.axesDragLastY = e, this.cellAxesRenderer.moveBy(
      r,
      a,
      this.container.clientWidth,
      this.container.clientHeight
    ), !0;
  }
  /** End the axes-inset drag. */
  endAxesDrag() {
    this.axesDragging && (this.axesDragging = !1, this.controls.enabled = !0);
  }
  /** Whether an axes drag is in progress. */
  isAxesDragging() {
    return this.axesDragging;
  }
  /** Check if cell axes data exists. */
  hasCellAxes() {
    return this.cellAxesRenderer !== null;
  }
  /** Swap between InstancedMesh and Impostor renderers. */
  swapRenderers(t) {
    var a, o, c, u;
    this.atomRenderer && (this.scene.remove(this.atomRenderer.mesh), this.atomRenderer.dispose()), this.bondRenderer && (this.scene.remove(this.bondRenderer.mesh), this.bondRenderer.dispose()), this.useImpostor = t;
    const e = new oU(), r = new cU();
    this.atomRenderer = e, this.bondRenderer = r, this.scene.add(this.atomRenderer.mesh), this.scene.add(this.bondRenderer.mesh), this.atomOpacity !== 1 && ((o = (a = this.atomRenderer).setOpacity) == null || o.call(a, this.atomOpacity)), this.bondOpacity !== 1 && ((u = (c = this.bondRenderer).setOpacity) == null || u.call(c, this.bondOpacity));
  }
  /** Fit camera to show all atoms (or simulation cell if present). */
  fitToView(t) {
    this.lastExtent = LU(this.camera, this.controls, t), this.camera instanceof $r && this.doApplyFrustumInsets();
  }
  /** Reset view to fit all atoms. */
  resetView() {
    this.snapshot && this.fitToView(this.snapshot);
  }
  /** Set the rotation center (orbit target) to the given world coordinates. */
  setRotationCenter(t, e, r) {
    this.controls.target.set(t, e, r), this.controls.update();
  }
  /** Set pixel insets for overlay panels that occlude viewport edges. */
  setViewInsets(t, e) {
    this.viewInsetLeft = t, this.viewInsetRight = e, this.doApplyFrustumInsets();
  }
  /** Recalculate the orthographic frustum accounting for overlay insets. */
  doApplyFrustumInsets() {
    this.camera instanceof $r && this.container && UU(
      this.camera,
      this.container.clientWidth,
      this.container.clientHeight,
      this.viewInsetLeft,
      this.viewInsetRight,
      this.lastExtent
    );
  }
  /** Switch between orthographic and perspective projection. */
  setPerspective(t) {
    if (this.perspectiveMode === t || (this.perspectiveMode = t, !this.container)) return;
    const e = this.controls.target.clone(), r = OU(
      this.camera,
      t,
      this.container.clientWidth,
      this.container.clientHeight
    ), a = this.controls.enableDamping, o = this.controls.dampingFactor, c = this.controls.rotateSpeed, u = this.controls.zoomSpeed;
    this.controls.dispose(), this.camera = r, this.controls = new ib(this.camera, this.renderer.domElement), this.controls.enableDamping = a, this.controls.dampingFactor = o, this.controls.rotateSpeed = c, this.controls.zoomSpeed = u, this.controls.target.copy(e), this.controls.update(), this.snapshot && this.fitToView(this.snapshot);
  }
  /** Get the canvas element for event listener attachment. */
  getCanvas() {
    var t;
    return ((t = this.renderer) == null ? void 0 : t.domElement) ?? null;
  }
  /** Get a copy of current atom positions (public, for external use). */
  getCurrentPositionsCopy() {
    return this.snapshot ? new Float32Array(this.currentPositions ?? this.snapshot.positions) : null;
  }
  /** Get current atom positions (may reflect trajectory frame). */
  getCurrentPositions() {
    return this.currentPositions ?? this.snapshot.positions;
  }
  // ---- Raycasting ----
  /** Perform a pick at the given screen coordinates using CPU screen-space projection. */
  raycastAtPixel(t, e) {
    return !this.container || !this.snapshot ? null : TU(
      this.camera,
      this.container,
      this.snapshot,
      this.getCurrentPositions(),
      this.atomScale,
      t,
      e
    );
  }
  // ---- Selection & Measurement ----
  /** Toggle atom selection (right-click). Returns new selection state. */
  toggleAtomSelection(t) {
    const e = this.selectedAtoms.indexOf(t);
    return e >= 0 ? this.selectedAtoms.splice(e, 1) : (this.selectedAtoms.length >= 4 && this.selectedAtoms.shift(), this.selectedAtoms.push(t)), this.updateSelectionVisuals(), { atoms: [...this.selectedAtoms] };
  }
  /** Set selected atoms directly (for external triggers). Returns new selection state. */
  setSelection(t) {
    return this.selectedAtoms = t.slice(0, 4), this.updateSelectionVisuals(), { atoms: [...this.selectedAtoms] };
  }
  /** Clear all selected atoms. */
  clearSelection() {
    this.selectedAtoms = [], this.updateSelectionVisuals();
  }
  /** Compute the current geometric measurement based on selected atoms. */
  getMeasurement() {
    return !this.snapshot || this.selectedAtoms.length < 2 ? null : DU(this.getCurrentPositions(), this.selectedAtoms);
  }
  updateSelectionVisuals() {
    for (; this.selectionGroup.children.length > 0; ) {
      const r = this.selectionGroup.children[0];
      this.selectionGroup.remove(r), (r instanceof Dn || r instanceof Dc) && (r.geometry.dispose(), Array.isArray(r.material) ? r.material.forEach((a) => a.dispose()) : r.material.dispose());
    }
    if (!this.snapshot || this.selectedAtoms.length === 0) return;
    const t = this.getCurrentPositions(), e = this.snapshot.elements;
    for (const r of this.selectedAtoms) {
      const a = O0(e[r]) * U0 * 1.6, o = new C0(a, 16, 16), c = new Nd({
        color: 4359668,
        transparent: !0,
        opacity: 0.35,
        depthWrite: !1
      }), u = new Dn(o, c);
      u.position.set(
        t[r * 3],
        t[r * 3 + 1],
        t[r * 3 + 2]
      ), this.selectionGroup.add(u);
    }
    if (this.selectedAtoms.length >= 2) {
      const r = this.selectedAtoms.map(
        (u) => new ot(t[u * 3], t[u * 3 + 1], t[u * 3 + 2])
      ), a = new qn().setFromPoints(r), o = new Ld({
        color: 4359668,
        depthTest: !1
      }), c = new Dc(a, o);
      c.renderOrder = 999, this.selectionGroup.add(c);
    }
  }
  setupDprListener() {
    const t = () => {
      var e;
      this.onResize(), (e = this.dprMediaQuery) == null || e.removeEventListener("change", t), this.dprMediaQuery = window.matchMedia(
        `(resolution: ${window.devicePixelRatio}dppx)`
      ), this.dprChangeHandler = t, this.dprMediaQuery.addEventListener("change", t);
    };
    this.dprMediaQuery = window.matchMedia(
      `(resolution: ${window.devicePixelRatio}dppx)`
    ), this.dprChangeHandler = t, this.dprMediaQuery.addEventListener("change", t);
  }
  onResize() {
    var a;
    if (!this.container) return;
    const t = this.container.clientWidth, e = this.container.clientHeight;
    if (t === 0 || e === 0) return;
    const r = Math.min(window.devicePixelRatio, 2);
    this.lastContainerW = t, this.lastContainerH = e, this.lastDpr = r, this.renderer.setPixelRatio(r), this.camera instanceof $r ? this.doApplyFrustumInsets() : (this.camera.aspect = t / e, this.camera.updateProjectionMatrix()), this.renderer.setSize(t, e, !1), (a = this.labelOverlay) == null || a.resize(t, e, r);
  }
  /** Clean up all resources. */
  dispose() {
    this.animationId !== null && cancelAnimationFrame(this.animationId), this.clearSelection(), this.atomRenderer && this.atomRenderer.dispose(), this.bondRenderer && this.bondRenderer.dispose(), this.cellRenderer && this.cellRenderer.dispose(), this.cellAxesRenderer && this.cellAxesRenderer.dispose(), this.arrowRenderer && this.arrowRenderer.dispose(), this.polyhedronRenderer && this.polyhedronRenderer.dispose(), this.labelOverlay && this.labelOverlay.dispose(), this.dprMediaQuery && this.dprChangeHandler && this.dprMediaQuery.removeEventListener("change", this.dprChangeHandler), this.controls.dispose(), this.renderer.dispose(), this.container && this.renderer.domElement.parentNode && this.container.removeChild(this.renderer.domElement);
  }
}
function FM({
  snapshot: n,
  frame: t,
  atomLabels: e,
  atomVectors: r,
  onRendererReady: a,
  onHover: o,
  onAtomRightClick: c,
  onFrameUpdated: u
}) {
  const d = ct.useRef(null), h = ct.useRef(null), p = ct.useRef(o), m = ct.useRef(c), g = ct.useRef(u);
  return p.current = o, m.current = c, g.current = u, ct.useEffect(() => {
    if (!d.current) return;
    const _ = new PU();
    return _.mount(d.current), h.current = _, a == null || a(_), () => {
      _.dispose(), h.current = null;
    };
  }, []), ct.useEffect(() => {
    const _ = h.current, b = _ == null ? void 0 : _.getCanvas();
    if (!b || !_) return;
    let E = null;
    const S = (R) => {
      E === null && (E = requestAnimationFrame(() => {
        var U;
        const T = _.raycastAtPixel(R.clientX, R.clientY);
        (U = p.current) == null || U.call(p, T), E = null;
      }));
    }, y = (R) => {
      var U;
      R.preventDefault();
      const T = _.raycastAtPixel(R.clientX, R.clientY);
      T && T.kind === "atom" && ((U = m.current) == null || U.call(m, T.atomIndex));
    }, A = () => {
      var R;
      (R = p.current) == null || R.call(p, null);
    }, w = (R) => {
      const T = _.raycastAtPixel(R.clientX, R.clientY);
      if (T && T.kind === "atom") {
        const U = _.getCurrentPositionsCopy();
        if (U) {
          const B = T.atomIndex;
          _.setRotationCenter(
            U[B * 3],
            U[B * 3 + 1],
            U[B * 3 + 2]
          );
        }
      }
    }, M = d.current, O = (R) => {
      const T = M.getBoundingClientRect();
      return { x: R.clientX - T.left, y: R.clientY - T.top };
    }, L = (R) => {
      var B, I;
      const { x: T, y: U } = O(R);
      _.hitTestAxesInset(T, U) && (R.preventDefault(), _.startAxesDrag(T, U), (I = (B = R.target) == null ? void 0 : B.setPointerCapture) == null || I.call(B, R.pointerId));
    }, N = (R) => {
      if (_.isAxesDragging()) {
        const { x: T, y: U } = O(R);
        _.moveAxesDrag(T, U);
      }
    }, z = (R) => {
      _.endAxesDrag();
    };
    return b.addEventListener("mousemove", S), b.addEventListener("contextmenu", y), b.addEventListener("mouseleave", A), b.addEventListener("dblclick", w), b.addEventListener("pointerdown", L), b.addEventListener("pointermove", N), b.addEventListener("pointerup", z), b.addEventListener("pointercancel", z), () => {
      b.removeEventListener("mousemove", S), b.removeEventListener("contextmenu", y), b.removeEventListener("mouseleave", A), b.removeEventListener("dblclick", w), b.removeEventListener("pointerdown", L), b.removeEventListener("pointermove", N), b.removeEventListener("pointerup", z), b.removeEventListener("pointercancel", z), E !== null && cancelAnimationFrame(E);
    };
  }, []), ct.useEffect(() => {
    n && h.current && h.current.loadSnapshot(n);
  }, [n]), ct.useEffect(() => {
    var _;
    t && h.current && (h.current.updateFrame(t), (_ = g.current) == null || _.call(g));
  }, [t]), ct.useEffect(() => {
    var _;
    (_ = h.current) == null || _.setLabels(e ?? null);
  }, [e]), ct.useEffect(() => {
    var _;
    (_ = h.current) == null || _.setVectors(r ?? null);
  }, [r]), /* @__PURE__ */ J.jsx(
    "div",
    {
      ref: d,
      style: {
        width: "100%",
        height: "100%",
        position: "relative",
        background: "#ffffff"
      }
    }
  );
}
function En(n) {
  if (typeof n == "string" || typeof n == "number") return "" + n;
  let t = "";
  if (Array.isArray(n))
    for (let e = 0, r; e < n.length; e++)
      (r = En(n[e])) !== "" && (t += (t && " ") + r);
  else
    for (let e in n)
      n[e] && (t += (t && " ") + e);
  return t;
}
var zU = { value: () => {
} };
function Pd() {
  for (var n = 0, t = arguments.length, e = {}, r; n < t; ++n) {
    if (!(r = arguments[n] + "") || r in e || /[\s.]/.test(r)) throw new Error("illegal type: " + r);
    e[r] = [];
  }
  return new ad(e);
}
function ad(n) {
  this._ = n;
}
function IU(n, t) {
  return n.trim().split(/^|\s+/).map(function(e) {
    var r = "", a = e.indexOf(".");
    if (a >= 0 && (r = e.slice(a + 1), e = e.slice(0, a)), e && !t.hasOwnProperty(e)) throw new Error("unknown type: " + e);
    return { type: e, name: r };
  });
}
ad.prototype = Pd.prototype = {
  constructor: ad,
  on: function(n, t) {
    var e = this._, r = IU(n + "", e), a, o = -1, c = r.length;
    if (arguments.length < 2) {
      for (; ++o < c; ) if ((a = (n = r[o]).type) && (a = BU(e[a], n.name))) return a;
      return;
    }
    if (t != null && typeof t != "function") throw new Error("invalid callback: " + t);
    for (; ++o < c; )
      if (a = (n = r[o]).type) e[a] = Sb(e[a], n.name, t);
      else if (t == null) for (a in e) e[a] = Sb(e[a], n.name, null);
    return this;
  },
  copy: function() {
    var n = {}, t = this._;
    for (var e in t) n[e] = t[e].slice();
    return new ad(n);
  },
  call: function(n, t) {
    if ((a = arguments.length - 2) > 0) for (var e = new Array(a), r = 0, a, o; r < a; ++r) e[r] = arguments[r + 2];
    if (!this._.hasOwnProperty(n)) throw new Error("unknown type: " + n);
    for (o = this._[n], r = 0, a = o.length; r < a; ++r) o[r].value.apply(t, e);
  },
  apply: function(n, t, e) {
    if (!this._.hasOwnProperty(n)) throw new Error("unknown type: " + n);
    for (var r = this._[n], a = 0, o = r.length; a < o; ++a) r[a].value.apply(t, e);
  }
};
function BU(n, t) {
  for (var e = 0, r = n.length, a; e < r; ++e)
    if ((a = n[e]).name === t)
      return a.value;
}
function Sb(n, t, e) {
  for (var r = 0, a = n.length; r < a; ++r)
    if (n[r].name === t) {
      n[r] = zU, n = n.slice(0, r).concat(n.slice(r + 1));
      break;
    }
  return e != null && n.push({ name: t, value: e }), n;
}
var Qg = "http://www.w3.org/1999/xhtml";
const bb = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: Qg,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function zd(n) {
  var t = n += "", e = t.indexOf(":");
  return e >= 0 && (t = n.slice(0, e)) !== "xmlns" && (n = n.slice(e + 1)), bb.hasOwnProperty(t) ? { space: bb[t], local: n } : n;
}
function FU(n) {
  return function() {
    var t = this.ownerDocument, e = this.namespaceURI;
    return e === Qg && t.documentElement.namespaceURI === Qg ? t.createElement(n) : t.createElementNS(e, n);
  };
}
function HU(n) {
  return function() {
    return this.ownerDocument.createElementNS(n.space, n.local);
  };
}
function HM(n) {
  var t = zd(n);
  return (t.local ? HU : FU)(t);
}
function VU() {
}
function z0(n) {
  return n == null ? VU : function() {
    return this.querySelector(n);
  };
}
function kU(n) {
  typeof n != "function" && (n = z0(n));
  for (var t = this._groups, e = t.length, r = new Array(e), a = 0; a < e; ++a)
    for (var o = t[a], c = o.length, u = r[a] = new Array(c), d, h, p = 0; p < c; ++p)
      (d = o[p]) && (h = n.call(d, d.__data__, p, o)) && ("__data__" in d && (h.__data__ = d.__data__), u[p] = h);
  return new Ri(r, this._parents);
}
function GU(n) {
  return n == null ? [] : Array.isArray(n) ? n : Array.from(n);
}
function XU() {
  return [];
}
function VM(n) {
  return n == null ? XU : function() {
    return this.querySelectorAll(n);
  };
}
function jU(n) {
  return function() {
    return GU(n.apply(this, arguments));
  };
}
function WU(n) {
  typeof n == "function" ? n = jU(n) : n = VM(n);
  for (var t = this._groups, e = t.length, r = [], a = [], o = 0; o < e; ++o)
    for (var c = t[o], u = c.length, d, h = 0; h < u; ++h)
      (d = c[h]) && (r.push(n.call(d, d.__data__, h, c)), a.push(d));
  return new Ri(r, a);
}
function kM(n) {
  return function() {
    return this.matches(n);
  };
}
function GM(n) {
  return function(t) {
    return t.matches(n);
  };
}
var YU = Array.prototype.find;
function qU(n) {
  return function() {
    return YU.call(this.children, n);
  };
}
function ZU() {
  return this.firstElementChild;
}
function $U(n) {
  return this.select(n == null ? ZU : qU(typeof n == "function" ? n : GM(n)));
}
var KU = Array.prototype.filter;
function QU() {
  return Array.from(this.children);
}
function JU(n) {
  return function() {
    return KU.call(this.children, n);
  };
}
function tO(n) {
  return this.selectAll(n == null ? QU : JU(typeof n == "function" ? n : GM(n)));
}
function eO(n) {
  typeof n != "function" && (n = kM(n));
  for (var t = this._groups, e = t.length, r = new Array(e), a = 0; a < e; ++a)
    for (var o = t[a], c = o.length, u = r[a] = [], d, h = 0; h < c; ++h)
      (d = o[h]) && n.call(d, d.__data__, h, o) && u.push(d);
  return new Ri(r, this._parents);
}
function XM(n) {
  return new Array(n.length);
}
function nO() {
  return new Ri(this._enter || this._groups.map(XM), this._parents);
}
function _d(n, t) {
  this.ownerDocument = n.ownerDocument, this.namespaceURI = n.namespaceURI, this._next = null, this._parent = n, this.__data__ = t;
}
_d.prototype = {
  constructor: _d,
  appendChild: function(n) {
    return this._parent.insertBefore(n, this._next);
  },
  insertBefore: function(n, t) {
    return this._parent.insertBefore(n, t);
  },
  querySelector: function(n) {
    return this._parent.querySelector(n);
  },
  querySelectorAll: function(n) {
    return this._parent.querySelectorAll(n);
  }
};
function iO(n) {
  return function() {
    return n;
  };
}
function rO(n, t, e, r, a, o) {
  for (var c = 0, u, d = t.length, h = o.length; c < h; ++c)
    (u = t[c]) ? (u.__data__ = o[c], r[c] = u) : e[c] = new _d(n, o[c]);
  for (; c < d; ++c)
    (u = t[c]) && (a[c] = u);
}
function sO(n, t, e, r, a, o, c) {
  var u, d, h = /* @__PURE__ */ new Map(), p = t.length, m = o.length, g = new Array(p), _;
  for (u = 0; u < p; ++u)
    (d = t[u]) && (g[u] = _ = c.call(d, d.__data__, u, t) + "", h.has(_) ? a[u] = d : h.set(_, d));
  for (u = 0; u < m; ++u)
    _ = c.call(n, o[u], u, o) + "", (d = h.get(_)) ? (r[u] = d, d.__data__ = o[u], h.delete(_)) : e[u] = new _d(n, o[u]);
  for (u = 0; u < p; ++u)
    (d = t[u]) && h.get(g[u]) === d && (a[u] = d);
}
function aO(n) {
  return n.__data__;
}
function oO(n, t) {
  if (!arguments.length) return Array.from(this, aO);
  var e = t ? sO : rO, r = this._parents, a = this._groups;
  typeof n != "function" && (n = iO(n));
  for (var o = a.length, c = new Array(o), u = new Array(o), d = new Array(o), h = 0; h < o; ++h) {
    var p = r[h], m = a[h], g = m.length, _ = lO(n.call(p, p && p.__data__, h, r)), b = _.length, E = u[h] = new Array(b), S = c[h] = new Array(b), y = d[h] = new Array(g);
    e(p, m, E, S, y, _, t);
    for (var A = 0, w = 0, M, O; A < b; ++A)
      if (M = E[A]) {
        for (A >= w && (w = A + 1); !(O = S[w]) && ++w < b; ) ;
        M._next = O || null;
      }
  }
  return c = new Ri(c, r), c._enter = u, c._exit = d, c;
}
function lO(n) {
  return typeof n == "object" && "length" in n ? n : Array.from(n);
}
function cO() {
  return new Ri(this._exit || this._groups.map(XM), this._parents);
}
function uO(n, t, e) {
  var r = this.enter(), a = this, o = this.exit();
  return typeof n == "function" ? (r = n(r), r && (r = r.selection())) : r = r.append(n + ""), t != null && (a = t(a), a && (a = a.selection())), e == null ? o.remove() : e(o), r && a ? r.merge(a).order() : a;
}
function fO(n) {
  for (var t = n.selection ? n.selection() : n, e = this._groups, r = t._groups, a = e.length, o = r.length, c = Math.min(a, o), u = new Array(a), d = 0; d < c; ++d)
    for (var h = e[d], p = r[d], m = h.length, g = u[d] = new Array(m), _, b = 0; b < m; ++b)
      (_ = h[b] || p[b]) && (g[b] = _);
  for (; d < a; ++d)
    u[d] = e[d];
  return new Ri(u, this._parents);
}
function dO() {
  for (var n = this._groups, t = -1, e = n.length; ++t < e; )
    for (var r = n[t], a = r.length - 1, o = r[a], c; --a >= 0; )
      (c = r[a]) && (o && c.compareDocumentPosition(o) ^ 4 && o.parentNode.insertBefore(c, o), o = c);
  return this;
}
function hO(n) {
  n || (n = pO);
  function t(m, g) {
    return m && g ? n(m.__data__, g.__data__) : !m - !g;
  }
  for (var e = this._groups, r = e.length, a = new Array(r), o = 0; o < r; ++o) {
    for (var c = e[o], u = c.length, d = a[o] = new Array(u), h, p = 0; p < u; ++p)
      (h = c[p]) && (d[p] = h);
    d.sort(t);
  }
  return new Ri(a, this._parents).order();
}
function pO(n, t) {
  return n < t ? -1 : n > t ? 1 : n >= t ? 0 : NaN;
}
function mO() {
  var n = arguments[0];
  return arguments[0] = this, n.apply(null, arguments), this;
}
function gO() {
  return Array.from(this);
}
function vO() {
  for (var n = this._groups, t = 0, e = n.length; t < e; ++t)
    for (var r = n[t], a = 0, o = r.length; a < o; ++a) {
      var c = r[a];
      if (c) return c;
    }
  return null;
}
function _O() {
  let n = 0;
  for (const t of this) ++n;
  return n;
}
function yO() {
  return !this.node();
}
function xO(n) {
  for (var t = this._groups, e = 0, r = t.length; e < r; ++e)
    for (var a = t[e], o = 0, c = a.length, u; o < c; ++o)
      (u = a[o]) && n.call(u, u.__data__, o, a);
  return this;
}
function SO(n) {
  return function() {
    this.removeAttribute(n);
  };
}
function bO(n) {
  return function() {
    this.removeAttributeNS(n.space, n.local);
  };
}
function MO(n, t) {
  return function() {
    this.setAttribute(n, t);
  };
}
function EO(n, t) {
  return function() {
    this.setAttributeNS(n.space, n.local, t);
  };
}
function wO(n, t) {
  return function() {
    var e = t.apply(this, arguments);
    e == null ? this.removeAttribute(n) : this.setAttribute(n, e);
  };
}
function TO(n, t) {
  return function() {
    var e = t.apply(this, arguments);
    e == null ? this.removeAttributeNS(n.space, n.local) : this.setAttributeNS(n.space, n.local, e);
  };
}
function AO(n, t) {
  var e = zd(n);
  if (arguments.length < 2) {
    var r = this.node();
    return e.local ? r.getAttributeNS(e.space, e.local) : r.getAttribute(e);
  }
  return this.each((t == null ? e.local ? bO : SO : typeof t == "function" ? e.local ? TO : wO : e.local ? EO : MO)(e, t));
}
function jM(n) {
  return n.ownerDocument && n.ownerDocument.defaultView || n.document && n || n.defaultView;
}
function CO(n) {
  return function() {
    this.style.removeProperty(n);
  };
}
function RO(n, t, e) {
  return function() {
    this.style.setProperty(n, t, e);
  };
}
function DO(n, t, e) {
  return function() {
    var r = t.apply(this, arguments);
    r == null ? this.style.removeProperty(n) : this.style.setProperty(n, r, e);
  };
}
function NO(n, t, e) {
  return arguments.length > 1 ? this.each((t == null ? CO : typeof t == "function" ? DO : RO)(n, t, e ?? "")) : ol(this.node(), n);
}
function ol(n, t) {
  return n.style.getPropertyValue(t) || jM(n).getComputedStyle(n, null).getPropertyValue(t);
}
function LO(n) {
  return function() {
    delete this[n];
  };
}
function UO(n, t) {
  return function() {
    this[n] = t;
  };
}
function OO(n, t) {
  return function() {
    var e = t.apply(this, arguments);
    e == null ? delete this[n] : this[n] = e;
  };
}
function PO(n, t) {
  return arguments.length > 1 ? this.each((t == null ? LO : typeof t == "function" ? OO : UO)(n, t)) : this.node()[n];
}
function WM(n) {
  return n.trim().split(/^|\s+/);
}
function I0(n) {
  return n.classList || new YM(n);
}
function YM(n) {
  this._node = n, this._names = WM(n.getAttribute("class") || "");
}
YM.prototype = {
  add: function(n) {
    var t = this._names.indexOf(n);
    t < 0 && (this._names.push(n), this._node.setAttribute("class", this._names.join(" ")));
  },
  remove: function(n) {
    var t = this._names.indexOf(n);
    t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" ")));
  },
  contains: function(n) {
    return this._names.indexOf(n) >= 0;
  }
};
function qM(n, t) {
  for (var e = I0(n), r = -1, a = t.length; ++r < a; ) e.add(t[r]);
}
function ZM(n, t) {
  for (var e = I0(n), r = -1, a = t.length; ++r < a; ) e.remove(t[r]);
}
function zO(n) {
  return function() {
    qM(this, n);
  };
}
function IO(n) {
  return function() {
    ZM(this, n);
  };
}
function BO(n, t) {
  return function() {
    (t.apply(this, arguments) ? qM : ZM)(this, n);
  };
}
function FO(n, t) {
  var e = WM(n + "");
  if (arguments.length < 2) {
    for (var r = I0(this.node()), a = -1, o = e.length; ++a < o; ) if (!r.contains(e[a])) return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? BO : t ? zO : IO)(e, t));
}
function HO() {
  this.textContent = "";
}
function VO(n) {
  return function() {
    this.textContent = n;
  };
}
function kO(n) {
  return function() {
    var t = n.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function GO(n) {
  return arguments.length ? this.each(n == null ? HO : (typeof n == "function" ? kO : VO)(n)) : this.node().textContent;
}
function XO() {
  this.innerHTML = "";
}
function jO(n) {
  return function() {
    this.innerHTML = n;
  };
}
function WO(n) {
  return function() {
    var t = n.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function YO(n) {
  return arguments.length ? this.each(n == null ? XO : (typeof n == "function" ? WO : jO)(n)) : this.node().innerHTML;
}
function qO() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function ZO() {
  return this.each(qO);
}
function $O() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function KO() {
  return this.each($O);
}
function QO(n) {
  var t = typeof n == "function" ? n : HM(n);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function JO() {
  return null;
}
function tP(n, t) {
  var e = typeof n == "function" ? n : HM(n), r = t == null ? JO : typeof t == "function" ? t : z0(t);
  return this.select(function() {
    return this.insertBefore(e.apply(this, arguments), r.apply(this, arguments) || null);
  });
}
function eP() {
  var n = this.parentNode;
  n && n.removeChild(this);
}
function nP() {
  return this.each(eP);
}
function iP() {
  var n = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(n, this.nextSibling) : n;
}
function rP() {
  var n = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(n, this.nextSibling) : n;
}
function sP(n) {
  return this.select(n ? rP : iP);
}
function aP(n) {
  return arguments.length ? this.property("__data__", n) : this.node().__data__;
}
function oP(n) {
  return function(t) {
    n.call(this, t, this.__data__);
  };
}
function lP(n) {
  return n.trim().split(/^|\s+/).map(function(t) {
    var e = "", r = t.indexOf(".");
    return r >= 0 && (e = t.slice(r + 1), t = t.slice(0, r)), { type: t, name: e };
  });
}
function cP(n) {
  return function() {
    var t = this.__on;
    if (t) {
      for (var e = 0, r = -1, a = t.length, o; e < a; ++e)
        o = t[e], (!n.type || o.type === n.type) && o.name === n.name ? this.removeEventListener(o.type, o.listener, o.options) : t[++r] = o;
      ++r ? t.length = r : delete this.__on;
    }
  };
}
function uP(n, t, e) {
  return function() {
    var r = this.__on, a, o = oP(t);
    if (r) {
      for (var c = 0, u = r.length; c < u; ++c)
        if ((a = r[c]).type === n.type && a.name === n.name) {
          this.removeEventListener(a.type, a.listener, a.options), this.addEventListener(a.type, a.listener = o, a.options = e), a.value = t;
          return;
        }
    }
    this.addEventListener(n.type, o, e), a = { type: n.type, name: n.name, value: t, listener: o, options: e }, r ? r.push(a) : this.__on = [a];
  };
}
function fP(n, t, e) {
  var r = lP(n + ""), a, o = r.length, c;
  if (arguments.length < 2) {
    var u = this.node().__on;
    if (u) {
      for (var d = 0, h = u.length, p; d < h; ++d)
        for (a = 0, p = u[d]; a < o; ++a)
          if ((c = r[a]).type === p.type && c.name === p.name)
            return p.value;
    }
    return;
  }
  for (u = t ? uP : cP, a = 0; a < o; ++a) this.each(u(r[a], t, e));
  return this;
}
function $M(n, t, e) {
  var r = jM(n), a = r.CustomEvent;
  typeof a == "function" ? a = new a(t, e) : (a = r.document.createEvent("Event"), e ? (a.initEvent(t, e.bubbles, e.cancelable), a.detail = e.detail) : a.initEvent(t, !1, !1)), n.dispatchEvent(a);
}
function dP(n, t) {
  return function() {
    return $M(this, n, t);
  };
}
function hP(n, t) {
  return function() {
    return $M(this, n, t.apply(this, arguments));
  };
}
function pP(n, t) {
  return this.each((typeof t == "function" ? hP : dP)(n, t));
}
function* mP() {
  for (var n = this._groups, t = 0, e = n.length; t < e; ++t)
    for (var r = n[t], a = 0, o = r.length, c; a < o; ++a)
      (c = r[a]) && (yield c);
}
var KM = [null];
function Ri(n, t) {
  this._groups = n, this._parents = t;
}
function Yc() {
  return new Ri([[document.documentElement]], KM);
}
function gP() {
  return this;
}
Ri.prototype = Yc.prototype = {
  constructor: Ri,
  select: kU,
  selectAll: WU,
  selectChild: $U,
  selectChildren: tO,
  filter: eO,
  data: oO,
  enter: nO,
  exit: cO,
  join: uO,
  merge: fO,
  selection: gP,
  order: dO,
  sort: hO,
  call: mO,
  nodes: gO,
  node: vO,
  size: _O,
  empty: yO,
  each: xO,
  attr: AO,
  style: NO,
  property: PO,
  classed: FO,
  text: GO,
  html: YO,
  raise: ZO,
  lower: KO,
  append: QO,
  insert: tP,
  remove: nP,
  clone: sP,
  datum: aP,
  on: fP,
  dispatch: pP,
  [Symbol.iterator]: mP
};
function Ai(n) {
  return typeof n == "string" ? new Ri([[document.querySelector(n)]], [document.documentElement]) : new Ri([[n]], KM);
}
function vP(n) {
  let t;
  for (; t = n.sourceEvent; ) n = t;
  return n;
}
function $i(n, t) {
  if (n = vP(n), t === void 0 && (t = n.currentTarget), t) {
    var e = t.ownerSVGElement || t;
    if (e.createSVGPoint) {
      var r = e.createSVGPoint();
      return r.x = n.clientX, r.y = n.clientY, r = r.matrixTransform(t.getScreenCTM().inverse()), [r.x, r.y];
    }
    if (t.getBoundingClientRect) {
      var a = t.getBoundingClientRect();
      return [n.clientX - a.left - t.clientLeft, n.clientY - a.top - t.clientTop];
    }
  }
  return [n.pageX, n.pageY];
}
const _P = { passive: !1 }, Lc = { capture: !0, passive: !1 };
function Gm(n) {
  n.stopImmediatePropagation();
}
function Qo(n) {
  n.preventDefault(), n.stopImmediatePropagation();
}
function QM(n) {
  var t = n.document.documentElement, e = Ai(n).on("dragstart.drag", Qo, Lc);
  "onselectstart" in t ? e.on("selectstart.drag", Qo, Lc) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function JM(n, t) {
  var e = n.document.documentElement, r = Ai(n).on("dragstart.drag", null);
  t && (r.on("click.drag", Qo, Lc), setTimeout(function() {
    r.on("click.drag", null);
  }, 0)), "onselectstart" in e ? r.on("selectstart.drag", null) : (e.style.MozUserSelect = e.__noselect, delete e.__noselect);
}
const Xf = (n) => () => n;
function Jg(n, {
  sourceEvent: t,
  subject: e,
  target: r,
  identifier: a,
  active: o,
  x: c,
  y: u,
  dx: d,
  dy: h,
  dispatch: p
}) {
  Object.defineProperties(this, {
    type: { value: n, enumerable: !0, configurable: !0 },
    sourceEvent: { value: t, enumerable: !0, configurable: !0 },
    subject: { value: e, enumerable: !0, configurable: !0 },
    target: { value: r, enumerable: !0, configurable: !0 },
    identifier: { value: a, enumerable: !0, configurable: !0 },
    active: { value: o, enumerable: !0, configurable: !0 },
    x: { value: c, enumerable: !0, configurable: !0 },
    y: { value: u, enumerable: !0, configurable: !0 },
    dx: { value: d, enumerable: !0, configurable: !0 },
    dy: { value: h, enumerable: !0, configurable: !0 },
    _: { value: p }
  });
}
Jg.prototype.on = function() {
  var n = this._.on.apply(this._, arguments);
  return n === this._ ? this : n;
};
function yP(n) {
  return !n.ctrlKey && !n.button;
}
function xP() {
  return this.parentNode;
}
function SP(n, t) {
  return t ?? { x: n.x, y: n.y };
}
function bP() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function tE() {
  var n = yP, t = xP, e = SP, r = bP, a = {}, o = Pd("start", "drag", "end"), c = 0, u, d, h, p, m = 0;
  function g(M) {
    M.on("mousedown.drag", _).filter(r).on("touchstart.drag", S).on("touchmove.drag", y, _P).on("touchend.drag touchcancel.drag", A).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  function _(M, O) {
    if (!(p || !n.call(this, M, O))) {
      var L = w(this, t.call(this, M, O), M, O, "mouse");
      L && (Ai(M.view).on("mousemove.drag", b, Lc).on("mouseup.drag", E, Lc), QM(M.view), Gm(M), h = !1, u = M.clientX, d = M.clientY, L("start", M));
    }
  }
  function b(M) {
    if (Qo(M), !h) {
      var O = M.clientX - u, L = M.clientY - d;
      h = O * O + L * L > m;
    }
    a.mouse("drag", M);
  }
  function E(M) {
    Ai(M.view).on("mousemove.drag mouseup.drag", null), JM(M.view, h), Qo(M), a.mouse("end", M);
  }
  function S(M, O) {
    if (n.call(this, M, O)) {
      var L = M.changedTouches, N = t.call(this, M, O), z = L.length, R, T;
      for (R = 0; R < z; ++R)
        (T = w(this, N, M, O, L[R].identifier, L[R])) && (Gm(M), T("start", M, L[R]));
    }
  }
  function y(M) {
    var O = M.changedTouches, L = O.length, N, z;
    for (N = 0; N < L; ++N)
      (z = a[O[N].identifier]) && (Qo(M), z("drag", M, O[N]));
  }
  function A(M) {
    var O = M.changedTouches, L = O.length, N, z;
    for (p && clearTimeout(p), p = setTimeout(function() {
      p = null;
    }, 500), N = 0; N < L; ++N)
      (z = a[O[N].identifier]) && (Gm(M), z("end", M, O[N]));
  }
  function w(M, O, L, N, z, R) {
    var T = o.copy(), U = $i(R || L, O), B, I, C;
    if ((C = e.call(M, new Jg("beforestart", {
      sourceEvent: L,
      target: g,
      identifier: z,
      active: c,
      x: U[0],
      y: U[1],
      dx: 0,
      dy: 0,
      dispatch: T
    }), N)) != null)
      return B = C.x - U[0] || 0, I = C.y - U[1] || 0, function X(D, V, H) {
        var j = U, K;
        switch (D) {
          case "start":
            a[z] = X, K = c++;
            break;
          case "end":
            delete a[z], --c;
          // falls through
          case "drag":
            U = $i(H || V, O), K = c;
            break;
        }
        T.call(
          D,
          M,
          new Jg(D, {
            sourceEvent: V,
            subject: C,
            target: g,
            identifier: z,
            active: K,
            x: U[0] + B,
            y: U[1] + I,
            dx: U[0] - j[0],
            dy: U[1] - j[1],
            dispatch: T
          }),
          N
        );
      };
  }
  return g.filter = function(M) {
    return arguments.length ? (n = typeof M == "function" ? M : Xf(!!M), g) : n;
  }, g.container = function(M) {
    return arguments.length ? (t = typeof M == "function" ? M : Xf(M), g) : t;
  }, g.subject = function(M) {
    return arguments.length ? (e = typeof M == "function" ? M : Xf(M), g) : e;
  }, g.touchable = function(M) {
    return arguments.length ? (r = typeof M == "function" ? M : Xf(!!M), g) : r;
  }, g.on = function() {
    var M = o.on.apply(o, arguments);
    return M === o ? g : M;
  }, g.clickDistance = function(M) {
    return arguments.length ? (m = (M = +M) * M, g) : Math.sqrt(m);
  }, g;
}
function B0(n, t, e) {
  n.prototype = t.prototype = e, e.constructor = n;
}
function eE(n, t) {
  var e = Object.create(n.prototype);
  for (var r in t) e[r] = t[r];
  return e;
}
function qc() {
}
var Uc = 0.7, yd = 1 / Uc, Jo = "\\s*([+-]?\\d+)\\s*", Oc = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", pr = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", MP = /^#([0-9a-f]{3,8})$/, EP = new RegExp(`^rgb\\(${Jo},${Jo},${Jo}\\)$`), wP = new RegExp(`^rgb\\(${pr},${pr},${pr}\\)$`), TP = new RegExp(`^rgba\\(${Jo},${Jo},${Jo},${Oc}\\)$`), AP = new RegExp(`^rgba\\(${pr},${pr},${pr},${Oc}\\)$`), CP = new RegExp(`^hsl\\(${Oc},${pr},${pr}\\)$`), RP = new RegExp(`^hsla\\(${Oc},${pr},${pr},${Oc}\\)$`), Mb = {
  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
};
B0(qc, Ua, {
  copy(n) {
    return Object.assign(new this.constructor(), this, n);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: Eb,
  // Deprecated! Use color.formatHex.
  formatHex: Eb,
  formatHex8: DP,
  formatHsl: NP,
  formatRgb: wb,
  toString: wb
});
function Eb() {
  return this.rgb().formatHex();
}
function DP() {
  return this.rgb().formatHex8();
}
function NP() {
  return nE(this).formatHsl();
}
function wb() {
  return this.rgb().formatRgb();
}
function Ua(n) {
  var t, e;
  return n = (n + "").trim().toLowerCase(), (t = MP.exec(n)) ? (e = t[1].length, t = parseInt(t[1], 16), e === 6 ? Tb(t) : e === 3 ? new hi(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : e === 8 ? jf(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : e === 4 ? jf(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = EP.exec(n)) ? new hi(t[1], t[2], t[3], 1) : (t = wP.exec(n)) ? new hi(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = TP.exec(n)) ? jf(t[1], t[2], t[3], t[4]) : (t = AP.exec(n)) ? jf(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = CP.exec(n)) ? Rb(t[1], t[2] / 100, t[3] / 100, 1) : (t = RP.exec(n)) ? Rb(t[1], t[2] / 100, t[3] / 100, t[4]) : Mb.hasOwnProperty(n) ? Tb(Mb[n]) : n === "transparent" ? new hi(NaN, NaN, NaN, 0) : null;
}
function Tb(n) {
  return new hi(n >> 16 & 255, n >> 8 & 255, n & 255, 1);
}
function jf(n, t, e, r) {
  return r <= 0 && (n = t = e = NaN), new hi(n, t, e, r);
}
function LP(n) {
  return n instanceof qc || (n = Ua(n)), n ? (n = n.rgb(), new hi(n.r, n.g, n.b, n.opacity)) : new hi();
}
function t0(n, t, e, r) {
  return arguments.length === 1 ? LP(n) : new hi(n, t, e, r ?? 1);
}
function hi(n, t, e, r) {
  this.r = +n, this.g = +t, this.b = +e, this.opacity = +r;
}
B0(hi, t0, eE(qc, {
  brighter(n) {
    return n = n == null ? yd : Math.pow(yd, n), new hi(this.r * n, this.g * n, this.b * n, this.opacity);
  },
  darker(n) {
    return n = n == null ? Uc : Math.pow(Uc, n), new hi(this.r * n, this.g * n, this.b * n, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new hi(Ra(this.r), Ra(this.g), Ra(this.b), xd(this.opacity));
  },
  displayable() {
    return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
  },
  hex: Ab,
  // Deprecated! Use color.formatHex.
  formatHex: Ab,
  formatHex8: UP,
  formatRgb: Cb,
  toString: Cb
}));
function Ab() {
  return `#${Aa(this.r)}${Aa(this.g)}${Aa(this.b)}`;
}
function UP() {
  return `#${Aa(this.r)}${Aa(this.g)}${Aa(this.b)}${Aa((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function Cb() {
  const n = xd(this.opacity);
  return `${n === 1 ? "rgb(" : "rgba("}${Ra(this.r)}, ${Ra(this.g)}, ${Ra(this.b)}${n === 1 ? ")" : `, ${n})`}`;
}
function xd(n) {
  return isNaN(n) ? 1 : Math.max(0, Math.min(1, n));
}
function Ra(n) {
  return Math.max(0, Math.min(255, Math.round(n) || 0));
}
function Aa(n) {
  return n = Ra(n), (n < 16 ? "0" : "") + n.toString(16);
}
function Rb(n, t, e, r) {
  return r <= 0 ? n = t = e = NaN : e <= 0 || e >= 1 ? n = t = NaN : t <= 0 && (n = NaN), new Qi(n, t, e, r);
}
function nE(n) {
  if (n instanceof Qi) return new Qi(n.h, n.s, n.l, n.opacity);
  if (n instanceof qc || (n = Ua(n)), !n) return new Qi();
  if (n instanceof Qi) return n;
  n = n.rgb();
  var t = n.r / 255, e = n.g / 255, r = n.b / 255, a = Math.min(t, e, r), o = Math.max(t, e, r), c = NaN, u = o - a, d = (o + a) / 2;
  return u ? (t === o ? c = (e - r) / u + (e < r) * 6 : e === o ? c = (r - t) / u + 2 : c = (t - e) / u + 4, u /= d < 0.5 ? o + a : 2 - o - a, c *= 60) : u = d > 0 && d < 1 ? 0 : c, new Qi(c, u, d, n.opacity);
}
function OP(n, t, e, r) {
  return arguments.length === 1 ? nE(n) : new Qi(n, t, e, r ?? 1);
}
function Qi(n, t, e, r) {
  this.h = +n, this.s = +t, this.l = +e, this.opacity = +r;
}
B0(Qi, OP, eE(qc, {
  brighter(n) {
    return n = n == null ? yd : Math.pow(yd, n), new Qi(this.h, this.s, this.l * n, this.opacity);
  },
  darker(n) {
    return n = n == null ? Uc : Math.pow(Uc, n), new Qi(this.h, this.s, this.l * n, this.opacity);
  },
  rgb() {
    var n = this.h % 360 + (this.h < 0) * 360, t = isNaN(n) || isNaN(this.s) ? 0 : this.s, e = this.l, r = e + (e < 0.5 ? e : 1 - e) * t, a = 2 * e - r;
    return new hi(
      Xm(n >= 240 ? n - 240 : n + 120, a, r),
      Xm(n, a, r),
      Xm(n < 120 ? n + 240 : n - 120, a, r),
      this.opacity
    );
  },
  clamp() {
    return new Qi(Db(this.h), Wf(this.s), Wf(this.l), xd(this.opacity));
  },
  displayable() {
    return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
  },
  formatHsl() {
    const n = xd(this.opacity);
    return `${n === 1 ? "hsl(" : "hsla("}${Db(this.h)}, ${Wf(this.s) * 100}%, ${Wf(this.l) * 100}%${n === 1 ? ")" : `, ${n})`}`;
  }
}));
function Db(n) {
  return n = (n || 0) % 360, n < 0 ? n + 360 : n;
}
function Wf(n) {
  return Math.max(0, Math.min(1, n || 0));
}
function Xm(n, t, e) {
  return (n < 60 ? t + (e - t) * n / 60 : n < 180 ? e : n < 240 ? t + (e - t) * (240 - n) / 60 : t) * 255;
}
const F0 = (n) => () => n;
function PP(n, t) {
  return function(e) {
    return n + e * t;
  };
}
function zP(n, t, e) {
  return n = Math.pow(n, e), t = Math.pow(t, e) - n, e = 1 / e, function(r) {
    return Math.pow(n + r * t, e);
  };
}
function IP(n) {
  return (n = +n) == 1 ? iE : function(t, e) {
    return e - t ? zP(t, e, n) : F0(isNaN(t) ? e : t);
  };
}
function iE(n, t) {
  var e = t - n;
  return e ? PP(n, e) : F0(isNaN(n) ? t : n);
}
const Sd = (function n(t) {
  var e = IP(t);
  function r(a, o) {
    var c = e((a = t0(a)).r, (o = t0(o)).r), u = e(a.g, o.g), d = e(a.b, o.b), h = iE(a.opacity, o.opacity);
    return function(p) {
      return a.r = c(p), a.g = u(p), a.b = d(p), a.opacity = h(p), a + "";
    };
  }
  return r.gamma = n, r;
})(1);
function BP(n, t) {
  t || (t = []);
  var e = n ? Math.min(t.length, n.length) : 0, r = t.slice(), a;
  return function(o) {
    for (a = 0; a < e; ++a) r[a] = n[a] * (1 - o) + t[a] * o;
    return r;
  };
}
function FP(n) {
  return ArrayBuffer.isView(n) && !(n instanceof DataView);
}
function HP(n, t) {
  var e = t ? t.length : 0, r = n ? Math.min(e, n.length) : 0, a = new Array(r), o = new Array(e), c;
  for (c = 0; c < r; ++c) a[c] = Tc(n[c], t[c]);
  for (; c < e; ++c) o[c] = t[c];
  return function(u) {
    for (c = 0; c < r; ++c) o[c] = a[c](u);
    return o;
  };
}
function VP(n, t) {
  var e = /* @__PURE__ */ new Date();
  return n = +n, t = +t, function(r) {
    return e.setTime(n * (1 - r) + t * r), e;
  };
}
function cr(n, t) {
  return n = +n, t = +t, function(e) {
    return n * (1 - e) + t * e;
  };
}
function kP(n, t) {
  var e = {}, r = {}, a;
  (n === null || typeof n != "object") && (n = {}), (t === null || typeof t != "object") && (t = {});
  for (a in t)
    a in n ? e[a] = Tc(n[a], t[a]) : r[a] = t[a];
  return function(o) {
    for (a in e) r[a] = e[a](o);
    return r;
  };
}
var e0 = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, jm = new RegExp(e0.source, "g");
function GP(n) {
  return function() {
    return n;
  };
}
function XP(n) {
  return function(t) {
    return n(t) + "";
  };
}
function rE(n, t) {
  var e = e0.lastIndex = jm.lastIndex = 0, r, a, o, c = -1, u = [], d = [];
  for (n = n + "", t = t + ""; (r = e0.exec(n)) && (a = jm.exec(t)); )
    (o = a.index) > e && (o = t.slice(e, o), u[c] ? u[c] += o : u[++c] = o), (r = r[0]) === (a = a[0]) ? u[c] ? u[c] += a : u[++c] = a : (u[++c] = null, d.push({ i: c, x: cr(r, a) })), e = jm.lastIndex;
  return e < t.length && (o = t.slice(e), u[c] ? u[c] += o : u[++c] = o), u.length < 2 ? d[0] ? XP(d[0].x) : GP(t) : (t = d.length, function(h) {
    for (var p = 0, m; p < t; ++p) u[(m = d[p]).i] = m.x(h);
    return u.join("");
  });
}
function Tc(n, t) {
  var e = typeof t, r;
  return t == null || e === "boolean" ? F0(t) : (e === "number" ? cr : e === "string" ? (r = Ua(t)) ? (t = r, Sd) : rE : t instanceof Ua ? Sd : t instanceof Date ? VP : FP(t) ? BP : Array.isArray(t) ? HP : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? kP : cr)(n, t);
}
var Nb = 180 / Math.PI, n0 = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function sE(n, t, e, r, a, o) {
  var c, u, d;
  return (c = Math.sqrt(n * n + t * t)) && (n /= c, t /= c), (d = n * e + t * r) && (e -= n * d, r -= t * d), (u = Math.sqrt(e * e + r * r)) && (e /= u, r /= u, d /= u), n * r < t * e && (n = -n, t = -t, d = -d, c = -c), {
    translateX: a,
    translateY: o,
    rotate: Math.atan2(t, n) * Nb,
    skewX: Math.atan(d) * Nb,
    scaleX: c,
    scaleY: u
  };
}
var Yf;
function jP(n) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(n + "");
  return t.isIdentity ? n0 : sE(t.a, t.b, t.c, t.d, t.e, t.f);
}
function WP(n) {
  return n == null || (Yf || (Yf = document.createElementNS("http://www.w3.org/2000/svg", "g")), Yf.setAttribute("transform", n), !(n = Yf.transform.baseVal.consolidate())) ? n0 : (n = n.matrix, sE(n.a, n.b, n.c, n.d, n.e, n.f));
}
function aE(n, t, e, r) {
  function a(h) {
    return h.length ? h.pop() + " " : "";
  }
  function o(h, p, m, g, _, b) {
    if (h !== m || p !== g) {
      var E = _.push("translate(", null, t, null, e);
      b.push({ i: E - 4, x: cr(h, m) }, { i: E - 2, x: cr(p, g) });
    } else (m || g) && _.push("translate(" + m + t + g + e);
  }
  function c(h, p, m, g) {
    h !== p ? (h - p > 180 ? p += 360 : p - h > 180 && (h += 360), g.push({ i: m.push(a(m) + "rotate(", null, r) - 2, x: cr(h, p) })) : p && m.push(a(m) + "rotate(" + p + r);
  }
  function u(h, p, m, g) {
    h !== p ? g.push({ i: m.push(a(m) + "skewX(", null, r) - 2, x: cr(h, p) }) : p && m.push(a(m) + "skewX(" + p + r);
  }
  function d(h, p, m, g, _, b) {
    if (h !== m || p !== g) {
      var E = _.push(a(_) + "scale(", null, ",", null, ")");
      b.push({ i: E - 4, x: cr(h, m) }, { i: E - 2, x: cr(p, g) });
    } else (m !== 1 || g !== 1) && _.push(a(_) + "scale(" + m + "," + g + ")");
  }
  return function(h, p) {
    var m = [], g = [];
    return h = n(h), p = n(p), o(h.translateX, h.translateY, p.translateX, p.translateY, m, g), c(h.rotate, p.rotate, m, g), u(h.skewX, p.skewX, m, g), d(h.scaleX, h.scaleY, p.scaleX, p.scaleY, m, g), h = p = null, function(_) {
      for (var b = -1, E = g.length, S; ++b < E; ) m[(S = g[b]).i] = S.x(_);
      return m.join("");
    };
  };
}
var YP = aE(jP, "px, ", "px)", "deg)"), qP = aE(WP, ", ", ")", ")"), ZP = 1e-12;
function Lb(n) {
  return ((n = Math.exp(n)) + 1 / n) / 2;
}
function $P(n) {
  return ((n = Math.exp(n)) - 1 / n) / 2;
}
function KP(n) {
  return ((n = Math.exp(2 * n)) - 1) / (n + 1);
}
const od = (function n(t, e, r) {
  function a(o, c) {
    var u = o[0], d = o[1], h = o[2], p = c[0], m = c[1], g = c[2], _ = p - u, b = m - d, E = _ * _ + b * b, S, y;
    if (E < ZP)
      y = Math.log(g / h) / t, S = function(N) {
        return [
          u + N * _,
          d + N * b,
          h * Math.exp(t * N * y)
        ];
      };
    else {
      var A = Math.sqrt(E), w = (g * g - h * h + r * E) / (2 * h * e * A), M = (g * g - h * h - r * E) / (2 * g * e * A), O = Math.log(Math.sqrt(w * w + 1) - w), L = Math.log(Math.sqrt(M * M + 1) - M);
      y = (L - O) / t, S = function(N) {
        var z = N * y, R = Lb(O), T = h / (e * A) * (R * KP(t * z + O) - $P(O));
        return [
          u + T * _,
          d + T * b,
          h * R / Lb(t * z + O)
        ];
      };
    }
    return S.duration = y * 1e3 * t / Math.SQRT2, S;
  }
  return a.rho = function(o) {
    var c = Math.max(1e-3, +o), u = c * c, d = u * u;
    return n(c, u, d);
  }, a;
})(Math.SQRT2, 2, 4);
var ll = 0, bc = 0, vc = 0, oE = 1e3, bd, Mc, Md = 0, Oa = 0, Id = 0, Pc = typeof performance == "object" && performance.now ? performance : Date, lE = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(n) {
  setTimeout(n, 17);
};
function H0() {
  return Oa || (lE(QP), Oa = Pc.now() + Id);
}
function QP() {
  Oa = 0;
}
function Ed() {
  this._call = this._time = this._next = null;
}
Ed.prototype = cE.prototype = {
  constructor: Ed,
  restart: function(n, t, e) {
    if (typeof n != "function") throw new TypeError("callback is not a function");
    e = (e == null ? H0() : +e) + (t == null ? 0 : +t), !this._next && Mc !== this && (Mc ? Mc._next = this : bd = this, Mc = this), this._call = n, this._time = e, i0();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, i0());
  }
};
function cE(n, t, e) {
  var r = new Ed();
  return r.restart(n, t, e), r;
}
function JP() {
  H0(), ++ll;
  for (var n = bd, t; n; )
    (t = Oa - n._time) >= 0 && n._call.call(void 0, t), n = n._next;
  --ll;
}
function Ub() {
  Oa = (Md = Pc.now()) + Id, ll = bc = 0;
  try {
    JP();
  } finally {
    ll = 0, ez(), Oa = 0;
  }
}
function tz() {
  var n = Pc.now(), t = n - Md;
  t > oE && (Id -= t, Md = n);
}
function ez() {
  for (var n, t = bd, e, r = 1 / 0; t; )
    t._call ? (r > t._time && (r = t._time), n = t, t = t._next) : (e = t._next, t._next = null, t = n ? n._next = e : bd = e);
  Mc = n, i0(r);
}
function i0(n) {
  if (!ll) {
    bc && (bc = clearTimeout(bc));
    var t = n - Oa;
    t > 24 ? (n < 1 / 0 && (bc = setTimeout(Ub, n - Pc.now() - Id)), vc && (vc = clearInterval(vc))) : (vc || (Md = Pc.now(), vc = setInterval(tz, oE)), ll = 1, lE(Ub));
  }
}
function Ob(n, t, e) {
  var r = new Ed();
  return t = t == null ? 0 : +t, r.restart((a) => {
    r.stop(), n(a + t);
  }, t, e), r;
}
var nz = Pd("start", "end", "cancel", "interrupt"), iz = [], uE = 0, Pb = 1, r0 = 2, ld = 3, zb = 4, s0 = 5, cd = 6;
function Bd(n, t, e, r, a, o) {
  var c = n.__transition;
  if (!c) n.__transition = {};
  else if (e in c) return;
  rz(n, e, {
    name: t,
    index: r,
    // For context during callback.
    group: a,
    // For context during callback.
    on: nz,
    tween: iz,
    time: o.time,
    delay: o.delay,
    duration: o.duration,
    ease: o.ease,
    timer: null,
    state: uE
  });
}
function V0(n, t) {
  var e = nr(n, t);
  if (e.state > uE) throw new Error("too late; already scheduled");
  return e;
}
function yr(n, t) {
  var e = nr(n, t);
  if (e.state > ld) throw new Error("too late; already running");
  return e;
}
function nr(n, t) {
  var e = n.__transition;
  if (!e || !(e = e[t])) throw new Error("transition not found");
  return e;
}
function rz(n, t, e) {
  var r = n.__transition, a;
  r[t] = e, e.timer = cE(o, 0, e.time);
  function o(h) {
    e.state = Pb, e.timer.restart(c, e.delay, e.time), e.delay <= h && c(h - e.delay);
  }
  function c(h) {
    var p, m, g, _;
    if (e.state !== Pb) return d();
    for (p in r)
      if (_ = r[p], _.name === e.name) {
        if (_.state === ld) return Ob(c);
        _.state === zb ? (_.state = cd, _.timer.stop(), _.on.call("interrupt", n, n.__data__, _.index, _.group), delete r[p]) : +p < t && (_.state = cd, _.timer.stop(), _.on.call("cancel", n, n.__data__, _.index, _.group), delete r[p]);
      }
    if (Ob(function() {
      e.state === ld && (e.state = zb, e.timer.restart(u, e.delay, e.time), u(h));
    }), e.state = r0, e.on.call("start", n, n.__data__, e.index, e.group), e.state === r0) {
      for (e.state = ld, a = new Array(g = e.tween.length), p = 0, m = -1; p < g; ++p)
        (_ = e.tween[p].value.call(n, n.__data__, e.index, e.group)) && (a[++m] = _);
      a.length = m + 1;
    }
  }
  function u(h) {
    for (var p = h < e.duration ? e.ease.call(null, h / e.duration) : (e.timer.restart(d), e.state = s0, 1), m = -1, g = a.length; ++m < g; )
      a[m].call(n, p);
    e.state === s0 && (e.on.call("end", n, n.__data__, e.index, e.group), d());
  }
  function d() {
    e.state = cd, e.timer.stop(), delete r[t];
    for (var h in r) return;
    delete n.__transition;
  }
}
function ud(n, t) {
  var e = n.__transition, r, a, o = !0, c;
  if (e) {
    t = t == null ? null : t + "";
    for (c in e) {
      if ((r = e[c]).name !== t) {
        o = !1;
        continue;
      }
      a = r.state > r0 && r.state < s0, r.state = cd, r.timer.stop(), r.on.call(a ? "interrupt" : "cancel", n, n.__data__, r.index, r.group), delete e[c];
    }
    o && delete n.__transition;
  }
}
function sz(n) {
  return this.each(function() {
    ud(this, n);
  });
}
function az(n, t) {
  var e, r;
  return function() {
    var a = yr(this, n), o = a.tween;
    if (o !== e) {
      r = e = o;
      for (var c = 0, u = r.length; c < u; ++c)
        if (r[c].name === t) {
          r = r.slice(), r.splice(c, 1);
          break;
        }
    }
    a.tween = r;
  };
}
function oz(n, t, e) {
  var r, a;
  if (typeof e != "function") throw new Error();
  return function() {
    var o = yr(this, n), c = o.tween;
    if (c !== r) {
      a = (r = c).slice();
      for (var u = { name: t, value: e }, d = 0, h = a.length; d < h; ++d)
        if (a[d].name === t) {
          a[d] = u;
          break;
        }
      d === h && a.push(u);
    }
    o.tween = a;
  };
}
function lz(n, t) {
  var e = this._id;
  if (n += "", arguments.length < 2) {
    for (var r = nr(this.node(), e).tween, a = 0, o = r.length, c; a < o; ++a)
      if ((c = r[a]).name === n)
        return c.value;
    return null;
  }
  return this.each((t == null ? az : oz)(e, n, t));
}
function k0(n, t, e) {
  var r = n._id;
  return n.each(function() {
    var a = yr(this, r);
    (a.value || (a.value = {}))[t] = e.apply(this, arguments);
  }), function(a) {
    return nr(a, r).value[t];
  };
}
function fE(n, t) {
  var e;
  return (typeof t == "number" ? cr : t instanceof Ua ? Sd : (e = Ua(t)) ? (t = e, Sd) : rE)(n, t);
}
function cz(n) {
  return function() {
    this.removeAttribute(n);
  };
}
function uz(n) {
  return function() {
    this.removeAttributeNS(n.space, n.local);
  };
}
function fz(n, t, e) {
  var r, a = e + "", o;
  return function() {
    var c = this.getAttribute(n);
    return c === a ? null : c === r ? o : o = t(r = c, e);
  };
}
function dz(n, t, e) {
  var r, a = e + "", o;
  return function() {
    var c = this.getAttributeNS(n.space, n.local);
    return c === a ? null : c === r ? o : o = t(r = c, e);
  };
}
function hz(n, t, e) {
  var r, a, o;
  return function() {
    var c, u = e(this), d;
    return u == null ? void this.removeAttribute(n) : (c = this.getAttribute(n), d = u + "", c === d ? null : c === r && d === a ? o : (a = d, o = t(r = c, u)));
  };
}
function pz(n, t, e) {
  var r, a, o;
  return function() {
    var c, u = e(this), d;
    return u == null ? void this.removeAttributeNS(n.space, n.local) : (c = this.getAttributeNS(n.space, n.local), d = u + "", c === d ? null : c === r && d === a ? o : (a = d, o = t(r = c, u)));
  };
}
function mz(n, t) {
  var e = zd(n), r = e === "transform" ? qP : fE;
  return this.attrTween(n, typeof t == "function" ? (e.local ? pz : hz)(e, r, k0(this, "attr." + n, t)) : t == null ? (e.local ? uz : cz)(e) : (e.local ? dz : fz)(e, r, t));
}
function gz(n, t) {
  return function(e) {
    this.setAttribute(n, t.call(this, e));
  };
}
function vz(n, t) {
  return function(e) {
    this.setAttributeNS(n.space, n.local, t.call(this, e));
  };
}
function _z(n, t) {
  var e, r;
  function a() {
    var o = t.apply(this, arguments);
    return o !== r && (e = (r = o) && vz(n, o)), e;
  }
  return a._value = t, a;
}
function yz(n, t) {
  var e, r;
  function a() {
    var o = t.apply(this, arguments);
    return o !== r && (e = (r = o) && gz(n, o)), e;
  }
  return a._value = t, a;
}
function xz(n, t) {
  var e = "attr." + n;
  if (arguments.length < 2) return (e = this.tween(e)) && e._value;
  if (t == null) return this.tween(e, null);
  if (typeof t != "function") throw new Error();
  var r = zd(n);
  return this.tween(e, (r.local ? _z : yz)(r, t));
}
function Sz(n, t) {
  return function() {
    V0(this, n).delay = +t.apply(this, arguments);
  };
}
function bz(n, t) {
  return t = +t, function() {
    V0(this, n).delay = t;
  };
}
function Mz(n) {
  var t = this._id;
  return arguments.length ? this.each((typeof n == "function" ? Sz : bz)(t, n)) : nr(this.node(), t).delay;
}
function Ez(n, t) {
  return function() {
    yr(this, n).duration = +t.apply(this, arguments);
  };
}
function wz(n, t) {
  return t = +t, function() {
    yr(this, n).duration = t;
  };
}
function Tz(n) {
  var t = this._id;
  return arguments.length ? this.each((typeof n == "function" ? Ez : wz)(t, n)) : nr(this.node(), t).duration;
}
function Az(n, t) {
  if (typeof t != "function") throw new Error();
  return function() {
    yr(this, n).ease = t;
  };
}
function Cz(n) {
  var t = this._id;
  return arguments.length ? this.each(Az(t, n)) : nr(this.node(), t).ease;
}
function Rz(n, t) {
  return function() {
    var e = t.apply(this, arguments);
    if (typeof e != "function") throw new Error();
    yr(this, n).ease = e;
  };
}
function Dz(n) {
  if (typeof n != "function") throw new Error();
  return this.each(Rz(this._id, n));
}
function Nz(n) {
  typeof n != "function" && (n = kM(n));
  for (var t = this._groups, e = t.length, r = new Array(e), a = 0; a < e; ++a)
    for (var o = t[a], c = o.length, u = r[a] = [], d, h = 0; h < c; ++h)
      (d = o[h]) && n.call(d, d.__data__, h, o) && u.push(d);
  return new ns(r, this._parents, this._name, this._id);
}
function Lz(n) {
  if (n._id !== this._id) throw new Error();
  for (var t = this._groups, e = n._groups, r = t.length, a = e.length, o = Math.min(r, a), c = new Array(r), u = 0; u < o; ++u)
    for (var d = t[u], h = e[u], p = d.length, m = c[u] = new Array(p), g, _ = 0; _ < p; ++_)
      (g = d[_] || h[_]) && (m[_] = g);
  for (; u < r; ++u)
    c[u] = t[u];
  return new ns(c, this._parents, this._name, this._id);
}
function Uz(n) {
  return (n + "").trim().split(/^|\s+/).every(function(t) {
    var e = t.indexOf(".");
    return e >= 0 && (t = t.slice(0, e)), !t || t === "start";
  });
}
function Oz(n, t, e) {
  var r, a, o = Uz(t) ? V0 : yr;
  return function() {
    var c = o(this, n), u = c.on;
    u !== r && (a = (r = u).copy()).on(t, e), c.on = a;
  };
}
function Pz(n, t) {
  var e = this._id;
  return arguments.length < 2 ? nr(this.node(), e).on.on(n) : this.each(Oz(e, n, t));
}
function zz(n) {
  return function() {
    var t = this.parentNode;
    for (var e in this.__transition) if (+e !== n) return;
    t && t.removeChild(this);
  };
}
function Iz() {
  return this.on("end.remove", zz(this._id));
}
function Bz(n) {
  var t = this._name, e = this._id;
  typeof n != "function" && (n = z0(n));
  for (var r = this._groups, a = r.length, o = new Array(a), c = 0; c < a; ++c)
    for (var u = r[c], d = u.length, h = o[c] = new Array(d), p, m, g = 0; g < d; ++g)
      (p = u[g]) && (m = n.call(p, p.__data__, g, u)) && ("__data__" in p && (m.__data__ = p.__data__), h[g] = m, Bd(h[g], t, e, g, h, nr(p, e)));
  return new ns(o, this._parents, t, e);
}
function Fz(n) {
  var t = this._name, e = this._id;
  typeof n != "function" && (n = VM(n));
  for (var r = this._groups, a = r.length, o = [], c = [], u = 0; u < a; ++u)
    for (var d = r[u], h = d.length, p, m = 0; m < h; ++m)
      if (p = d[m]) {
        for (var g = n.call(p, p.__data__, m, d), _, b = nr(p, e), E = 0, S = g.length; E < S; ++E)
          (_ = g[E]) && Bd(_, t, e, E, g, b);
        o.push(g), c.push(p);
      }
  return new ns(o, c, t, e);
}
var Hz = Yc.prototype.constructor;
function Vz() {
  return new Hz(this._groups, this._parents);
}
function kz(n, t) {
  var e, r, a;
  return function() {
    var o = ol(this, n), c = (this.style.removeProperty(n), ol(this, n));
    return o === c ? null : o === e && c === r ? a : a = t(e = o, r = c);
  };
}
function dE(n) {
  return function() {
    this.style.removeProperty(n);
  };
}
function Gz(n, t, e) {
  var r, a = e + "", o;
  return function() {
    var c = ol(this, n);
    return c === a ? null : c === r ? o : o = t(r = c, e);
  };
}
function Xz(n, t, e) {
  var r, a, o;
  return function() {
    var c = ol(this, n), u = e(this), d = u + "";
    return u == null && (d = u = (this.style.removeProperty(n), ol(this, n))), c === d ? null : c === r && d === a ? o : (a = d, o = t(r = c, u));
  };
}
function jz(n, t) {
  var e, r, a, o = "style." + t, c = "end." + o, u;
  return function() {
    var d = yr(this, n), h = d.on, p = d.value[o] == null ? u || (u = dE(t)) : void 0;
    (h !== e || a !== p) && (r = (e = h).copy()).on(c, a = p), d.on = r;
  };
}
function Wz(n, t, e) {
  var r = (n += "") == "transform" ? YP : fE;
  return t == null ? this.styleTween(n, kz(n, r)).on("end.style." + n, dE(n)) : typeof t == "function" ? this.styleTween(n, Xz(n, r, k0(this, "style." + n, t))).each(jz(this._id, n)) : this.styleTween(n, Gz(n, r, t), e).on("end.style." + n, null);
}
function Yz(n, t, e) {
  return function(r) {
    this.style.setProperty(n, t.call(this, r), e);
  };
}
function qz(n, t, e) {
  var r, a;
  function o() {
    var c = t.apply(this, arguments);
    return c !== a && (r = (a = c) && Yz(n, c, e)), r;
  }
  return o._value = t, o;
}
function Zz(n, t, e) {
  var r = "style." + (n += "");
  if (arguments.length < 2) return (r = this.tween(r)) && r._value;
  if (t == null) return this.tween(r, null);
  if (typeof t != "function") throw new Error();
  return this.tween(r, qz(n, t, e ?? ""));
}
function $z(n) {
  return function() {
    this.textContent = n;
  };
}
function Kz(n) {
  return function() {
    var t = n(this);
    this.textContent = t ?? "";
  };
}
function Qz(n) {
  return this.tween("text", typeof n == "function" ? Kz(k0(this, "text", n)) : $z(n == null ? "" : n + ""));
}
function Jz(n) {
  return function(t) {
    this.textContent = n.call(this, t);
  };
}
function tI(n) {
  var t, e;
  function r() {
    var a = n.apply(this, arguments);
    return a !== e && (t = (e = a) && Jz(a)), t;
  }
  return r._value = n, r;
}
function eI(n) {
  var t = "text";
  if (arguments.length < 1) return (t = this.tween(t)) && t._value;
  if (n == null) return this.tween(t, null);
  if (typeof n != "function") throw new Error();
  return this.tween(t, tI(n));
}
function nI() {
  for (var n = this._name, t = this._id, e = hE(), r = this._groups, a = r.length, o = 0; o < a; ++o)
    for (var c = r[o], u = c.length, d, h = 0; h < u; ++h)
      if (d = c[h]) {
        var p = nr(d, t);
        Bd(d, n, e, h, c, {
          time: p.time + p.delay + p.duration,
          delay: 0,
          duration: p.duration,
          ease: p.ease
        });
      }
  return new ns(r, this._parents, n, e);
}
function iI() {
  var n, t, e = this, r = e._id, a = e.size();
  return new Promise(function(o, c) {
    var u = { value: c }, d = { value: function() {
      --a === 0 && o();
    } };
    e.each(function() {
      var h = yr(this, r), p = h.on;
      p !== n && (t = (n = p).copy(), t._.cancel.push(u), t._.interrupt.push(u), t._.end.push(d)), h.on = t;
    }), a === 0 && o();
  });
}
var rI = 0;
function ns(n, t, e, r) {
  this._groups = n, this._parents = t, this._name = e, this._id = r;
}
function hE() {
  return ++rI;
}
var Wr = Yc.prototype;
ns.prototype = {
  constructor: ns,
  select: Bz,
  selectAll: Fz,
  selectChild: Wr.selectChild,
  selectChildren: Wr.selectChildren,
  filter: Nz,
  merge: Lz,
  selection: Vz,
  transition: nI,
  call: Wr.call,
  nodes: Wr.nodes,
  node: Wr.node,
  size: Wr.size,
  empty: Wr.empty,
  each: Wr.each,
  on: Pz,
  attr: mz,
  attrTween: xz,
  style: Wz,
  styleTween: Zz,
  text: Qz,
  textTween: eI,
  remove: Iz,
  tween: lz,
  delay: Mz,
  duration: Tz,
  ease: Cz,
  easeVarying: Dz,
  end: iI,
  [Symbol.iterator]: Wr[Symbol.iterator]
};
function sI(n) {
  return ((n *= 2) <= 1 ? n * n * n : (n -= 2) * n * n + 2) / 2;
}
var aI = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: sI
};
function oI(n, t) {
  for (var e; !(e = n.__transition) || !(e = e[t]); )
    if (!(n = n.parentNode))
      throw new Error(`transition ${t} not found`);
  return e;
}
function lI(n) {
  var t, e;
  n instanceof ns ? (t = n._id, n = n._name) : (t = hE(), (e = aI).time = H0(), n = n == null ? null : n + "");
  for (var r = this._groups, a = r.length, o = 0; o < a; ++o)
    for (var c = r[o], u = c.length, d, h = 0; h < u; ++h)
      (d = c[h]) && Bd(d, n, t, h, c, e || oI(d, t));
  return new ns(r, this._parents, n, t);
}
Yc.prototype.interrupt = sz;
Yc.prototype.transition = lI;
const qf = (n) => () => n;
function cI(n, {
  sourceEvent: t,
  target: e,
  transform: r,
  dispatch: a
}) {
  Object.defineProperties(this, {
    type: { value: n, enumerable: !0, configurable: !0 },
    sourceEvent: { value: t, enumerable: !0, configurable: !0 },
    target: { value: e, enumerable: !0, configurable: !0 },
    transform: { value: r, enumerable: !0, configurable: !0 },
    _: { value: a }
  });
}
function Kr(n, t, e) {
  this.k = n, this.x = t, this.y = e;
}
Kr.prototype = {
  constructor: Kr,
  scale: function(n) {
    return n === 1 ? this : new Kr(this.k * n, this.x, this.y);
  },
  translate: function(n, t) {
    return n === 0 & t === 0 ? this : new Kr(this.k, this.x + this.k * n, this.y + this.k * t);
  },
  apply: function(n) {
    return [n[0] * this.k + this.x, n[1] * this.k + this.y];
  },
  applyX: function(n) {
    return n * this.k + this.x;
  },
  applyY: function(n) {
    return n * this.k + this.y;
  },
  invert: function(n) {
    return [(n[0] - this.x) / this.k, (n[1] - this.y) / this.k];
  },
  invertX: function(n) {
    return (n - this.x) / this.k;
  },
  invertY: function(n) {
    return (n - this.y) / this.k;
  },
  rescaleX: function(n) {
    return n.copy().domain(n.range().map(this.invertX, this).map(n.invert, n));
  },
  rescaleY: function(n) {
    return n.copy().domain(n.range().map(this.invertY, this).map(n.invert, n));
  },
  toString: function() {
    return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
  }
};
var Fd = new Kr(1, 0, 0);
pE.prototype = Kr.prototype;
function pE(n) {
  for (; !n.__zoom; ) if (!(n = n.parentNode)) return Fd;
  return n.__zoom;
}
function Wm(n) {
  n.stopImmediatePropagation();
}
function _c(n) {
  n.preventDefault(), n.stopImmediatePropagation();
}
function uI(n) {
  return (!n.ctrlKey || n.type === "wheel") && !n.button;
}
function fI() {
  var n = this;
  return n instanceof SVGElement ? (n = n.ownerSVGElement || n, n.hasAttribute("viewBox") ? (n = n.viewBox.baseVal, [[n.x, n.y], [n.x + n.width, n.y + n.height]]) : [[0, 0], [n.width.baseVal.value, n.height.baseVal.value]]) : [[0, 0], [n.clientWidth, n.clientHeight]];
}
function Ib() {
  return this.__zoom || Fd;
}
function dI(n) {
  return -n.deltaY * (n.deltaMode === 1 ? 0.05 : n.deltaMode ? 1 : 2e-3) * (n.ctrlKey ? 10 : 1);
}
function hI() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function pI(n, t, e) {
  var r = n.invertX(t[0][0]) - e[0][0], a = n.invertX(t[1][0]) - e[1][0], o = n.invertY(t[0][1]) - e[0][1], c = n.invertY(t[1][1]) - e[1][1];
  return n.translate(
    a > r ? (r + a) / 2 : Math.min(0, r) || Math.max(0, a),
    c > o ? (o + c) / 2 : Math.min(0, o) || Math.max(0, c)
  );
}
function mE() {
  var n = uI, t = fI, e = pI, r = dI, a = hI, o = [0, 1 / 0], c = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], u = 250, d = od, h = Pd("start", "zoom", "end"), p, m, g, _ = 500, b = 150, E = 0, S = 10;
  function y(C) {
    C.property("__zoom", Ib).on("wheel.zoom", z, { passive: !1 }).on("mousedown.zoom", R).on("dblclick.zoom", T).filter(a).on("touchstart.zoom", U).on("touchmove.zoom", B).on("touchend.zoom touchcancel.zoom", I).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  y.transform = function(C, X, D, V) {
    var H = C.selection ? C.selection() : C;
    H.property("__zoom", Ib), C !== H ? O(C, X, D, V) : H.interrupt().each(function() {
      L(this, arguments).event(V).start().zoom(null, typeof X == "function" ? X.apply(this, arguments) : X).end();
    });
  }, y.scaleBy = function(C, X, D, V) {
    y.scaleTo(C, function() {
      var H = this.__zoom.k, j = typeof X == "function" ? X.apply(this, arguments) : X;
      return H * j;
    }, D, V);
  }, y.scaleTo = function(C, X, D, V) {
    y.transform(C, function() {
      var H = t.apply(this, arguments), j = this.__zoom, K = D == null ? M(H) : typeof D == "function" ? D.apply(this, arguments) : D, F = j.invert(K), q = typeof X == "function" ? X.apply(this, arguments) : X;
      return e(w(A(j, q), K, F), H, c);
    }, D, V);
  }, y.translateBy = function(C, X, D, V) {
    y.transform(C, function() {
      return e(this.__zoom.translate(
        typeof X == "function" ? X.apply(this, arguments) : X,
        typeof D == "function" ? D.apply(this, arguments) : D
      ), t.apply(this, arguments), c);
    }, null, V);
  }, y.translateTo = function(C, X, D, V, H) {
    y.transform(C, function() {
      var j = t.apply(this, arguments), K = this.__zoom, F = V == null ? M(j) : typeof V == "function" ? V.apply(this, arguments) : V;
      return e(Fd.translate(F[0], F[1]).scale(K.k).translate(
        typeof X == "function" ? -X.apply(this, arguments) : -X,
        typeof D == "function" ? -D.apply(this, arguments) : -D
      ), j, c);
    }, V, H);
  };
  function A(C, X) {
    return X = Math.max(o[0], Math.min(o[1], X)), X === C.k ? C : new Kr(X, C.x, C.y);
  }
  function w(C, X, D) {
    var V = X[0] - D[0] * C.k, H = X[1] - D[1] * C.k;
    return V === C.x && H === C.y ? C : new Kr(C.k, V, H);
  }
  function M(C) {
    return [(+C[0][0] + +C[1][0]) / 2, (+C[0][1] + +C[1][1]) / 2];
  }
  function O(C, X, D, V) {
    C.on("start.zoom", function() {
      L(this, arguments).event(V).start();
    }).on("interrupt.zoom end.zoom", function() {
      L(this, arguments).event(V).end();
    }).tween("zoom", function() {
      var H = this, j = arguments, K = L(H, j).event(V), F = t.apply(H, j), q = D == null ? M(F) : typeof D == "function" ? D.apply(H, j) : D, it = Math.max(F[1][0] - F[0][0], F[1][1] - F[0][1]), G = H.__zoom, k = typeof X == "function" ? X.apply(H, j) : X, $ = d(G.invert(q).concat(it / G.k), k.invert(q).concat(it / k.k));
      return function(Q) {
        if (Q === 1) Q = k;
        else {
          var et = $(Q), st = it / et[2];
          Q = new Kr(st, q[0] - et[0] * st, q[1] - et[1] * st);
        }
        K.zoom(null, Q);
      };
    });
  }
  function L(C, X, D) {
    return !D && C.__zooming || new N(C, X);
  }
  function N(C, X) {
    this.that = C, this.args = X, this.active = 0, this.sourceEvent = null, this.extent = t.apply(C, X), this.taps = 0;
  }
  N.prototype = {
    event: function(C) {
      return C && (this.sourceEvent = C), this;
    },
    start: function() {
      return ++this.active === 1 && (this.that.__zooming = this, this.emit("start")), this;
    },
    zoom: function(C, X) {
      return this.mouse && C !== "mouse" && (this.mouse[1] = X.invert(this.mouse[0])), this.touch0 && C !== "touch" && (this.touch0[1] = X.invert(this.touch0[0])), this.touch1 && C !== "touch" && (this.touch1[1] = X.invert(this.touch1[0])), this.that.__zoom = X, this.emit("zoom"), this;
    },
    end: function() {
      return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
    },
    emit: function(C) {
      var X = Ai(this.that).datum();
      h.call(
        C,
        this.that,
        new cI(C, {
          sourceEvent: this.sourceEvent,
          target: y,
          transform: this.that.__zoom,
          dispatch: h
        }),
        X
      );
    }
  };
  function z(C, ...X) {
    if (!n.apply(this, arguments)) return;
    var D = L(this, X).event(C), V = this.__zoom, H = Math.max(o[0], Math.min(o[1], V.k * Math.pow(2, r.apply(this, arguments)))), j = $i(C);
    if (D.wheel)
      (D.mouse[0][0] !== j[0] || D.mouse[0][1] !== j[1]) && (D.mouse[1] = V.invert(D.mouse[0] = j)), clearTimeout(D.wheel);
    else {
      if (V.k === H) return;
      D.mouse = [j, V.invert(j)], ud(this), D.start();
    }
    _c(C), D.wheel = setTimeout(K, b), D.zoom("mouse", e(w(A(V, H), D.mouse[0], D.mouse[1]), D.extent, c));
    function K() {
      D.wheel = null, D.end();
    }
  }
  function R(C, ...X) {
    if (g || !n.apply(this, arguments)) return;
    var D = C.currentTarget, V = L(this, X, !0).event(C), H = Ai(C.view).on("mousemove.zoom", q, !0).on("mouseup.zoom", it, !0), j = $i(C, D), K = C.clientX, F = C.clientY;
    QM(C.view), Wm(C), V.mouse = [j, this.__zoom.invert(j)], ud(this), V.start();
    function q(G) {
      if (_c(G), !V.moved) {
        var k = G.clientX - K, $ = G.clientY - F;
        V.moved = k * k + $ * $ > E;
      }
      V.event(G).zoom("mouse", e(w(V.that.__zoom, V.mouse[0] = $i(G, D), V.mouse[1]), V.extent, c));
    }
    function it(G) {
      H.on("mousemove.zoom mouseup.zoom", null), JM(G.view, V.moved), _c(G), V.event(G).end();
    }
  }
  function T(C, ...X) {
    if (n.apply(this, arguments)) {
      var D = this.__zoom, V = $i(C.changedTouches ? C.changedTouches[0] : C, this), H = D.invert(V), j = D.k * (C.shiftKey ? 0.5 : 2), K = e(w(A(D, j), V, H), t.apply(this, X), c);
      _c(C), u > 0 ? Ai(this).transition().duration(u).call(O, K, V, C) : Ai(this).call(y.transform, K, V, C);
    }
  }
  function U(C, ...X) {
    if (n.apply(this, arguments)) {
      var D = C.touches, V = D.length, H = L(this, X, C.changedTouches.length === V).event(C), j, K, F, q;
      for (Wm(C), K = 0; K < V; ++K)
        F = D[K], q = $i(F, this), q = [q, this.__zoom.invert(q), F.identifier], H.touch0 ? !H.touch1 && H.touch0[2] !== q[2] && (H.touch1 = q, H.taps = 0) : (H.touch0 = q, j = !0, H.taps = 1 + !!p);
      p && (p = clearTimeout(p)), j && (H.taps < 2 && (m = q[0], p = setTimeout(function() {
        p = null;
      }, _)), ud(this), H.start());
    }
  }
  function B(C, ...X) {
    if (this.__zooming) {
      var D = L(this, X).event(C), V = C.changedTouches, H = V.length, j, K, F, q;
      for (_c(C), j = 0; j < H; ++j)
        K = V[j], F = $i(K, this), D.touch0 && D.touch0[2] === K.identifier ? D.touch0[0] = F : D.touch1 && D.touch1[2] === K.identifier && (D.touch1[0] = F);
      if (K = D.that.__zoom, D.touch1) {
        var it = D.touch0[0], G = D.touch0[1], k = D.touch1[0], $ = D.touch1[1], Q = (Q = k[0] - it[0]) * Q + (Q = k[1] - it[1]) * Q, et = (et = $[0] - G[0]) * et + (et = $[1] - G[1]) * et;
        K = A(K, Math.sqrt(Q / et)), F = [(it[0] + k[0]) / 2, (it[1] + k[1]) / 2], q = [(G[0] + $[0]) / 2, (G[1] + $[1]) / 2];
      } else if (D.touch0) F = D.touch0[0], q = D.touch0[1];
      else return;
      D.zoom("touch", e(w(K, F, q), D.extent, c));
    }
  }
  function I(C, ...X) {
    if (this.__zooming) {
      var D = L(this, X).event(C), V = C.changedTouches, H = V.length, j, K;
      for (Wm(C), g && clearTimeout(g), g = setTimeout(function() {
        g = null;
      }, _), j = 0; j < H; ++j)
        K = V[j], D.touch0 && D.touch0[2] === K.identifier ? delete D.touch0 : D.touch1 && D.touch1[2] === K.identifier && delete D.touch1;
      if (D.touch1 && !D.touch0 && (D.touch0 = D.touch1, delete D.touch1), D.touch0) D.touch0[1] = this.__zoom.invert(D.touch0[0]);
      else if (D.end(), D.taps === 2 && (K = $i(K, this), Math.hypot(m[0] - K[0], m[1] - K[1]) < S)) {
        var F = Ai(this).on("dblclick.zoom");
        F && F.apply(this, arguments);
      }
    }
  }
  return y.wheelDelta = function(C) {
    return arguments.length ? (r = typeof C == "function" ? C : qf(+C), y) : r;
  }, y.filter = function(C) {
    return arguments.length ? (n = typeof C == "function" ? C : qf(!!C), y) : n;
  }, y.touchable = function(C) {
    return arguments.length ? (a = typeof C == "function" ? C : qf(!!C), y) : a;
  }, y.extent = function(C) {
    return arguments.length ? (t = typeof C == "function" ? C : qf([[+C[0][0], +C[0][1]], [+C[1][0], +C[1][1]]]), y) : t;
  }, y.scaleExtent = function(C) {
    return arguments.length ? (o[0] = +C[0], o[1] = +C[1], y) : [o[0], o[1]];
  }, y.translateExtent = function(C) {
    return arguments.length ? (c[0][0] = +C[0][0], c[1][0] = +C[1][0], c[0][1] = +C[0][1], c[1][1] = +C[1][1], y) : [[c[0][0], c[0][1]], [c[1][0], c[1][1]]];
  }, y.constrain = function(C) {
    return arguments.length ? (e = C, y) : e;
  }, y.duration = function(C) {
    return arguments.length ? (u = +C, y) : u;
  }, y.interpolate = function(C) {
    return arguments.length ? (d = C, y) : d;
  }, y.on = function() {
    var C = h.on.apply(h, arguments);
    return C === h ? y : C;
  }, y.clickDistance = function(C) {
    return arguments.length ? (E = (C = +C) * C, y) : Math.sqrt(E);
  }, y.tapDistance = function(C) {
    return arguments.length ? (S = +C, y) : S;
  }, y;
}
const vr = {
  error001: () => "[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",
  error002: () => "It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",
  error003: (n) => `Node type "${n}" not found. Using fallback type "default".`,
  error004: () => "The React Flow parent container needs a width and a height to render the graph.",
  error005: () => "Only child nodes can use a parent extent.",
  error006: () => "Can't create edge. An edge needs a source and a target.",
  error007: (n) => `The old edge with id=${n} does not exist.`,
  error009: (n) => `Marker type "${n}" doesn't exist.`,
  error008: (n, { id: t, sourceHandle: e, targetHandle: r }) => `Couldn't create edge for ${n} handle id: "${n === "source" ? e : r}", edge id: ${t}.`,
  error010: () => "Handle: No node id found. Make sure to only use a Handle inside a custom Node.",
  error011: (n) => `Edge type "${n}" not found. Using fallback type "default".`,
  error012: (n) => `Node with id "${n}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,
  error013: (n = "react") => `It seems that you haven't loaded the styles. Please import '@xyflow/${n}/dist/style.css' or base.css to make sure everything is working properly.`,
  error014: () => "useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",
  error015: () => "It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."
}, zc = [
  [Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
  [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]
], gE = ["Enter", " ", "Escape"], vE = {
  "node.a11yDescription.default": "Press enter or space to select a node. Press delete to remove it and escape to cancel.",
  "node.a11yDescription.keyboardDisabled": "Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.",
  "node.a11yDescription.ariaLiveMessage": ({ direction: n, x: t, y: e }) => `Moved selected node ${n}. New position, x: ${t}, y: ${e}`,
  "edge.a11yDescription.default": "Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.",
  // Control elements
  "controls.ariaLabel": "Control Panel",
  "controls.zoomIn.ariaLabel": "Zoom In",
  "controls.zoomOut.ariaLabel": "Zoom Out",
  "controls.fitView.ariaLabel": "Fit View",
  "controls.interactive.ariaLabel": "Toggle Interactivity",
  // Mini map
  "minimap.ariaLabel": "Mini Map",
  // Handle
  "handle.ariaLabel": "Handle"
};
var cl;
(function(n) {
  n.Strict = "strict", n.Loose = "loose";
})(cl || (cl = {}));
var Da;
(function(n) {
  n.Free = "free", n.Vertical = "vertical", n.Horizontal = "horizontal";
})(Da || (Da = {}));
var Ic;
(function(n) {
  n.Partial = "partial", n.Full = "full";
})(Ic || (Ic = {}));
const _E = {
  inProgress: !1,
  isValid: null,
  from: null,
  fromHandle: null,
  fromPosition: null,
  fromNode: null,
  to: null,
  toHandle: null,
  toPosition: null,
  toNode: null,
  pointer: null
};
var Hs;
(function(n) {
  n.Bezier = "default", n.Straight = "straight", n.Step = "step", n.SmoothStep = "smoothstep", n.SimpleBezier = "simplebezier";
})(Hs || (Hs = {}));
var wd;
(function(n) {
  n.Arrow = "arrow", n.ArrowClosed = "arrowclosed";
})(wd || (wd = {}));
var re;
(function(n) {
  n.Left = "left", n.Top = "top", n.Right = "right", n.Bottom = "bottom";
})(re || (re = {}));
const Bb = {
  [re.Left]: re.Right,
  [re.Right]: re.Left,
  [re.Top]: re.Bottom,
  [re.Bottom]: re.Top
};
function yE(n) {
  return n === null ? null : n ? "valid" : "invalid";
}
const xE = (n) => "id" in n && "source" in n && "target" in n, mI = (n) => "id" in n && "position" in n && !("source" in n) && !("target" in n), G0 = (n) => "id" in n && "internals" in n && !("source" in n) && !("target" in n), Zc = (n, t = [0, 0]) => {
  const { width: e, height: r } = is(n), a = n.origin ?? t, o = e * a[0], c = r * a[1];
  return {
    x: n.position.x - o,
    y: n.position.y - c
  };
}, gI = (n, t = { nodeOrigin: [0, 0] }) => {
  if (n.length === 0)
    return { x: 0, y: 0, width: 0, height: 0 };
  const e = n.reduce((r, a) => {
    const o = typeof a == "string";
    let c = !t.nodeLookup && !o ? a : void 0;
    t.nodeLookup && (c = o ? t.nodeLookup.get(a) : G0(a) ? a : t.nodeLookup.get(a.id));
    const u = c ? Td(c, t.nodeOrigin) : { x: 0, y: 0, x2: 0, y2: 0 };
    return Hd(r, u);
  }, { x: 1 / 0, y: 1 / 0, x2: -1 / 0, y2: -1 / 0 });
  return Vd(e);
}, $c = (n, t = {}) => {
  let e = { x: 1 / 0, y: 1 / 0, x2: -1 / 0, y2: -1 / 0 }, r = !1;
  return n.forEach((a) => {
    (t.filter === void 0 || t.filter(a)) && (e = Hd(e, Td(a)), r = !0);
  }), r ? Vd(e) : { x: 0, y: 0, width: 0, height: 0 };
}, X0 = (n, t, [e, r, a] = [0, 0, 1], o = !1, c = !1) => {
  const u = {
    ...Qc(t, [e, r, a]),
    width: t.width / a,
    height: t.height / a
  }, d = [];
  for (const h of n.values()) {
    const { measured: p, selectable: m = !0, hidden: g = !1 } = h;
    if (c && !m || g)
      continue;
    const _ = p.width ?? h.width ?? h.initialWidth ?? null, b = p.height ?? h.height ?? h.initialHeight ?? null, E = Bc(u, fl(h)), S = (_ ?? 0) * (b ?? 0), y = o && E > 0;
    (!h.internals.handleBounds || y || E >= S || h.dragging) && d.push(h);
  }
  return d;
}, vI = (n, t) => {
  const e = /* @__PURE__ */ new Set();
  return n.forEach((r) => {
    e.add(r.id);
  }), t.filter((r) => e.has(r.source) || e.has(r.target));
};
function _I(n, t) {
  const e = /* @__PURE__ */ new Map(), r = t != null && t.nodes ? new Set(t.nodes.map((a) => a.id)) : null;
  return n.forEach((a) => {
    a.measured.width && a.measured.height && ((t == null ? void 0 : t.includeHiddenNodes) || !a.hidden) && (!r || r.has(a.id)) && e.set(a.id, a);
  }), e;
}
async function yI({ nodes: n, width: t, height: e, panZoom: r, minZoom: a, maxZoom: o }, c) {
  if (n.size === 0)
    return Promise.resolve(!0);
  const u = _I(n, c), d = $c(u), h = j0(d, t, e, (c == null ? void 0 : c.minZoom) ?? a, (c == null ? void 0 : c.maxZoom) ?? o, (c == null ? void 0 : c.padding) ?? 0.1);
  return await r.setViewport(h, {
    duration: c == null ? void 0 : c.duration,
    ease: c == null ? void 0 : c.ease,
    interpolate: c == null ? void 0 : c.interpolate
  }), Promise.resolve(!0);
}
function SE({ nodeId: n, nextPosition: t, nodeLookup: e, nodeOrigin: r = [0, 0], nodeExtent: a, onError: o }) {
  const c = e.get(n), u = c.parentId ? e.get(c.parentId) : void 0, { x: d, y: h } = u ? u.internals.positionAbsolute : { x: 0, y: 0 }, p = c.origin ?? r;
  let m = c.extent || a;
  if (c.extent === "parent" && !c.expandParent)
    if (!u)
      o == null || o("005", vr.error005());
    else {
      const _ = u.measured.width, b = u.measured.height;
      _ && b && (m = [
        [d, h],
        [d + _, h + b]
      ]);
    }
  else u && dl(c.extent) && (m = [
    [c.extent[0][0] + d, c.extent[0][1] + h],
    [c.extent[1][0] + d, c.extent[1][1] + h]
  ]);
  const g = dl(m) ? Pa(t, m, c.measured) : t;
  return (c.measured.width === void 0 || c.measured.height === void 0) && (o == null || o("015", vr.error015())), {
    position: {
      x: g.x - d + (c.measured.width ?? 0) * p[0],
      y: g.y - h + (c.measured.height ?? 0) * p[1]
    },
    positionAbsolute: g
  };
}
async function xI({ nodesToRemove: n = [], edgesToRemove: t = [], nodes: e, edges: r, onBeforeDelete: a }) {
  const o = new Set(n.map((g) => g.id)), c = [];
  for (const g of e) {
    if (g.deletable === !1)
      continue;
    const _ = o.has(g.id), b = !_ && g.parentId && c.find((E) => E.id === g.parentId);
    (_ || b) && c.push(g);
  }
  const u = new Set(t.map((g) => g.id)), d = r.filter((g) => g.deletable !== !1), p = vI(c, d);
  for (const g of d)
    u.has(g.id) && !p.find((b) => b.id === g.id) && p.push(g);
  if (!a)
    return {
      edges: p,
      nodes: c
    };
  const m = await a({
    nodes: c,
    edges: p
  });
  return typeof m == "boolean" ? m ? { edges: p, nodes: c } : { edges: [], nodes: [] } : m;
}
const ul = (n, t = 0, e = 1) => Math.min(Math.max(n, t), e), Pa = (n = { x: 0, y: 0 }, t, e) => ({
  x: ul(n.x, t[0][0], t[1][0] - ((e == null ? void 0 : e.width) ?? 0)),
  y: ul(n.y, t[0][1], t[1][1] - ((e == null ? void 0 : e.height) ?? 0))
});
function bE(n, t, e) {
  const { width: r, height: a } = is(e), { x: o, y: c } = e.internals.positionAbsolute;
  return Pa(n, [
    [o, c],
    [o + r, c + a]
  ], t);
}
const Fb = (n, t, e) => n < t ? ul(Math.abs(n - t), 1, t) / t : n > e ? -ul(Math.abs(n - e), 1, t) / t : 0, ME = (n, t, e = 15, r = 40) => {
  const a = Fb(n.x, r, t.width - r) * e, o = Fb(n.y, r, t.height - r) * e;
  return [a, o];
}, Hd = (n, t) => ({
  x: Math.min(n.x, t.x),
  y: Math.min(n.y, t.y),
  x2: Math.max(n.x2, t.x2),
  y2: Math.max(n.y2, t.y2)
}), a0 = ({ x: n, y: t, width: e, height: r }) => ({
  x: n,
  y: t,
  x2: n + e,
  y2: t + r
}), Vd = ({ x: n, y: t, x2: e, y2: r }) => ({
  x: n,
  y: t,
  width: e - n,
  height: r - t
}), fl = (n, t = [0, 0]) => {
  var a, o;
  const { x: e, y: r } = G0(n) ? n.internals.positionAbsolute : Zc(n, t);
  return {
    x: e,
    y: r,
    width: ((a = n.measured) == null ? void 0 : a.width) ?? n.width ?? n.initialWidth ?? 0,
    height: ((o = n.measured) == null ? void 0 : o.height) ?? n.height ?? n.initialHeight ?? 0
  };
}, Td = (n, t = [0, 0]) => {
  var a, o;
  const { x: e, y: r } = G0(n) ? n.internals.positionAbsolute : Zc(n, t);
  return {
    x: e,
    y: r,
    x2: e + (((a = n.measured) == null ? void 0 : a.width) ?? n.width ?? n.initialWidth ?? 0),
    y2: r + (((o = n.measured) == null ? void 0 : o.height) ?? n.height ?? n.initialHeight ?? 0)
  };
}, EE = (n, t) => Vd(Hd(a0(n), a0(t))), Bc = (n, t) => {
  const e = Math.max(0, Math.min(n.x + n.width, t.x + t.width) - Math.max(n.x, t.x)), r = Math.max(0, Math.min(n.y + n.height, t.y + t.height) - Math.max(n.y, t.y));
  return Math.ceil(e * r);
}, Hb = (n) => Ji(n.width) && Ji(n.height) && Ji(n.x) && Ji(n.y), Ji = (n) => !isNaN(n) && isFinite(n), SI = (n, t) => {
}, Kc = (n, t = [1, 1]) => ({
  x: t[0] * Math.round(n.x / t[0]),
  y: t[1] * Math.round(n.y / t[1])
}), Qc = ({ x: n, y: t }, [e, r, a], o = !1, c = [1, 1]) => {
  const u = {
    x: (n - e) / a,
    y: (t - r) / a
  };
  return o ? Kc(u, c) : u;
}, Ad = ({ x: n, y: t }, [e, r, a]) => ({
  x: n * a + e,
  y: t * a + r
});
function Ho(n, t) {
  if (typeof n == "number")
    return Math.floor((t - t / (1 + n)) * 0.5);
  if (typeof n == "string" && n.endsWith("px")) {
    const e = parseFloat(n);
    if (!Number.isNaN(e))
      return Math.floor(e);
  }
  if (typeof n == "string" && n.endsWith("%")) {
    const e = parseFloat(n);
    if (!Number.isNaN(e))
      return Math.floor(t * e * 0.01);
  }
  return console.error(`[React Flow] The padding value "${n}" is invalid. Please provide a number or a string with a valid unit (px or %).`), 0;
}
function bI(n, t, e) {
  if (typeof n == "string" || typeof n == "number") {
    const r = Ho(n, e), a = Ho(n, t);
    return {
      top: r,
      right: a,
      bottom: r,
      left: a,
      x: a * 2,
      y: r * 2
    };
  }
  if (typeof n == "object") {
    const r = Ho(n.top ?? n.y ?? 0, e), a = Ho(n.bottom ?? n.y ?? 0, e), o = Ho(n.left ?? n.x ?? 0, t), c = Ho(n.right ?? n.x ?? 0, t);
    return { top: r, right: c, bottom: a, left: o, x: o + c, y: r + a };
  }
  return { top: 0, right: 0, bottom: 0, left: 0, x: 0, y: 0 };
}
function MI(n, t, e, r, a, o) {
  const { x: c, y: u } = Ad(n, [t, e, r]), { x: d, y: h } = Ad({ x: n.x + n.width, y: n.y + n.height }, [t, e, r]), p = a - d, m = o - h;
  return {
    left: Math.floor(c),
    top: Math.floor(u),
    right: Math.floor(p),
    bottom: Math.floor(m)
  };
}
const j0 = (n, t, e, r, a, o) => {
  const c = bI(o, t, e), u = (t - c.x) / n.width, d = (e - c.y) / n.height, h = Math.min(u, d), p = ul(h, r, a), m = n.x + n.width / 2, g = n.y + n.height / 2, _ = t / 2 - m * p, b = e / 2 - g * p, E = MI(n, _, b, p, t, e), S = {
    left: Math.min(E.left - c.left, 0),
    top: Math.min(E.top - c.top, 0),
    right: Math.min(E.right - c.right, 0),
    bottom: Math.min(E.bottom - c.bottom, 0)
  };
  return {
    x: _ - S.left + S.right,
    y: b - S.top + S.bottom,
    zoom: p
  };
}, Fc = () => {
  var n;
  return typeof navigator < "u" && ((n = navigator == null ? void 0 : navigator.userAgent) == null ? void 0 : n.indexOf("Mac")) >= 0;
};
function dl(n) {
  return n != null && n !== "parent";
}
function is(n) {
  var t, e;
  return {
    width: ((t = n.measured) == null ? void 0 : t.width) ?? n.width ?? n.initialWidth ?? 0,
    height: ((e = n.measured) == null ? void 0 : e.height) ?? n.height ?? n.initialHeight ?? 0
  };
}
function wE(n) {
  var t, e;
  return (((t = n.measured) == null ? void 0 : t.width) ?? n.width ?? n.initialWidth) !== void 0 && (((e = n.measured) == null ? void 0 : e.height) ?? n.height ?? n.initialHeight) !== void 0;
}
function TE(n, t = { width: 0, height: 0 }, e, r, a) {
  const o = { ...n }, c = r.get(e);
  if (c) {
    const u = c.origin || a;
    o.x += c.internals.positionAbsolute.x - (t.width ?? 0) * u[0], o.y += c.internals.positionAbsolute.y - (t.height ?? 0) * u[1];
  }
  return o;
}
function Vb(n, t) {
  if (n.size !== t.size)
    return !1;
  for (const e of n)
    if (!t.has(e))
      return !1;
  return !0;
}
function EI() {
  let n, t;
  return { promise: new Promise((r, a) => {
    n = r, t = a;
  }), resolve: n, reject: t };
}
function wI(n) {
  return { ...vE, ...n || {} };
}
function Ac(n, { snapGrid: t = [0, 0], snapToGrid: e = !1, transform: r, containerBounds: a }) {
  const { x: o, y: c } = tr(n), u = Qc({ x: o - ((a == null ? void 0 : a.left) ?? 0), y: c - ((a == null ? void 0 : a.top) ?? 0) }, r), { x: d, y: h } = e ? Kc(u, t) : u;
  return {
    xSnapped: d,
    ySnapped: h,
    ...u
  };
}
const W0 = (n) => ({
  width: n.offsetWidth,
  height: n.offsetHeight
}), AE = (n) => {
  var t;
  return ((t = n == null ? void 0 : n.getRootNode) == null ? void 0 : t.call(n)) || (window == null ? void 0 : window.document);
}, TI = ["INPUT", "SELECT", "TEXTAREA"];
function CE(n) {
  var r, a;
  const t = ((a = (r = n.composedPath) == null ? void 0 : r.call(n)) == null ? void 0 : a[0]) || n.target;
  return (t == null ? void 0 : t.nodeType) !== 1 ? !1 : TI.includes(t.nodeName) || t.hasAttribute("contenteditable") || !!t.closest(".nokey");
}
const RE = (n) => "clientX" in n, tr = (n, t) => {
  var o, c;
  const e = RE(n), r = e ? n.clientX : (o = n.touches) == null ? void 0 : o[0].clientX, a = e ? n.clientY : (c = n.touches) == null ? void 0 : c[0].clientY;
  return {
    x: r - ((t == null ? void 0 : t.left) ?? 0),
    y: a - ((t == null ? void 0 : t.top) ?? 0)
  };
}, kb = (n, t, e, r, a) => {
  const o = t.querySelectorAll(`.${n}`);
  return !o || !o.length ? null : Array.from(o).map((c) => {
    const u = c.getBoundingClientRect();
    return {
      id: c.getAttribute("data-handleid"),
      type: n,
      nodeId: a,
      position: c.getAttribute("data-handlepos"),
      x: (u.left - e.left) / r,
      y: (u.top - e.top) / r,
      ...W0(c)
    };
  });
};
function DE({ sourceX: n, sourceY: t, targetX: e, targetY: r, sourceControlX: a, sourceControlY: o, targetControlX: c, targetControlY: u }) {
  const d = n * 0.125 + a * 0.375 + c * 0.375 + e * 0.125, h = t * 0.125 + o * 0.375 + u * 0.375 + r * 0.125, p = Math.abs(d - n), m = Math.abs(h - t);
  return [d, h, p, m];
}
function Zf(n, t) {
  return n >= 0 ? 0.5 * n : t * 25 * Math.sqrt(-n);
}
function Gb({ pos: n, x1: t, y1: e, x2: r, y2: a, c: o }) {
  switch (n) {
    case re.Left:
      return [t - Zf(t - r, o), e];
    case re.Right:
      return [t + Zf(r - t, o), e];
    case re.Top:
      return [t, e - Zf(e - a, o)];
    case re.Bottom:
      return [t, e + Zf(a - e, o)];
  }
}
function NE({ sourceX: n, sourceY: t, sourcePosition: e = re.Bottom, targetX: r, targetY: a, targetPosition: o = re.Top, curvature: c = 0.25 }) {
  const [u, d] = Gb({
    pos: e,
    x1: n,
    y1: t,
    x2: r,
    y2: a,
    c
  }), [h, p] = Gb({
    pos: o,
    x1: r,
    y1: a,
    x2: n,
    y2: t,
    c
  }), [m, g, _, b] = DE({
    sourceX: n,
    sourceY: t,
    targetX: r,
    targetY: a,
    sourceControlX: u,
    sourceControlY: d,
    targetControlX: h,
    targetControlY: p
  });
  return [
    `M${n},${t} C${u},${d} ${h},${p} ${r},${a}`,
    m,
    g,
    _,
    b
  ];
}
function LE({ sourceX: n, sourceY: t, targetX: e, targetY: r }) {
  const a = Math.abs(e - n) / 2, o = e < n ? e + a : e - a, c = Math.abs(r - t) / 2, u = r < t ? r + c : r - c;
  return [o, u, a, c];
}
function AI({ sourceNode: n, targetNode: t, selected: e = !1, zIndex: r = 0, elevateOnSelect: a = !1, zIndexMode: o = "basic" }) {
  if (o === "manual")
    return r;
  const c = a && e ? r + 1e3 : r, u = Math.max(n.parentId || a && n.selected ? n.internals.z : 0, t.parentId || a && t.selected ? t.internals.z : 0);
  return c + u;
}
function CI({ sourceNode: n, targetNode: t, width: e, height: r, transform: a }) {
  const o = Hd(Td(n), Td(t));
  o.x === o.x2 && (o.x2 += 1), o.y === o.y2 && (o.y2 += 1);
  const c = {
    x: -a[0] / a[2],
    y: -a[1] / a[2],
    width: e / a[2],
    height: r / a[2]
  };
  return Bc(c, Vd(o)) > 0;
}
const RI = ({ source: n, sourceHandle: t, target: e, targetHandle: r }) => `xy-edge__${n}${t || ""}-${e}${r || ""}`, DI = (n, t) => t.some((e) => e.source === n.source && e.target === n.target && (e.sourceHandle === n.sourceHandle || !e.sourceHandle && !n.sourceHandle) && (e.targetHandle === n.targetHandle || !e.targetHandle && !n.targetHandle)), UE = (n, t, e = {}) => {
  if (!n.source || !n.target)
    return t;
  const r = e.getEdgeId || RI;
  let a;
  return xE(n) ? a = { ...n } : a = {
    ...n,
    id: r(n)
  }, DI(a, t) ? t : (a.sourceHandle === null && delete a.sourceHandle, a.targetHandle === null && delete a.targetHandle, t.concat(a));
};
function OE({ sourceX: n, sourceY: t, targetX: e, targetY: r }) {
  const [a, o, c, u] = LE({
    sourceX: n,
    sourceY: t,
    targetX: e,
    targetY: r
  });
  return [`M ${n},${t}L ${e},${r}`, a, o, c, u];
}
const Xb = {
  [re.Left]: { x: -1, y: 0 },
  [re.Right]: { x: 1, y: 0 },
  [re.Top]: { x: 0, y: -1 },
  [re.Bottom]: { x: 0, y: 1 }
}, NI = ({ source: n, sourcePosition: t = re.Bottom, target: e }) => t === re.Left || t === re.Right ? n.x < e.x ? { x: 1, y: 0 } : { x: -1, y: 0 } : n.y < e.y ? { x: 0, y: 1 } : { x: 0, y: -1 }, jb = (n, t) => Math.sqrt(Math.pow(t.x - n.x, 2) + Math.pow(t.y - n.y, 2));
function LI({ source: n, sourcePosition: t = re.Bottom, target: e, targetPosition: r = re.Top, center: a, offset: o, stepPosition: c }) {
  const u = Xb[t], d = Xb[r], h = { x: n.x + u.x * o, y: n.y + u.y * o }, p = { x: e.x + d.x * o, y: e.y + d.y * o }, m = NI({
    source: h,
    sourcePosition: t,
    target: p
  }), g = m.x !== 0 ? "x" : "y", _ = m[g];
  let b = [], E, S;
  const y = { x: 0, y: 0 }, A = { x: 0, y: 0 }, [, , w, M] = LE({
    sourceX: n.x,
    sourceY: n.y,
    targetX: e.x,
    targetY: e.y
  });
  if (u[g] * d[g] === -1) {
    g === "x" ? (E = a.x ?? h.x + (p.x - h.x) * c, S = a.y ?? (h.y + p.y) / 2) : (E = a.x ?? (h.x + p.x) / 2, S = a.y ?? h.y + (p.y - h.y) * c);
    const L = [
      { x: E, y: h.y },
      { x: E, y: p.y }
    ], N = [
      { x: h.x, y: S },
      { x: p.x, y: S }
    ];
    u[g] === _ ? b = g === "x" ? L : N : b = g === "x" ? N : L;
  } else {
    const L = [{ x: h.x, y: p.y }], N = [{ x: p.x, y: h.y }];
    if (g === "x" ? b = u.x === _ ? N : L : b = u.y === _ ? L : N, t === r) {
      const B = Math.abs(n[g] - e[g]);
      if (B <= o) {
        const I = Math.min(o - 1, o - B);
        u[g] === _ ? y[g] = (h[g] > n[g] ? -1 : 1) * I : A[g] = (p[g] > e[g] ? -1 : 1) * I;
      }
    }
    if (t !== r) {
      const B = g === "x" ? "y" : "x", I = u[g] === d[B], C = h[B] > p[B], X = h[B] < p[B];
      (u[g] === 1 && (!I && C || I && X) || u[g] !== 1 && (!I && X || I && C)) && (b = g === "x" ? L : N);
    }
    const z = { x: h.x + y.x, y: h.y + y.y }, R = { x: p.x + A.x, y: p.y + A.y }, T = Math.max(Math.abs(z.x - b[0].x), Math.abs(R.x - b[0].x)), U = Math.max(Math.abs(z.y - b[0].y), Math.abs(R.y - b[0].y));
    T >= U ? (E = (z.x + R.x) / 2, S = b[0].y) : (E = b[0].x, S = (z.y + R.y) / 2);
  }
  return [[
    n,
    { x: h.x + y.x, y: h.y + y.y },
    ...b,
    { x: p.x + A.x, y: p.y + A.y },
    e
  ], E, S, w, M];
}
function UI(n, t, e, r) {
  const a = Math.min(jb(n, t) / 2, jb(t, e) / 2, r), { x: o, y: c } = t;
  if (n.x === o && o === e.x || n.y === c && c === e.y)
    return `L${o} ${c}`;
  if (n.y === c) {
    const h = n.x < e.x ? -1 : 1, p = n.y < e.y ? 1 : -1;
    return `L ${o + a * h},${c}Q ${o},${c} ${o},${c + a * p}`;
  }
  const u = n.x < e.x ? 1 : -1, d = n.y < e.y ? -1 : 1;
  return `L ${o},${c + a * d}Q ${o},${c} ${o + a * u},${c}`;
}
function o0({ sourceX: n, sourceY: t, sourcePosition: e = re.Bottom, targetX: r, targetY: a, targetPosition: o = re.Top, borderRadius: c = 5, centerX: u, centerY: d, offset: h = 20, stepPosition: p = 0.5 }) {
  const [m, g, _, b, E] = LI({
    source: { x: n, y: t },
    sourcePosition: e,
    target: { x: r, y: a },
    targetPosition: o,
    center: { x: u, y: d },
    offset: h,
    stepPosition: p
  });
  return [m.reduce((y, A, w) => {
    let M = "";
    return w > 0 && w < m.length - 1 ? M = UI(m[w - 1], A, m[w + 1], c) : M = `${w === 0 ? "M" : "L"}${A.x} ${A.y}`, y += M, y;
  }, ""), g, _, b, E];
}
function Wb(n) {
  var t;
  return n && !!(n.internals.handleBounds || (t = n.handles) != null && t.length) && !!(n.measured.width || n.width || n.initialWidth);
}
function OI(n) {
  var m;
  const { sourceNode: t, targetNode: e } = n;
  if (!Wb(t) || !Wb(e))
    return null;
  const r = t.internals.handleBounds || Yb(t.handles), a = e.internals.handleBounds || Yb(e.handles), o = qb((r == null ? void 0 : r.source) ?? [], n.sourceHandle), c = qb(
    // when connection type is loose we can define all handles as sources and connect source -> source
    n.connectionMode === cl.Strict ? (a == null ? void 0 : a.target) ?? [] : ((a == null ? void 0 : a.target) ?? []).concat((a == null ? void 0 : a.source) ?? []),
    n.targetHandle
  );
  if (!o || !c)
    return (m = n.onError) == null || m.call(n, "008", vr.error008(o ? "target" : "source", {
      id: n.id,
      sourceHandle: n.sourceHandle,
      targetHandle: n.targetHandle
    })), null;
  const u = (o == null ? void 0 : o.position) || re.Bottom, d = (c == null ? void 0 : c.position) || re.Top, h = za(t, o, u), p = za(e, c, d);
  return {
    sourceX: h.x,
    sourceY: h.y,
    targetX: p.x,
    targetY: p.y,
    sourcePosition: u,
    targetPosition: d
  };
}
function Yb(n) {
  if (!n)
    return null;
  const t = [], e = [];
  for (const r of n)
    r.width = r.width ?? 1, r.height = r.height ?? 1, r.type === "source" ? t.push(r) : r.type === "target" && e.push(r);
  return {
    source: t,
    target: e
  };
}
function za(n, t, e = re.Left, r = !1) {
  const a = ((t == null ? void 0 : t.x) ?? 0) + n.internals.positionAbsolute.x, o = ((t == null ? void 0 : t.y) ?? 0) + n.internals.positionAbsolute.y, { width: c, height: u } = t ?? is(n);
  if (r)
    return { x: a + c / 2, y: o + u / 2 };
  switch ((t == null ? void 0 : t.position) ?? e) {
    case re.Top:
      return { x: a + c / 2, y: o };
    case re.Right:
      return { x: a + c, y: o + u / 2 };
    case re.Bottom:
      return { x: a + c / 2, y: o + u };
    case re.Left:
      return { x: a, y: o + u / 2 };
  }
}
function qb(n, t) {
  return n && (t ? n.find((e) => e.id === t) : n[0]) || null;
}
function l0(n, t) {
  return n ? typeof n == "string" ? n : `${t ? `${t}__` : ""}${Object.keys(n).sort().map((r) => `${r}=${n[r]}`).join("&")}` : "";
}
function PI(n, { id: t, defaultColor: e, defaultMarkerStart: r, defaultMarkerEnd: a }) {
  const o = /* @__PURE__ */ new Set();
  return n.reduce((c, u) => ([u.markerStart || r, u.markerEnd || a].forEach((d) => {
    if (d && typeof d == "object") {
      const h = l0(d, t);
      o.has(h) || (c.push({ id: h, color: d.color || e, ...d }), o.add(h));
    }
  }), c), []).sort((c, u) => c.id.localeCompare(u.id));
}
const PE = 1e3, zI = 10, Y0 = {
  nodeOrigin: [0, 0],
  nodeExtent: zc,
  elevateNodesOnSelect: !0,
  zIndexMode: "basic",
  defaults: {}
}, II = {
  ...Y0,
  checkEquality: !0
};
function q0(n, t) {
  const e = { ...n };
  for (const r in t)
    t[r] !== void 0 && (e[r] = t[r]);
  return e;
}
function BI(n, t, e) {
  const r = q0(Y0, e);
  for (const a of n.values())
    if (a.parentId)
      $0(a, n, t, r);
    else {
      const o = Zc(a, r.nodeOrigin), c = dl(a.extent) ? a.extent : r.nodeExtent, u = Pa(o, c, is(a));
      a.internals.positionAbsolute = u;
    }
}
function FI(n, t) {
  if (!n.handles)
    return n.measured ? t == null ? void 0 : t.internals.handleBounds : void 0;
  const e = [], r = [];
  for (const a of n.handles) {
    const o = {
      id: a.id,
      width: a.width ?? 1,
      height: a.height ?? 1,
      nodeId: n.id,
      x: a.x,
      y: a.y,
      position: a.position,
      type: a.type
    };
    a.type === "source" ? e.push(o) : a.type === "target" && r.push(o);
  }
  return {
    source: e,
    target: r
  };
}
function Z0(n) {
  return n === "manual";
}
function c0(n, t, e, r = {}) {
  var h, p;
  const a = q0(II, r), o = { i: 0 }, c = new Map(t), u = a != null && a.elevateNodesOnSelect && !Z0(a.zIndexMode) ? PE : 0;
  let d = n.length > 0;
  t.clear(), e.clear();
  for (const m of n) {
    let g = c.get(m.id);
    if (a.checkEquality && m === (g == null ? void 0 : g.internals.userNode))
      t.set(m.id, g);
    else {
      const _ = Zc(m, a.nodeOrigin), b = dl(m.extent) ? m.extent : a.nodeExtent, E = Pa(_, b, is(m));
      g = {
        ...a.defaults,
        ...m,
        measured: {
          width: (h = m.measured) == null ? void 0 : h.width,
          height: (p = m.measured) == null ? void 0 : p.height
        },
        internals: {
          positionAbsolute: E,
          // if user re-initializes the node or removes `measured` for whatever reason, we reset the handleBounds so that the node gets re-measured
          handleBounds: FI(m, g),
          z: zE(m, u, a.zIndexMode),
          userNode: m
        }
      }, t.set(m.id, g);
    }
    (g.measured === void 0 || g.measured.width === void 0 || g.measured.height === void 0) && !g.hidden && (d = !1), m.parentId && $0(g, t, e, r, o);
  }
  return d;
}
function HI(n, t) {
  if (!n.parentId)
    return;
  const e = t.get(n.parentId);
  e ? e.set(n.id, n) : t.set(n.parentId, /* @__PURE__ */ new Map([[n.id, n]]));
}
function $0(n, t, e, r, a) {
  const { elevateNodesOnSelect: o, nodeOrigin: c, nodeExtent: u, zIndexMode: d } = q0(Y0, r), h = n.parentId, p = t.get(h);
  if (!p) {
    console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);
    return;
  }
  HI(n, e), a && !p.parentId && p.internals.rootParentIndex === void 0 && d === "auto" && (p.internals.rootParentIndex = ++a.i, p.internals.z = p.internals.z + a.i * zI), a && p.internals.rootParentIndex !== void 0 && (a.i = p.internals.rootParentIndex);
  const m = o && !Z0(d) ? PE : 0, { x: g, y: _, z: b } = VI(n, p, c, u, m, d), { positionAbsolute: E } = n.internals, S = g !== E.x || _ !== E.y;
  (S || b !== n.internals.z) && t.set(n.id, {
    ...n,
    internals: {
      ...n.internals,
      positionAbsolute: S ? { x: g, y: _ } : E,
      z: b
    }
  });
}
function zE(n, t, e) {
  const r = Ji(n.zIndex) ? n.zIndex : 0;
  return Z0(e) ? r : r + (n.selected ? t : 0);
}
function VI(n, t, e, r, a, o) {
  const { x: c, y: u } = t.internals.positionAbsolute, d = is(n), h = Zc(n, e), p = dl(n.extent) ? Pa(h, n.extent, d) : h;
  let m = Pa({ x: c + p.x, y: u + p.y }, r, d);
  n.extent === "parent" && (m = bE(m, d, t));
  const g = zE(n, a, o), _ = t.internals.z ?? 0;
  return {
    x: m.x,
    y: m.y,
    z: _ >= g ? _ + 1 : g
  };
}
function K0(n, t, e, r = [0, 0]) {
  var c;
  const a = [], o = /* @__PURE__ */ new Map();
  for (const u of n) {
    const d = t.get(u.parentId);
    if (!d)
      continue;
    const h = ((c = o.get(u.parentId)) == null ? void 0 : c.expandedRect) ?? fl(d), p = EE(h, u.rect);
    o.set(u.parentId, { expandedRect: p, parent: d });
  }
  return o.size > 0 && o.forEach(({ expandedRect: u, parent: d }, h) => {
    var w;
    const p = d.internals.positionAbsolute, m = is(d), g = d.origin ?? r, _ = u.x < p.x ? Math.round(Math.abs(p.x - u.x)) : 0, b = u.y < p.y ? Math.round(Math.abs(p.y - u.y)) : 0, E = Math.max(m.width, Math.round(u.width)), S = Math.max(m.height, Math.round(u.height)), y = (E - m.width) * g[0], A = (S - m.height) * g[1];
    (_ > 0 || b > 0 || y || A) && (a.push({
      id: h,
      type: "position",
      position: {
        x: d.position.x - _ + y,
        y: d.position.y - b + A
      }
    }), (w = e.get(h)) == null || w.forEach((M) => {
      n.some((O) => O.id === M.id) || a.push({
        id: M.id,
        type: "position",
        position: {
          x: M.position.x + _,
          y: M.position.y + b
        }
      });
    })), (m.width < u.width || m.height < u.height || _ || b) && a.push({
      id: h,
      type: "dimensions",
      setAttributes: !0,
      dimensions: {
        width: E + (_ ? g[0] * _ - y : 0),
        height: S + (b ? g[1] * b - A : 0)
      }
    });
  }), a;
}
function kI(n, t, e, r, a, o, c) {
  const u = r == null ? void 0 : r.querySelector(".xyflow__viewport");
  let d = !1;
  if (!u)
    return { changes: [], updatedInternals: d };
  const h = [], p = window.getComputedStyle(u), { m22: m } = new window.DOMMatrixReadOnly(p.transform), g = [];
  for (const _ of n.values()) {
    const b = t.get(_.id);
    if (!b)
      continue;
    if (b.hidden) {
      t.set(b.id, {
        ...b,
        internals: {
          ...b.internals,
          handleBounds: void 0
        }
      }), d = !0;
      continue;
    }
    const E = W0(_.nodeElement), S = b.measured.width !== E.width || b.measured.height !== E.height;
    if (!!(E.width && E.height && (S || !b.internals.handleBounds || _.force))) {
      const A = _.nodeElement.getBoundingClientRect(), w = dl(b.extent) ? b.extent : o;
      let { positionAbsolute: M } = b.internals;
      b.parentId && b.extent === "parent" ? M = bE(M, E, t.get(b.parentId)) : w && (M = Pa(M, w, E));
      const O = {
        ...b,
        measured: E,
        internals: {
          ...b.internals,
          positionAbsolute: M,
          handleBounds: {
            source: kb("source", _.nodeElement, A, m, b.id),
            target: kb("target", _.nodeElement, A, m, b.id)
          }
        }
      };
      t.set(b.id, O), b.parentId && $0(O, t, e, { nodeOrigin: a, zIndexMode: c }), d = !0, S && (h.push({
        id: b.id,
        type: "dimensions",
        dimensions: E
      }), b.expandParent && b.parentId && g.push({
        id: b.id,
        parentId: b.parentId,
        rect: fl(O, a)
      }));
    }
  }
  if (g.length > 0) {
    const _ = K0(g, t, e, a);
    h.push(..._);
  }
  return { changes: h, updatedInternals: d };
}
async function GI({ delta: n, panZoom: t, transform: e, translateExtent: r, width: a, height: o }) {
  if (!t || !n.x && !n.y)
    return Promise.resolve(!1);
  const c = await t.setViewportConstrained({
    x: e[0] + n.x,
    y: e[1] + n.y,
    zoom: e[2]
  }, [
    [0, 0],
    [a, o]
  ], r), u = !!c && (c.x !== e[0] || c.y !== e[1] || c.k !== e[2]);
  return Promise.resolve(u);
}
function Zb(n, t, e, r, a, o) {
  let c = a;
  const u = r.get(c) || /* @__PURE__ */ new Map();
  r.set(c, u.set(e, t)), c = `${a}-${n}`;
  const d = r.get(c) || /* @__PURE__ */ new Map();
  if (r.set(c, d.set(e, t)), o) {
    c = `${a}-${n}-${o}`;
    const h = r.get(c) || /* @__PURE__ */ new Map();
    r.set(c, h.set(e, t));
  }
}
function IE(n, t, e) {
  n.clear(), t.clear();
  for (const r of e) {
    const { source: a, target: o, sourceHandle: c = null, targetHandle: u = null } = r, d = { edgeId: r.id, source: a, target: o, sourceHandle: c, targetHandle: u }, h = `${a}-${c}--${o}-${u}`, p = `${o}-${u}--${a}-${c}`;
    Zb("source", d, p, n, a, c), Zb("target", d, h, n, o, u), t.set(r.id, r);
  }
}
function BE(n, t) {
  if (!n.parentId)
    return !1;
  const e = t.get(n.parentId);
  return e ? e.selected ? !0 : BE(e, t) : !1;
}
function $b(n, t, e) {
  var a;
  let r = n;
  do {
    if ((a = r == null ? void 0 : r.matches) != null && a.call(r, t))
      return !0;
    if (r === e)
      return !1;
    r = r == null ? void 0 : r.parentElement;
  } while (r);
  return !1;
}
function XI(n, t, e, r) {
  const a = /* @__PURE__ */ new Map();
  for (const [o, c] of n)
    if ((c.selected || c.id === r) && (!c.parentId || !BE(c, n)) && (c.draggable || t && typeof c.draggable > "u")) {
      const u = n.get(o);
      u && a.set(o, {
        id: o,
        position: u.position || { x: 0, y: 0 },
        distance: {
          x: e.x - u.internals.positionAbsolute.x,
          y: e.y - u.internals.positionAbsolute.y
        },
        extent: u.extent,
        parentId: u.parentId,
        origin: u.origin,
        expandParent: u.expandParent,
        internals: {
          positionAbsolute: u.internals.positionAbsolute || { x: 0, y: 0 }
        },
        measured: {
          width: u.measured.width ?? 0,
          height: u.measured.height ?? 0
        }
      });
    }
  return a;
}
function Ym({ nodeId: n, dragItems: t, nodeLookup: e, dragging: r = !0 }) {
  var c, u, d;
  const a = [];
  for (const [h, p] of t) {
    const m = (c = e.get(h)) == null ? void 0 : c.internals.userNode;
    m && a.push({
      ...m,
      position: p.position,
      dragging: r
    });
  }
  if (!n)
    return [a[0], a];
  const o = (u = e.get(n)) == null ? void 0 : u.internals.userNode;
  return [
    o ? {
      ...o,
      position: ((d = t.get(n)) == null ? void 0 : d.position) || o.position,
      dragging: r
    } : a[0],
    a
  ];
}
function jI({ dragItems: n, snapGrid: t, x: e, y: r }) {
  const a = n.values().next().value;
  if (!a)
    return null;
  const o = {
    x: e - a.distance.x,
    y: r - a.distance.y
  }, c = Kc(o, t);
  return {
    x: c.x - o.x,
    y: c.y - o.y
  };
}
function WI({ onNodeMouseDown: n, getStoreItems: t, onDragStart: e, onDrag: r, onDragStop: a }) {
  let o = { x: null, y: null }, c = 0, u = /* @__PURE__ */ new Map(), d = !1, h = { x: 0, y: 0 }, p = null, m = !1, g = null, _ = !1, b = !1, E = null;
  function S({ noDragClassName: A, handleSelector: w, domNode: M, isSelectable: O, nodeId: L, nodeClickDistance: N = 0 }) {
    g = Ai(M);
    function z({ x: B, y: I }) {
      const { nodeLookup: C, nodeExtent: X, snapGrid: D, snapToGrid: V, nodeOrigin: H, onNodeDrag: j, onSelectionDrag: K, onError: F, updateNodePositions: q } = t();
      o = { x: B, y: I };
      let it = !1;
      const G = u.size > 1, k = G && X ? a0($c(u)) : null, $ = G && V ? jI({
        dragItems: u,
        snapGrid: D,
        x: B,
        y: I
      }) : null;
      for (const [Q, et] of u) {
        if (!C.has(Q))
          continue;
        let st = { x: B - et.distance.x, y: I - et.distance.y };
        V && (st = $ ? {
          x: Math.round(st.x + $.x),
          y: Math.round(st.y + $.y)
        } : Kc(st, D));
        let _t = null;
        if (G && X && !et.extent && k) {
          const { positionAbsolute: Ot } = et.internals, nt = Ot.x - k.x + X[0][0], Jt = Ot.x + et.measured.width - k.x2 + X[1][0], Ft = Ot.y - k.y + X[0][1], ne = Ot.y + et.measured.height - k.y2 + X[1][1];
          _t = [
            [nt, Ft],
            [Jt, ne]
          ];
        }
        const { position: Mt, positionAbsolute: Rt } = SE({
          nodeId: Q,
          nextPosition: st,
          nodeLookup: C,
          nodeExtent: _t || X,
          nodeOrigin: H,
          onError: F
        });
        it = it || et.position.x !== Mt.x || et.position.y !== Mt.y, et.position = Mt, et.internals.positionAbsolute = Rt;
      }
      if (b = b || it, !!it && (q(u, !0), E && (r || j || !L && K))) {
        const [Q, et] = Ym({
          nodeId: L,
          dragItems: u,
          nodeLookup: C
        });
        r == null || r(E, u, Q, et), j == null || j(E, Q, et), L || K == null || K(E, et);
      }
    }
    async function R() {
      if (!p)
        return;
      const { transform: B, panBy: I, autoPanSpeed: C, autoPanOnNodeDrag: X } = t();
      if (!X) {
        d = !1, cancelAnimationFrame(c);
        return;
      }
      const [D, V] = ME(h, p, C);
      (D !== 0 || V !== 0) && (o.x = (o.x ?? 0) - D / B[2], o.y = (o.y ?? 0) - V / B[2], await I({ x: D, y: V }) && z(o)), c = requestAnimationFrame(R);
    }
    function T(B) {
      var G;
      const { nodeLookup: I, multiSelectionActive: C, nodesDraggable: X, transform: D, snapGrid: V, snapToGrid: H, selectNodesOnDrag: j, onNodeDragStart: K, onSelectionDragStart: F, unselectNodesAndEdges: q } = t();
      m = !0, (!j || !O) && !C && L && ((G = I.get(L)) != null && G.selected || q()), O && j && L && (n == null || n(L));
      const it = Ac(B.sourceEvent, { transform: D, snapGrid: V, snapToGrid: H, containerBounds: p });
      if (o = it, u = XI(I, X, it, L), u.size > 0 && (e || K || !L && F)) {
        const [k, $] = Ym({
          nodeId: L,
          dragItems: u,
          nodeLookup: I
        });
        e == null || e(B.sourceEvent, u, k, $), K == null || K(B.sourceEvent, k, $), L || F == null || F(B.sourceEvent, $);
      }
    }
    const U = tE().clickDistance(N).on("start", (B) => {
      const { domNode: I, nodeDragThreshold: C, transform: X, snapGrid: D, snapToGrid: V } = t();
      p = (I == null ? void 0 : I.getBoundingClientRect()) || null, _ = !1, b = !1, E = B.sourceEvent, C === 0 && T(B), o = Ac(B.sourceEvent, { transform: X, snapGrid: D, snapToGrid: V, containerBounds: p }), h = tr(B.sourceEvent, p);
    }).on("drag", (B) => {
      const { autoPanOnNodeDrag: I, transform: C, snapGrid: X, snapToGrid: D, nodeDragThreshold: V, nodeLookup: H } = t(), j = Ac(B.sourceEvent, { transform: C, snapGrid: X, snapToGrid: D, containerBounds: p });
      if (E = B.sourceEvent, (B.sourceEvent.type === "touchmove" && B.sourceEvent.touches.length > 1 || // if user deletes a node while dragging, we need to abort the drag to prevent errors
      L && !H.has(L)) && (_ = !0), !_) {
        if (!d && I && m && (d = !0, R()), !m) {
          const K = tr(B.sourceEvent, p), F = K.x - h.x, q = K.y - h.y;
          Math.sqrt(F * F + q * q) > V && T(B);
        }
        (o.x !== j.xSnapped || o.y !== j.ySnapped) && u && m && (h = tr(B.sourceEvent, p), z(j));
      }
    }).on("end", (B) => {
      if (!(!m || _) && (d = !1, m = !1, cancelAnimationFrame(c), u.size > 0)) {
        const { nodeLookup: I, updateNodePositions: C, onNodeDragStop: X, onSelectionDragStop: D } = t();
        if (b && (C(u, !1), b = !1), a || X || !L && D) {
          const [V, H] = Ym({
            nodeId: L,
            dragItems: u,
            nodeLookup: I,
            dragging: !1
          });
          a == null || a(B.sourceEvent, u, V, H), X == null || X(B.sourceEvent, V, H), L || D == null || D(B.sourceEvent, H);
        }
      }
    }).filter((B) => {
      const I = B.target;
      return !B.button && (!A || !$b(I, `.${A}`, M)) && (!w || $b(I, w, M));
    });
    g.call(U);
  }
  function y() {
    g == null || g.on(".drag", null);
  }
  return {
    update: S,
    destroy: y
  };
}
function YI(n, t, e) {
  const r = [], a = {
    x: n.x - e,
    y: n.y - e,
    width: e * 2,
    height: e * 2
  };
  for (const o of t.values())
    Bc(a, fl(o)) > 0 && r.push(o);
  return r;
}
const qI = 250;
function ZI(n, t, e, r) {
  var u, d;
  let a = [], o = 1 / 0;
  const c = YI(n, e, t + qI);
  for (const h of c) {
    const p = [...((u = h.internals.handleBounds) == null ? void 0 : u.source) ?? [], ...((d = h.internals.handleBounds) == null ? void 0 : d.target) ?? []];
    for (const m of p) {
      if (r.nodeId === m.nodeId && r.type === m.type && r.id === m.id)
        continue;
      const { x: g, y: _ } = za(h, m, m.position, !0), b = Math.sqrt(Math.pow(g - n.x, 2) + Math.pow(_ - n.y, 2));
      b > t || (b < o ? (a = [{ ...m, x: g, y: _ }], o = b) : b === o && a.push({ ...m, x: g, y: _ }));
    }
  }
  if (!a.length)
    return null;
  if (a.length > 1) {
    const h = r.type === "source" ? "target" : "source";
    return a.find((p) => p.type === h) ?? a[0];
  }
  return a[0];
}
function FE(n, t, e, r, a, o = !1) {
  var h, p, m;
  const c = r.get(n);
  if (!c)
    return null;
  const u = a === "strict" ? (h = c.internals.handleBounds) == null ? void 0 : h[t] : [...((p = c.internals.handleBounds) == null ? void 0 : p.source) ?? [], ...((m = c.internals.handleBounds) == null ? void 0 : m.target) ?? []], d = (e ? u == null ? void 0 : u.find((g) => g.id === e) : u == null ? void 0 : u[0]) ?? null;
  return d && o ? { ...d, ...za(c, d, d.position, !0) } : d;
}
function HE(n, t) {
  return n || (t != null && t.classList.contains("target") ? "target" : t != null && t.classList.contains("source") ? "source" : null);
}
function $I(n, t) {
  let e = null;
  return t ? e = !0 : n && !t && (e = !1), e;
}
const VE = () => !0;
function KI(n, { connectionMode: t, connectionRadius: e, handleId: r, nodeId: a, edgeUpdaterType: o, isTarget: c, domNode: u, nodeLookup: d, lib: h, autoPanOnConnect: p, flowId: m, panBy: g, cancelConnection: _, onConnectStart: b, onConnect: E, onConnectEnd: S, isValidConnection: y = VE, onReconnectEnd: A, updateConnection: w, getTransform: M, getFromHandle: O, autoPanSpeed: L, dragThreshold: N = 1, handleDomNode: z }) {
  const R = AE(n.target);
  let T = 0, U;
  const { x: B, y: I } = tr(n), C = HE(o, z), X = u == null ? void 0 : u.getBoundingClientRect();
  let D = !1;
  if (!X || !C)
    return;
  const V = FE(a, C, r, d, t);
  if (!V)
    return;
  let H = tr(n, X), j = !1, K = null, F = !1, q = null;
  function it() {
    if (!p || !X)
      return;
    const [Mt, Rt] = ME(H, X, L);
    g({ x: Mt, y: Rt }), T = requestAnimationFrame(it);
  }
  const G = {
    ...V,
    nodeId: a,
    type: C,
    position: V.position
  }, k = d.get(a);
  let Q = {
    inProgress: !0,
    isValid: null,
    from: za(k, G, re.Left, !0),
    fromHandle: G,
    fromPosition: G.position,
    fromNode: k,
    to: H,
    toHandle: null,
    toPosition: Bb[G.position],
    toNode: null,
    pointer: H
  };
  function et() {
    D = !0, w(Q), b == null || b(n, { nodeId: a, handleId: r, handleType: C });
  }
  N === 0 && et();
  function st(Mt) {
    if (!D) {
      const { x: ne, y: jt } = tr(Mt), xe = ne - B, qt = jt - I;
      if (!(xe * xe + qt * qt > N * N))
        return;
      et();
    }
    if (!O() || !G) {
      _t(Mt);
      return;
    }
    const Rt = M();
    H = tr(Mt, X), U = ZI(Qc(H, Rt, !1, [1, 1]), e, d, G), j || (it(), j = !0);
    const Ot = kE(Mt, {
      handle: U,
      connectionMode: t,
      fromNodeId: a,
      fromHandleId: r,
      fromType: c ? "target" : "source",
      isValidConnection: y,
      doc: R,
      lib: h,
      flowId: m,
      nodeLookup: d
    });
    q = Ot.handleDomNode, K = Ot.connection, F = $I(!!U, Ot.isValid);
    const nt = d.get(a), Jt = nt ? za(nt, G, re.Left, !0) : Q.from, Ft = {
      ...Q,
      from: Jt,
      isValid: F,
      to: Ot.toHandle && F ? Ad({ x: Ot.toHandle.x, y: Ot.toHandle.y }, Rt) : H,
      toHandle: Ot.toHandle,
      toPosition: F && Ot.toHandle ? Ot.toHandle.position : Bb[G.position],
      toNode: Ot.toHandle ? d.get(Ot.toHandle.nodeId) : null,
      pointer: H
    };
    w(Ft), Q = Ft;
  }
  function _t(Mt) {
    if (!("touches" in Mt && Mt.touches.length > 0)) {
      if (D) {
        (U || q) && K && F && (E == null || E(K));
        const { inProgress: Rt, ...Ot } = Q, nt = {
          ...Ot,
          toPosition: Q.toHandle ? Q.toPosition : null
        };
        S == null || S(Mt, nt), o && (A == null || A(Mt, nt));
      }
      _(), cancelAnimationFrame(T), j = !1, F = !1, K = null, q = null, R.removeEventListener("mousemove", st), R.removeEventListener("mouseup", _t), R.removeEventListener("touchmove", st), R.removeEventListener("touchend", _t);
    }
  }
  R.addEventListener("mousemove", st), R.addEventListener("mouseup", _t), R.addEventListener("touchmove", st), R.addEventListener("touchend", _t);
}
function kE(n, { handle: t, connectionMode: e, fromNodeId: r, fromHandleId: a, fromType: o, doc: c, lib: u, flowId: d, isValidConnection: h = VE, nodeLookup: p }) {
  const m = o === "target", g = t ? c.querySelector(`.${u}-flow__handle[data-id="${d}-${t == null ? void 0 : t.nodeId}-${t == null ? void 0 : t.id}-${t == null ? void 0 : t.type}"]`) : null, { x: _, y: b } = tr(n), E = c.elementFromPoint(_, b), S = E != null && E.classList.contains(`${u}-flow__handle`) ? E : g, y = {
    handleDomNode: S,
    isValid: !1,
    connection: null,
    toHandle: null
  };
  if (S) {
    const A = HE(void 0, S), w = S.getAttribute("data-nodeid"), M = S.getAttribute("data-handleid"), O = S.classList.contains("connectable"), L = S.classList.contains("connectableend");
    if (!w || !A)
      return y;
    const N = {
      source: m ? w : r,
      sourceHandle: m ? M : a,
      target: m ? r : w,
      targetHandle: m ? a : M
    };
    y.connection = N;
    const R = O && L && (e === cl.Strict ? m && A === "source" || !m && A === "target" : w !== r || M !== a);
    y.isValid = R && h(N), y.toHandle = FE(w, A, M, p, e, !0);
  }
  return y;
}
const u0 = {
  onPointerDown: KI,
  isValid: kE
};
function QI({ domNode: n, panZoom: t, getTransform: e, getViewScale: r }) {
  const a = Ai(n);
  function o({ translateExtent: u, width: d, height: h, zoomStep: p = 1, pannable: m = !0, zoomable: g = !0, inversePan: _ = !1 }) {
    const b = (w) => {
      if (w.sourceEvent.type !== "wheel" || !t)
        return;
      const M = e(), O = w.sourceEvent.ctrlKey && Fc() ? 10 : 1, L = -w.sourceEvent.deltaY * (w.sourceEvent.deltaMode === 1 ? 0.05 : w.sourceEvent.deltaMode ? 1 : 2e-3) * p, N = M[2] * Math.pow(2, L * O);
      t.scaleTo(N);
    };
    let E = [0, 0];
    const S = (w) => {
      (w.sourceEvent.type === "mousedown" || w.sourceEvent.type === "touchstart") && (E = [
        w.sourceEvent.clientX ?? w.sourceEvent.touches[0].clientX,
        w.sourceEvent.clientY ?? w.sourceEvent.touches[0].clientY
      ]);
    }, y = (w) => {
      const M = e();
      if (w.sourceEvent.type !== "mousemove" && w.sourceEvent.type !== "touchmove" || !t)
        return;
      const O = [
        w.sourceEvent.clientX ?? w.sourceEvent.touches[0].clientX,
        w.sourceEvent.clientY ?? w.sourceEvent.touches[0].clientY
      ], L = [O[0] - E[0], O[1] - E[1]];
      E = O;
      const N = r() * Math.max(M[2], Math.log(M[2])) * (_ ? -1 : 1), z = {
        x: M[0] - L[0] * N,
        y: M[1] - L[1] * N
      }, R = [
        [0, 0],
        [d, h]
      ];
      t.setViewportConstrained({
        x: z.x,
        y: z.y,
        zoom: M[2]
      }, R, u);
    }, A = mE().on("start", S).on("zoom", m ? y : null).on("zoom.wheel", g ? b : null);
    a.call(A, {});
  }
  function c() {
    a.on("zoom", null);
  }
  return {
    update: o,
    destroy: c,
    pointer: $i
  };
}
const kd = (n) => ({
  x: n.x,
  y: n.y,
  zoom: n.k
}), qm = ({ x: n, y: t, zoom: e }) => Fd.translate(n, t).scale(e), Wo = (n, t) => n.target.closest(`.${t}`), GE = (n, t) => t === 2 && Array.isArray(n) && n.includes(2), JI = (n) => ((n *= 2) <= 1 ? n * n * n : (n -= 2) * n * n + 2) / 2, Zm = (n, t = 0, e = JI, r = () => {
}) => {
  const a = typeof t == "number" && t > 0;
  return a || r(), a ? n.transition().duration(t).ease(e).on("end", r) : n;
}, XE = (n) => {
  const t = n.ctrlKey && Fc() ? 10 : 1;
  return -n.deltaY * (n.deltaMode === 1 ? 0.05 : n.deltaMode ? 1 : 2e-3) * t;
};
function t4({ zoomPanValues: n, noWheelClassName: t, d3Selection: e, d3Zoom: r, panOnScrollMode: a, panOnScrollSpeed: o, zoomOnPinch: c, onPanZoomStart: u, onPanZoom: d, onPanZoomEnd: h }) {
  return (p) => {
    if (Wo(p, t))
      return p.ctrlKey && p.preventDefault(), !1;
    p.preventDefault(), p.stopImmediatePropagation();
    const m = e.property("__zoom").k || 1;
    if (p.ctrlKey && c) {
      const S = $i(p), y = XE(p), A = m * Math.pow(2, y);
      r.scaleTo(e, A, S, p);
      return;
    }
    const g = p.deltaMode === 1 ? 20 : 1;
    let _ = a === Da.Vertical ? 0 : p.deltaX * g, b = a === Da.Horizontal ? 0 : p.deltaY * g;
    !Fc() && p.shiftKey && a !== Da.Vertical && (_ = p.deltaY * g, b = 0), r.translateBy(
      e,
      -(_ / m) * o,
      -(b / m) * o,
      // @ts-ignore
      { internal: !0 }
    );
    const E = kd(e.property("__zoom"));
    clearTimeout(n.panScrollTimeout), n.isPanScrolling ? (d == null || d(p, E), n.panScrollTimeout = setTimeout(() => {
      h == null || h(p, E), n.isPanScrolling = !1;
    }, 150)) : (n.isPanScrolling = !0, u == null || u(p, E));
  };
}
function e4({ noWheelClassName: n, preventScrolling: t, d3ZoomHandler: e }) {
  return function(r, a) {
    const o = r.type === "wheel", c = !t && o && !r.ctrlKey, u = Wo(r, n);
    if (r.ctrlKey && o && u && r.preventDefault(), c || u)
      return null;
    r.preventDefault(), e.call(this, r, a);
  };
}
function n4({ zoomPanValues: n, onDraggingChange: t, onPanZoomStart: e }) {
  return (r) => {
    var o, c, u;
    if ((o = r.sourceEvent) != null && o.internal)
      return;
    const a = kd(r.transform);
    n.mouseButton = ((c = r.sourceEvent) == null ? void 0 : c.button) || 0, n.isZoomingOrPanning = !0, n.prevViewport = a, ((u = r.sourceEvent) == null ? void 0 : u.type) === "mousedown" && t(!0), e && (e == null || e(r.sourceEvent, a));
  };
}
function i4({ zoomPanValues: n, panOnDrag: t, onPaneContextMenu: e, onTransformChange: r, onPanZoom: a }) {
  return (o) => {
    var c, u;
    n.usedRightMouseButton = !!(e && GE(t, n.mouseButton ?? 0)), (c = o.sourceEvent) != null && c.sync || r([o.transform.x, o.transform.y, o.transform.k]), a && !((u = o.sourceEvent) != null && u.internal) && (a == null || a(o.sourceEvent, kd(o.transform)));
  };
}
function r4({ zoomPanValues: n, panOnDrag: t, panOnScroll: e, onDraggingChange: r, onPanZoomEnd: a, onPaneContextMenu: o }) {
  return (c) => {
    var u;
    if (!((u = c.sourceEvent) != null && u.internal) && (n.isZoomingOrPanning = !1, o && GE(t, n.mouseButton ?? 0) && !n.usedRightMouseButton && c.sourceEvent && o(c.sourceEvent), n.usedRightMouseButton = !1, r(!1), a)) {
      const d = kd(c.transform);
      n.prevViewport = d, clearTimeout(n.timerId), n.timerId = setTimeout(
        () => {
          a == null || a(c.sourceEvent, d);
        },
        // we need a setTimeout for panOnScroll to supress multiple end events fired during scroll
        e ? 150 : 0
      );
    }
  };
}
function s4({ zoomActivationKeyPressed: n, zoomOnScroll: t, zoomOnPinch: e, panOnDrag: r, panOnScroll: a, zoomOnDoubleClick: o, userSelectionActive: c, noWheelClassName: u, noPanClassName: d, lib: h, connectionInProgress: p }) {
  return (m) => {
    var S;
    const g = n || t, _ = e && m.ctrlKey, b = m.type === "wheel";
    if (m.button === 1 && m.type === "mousedown" && (Wo(m, `${h}-flow__node`) || Wo(m, `${h}-flow__edge`)))
      return !0;
    if (!r && !g && !a && !o && !e || c || p && !b || Wo(m, u) && b || Wo(m, d) && (!b || a && b && !n) || !e && m.ctrlKey && b)
      return !1;
    if (!e && m.type === "touchstart" && ((S = m.touches) == null ? void 0 : S.length) > 1)
      return m.preventDefault(), !1;
    if (!g && !a && !_ && b || !r && (m.type === "mousedown" || m.type === "touchstart") || Array.isArray(r) && !r.includes(m.button) && m.type === "mousedown")
      return !1;
    const E = Array.isArray(r) && r.includes(m.button) || !m.button || m.button <= 1;
    return (!m.ctrlKey || b) && E;
  };
}
function a4({ domNode: n, minZoom: t, maxZoom: e, translateExtent: r, viewport: a, onPanZoom: o, onPanZoomStart: c, onPanZoomEnd: u, onDraggingChange: d }) {
  const h = {
    isZoomingOrPanning: !1,
    usedRightMouseButton: !1,
    prevViewport: {},
    mouseButton: 0,
    timerId: void 0,
    panScrollTimeout: void 0,
    isPanScrolling: !1
  }, p = n.getBoundingClientRect(), m = mE().scaleExtent([t, e]).translateExtent(r), g = Ai(n).call(m);
  A({
    x: a.x,
    y: a.y,
    zoom: ul(a.zoom, t, e)
  }, [
    [0, 0],
    [p.width, p.height]
  ], r);
  const _ = g.on("wheel.zoom"), b = g.on("dblclick.zoom");
  m.wheelDelta(XE);
  function E(U, B) {
    return g ? new Promise((I) => {
      m == null || m.interpolate((B == null ? void 0 : B.interpolate) === "linear" ? Tc : od).transform(Zm(g, B == null ? void 0 : B.duration, B == null ? void 0 : B.ease, () => I(!0)), U);
    }) : Promise.resolve(!1);
  }
  function S({ noWheelClassName: U, noPanClassName: B, onPaneContextMenu: I, userSelectionActive: C, panOnScroll: X, panOnDrag: D, panOnScrollMode: V, panOnScrollSpeed: H, preventScrolling: j, zoomOnPinch: K, zoomOnScroll: F, zoomOnDoubleClick: q, zoomActivationKeyPressed: it, lib: G, onTransformChange: k, connectionInProgress: $, paneClickDistance: Q, selectionOnDrag: et }) {
    C && !h.isZoomingOrPanning && y();
    const st = X && !it && !C;
    m.clickDistance(et ? 1 / 0 : !Ji(Q) || Q < 0 ? 0 : Q);
    const _t = st ? t4({
      zoomPanValues: h,
      noWheelClassName: U,
      d3Selection: g,
      d3Zoom: m,
      panOnScrollMode: V,
      panOnScrollSpeed: H,
      zoomOnPinch: K,
      onPanZoomStart: c,
      onPanZoom: o,
      onPanZoomEnd: u
    }) : e4({
      noWheelClassName: U,
      preventScrolling: j,
      d3ZoomHandler: _
    });
    if (g.on("wheel.zoom", _t, { passive: !1 }), !C) {
      const Rt = n4({
        zoomPanValues: h,
        onDraggingChange: d,
        onPanZoomStart: c
      });
      m.on("start", Rt);
      const Ot = i4({
        zoomPanValues: h,
        panOnDrag: D,
        onPaneContextMenu: !!I,
        onPanZoom: o,
        onTransformChange: k
      });
      m.on("zoom", Ot);
      const nt = r4({
        zoomPanValues: h,
        panOnDrag: D,
        panOnScroll: X,
        onPaneContextMenu: I,
        onPanZoomEnd: u,
        onDraggingChange: d
      });
      m.on("end", nt);
    }
    const Mt = s4({
      zoomActivationKeyPressed: it,
      panOnDrag: D,
      zoomOnScroll: F,
      panOnScroll: X,
      zoomOnDoubleClick: q,
      zoomOnPinch: K,
      userSelectionActive: C,
      noPanClassName: B,
      noWheelClassName: U,
      lib: G,
      connectionInProgress: $
    });
    m.filter(Mt), q ? g.on("dblclick.zoom", b) : g.on("dblclick.zoom", null);
  }
  function y() {
    m.on("zoom", null);
  }
  async function A(U, B, I) {
    const C = qm(U), X = m == null ? void 0 : m.constrain()(C, B, I);
    return X && await E(X), new Promise((D) => D(X));
  }
  async function w(U, B) {
    const I = qm(U);
    return await E(I, B), new Promise((C) => C(I));
  }
  function M(U) {
    if (g) {
      const B = qm(U), I = g.property("__zoom");
      (I.k !== U.zoom || I.x !== U.x || I.y !== U.y) && (m == null || m.transform(g, B, null, { sync: !0 }));
    }
  }
  function O() {
    const U = g ? pE(g.node()) : { x: 0, y: 0, k: 1 };
    return { x: U.x, y: U.y, zoom: U.k };
  }
  function L(U, B) {
    return g ? new Promise((I) => {
      m == null || m.interpolate((B == null ? void 0 : B.interpolate) === "linear" ? Tc : od).scaleTo(Zm(g, B == null ? void 0 : B.duration, B == null ? void 0 : B.ease, () => I(!0)), U);
    }) : Promise.resolve(!1);
  }
  function N(U, B) {
    return g ? new Promise((I) => {
      m == null || m.interpolate((B == null ? void 0 : B.interpolate) === "linear" ? Tc : od).scaleBy(Zm(g, B == null ? void 0 : B.duration, B == null ? void 0 : B.ease, () => I(!0)), U);
    }) : Promise.resolve(!1);
  }
  function z(U) {
    m == null || m.scaleExtent(U);
  }
  function R(U) {
    m == null || m.translateExtent(U);
  }
  function T(U) {
    const B = !Ji(U) || U < 0 ? 0 : U;
    m == null || m.clickDistance(B);
  }
  return {
    update: S,
    destroy: y,
    setViewport: w,
    setViewportConstrained: A,
    getViewport: O,
    scaleTo: L,
    scaleBy: N,
    setScaleExtent: z,
    setTranslateExtent: R,
    syncViewport: M,
    setClickDistance: T
  };
}
var hl;
(function(n) {
  n.Line = "line", n.Handle = "handle";
})(hl || (hl = {}));
function o4({ width: n, prevWidth: t, height: e, prevHeight: r, affectsX: a, affectsY: o }) {
  const c = n - t, u = e - r, d = [c > 0 ? 1 : c < 0 ? -1 : 0, u > 0 ? 1 : u < 0 ? -1 : 0];
  return c && a && (d[0] = d[0] * -1), u && o && (d[1] = d[1] * -1), d;
}
function Kb(n) {
  const t = n.includes("right") || n.includes("left"), e = n.includes("bottom") || n.includes("top"), r = n.includes("left"), a = n.includes("top");
  return {
    isHorizontal: t,
    isVertical: e,
    affectsX: r,
    affectsY: a
  };
}
function zs(n, t) {
  return Math.max(0, t - n);
}
function Is(n, t) {
  return Math.max(0, n - t);
}
function $f(n, t, e) {
  return Math.max(0, t - n, n - e);
}
function Qb(n, t) {
  return n ? !t : t;
}
function l4(n, t, e, r, a, o, c, u) {
  let { affectsX: d, affectsY: h } = t;
  const { isHorizontal: p, isVertical: m } = t, g = p && m, { xSnapped: _, ySnapped: b } = e, { minWidth: E, maxWidth: S, minHeight: y, maxHeight: A } = r, { x: w, y: M, width: O, height: L, aspectRatio: N } = n;
  let z = Math.floor(p ? _ - n.pointerX : 0), R = Math.floor(m ? b - n.pointerY : 0);
  const T = O + (d ? -z : z), U = L + (h ? -R : R), B = -o[0] * O, I = -o[1] * L;
  let C = $f(T, E, S), X = $f(U, y, A);
  if (c) {
    let H = 0, j = 0;
    d && z < 0 ? H = zs(w + z + B, c[0][0]) : !d && z > 0 && (H = Is(w + T + B, c[1][0])), h && R < 0 ? j = zs(M + R + I, c[0][1]) : !h && R > 0 && (j = Is(M + U + I, c[1][1])), C = Math.max(C, H), X = Math.max(X, j);
  }
  if (u) {
    let H = 0, j = 0;
    d && z > 0 ? H = Is(w + z, u[0][0]) : !d && z < 0 && (H = zs(w + T, u[1][0])), h && R > 0 ? j = Is(M + R, u[0][1]) : !h && R < 0 && (j = zs(M + U, u[1][1])), C = Math.max(C, H), X = Math.max(X, j);
  }
  if (a) {
    if (p) {
      const H = $f(T / N, y, A) * N;
      if (C = Math.max(C, H), c) {
        let j = 0;
        !d && !h || d && !h && g ? j = Is(M + I + T / N, c[1][1]) * N : j = zs(M + I + (d ? z : -z) / N, c[0][1]) * N, C = Math.max(C, j);
      }
      if (u) {
        let j = 0;
        !d && !h || d && !h && g ? j = zs(M + T / N, u[1][1]) * N : j = Is(M + (d ? z : -z) / N, u[0][1]) * N, C = Math.max(C, j);
      }
    }
    if (m) {
      const H = $f(U * N, E, S) / N;
      if (X = Math.max(X, H), c) {
        let j = 0;
        !d && !h || h && !d && g ? j = Is(w + U * N + B, c[1][0]) / N : j = zs(w + (h ? R : -R) * N + B, c[0][0]) / N, X = Math.max(X, j);
      }
      if (u) {
        let j = 0;
        !d && !h || h && !d && g ? j = zs(w + U * N, u[1][0]) / N : j = Is(w + (h ? R : -R) * N, u[0][0]) / N, X = Math.max(X, j);
      }
    }
  }
  R = R + (R < 0 ? X : -X), z = z + (z < 0 ? C : -C), a && (g ? T > U * N ? R = (Qb(d, h) ? -z : z) / N : z = (Qb(d, h) ? -R : R) * N : p ? (R = z / N, h = d) : (z = R * N, d = h));
  const D = d ? w + z : w, V = h ? M + R : M;
  return {
    width: O + (d ? -z : z),
    height: L + (h ? -R : R),
    x: o[0] * z * (d ? -1 : 1) + D,
    y: o[1] * R * (h ? -1 : 1) + V
  };
}
const jE = { width: 0, height: 0, x: 0, y: 0 }, c4 = {
  ...jE,
  pointerX: 0,
  pointerY: 0,
  aspectRatio: 1
};
function u4(n) {
  return [
    [0, 0],
    [n.measured.width, n.measured.height]
  ];
}
function f4(n, t, e) {
  const r = t.position.x + n.position.x, a = t.position.y + n.position.y, o = n.measured.width ?? 0, c = n.measured.height ?? 0, u = e[0] * o, d = e[1] * c;
  return [
    [r - u, a - d],
    [r + o - u, a + c - d]
  ];
}
function d4({ domNode: n, nodeId: t, getStoreItems: e, onChange: r, onEnd: a }) {
  const o = Ai(n);
  let c = {
    controlDirection: Kb("bottom-right"),
    boundaries: {
      minWidth: 0,
      minHeight: 0,
      maxWidth: Number.MAX_VALUE,
      maxHeight: Number.MAX_VALUE
    },
    resizeDirection: void 0,
    keepAspectRatio: !1
  };
  function u({ controlPosition: h, boundaries: p, keepAspectRatio: m, resizeDirection: g, onResizeStart: _, onResize: b, onResizeEnd: E, shouldResize: S }) {
    let y = { ...jE }, A = { ...c4 };
    c = {
      boundaries: p,
      resizeDirection: g,
      keepAspectRatio: m,
      controlDirection: Kb(h)
    };
    let w, M = null, O = [], L, N, z, R = !1;
    const T = tE().on("start", (U) => {
      const { nodeLookup: B, transform: I, snapGrid: C, snapToGrid: X, nodeOrigin: D, paneDomNode: V } = e();
      if (w = B.get(t), !w)
        return;
      M = (V == null ? void 0 : V.getBoundingClientRect()) ?? null;
      const { xSnapped: H, ySnapped: j } = Ac(U.sourceEvent, {
        transform: I,
        snapGrid: C,
        snapToGrid: X,
        containerBounds: M
      });
      y = {
        width: w.measured.width ?? 0,
        height: w.measured.height ?? 0,
        x: w.position.x ?? 0,
        y: w.position.y ?? 0
      }, A = {
        ...y,
        pointerX: H,
        pointerY: j,
        aspectRatio: y.width / y.height
      }, L = void 0, w.parentId && (w.extent === "parent" || w.expandParent) && (L = B.get(w.parentId), N = L && w.extent === "parent" ? u4(L) : void 0), O = [], z = void 0;
      for (const [K, F] of B)
        if (F.parentId === t && (O.push({
          id: K,
          position: { ...F.position },
          extent: F.extent
        }), F.extent === "parent" || F.expandParent)) {
          const q = f4(F, w, F.origin ?? D);
          z ? z = [
            [Math.min(q[0][0], z[0][0]), Math.min(q[0][1], z[0][1])],
            [Math.max(q[1][0], z[1][0]), Math.max(q[1][1], z[1][1])]
          ] : z = q;
        }
      _ == null || _(U, { ...y });
    }).on("drag", (U) => {
      const { transform: B, snapGrid: I, snapToGrid: C, nodeOrigin: X } = e(), D = Ac(U.sourceEvent, {
        transform: B,
        snapGrid: I,
        snapToGrid: C,
        containerBounds: M
      }), V = [];
      if (!w)
        return;
      const { x: H, y: j, width: K, height: F } = y, q = {}, it = w.origin ?? X, { width: G, height: k, x: $, y: Q } = l4(A, c.controlDirection, D, c.boundaries, c.keepAspectRatio, it, N, z), et = G !== K, st = k !== F, _t = $ !== H && et, Mt = Q !== j && st;
      if (!_t && !Mt && !et && !st)
        return;
      if ((_t || Mt || it[0] === 1 || it[1] === 1) && (q.x = _t ? $ : y.x, q.y = Mt ? Q : y.y, y.x = q.x, y.y = q.y, O.length > 0)) {
        const Jt = $ - H, Ft = Q - j;
        for (const ne of O)
          ne.position = {
            x: ne.position.x - Jt + it[0] * (G - K),
            y: ne.position.y - Ft + it[1] * (k - F)
          }, V.push(ne);
      }
      if ((et || st) && (q.width = et && (!c.resizeDirection || c.resizeDirection === "horizontal") ? G : y.width, q.height = st && (!c.resizeDirection || c.resizeDirection === "vertical") ? k : y.height, y.width = q.width, y.height = q.height), L && w.expandParent) {
        const Jt = it[0] * (q.width ?? 0);
        q.x && q.x < Jt && (y.x = Jt, A.x = A.x - (q.x - Jt));
        const Ft = it[1] * (q.height ?? 0);
        q.y && q.y < Ft && (y.y = Ft, A.y = A.y - (q.y - Ft));
      }
      const Rt = o4({
        width: y.width,
        prevWidth: K,
        height: y.height,
        prevHeight: F,
        affectsX: c.controlDirection.affectsX,
        affectsY: c.controlDirection.affectsY
      }), Ot = { ...y, direction: Rt };
      (S == null ? void 0 : S(U, Ot)) !== !1 && (R = !0, b == null || b(U, Ot), r(q, V));
    }).on("end", (U) => {
      R && (E == null || E(U, { ...y }), a == null || a({ ...y }), R = !1);
    });
    o.call(T);
  }
  function d() {
    o.on(".drag", null);
  }
  return {
    update: u,
    destroy: d
  };
}
var $m = { exports: {} }, Km = {}, Qm = { exports: {} }, Jm = {};
/**
 * @license React
 * use-sync-external-store-shim.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var Jb;
function h4() {
  if (Jb) return Jm;
  Jb = 1;
  var n = Gc();
  function t(m, g) {
    return m === g && (m !== 0 || 1 / m === 1 / g) || m !== m && g !== g;
  }
  var e = typeof Object.is == "function" ? Object.is : t, r = n.useState, a = n.useEffect, o = n.useLayoutEffect, c = n.useDebugValue;
  function u(m, g) {
    var _ = g(), b = r({ inst: { value: _, getSnapshot: g } }), E = b[0].inst, S = b[1];
    return o(
      function() {
        E.value = _, E.getSnapshot = g, d(E) && S({ inst: E });
      },
      [m, _, g]
    ), a(
      function() {
        return d(E) && S({ inst: E }), m(function() {
          d(E) && S({ inst: E });
        });
      },
      [m]
    ), c(_), _;
  }
  function d(m) {
    var g = m.getSnapshot;
    m = m.value;
    try {
      var _ = g();
      return !e(m, _);
    } catch {
      return !0;
    }
  }
  function h(m, g) {
    return g();
  }
  var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? h : u;
  return Jm.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : p, Jm;
}
var t1;
function p4() {
  return t1 || (t1 = 1, Qm.exports = h4()), Qm.exports;
}
/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var e1;
function m4() {
  if (e1) return Km;
  e1 = 1;
  var n = Gc(), t = p4();
  function e(h, p) {
    return h === p && (h !== 0 || 1 / h === 1 / p) || h !== h && p !== p;
  }
  var r = typeof Object.is == "function" ? Object.is : e, a = t.useSyncExternalStore, o = n.useRef, c = n.useEffect, u = n.useMemo, d = n.useDebugValue;
  return Km.useSyncExternalStoreWithSelector = function(h, p, m, g, _) {
    var b = o(null);
    if (b.current === null) {
      var E = { hasValue: !1, value: null };
      b.current = E;
    } else E = b.current;
    b = u(
      function() {
        function y(L) {
          if (!A) {
            if (A = !0, w = L, L = g(L), _ !== void 0 && E.hasValue) {
              var N = E.value;
              if (_(N, L))
                return M = N;
            }
            return M = L;
          }
          if (N = M, r(w, L)) return N;
          var z = g(L);
          return _ !== void 0 && _(N, z) ? (w = L, N) : (w = L, M = z);
        }
        var A = !1, w, M, O = m === void 0 ? null : m;
        return [
          function() {
            return y(p());
          },
          O === null ? void 0 : function() {
            return y(O());
          }
        ];
      },
      [p, m, g, _]
    );
    var S = a(h, b[0], b[1]);
    return c(
      function() {
        E.hasValue = !0, E.value = S;
      },
      [S]
    ), d(S), S;
  }, Km;
}
var n1;
function g4() {
  return n1 || (n1 = 1, $m.exports = m4()), $m.exports;
}
var v4 = g4();
const _4 = /* @__PURE__ */ tM(v4), y4 = {}, i1 = (n) => {
  let t;
  const e = /* @__PURE__ */ new Set(), r = (p, m) => {
    const g = typeof p == "function" ? p(t) : p;
    if (!Object.is(g, t)) {
      const _ = t;
      t = m ?? (typeof g != "object" || g === null) ? g : Object.assign({}, t, g), e.forEach((b) => b(t, _));
    }
  }, a = () => t, d = { setState: r, getState: a, getInitialState: () => h, subscribe: (p) => (e.add(p), () => e.delete(p)), destroy: () => {
    (y4 ? "production" : void 0) !== "production" && console.warn(
      "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
    ), e.clear();
  } }, h = t = n(r, a, d);
  return d;
}, x4 = (n) => n ? i1(n) : i1, { useDebugValue: S4 } = xc, { useSyncExternalStoreWithSelector: b4 } = _4, M4 = (n) => n;
function WE(n, t = M4, e) {
  const r = b4(
    n.subscribe,
    n.getState,
    n.getServerState || n.getInitialState,
    t,
    e
  );
  return S4(r), r;
}
const r1 = (n, t) => {
  const e = x4(n), r = (a, o = t) => WE(e, a, o);
  return Object.assign(r, e), r;
}, E4 = (n, t) => n ? r1(n, t) : r1;
function on(n, t) {
  if (Object.is(n, t))
    return !0;
  if (typeof n != "object" || n === null || typeof t != "object" || t === null)
    return !1;
  if (n instanceof Map && t instanceof Map) {
    if (n.size !== t.size) return !1;
    for (const [r, a] of n)
      if (!Object.is(a, t.get(r)))
        return !1;
    return !0;
  }
  if (n instanceof Set && t instanceof Set) {
    if (n.size !== t.size) return !1;
    for (const r of n)
      if (!t.has(r))
        return !1;
    return !0;
  }
  const e = Object.keys(n);
  if (e.length !== Object.keys(t).length)
    return !1;
  for (const r of e)
    if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(n[r], t[r]))
      return !1;
  return !0;
}
eM();
const Gd = ct.createContext(null), w4 = Gd.Provider, YE = vr.error001();
function Ue(n, t) {
  const e = ct.useContext(Gd);
  if (e === null)
    throw new Error(YE);
  return WE(e, n, t);
}
function ln() {
  const n = ct.useContext(Gd);
  if (n === null)
    throw new Error(YE);
  return ct.useMemo(() => ({
    getState: n.getState,
    setState: n.setState,
    subscribe: n.subscribe
  }), [n]);
}
const s1 = { display: "none" }, T4 = {
  position: "absolute",
  width: 1,
  height: 1,
  margin: -1,
  border: 0,
  padding: 0,
  overflow: "hidden",
  clip: "rect(0px, 0px, 0px, 0px)",
  clipPath: "inset(100%)"
}, qE = "react-flow__node-desc", ZE = "react-flow__edge-desc", A4 = "react-flow__aria-live", C4 = (n) => n.ariaLiveMessage, R4 = (n) => n.ariaLabelConfig;
function D4({ rfId: n }) {
  const t = Ue(C4);
  return J.jsx("div", { id: `${A4}-${n}`, "aria-live": "assertive", "aria-atomic": "true", style: T4, children: t });
}
function N4({ rfId: n, disableKeyboardA11y: t }) {
  const e = Ue(R4);
  return J.jsxs(J.Fragment, { children: [J.jsx("div", { id: `${qE}-${n}`, style: s1, children: t ? e["node.a11yDescription.default"] : e["node.a11yDescription.keyboardDisabled"] }), J.jsx("div", { id: `${ZE}-${n}`, style: s1, children: e["edge.a11yDescription.default"] }), !t && J.jsx(D4, { rfId: n })] });
}
const Xd = ct.forwardRef(({ position: n = "top-left", children: t, className: e, style: r, ...a }, o) => {
  const c = `${n}`.split("-");
  return J.jsx("div", { className: En(["react-flow__panel", e, ...c]), style: r, ref: o, ...a, children: t });
});
Xd.displayName = "Panel";
function L4({ proOptions: n, position: t = "bottom-right" }) {
  return n != null && n.hideAttribution ? null : J.jsx(Xd, { position: t, className: "react-flow__attribution", "data-message": "Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev", children: J.jsx("a", { href: "https://reactflow.dev", target: "_blank", rel: "noopener noreferrer", "aria-label": "React Flow attribution", children: "React Flow" }) });
}
const U4 = (n) => {
  const t = [], e = [];
  for (const [, r] of n.nodeLookup)
    r.selected && t.push(r.internals.userNode);
  for (const [, r] of n.edgeLookup)
    r.selected && e.push(r);
  return { selectedNodes: t, selectedEdges: e };
}, Kf = (n) => n.id;
function O4(n, t) {
  return on(n.selectedNodes.map(Kf), t.selectedNodes.map(Kf)) && on(n.selectedEdges.map(Kf), t.selectedEdges.map(Kf));
}
function P4({ onSelectionChange: n }) {
  const t = ln(), { selectedNodes: e, selectedEdges: r } = Ue(U4, O4);
  return ct.useEffect(() => {
    const a = { nodes: e, edges: r };
    n == null || n(a), t.getState().onSelectionChangeHandlers.forEach((o) => o(a));
  }, [e, r, n]), null;
}
const z4 = (n) => !!n.onSelectionChangeHandlers;
function I4({ onSelectionChange: n }) {
  const t = Ue(z4);
  return n || t ? J.jsx(P4, { onSelectionChange: n }) : null;
}
const $E = [0, 0], B4 = { x: 0, y: 0, zoom: 1 }, F4 = [
  "nodes",
  "edges",
  "defaultNodes",
  "defaultEdges",
  "onConnect",
  "onConnectStart",
  "onConnectEnd",
  "onClickConnectStart",
  "onClickConnectEnd",
  "nodesDraggable",
  "autoPanOnNodeFocus",
  "nodesConnectable",
  "nodesFocusable",
  "edgesFocusable",
  "edgesReconnectable",
  "elevateNodesOnSelect",
  "elevateEdgesOnSelect",
  "minZoom",
  "maxZoom",
  "nodeExtent",
  "onNodesChange",
  "onEdgesChange",
  "elementsSelectable",
  "connectionMode",
  "snapGrid",
  "snapToGrid",
  "translateExtent",
  "connectOnClick",
  "defaultEdgeOptions",
  "fitView",
  "fitViewOptions",
  "onNodesDelete",
  "onEdgesDelete",
  "onDelete",
  "onNodeDrag",
  "onNodeDragStart",
  "onNodeDragStop",
  "onSelectionDrag",
  "onSelectionDragStart",
  "onSelectionDragStop",
  "onMoveStart",
  "onMove",
  "onMoveEnd",
  "noPanClassName",
  "nodeOrigin",
  "autoPanOnConnect",
  "autoPanOnNodeDrag",
  "onError",
  "connectionRadius",
  "isValidConnection",
  "selectNodesOnDrag",
  "nodeDragThreshold",
  "connectionDragThreshold",
  "onBeforeDelete",
  "debug",
  "autoPanSpeed",
  "ariaLabelConfig",
  "zIndexMode"
], a1 = [...F4, "rfId"], H4 = (n) => ({
  setNodes: n.setNodes,
  setEdges: n.setEdges,
  setMinZoom: n.setMinZoom,
  setMaxZoom: n.setMaxZoom,
  setTranslateExtent: n.setTranslateExtent,
  setNodeExtent: n.setNodeExtent,
  reset: n.reset,
  setDefaultNodesAndEdges: n.setDefaultNodesAndEdges
}), o1 = {
  /*
   * these are values that are also passed directly to other components
   * than the StoreUpdater. We can reduce the number of setStore calls
   * by setting the same values here as prev fields.
   */
  translateExtent: zc,
  nodeOrigin: $E,
  minZoom: 0.5,
  maxZoom: 2,
  elementsSelectable: !0,
  noPanClassName: "nopan",
  rfId: "1"
};
function V4(n) {
  const { setNodes: t, setEdges: e, setMinZoom: r, setMaxZoom: a, setTranslateExtent: o, setNodeExtent: c, reset: u, setDefaultNodesAndEdges: d } = Ue(H4, on), h = ln();
  ct.useEffect(() => (d(n.defaultNodes, n.defaultEdges), () => {
    p.current = o1, u();
  }), []);
  const p = ct.useRef(o1);
  return ct.useEffect(
    () => {
      for (const m of a1) {
        const g = n[m], _ = p.current[m];
        g !== _ && (typeof n[m] > "u" || (m === "nodes" ? t(g) : m === "edges" ? e(g) : m === "minZoom" ? r(g) : m === "maxZoom" ? a(g) : m === "translateExtent" ? o(g) : m === "nodeExtent" ? c(g) : m === "ariaLabelConfig" ? h.setState({ ariaLabelConfig: wI(g) }) : m === "fitView" ? h.setState({ fitViewQueued: g }) : m === "fitViewOptions" ? h.setState({ fitViewOptions: g }) : h.setState({ [m]: g })));
      }
      p.current = n;
    },
    // Only re-run the effect if one of the fields we track changes
    a1.map((m) => n[m])
  ), null;
}
function l1() {
  return typeof window > "u" || !window.matchMedia ? null : window.matchMedia("(prefers-color-scheme: dark)");
}
function k4(n) {
  var r;
  const [t, e] = ct.useState(n === "system" ? null : n);
  return ct.useEffect(() => {
    if (n !== "system") {
      e(n);
      return;
    }
    const a = l1(), o = () => e(a != null && a.matches ? "dark" : "light");
    return o(), a == null || a.addEventListener("change", o), () => {
      a == null || a.removeEventListener("change", o);
    };
  }, [n]), t !== null ? t : (r = l1()) != null && r.matches ? "dark" : "light";
}
const c1 = typeof document < "u" ? document : null;
function Hc(n = null, t = { target: c1, actInsideInputWithModifier: !0 }) {
  const [e, r] = ct.useState(!1), a = ct.useRef(!1), o = ct.useRef(/* @__PURE__ */ new Set([])), [c, u] = ct.useMemo(() => {
    if (n !== null) {
      const h = (Array.isArray(n) ? n : [n]).filter((m) => typeof m == "string").map((m) => m.replace("+", `
`).replace(`

`, `
+`).split(`
`)), p = h.reduce((m, g) => m.concat(...g), []);
      return [h, p];
    }
    return [[], []];
  }, [n]);
  return ct.useEffect(() => {
    const d = (t == null ? void 0 : t.target) ?? c1, h = (t == null ? void 0 : t.actInsideInputWithModifier) ?? !0;
    if (n !== null) {
      const p = (_) => {
        var S, y;
        if (a.current = _.ctrlKey || _.metaKey || _.shiftKey || _.altKey, (!a.current || a.current && !h) && CE(_))
          return !1;
        const E = f1(_.code, u);
        if (o.current.add(_[E]), u1(c, o.current, !1)) {
          const A = ((y = (S = _.composedPath) == null ? void 0 : S.call(_)) == null ? void 0 : y[0]) || _.target, w = (A == null ? void 0 : A.nodeName) === "BUTTON" || (A == null ? void 0 : A.nodeName) === "A";
          t.preventDefault !== !1 && (a.current || !w) && _.preventDefault(), r(!0);
        }
      }, m = (_) => {
        const b = f1(_.code, u);
        u1(c, o.current, !0) ? (r(!1), o.current.clear()) : o.current.delete(_[b]), _.key === "Meta" && o.current.clear(), a.current = !1;
      }, g = () => {
        o.current.clear(), r(!1);
      };
      return d == null || d.addEventListener("keydown", p), d == null || d.addEventListener("keyup", m), window.addEventListener("blur", g), window.addEventListener("contextmenu", g), () => {
        d == null || d.removeEventListener("keydown", p), d == null || d.removeEventListener("keyup", m), window.removeEventListener("blur", g), window.removeEventListener("contextmenu", g);
      };
    }
  }, [n, r]), e;
}
function u1(n, t, e) {
  return n.filter((r) => e || r.length === t.size).some((r) => r.every((a) => t.has(a)));
}
function f1(n, t) {
  return t.includes(n) ? "code" : "key";
}
const G4 = () => {
  const n = ln();
  return ct.useMemo(() => ({
    zoomIn: (t) => {
      const { panZoom: e } = n.getState();
      return e ? e.scaleBy(1.2, { duration: t == null ? void 0 : t.duration }) : Promise.resolve(!1);
    },
    zoomOut: (t) => {
      const { panZoom: e } = n.getState();
      return e ? e.scaleBy(1 / 1.2, { duration: t == null ? void 0 : t.duration }) : Promise.resolve(!1);
    },
    zoomTo: (t, e) => {
      const { panZoom: r } = n.getState();
      return r ? r.scaleTo(t, { duration: e == null ? void 0 : e.duration }) : Promise.resolve(!1);
    },
    getZoom: () => n.getState().transform[2],
    setViewport: async (t, e) => {
      const { transform: [r, a, o], panZoom: c } = n.getState();
      return c ? (await c.setViewport({
        x: t.x ?? r,
        y: t.y ?? a,
        zoom: t.zoom ?? o
      }, e), Promise.resolve(!0)) : Promise.resolve(!1);
    },
    getViewport: () => {
      const [t, e, r] = n.getState().transform;
      return { x: t, y: e, zoom: r };
    },
    setCenter: async (t, e, r) => n.getState().setCenter(t, e, r),
    fitBounds: async (t, e) => {
      const { width: r, height: a, minZoom: o, maxZoom: c, panZoom: u } = n.getState(), d = j0(t, r, a, o, c, (e == null ? void 0 : e.padding) ?? 0.1);
      return u ? (await u.setViewport(d, {
        duration: e == null ? void 0 : e.duration,
        ease: e == null ? void 0 : e.ease,
        interpolate: e == null ? void 0 : e.interpolate
      }), Promise.resolve(!0)) : Promise.resolve(!1);
    },
    screenToFlowPosition: (t, e = {}) => {
      const { transform: r, snapGrid: a, snapToGrid: o, domNode: c } = n.getState();
      if (!c)
        return t;
      const { x: u, y: d } = c.getBoundingClientRect(), h = {
        x: t.x - u,
        y: t.y - d
      }, p = e.snapGrid ?? a, m = e.snapToGrid ?? o;
      return Qc(h, r, m, p);
    },
    flowToScreenPosition: (t) => {
      const { transform: e, domNode: r } = n.getState();
      if (!r)
        return t;
      const { x: a, y: o } = r.getBoundingClientRect(), c = Ad(t, e);
      return {
        x: c.x + a,
        y: c.y + o
      };
    }
  }), []);
};
function KE(n, t) {
  const e = [], r = /* @__PURE__ */ new Map(), a = [];
  for (const o of n)
    if (o.type === "add") {
      a.push(o);
      continue;
    } else if (o.type === "remove" || o.type === "replace")
      r.set(o.id, [o]);
    else {
      const c = r.get(o.id);
      c ? c.push(o) : r.set(o.id, [o]);
    }
  for (const o of t) {
    const c = r.get(o.id);
    if (!c) {
      e.push(o);
      continue;
    }
    if (c[0].type === "remove")
      continue;
    if (c[0].type === "replace") {
      e.push({ ...c[0].item });
      continue;
    }
    const u = { ...o };
    for (const d of c)
      X4(d, u);
    e.push(u);
  }
  return a.length && a.forEach((o) => {
    o.index !== void 0 ? e.splice(o.index, 0, { ...o.item }) : e.push({ ...o.item });
  }), e;
}
function X4(n, t) {
  switch (n.type) {
    case "select": {
      t.selected = n.selected;
      break;
    }
    case "position": {
      typeof n.position < "u" && (t.position = n.position), typeof n.dragging < "u" && (t.dragging = n.dragging);
      break;
    }
    case "dimensions": {
      typeof n.dimensions < "u" && (t.measured = {
        ...n.dimensions
      }, n.setAttributes && ((n.setAttributes === !0 || n.setAttributes === "width") && (t.width = n.dimensions.width), (n.setAttributes === !0 || n.setAttributes === "height") && (t.height = n.dimensions.height))), typeof n.resizing == "boolean" && (t.resizing = n.resizing);
      break;
    }
  }
}
function QE(n, t) {
  return KE(n, t);
}
function JE(n, t) {
  return KE(n, t);
}
function Sa(n, t) {
  return {
    id: n,
    type: "select",
    selected: t
  };
}
function Yo(n, t = /* @__PURE__ */ new Set(), e = !1) {
  const r = [];
  for (const [a, o] of n) {
    const c = t.has(a);
    !(o.selected === void 0 && !c) && o.selected !== c && (e && (o.selected = c), r.push(Sa(o.id, c)));
  }
  return r;
}
function d1({ items: n = [], lookup: t }) {
  var a;
  const e = [], r = new Map(n.map((o) => [o.id, o]));
  for (const [o, c] of n.entries()) {
    const u = t.get(c.id), d = ((a = u == null ? void 0 : u.internals) == null ? void 0 : a.userNode) ?? u;
    d !== void 0 && d !== c && e.push({ id: c.id, item: c, type: "replace" }), d === void 0 && e.push({ item: c, type: "add", index: o });
  }
  for (const [o] of t)
    r.get(o) === void 0 && e.push({ id: o, type: "remove" });
  return e;
}
function h1(n) {
  return {
    id: n.id,
    type: "remove"
  };
}
const p1 = (n) => mI(n), j4 = (n) => xE(n);
function tw(n) {
  return ct.forwardRef(n);
}
const W4 = typeof window < "u" ? ct.useLayoutEffect : ct.useEffect;
function m1(n) {
  const [t, e] = ct.useState(BigInt(0)), [r] = ct.useState(() => Y4(() => e((a) => a + BigInt(1))));
  return W4(() => {
    const a = r.get();
    a.length && (n(a), r.reset());
  }, [t]), r;
}
function Y4(n) {
  let t = [];
  return {
    get: () => t,
    reset: () => {
      t = [];
    },
    push: (e) => {
      t.push(e), n();
    }
  };
}
const ew = ct.createContext(null);
function q4({ children: n }) {
  const t = ln(), e = ct.useCallback((u) => {
    const { nodes: d = [], setNodes: h, hasDefaultNodes: p, onNodesChange: m, nodeLookup: g, fitViewQueued: _, onNodesChangeMiddlewareMap: b } = t.getState();
    let E = d;
    for (const y of u)
      E = typeof y == "function" ? y(E) : y;
    let S = d1({
      items: E,
      lookup: g
    });
    for (const y of b.values())
      S = y(S);
    p && h(E), S.length > 0 ? m == null || m(S) : _ && window.requestAnimationFrame(() => {
      const { fitViewQueued: y, nodes: A, setNodes: w } = t.getState();
      y && w(A);
    });
  }, []), r = m1(e), a = ct.useCallback((u) => {
    const { edges: d = [], setEdges: h, hasDefaultEdges: p, onEdgesChange: m, edgeLookup: g } = t.getState();
    let _ = d;
    for (const b of u)
      _ = typeof b == "function" ? b(_) : b;
    p ? h(_) : m && m(d1({
      items: _,
      lookup: g
    }));
  }, []), o = m1(a), c = ct.useMemo(() => ({ nodeQueue: r, edgeQueue: o }), []);
  return J.jsx(ew.Provider, { value: c, children: n });
}
function Z4() {
  const n = ct.useContext(ew);
  if (!n)
    throw new Error("useBatchContext must be used within a BatchProvider");
  return n;
}
const $4 = (n) => !!n.panZoom;
function Vc() {
  const n = G4(), t = ln(), e = Z4(), r = Ue($4), a = ct.useMemo(() => {
    const o = (m) => t.getState().nodeLookup.get(m), c = (m) => {
      e.nodeQueue.push(m);
    }, u = (m) => {
      e.edgeQueue.push(m);
    }, d = (m) => {
      var y, A;
      const { nodeLookup: g, nodeOrigin: _ } = t.getState(), b = p1(m) ? m : g.get(m.id), E = b.parentId ? TE(b.position, b.measured, b.parentId, g, _) : b.position, S = {
        ...b,
        position: E,
        width: ((y = b.measured) == null ? void 0 : y.width) ?? b.width,
        height: ((A = b.measured) == null ? void 0 : A.height) ?? b.height
      };
      return fl(S);
    }, h = (m, g, _ = { replace: !1 }) => {
      c((b) => b.map((E) => {
        if (E.id === m) {
          const S = typeof g == "function" ? g(E) : g;
          return _.replace && p1(S) ? S : { ...E, ...S };
        }
        return E;
      }));
    }, p = (m, g, _ = { replace: !1 }) => {
      u((b) => b.map((E) => {
        if (E.id === m) {
          const S = typeof g == "function" ? g(E) : g;
          return _.replace && j4(S) ? S : { ...E, ...S };
        }
        return E;
      }));
    };
    return {
      getNodes: () => t.getState().nodes.map((m) => ({ ...m })),
      getNode: (m) => {
        var g;
        return (g = o(m)) == null ? void 0 : g.internals.userNode;
      },
      getInternalNode: o,
      getEdges: () => {
        const { edges: m = [] } = t.getState();
        return m.map((g) => ({ ...g }));
      },
      getEdge: (m) => t.getState().edgeLookup.get(m),
      setNodes: c,
      setEdges: u,
      addNodes: (m) => {
        const g = Array.isArray(m) ? m : [m];
        e.nodeQueue.push((_) => [..._, ...g]);
      },
      addEdges: (m) => {
        const g = Array.isArray(m) ? m : [m];
        e.edgeQueue.push((_) => [..._, ...g]);
      },
      toObject: () => {
        const { nodes: m = [], edges: g = [], transform: _ } = t.getState(), [b, E, S] = _;
        return {
          nodes: m.map((y) => ({ ...y })),
          edges: g.map((y) => ({ ...y })),
          viewport: {
            x: b,
            y: E,
            zoom: S
          }
        };
      },
      deleteElements: async ({ nodes: m = [], edges: g = [] }) => {
        const { nodes: _, edges: b, onNodesDelete: E, onEdgesDelete: S, triggerNodeChanges: y, triggerEdgeChanges: A, onDelete: w, onBeforeDelete: M } = t.getState(), { nodes: O, edges: L } = await xI({
          nodesToRemove: m,
          edgesToRemove: g,
          nodes: _,
          edges: b,
          onBeforeDelete: M
        }), N = L.length > 0, z = O.length > 0;
        if (N) {
          const R = L.map(h1);
          S == null || S(L), A(R);
        }
        if (z) {
          const R = O.map(h1);
          E == null || E(O), y(R);
        }
        return (z || N) && (w == null || w({ nodes: O, edges: L })), { deletedNodes: O, deletedEdges: L };
      },
      /**
       * Partial is defined as "the 2 nodes/areas are intersecting partially".
       * If a is contained in b or b is contained in a, they are both
       * considered fully intersecting.
       */
      getIntersectingNodes: (m, g = !0, _) => {
        const b = Hb(m), E = b ? m : d(m), S = _ !== void 0;
        return E ? (_ || t.getState().nodes).filter((y) => {
          const A = t.getState().nodeLookup.get(y.id);
          if (A && !b && (y.id === m.id || !A.internals.positionAbsolute))
            return !1;
          const w = fl(S ? y : A), M = Bc(w, E);
          return g && M > 0 || M >= w.width * w.height || M >= E.width * E.height;
        }) : [];
      },
      isNodeIntersecting: (m, g, _ = !0) => {
        const E = Hb(m) ? m : d(m);
        if (!E)
          return !1;
        const S = Bc(E, g);
        return _ && S > 0 || S >= g.width * g.height || S >= E.width * E.height;
      },
      updateNode: h,
      updateNodeData: (m, g, _ = { replace: !1 }) => {
        h(m, (b) => {
          const E = typeof g == "function" ? g(b) : g;
          return _.replace ? { ...b, data: E } : { ...b, data: { ...b.data, ...E } };
        }, _);
      },
      updateEdge: p,
      updateEdgeData: (m, g, _ = { replace: !1 }) => {
        p(m, (b) => {
          const E = typeof g == "function" ? g(b) : g;
          return _.replace ? { ...b, data: E } : { ...b, data: { ...b.data, ...E } };
        }, _);
      },
      getNodesBounds: (m) => {
        const { nodeLookup: g, nodeOrigin: _ } = t.getState();
        return gI(m, { nodeLookup: g, nodeOrigin: _ });
      },
      getHandleConnections: ({ type: m, id: g, nodeId: _ }) => {
        var b;
        return Array.from(((b = t.getState().connectionLookup.get(`${_}-${m}${g ? `-${g}` : ""}`)) == null ? void 0 : b.values()) ?? []);
      },
      getNodeConnections: ({ type: m, handleId: g, nodeId: _ }) => {
        var b;
        return Array.from(((b = t.getState().connectionLookup.get(`${_}${m ? g ? `-${m}-${g}` : `-${m}` : ""}`)) == null ? void 0 : b.values()) ?? []);
      },
      fitView: async (m) => {
        const g = t.getState().fitViewResolver ?? EI();
        return t.setState({ fitViewQueued: !0, fitViewOptions: m, fitViewResolver: g }), e.nodeQueue.push((_) => [..._]), g.promise;
      }
    };
  }, []);
  return ct.useMemo(() => ({
    ...a,
    ...n,
    viewportInitialized: r
  }), [r]);
}
const g1 = (n) => n.selected, K4 = typeof window < "u" ? window : void 0;
function Q4({ deleteKeyCode: n, multiSelectionKeyCode: t }) {
  const e = ln(), { deleteElements: r } = Vc(), a = Hc(n, { actInsideInputWithModifier: !1 }), o = Hc(t, { target: K4 });
  ct.useEffect(() => {
    if (a) {
      const { edges: c, nodes: u } = e.getState();
      r({ nodes: u.filter(g1), edges: c.filter(g1) }), e.setState({ nodesSelectionActive: !1 });
    }
  }, [a]), ct.useEffect(() => {
    e.setState({ multiSelectionActive: o });
  }, [o]);
}
function J4(n) {
  const t = ln();
  ct.useEffect(() => {
    const e = () => {
      var a, o, c, u;
      if (!n.current || !(((o = (a = n.current).checkVisibility) == null ? void 0 : o.call(a)) ?? !0))
        return !1;
      const r = W0(n.current);
      (r.height === 0 || r.width === 0) && ((u = (c = t.getState()).onError) == null || u.call(c, "004", vr.error004())), t.setState({ width: r.width || 500, height: r.height || 500 });
    };
    if (n.current) {
      e(), window.addEventListener("resize", e);
      const r = new ResizeObserver(() => e());
      return r.observe(n.current), () => {
        window.removeEventListener("resize", e), r && n.current && r.unobserve(n.current);
      };
    }
  }, []);
}
const jd = {
  position: "absolute",
  width: "100%",
  height: "100%",
  top: 0,
  left: 0
}, tB = (n) => ({
  userSelectionActive: n.userSelectionActive,
  lib: n.lib,
  connectionInProgress: n.connection.inProgress
});
function eB({ onPaneContextMenu: n, zoomOnScroll: t = !0, zoomOnPinch: e = !0, panOnScroll: r = !1, panOnScrollSpeed: a = 0.5, panOnScrollMode: o = Da.Free, zoomOnDoubleClick: c = !0, panOnDrag: u = !0, defaultViewport: d, translateExtent: h, minZoom: p, maxZoom: m, zoomActivationKeyCode: g, preventScrolling: _ = !0, children: b, noWheelClassName: E, noPanClassName: S, onViewportChange: y, isControlledViewport: A, paneClickDistance: w, selectionOnDrag: M }) {
  const O = ln(), L = ct.useRef(null), { userSelectionActive: N, lib: z, connectionInProgress: R } = Ue(tB, on), T = Hc(g), U = ct.useRef();
  J4(L);
  const B = ct.useCallback((I) => {
    y == null || y({ x: I[0], y: I[1], zoom: I[2] }), A || O.setState({ transform: I });
  }, [y, A]);
  return ct.useEffect(() => {
    if (L.current) {
      U.current = a4({
        domNode: L.current,
        minZoom: p,
        maxZoom: m,
        translateExtent: h,
        viewport: d,
        onDraggingChange: (D) => O.setState((V) => V.paneDragging === D ? V : { paneDragging: D }),
        onPanZoomStart: (D, V) => {
          const { onViewportChangeStart: H, onMoveStart: j } = O.getState();
          j == null || j(D, V), H == null || H(V);
        },
        onPanZoom: (D, V) => {
          const { onViewportChange: H, onMove: j } = O.getState();
          j == null || j(D, V), H == null || H(V);
        },
        onPanZoomEnd: (D, V) => {
          const { onViewportChangeEnd: H, onMoveEnd: j } = O.getState();
          j == null || j(D, V), H == null || H(V);
        }
      });
      const { x: I, y: C, zoom: X } = U.current.getViewport();
      return O.setState({
        panZoom: U.current,
        transform: [I, C, X],
        domNode: L.current.closest(".react-flow")
      }), () => {
        var D;
        (D = U.current) == null || D.destroy();
      };
    }
  }, []), ct.useEffect(() => {
    var I;
    (I = U.current) == null || I.update({
      onPaneContextMenu: n,
      zoomOnScroll: t,
      zoomOnPinch: e,
      panOnScroll: r,
      panOnScrollSpeed: a,
      panOnScrollMode: o,
      zoomOnDoubleClick: c,
      panOnDrag: u,
      zoomActivationKeyPressed: T,
      preventScrolling: _,
      noPanClassName: S,
      userSelectionActive: N,
      noWheelClassName: E,
      lib: z,
      onTransformChange: B,
      connectionInProgress: R,
      selectionOnDrag: M,
      paneClickDistance: w
    });
  }, [
    n,
    t,
    e,
    r,
    a,
    o,
    c,
    u,
    T,
    _,
    S,
    N,
    E,
    z,
    B,
    R,
    M,
    w
  ]), J.jsx("div", { className: "react-flow__renderer", ref: L, style: jd, children: b });
}
const nB = (n) => ({
  userSelectionActive: n.userSelectionActive,
  userSelectionRect: n.userSelectionRect
});
function iB() {
  const { userSelectionActive: n, userSelectionRect: t } = Ue(nB, on);
  return n && t ? J.jsx("div", { className: "react-flow__selection react-flow__container", style: {
    width: t.width,
    height: t.height,
    transform: `translate(${t.x}px, ${t.y}px)`
  } }) : null;
}
const tg = (n, t) => (e) => {
  e.target === t.current && (n == null || n(e));
}, rB = (n) => ({
  userSelectionActive: n.userSelectionActive,
  elementsSelectable: n.elementsSelectable,
  connectionInProgress: n.connection.inProgress,
  dragging: n.paneDragging
});
function sB({ isSelecting: n, selectionKeyPressed: t, selectionMode: e = Ic.Full, panOnDrag: r, paneClickDistance: a, selectionOnDrag: o, onSelectionStart: c, onSelectionEnd: u, onPaneClick: d, onPaneContextMenu: h, onPaneScroll: p, onPaneMouseEnter: m, onPaneMouseMove: g, onPaneMouseLeave: _, children: b }) {
  const E = ln(), { userSelectionActive: S, elementsSelectable: y, dragging: A, connectionInProgress: w } = Ue(rB, on), M = y && (n || S), O = ct.useRef(null), L = ct.useRef(), N = ct.useRef(/* @__PURE__ */ new Set()), z = ct.useRef(/* @__PURE__ */ new Set()), R = ct.useRef(!1), T = (H) => {
    if (R.current || w) {
      R.current = !1;
      return;
    }
    d == null || d(H), E.getState().resetSelectedElements(), E.setState({ nodesSelectionActive: !1 });
  }, U = (H) => {
    if (Array.isArray(r) && (r != null && r.includes(2))) {
      H.preventDefault();
      return;
    }
    h == null || h(H);
  }, B = p ? (H) => p(H) : void 0, I = (H) => {
    R.current && (H.stopPropagation(), R.current = !1);
  }, C = (H) => {
    var k, $;
    const { domNode: j } = E.getState();
    if (L.current = j == null ? void 0 : j.getBoundingClientRect(), !L.current)
      return;
    const K = H.target === O.current;
    if (!K && !!H.target.closest(".nokey") || !n || !(o && K || t) || H.button !== 0 || !H.isPrimary)
      return;
    ($ = (k = H.target) == null ? void 0 : k.setPointerCapture) == null || $.call(k, H.pointerId), R.current = !1;
    const { x: it, y: G } = tr(H.nativeEvent, L.current);
    E.setState({
      userSelectionRect: {
        width: 0,
        height: 0,
        startX: it,
        startY: G,
        x: it,
        y: G
      }
    }), K || (H.stopPropagation(), H.preventDefault());
  }, X = (H) => {
    const { userSelectionRect: j, transform: K, nodeLookup: F, edgeLookup: q, connectionLookup: it, triggerNodeChanges: G, triggerEdgeChanges: k, defaultEdgeOptions: $, resetSelectedElements: Q } = E.getState();
    if (!L.current || !j)
      return;
    const { x: et, y: st } = tr(H.nativeEvent, L.current), { startX: _t, startY: Mt } = j;
    if (!R.current) {
      const Ft = t ? 0 : a;
      if (Math.hypot(et - _t, st - Mt) <= Ft)
        return;
      Q(), c == null || c(H);
    }
    R.current = !0;
    const Rt = {
      startX: _t,
      startY: Mt,
      x: et < _t ? et : _t,
      y: st < Mt ? st : Mt,
      width: Math.abs(et - _t),
      height: Math.abs(st - Mt)
    }, Ot = N.current, nt = z.current;
    N.current = new Set(X0(F, Rt, K, e === Ic.Partial, !0).map((Ft) => Ft.id)), z.current = /* @__PURE__ */ new Set();
    const Jt = ($ == null ? void 0 : $.selectable) ?? !0;
    for (const Ft of N.current) {
      const ne = it.get(Ft);
      if (ne)
        for (const { edgeId: jt } of ne.values()) {
          const xe = q.get(jt);
          xe && (xe.selectable ?? Jt) && z.current.add(jt);
        }
    }
    if (!Vb(Ot, N.current)) {
      const Ft = Yo(F, N.current, !0);
      G(Ft);
    }
    if (!Vb(nt, z.current)) {
      const Ft = Yo(q, z.current);
      k(Ft);
    }
    E.setState({
      userSelectionRect: Rt,
      userSelectionActive: !0,
      nodesSelectionActive: !1
    });
  }, D = (H) => {
    var j, K;
    H.button === 0 && ((K = (j = H.target) == null ? void 0 : j.releasePointerCapture) == null || K.call(j, H.pointerId), !S && H.target === O.current && E.getState().userSelectionRect && (T == null || T(H)), E.setState({
      userSelectionActive: !1,
      userSelectionRect: null
    }), R.current && (u == null || u(H), E.setState({
      nodesSelectionActive: N.current.size > 0
    })));
  }, V = r === !0 || Array.isArray(r) && r.includes(0);
  return J.jsxs("div", { className: En(["react-flow__pane", { draggable: V, dragging: A, selection: n }]), onClick: M ? void 0 : tg(T, O), onContextMenu: tg(U, O), onWheel: tg(B, O), onPointerEnter: M ? void 0 : m, onPointerMove: M ? X : g, onPointerUp: M ? D : void 0, onPointerDownCapture: M ? C : void 0, onClickCapture: M ? I : void 0, onPointerLeave: _, ref: O, style: jd, children: [b, J.jsx(iB, {})] });
}
function f0({ id: n, store: t, unselect: e = !1, nodeRef: r }) {
  const { addSelectedNodes: a, unselectNodesAndEdges: o, multiSelectionActive: c, nodeLookup: u, onError: d } = t.getState(), h = u.get(n);
  if (!h) {
    d == null || d("012", vr.error012(n));
    return;
  }
  t.setState({ nodesSelectionActive: !1 }), h.selected ? (e || h.selected && c) && (o({ nodes: [h], edges: [] }), requestAnimationFrame(() => {
    var p;
    return (p = r == null ? void 0 : r.current) == null ? void 0 : p.blur();
  })) : a([n]);
}
function nw({ nodeRef: n, disabled: t = !1, noDragClassName: e, handleSelector: r, nodeId: a, isSelectable: o, nodeClickDistance: c }) {
  const u = ln(), [d, h] = ct.useState(!1), p = ct.useRef();
  return ct.useEffect(() => {
    p.current = WI({
      getStoreItems: () => u.getState(),
      onNodeMouseDown: (m) => {
        f0({
          id: m,
          store: u,
          nodeRef: n
        });
      },
      onDragStart: () => {
        h(!0);
      },
      onDragStop: () => {
        h(!1);
      }
    });
  }, []), ct.useEffect(() => {
    if (!(t || !n.current || !p.current))
      return p.current.update({
        noDragClassName: e,
        handleSelector: r,
        domNode: n.current,
        isSelectable: o,
        nodeId: a,
        nodeClickDistance: c
      }), () => {
        var m;
        (m = p.current) == null || m.destroy();
      };
  }, [e, r, t, o, n, a, c]), d;
}
const aB = (n) => (t) => t.selected && (t.draggable || n && typeof t.draggable > "u");
function iw() {
  const n = ln();
  return ct.useCallback((e) => {
    const { nodeExtent: r, snapToGrid: a, snapGrid: o, nodesDraggable: c, onError: u, updateNodePositions: d, nodeLookup: h, nodeOrigin: p } = n.getState(), m = /* @__PURE__ */ new Map(), g = aB(c), _ = a ? o[0] : 5, b = a ? o[1] : 5, E = e.direction.x * _ * e.factor, S = e.direction.y * b * e.factor;
    for (const [, y] of h) {
      if (!g(y))
        continue;
      let A = {
        x: y.internals.positionAbsolute.x + E,
        y: y.internals.positionAbsolute.y + S
      };
      a && (A = Kc(A, o));
      const { position: w, positionAbsolute: M } = SE({
        nodeId: y.id,
        nextPosition: A,
        nodeLookup: h,
        nodeExtent: r,
        nodeOrigin: p,
        onError: u
      });
      y.position = w, y.internals.positionAbsolute = M, m.set(y.id, y);
    }
    d(m);
  }, []);
}
const Q0 = ct.createContext(null), oB = Q0.Provider;
Q0.Consumer;
const rw = () => ct.useContext(Q0), lB = (n) => ({
  connectOnClick: n.connectOnClick,
  noPanClassName: n.noPanClassName,
  rfId: n.rfId
}), cB = (n, t, e) => (r) => {
  const { connectionClickStartHandle: a, connectionMode: o, connection: c } = r, { fromHandle: u, toHandle: d, isValid: h } = c, p = (d == null ? void 0 : d.nodeId) === n && (d == null ? void 0 : d.id) === t && (d == null ? void 0 : d.type) === e;
  return {
    connectingFrom: (u == null ? void 0 : u.nodeId) === n && (u == null ? void 0 : u.id) === t && (u == null ? void 0 : u.type) === e,
    connectingTo: p,
    clickConnecting: (a == null ? void 0 : a.nodeId) === n && (a == null ? void 0 : a.id) === t && (a == null ? void 0 : a.type) === e,
    isPossibleEndHandle: o === cl.Strict ? (u == null ? void 0 : u.type) !== e : n !== (u == null ? void 0 : u.nodeId) || t !== (u == null ? void 0 : u.id),
    connectionInProcess: !!u,
    clickConnectionInProcess: !!a,
    valid: p && h
  };
};
function uB({ type: n = "source", position: t = re.Top, isValidConnection: e, isConnectable: r = !0, isConnectableStart: a = !0, isConnectableEnd: o = !0, id: c, onConnect: u, children: d, className: h, onMouseDown: p, onTouchStart: m, ...g }, _) {
  var X, D;
  const b = c || null, E = n === "target", S = ln(), y = rw(), { connectOnClick: A, noPanClassName: w, rfId: M } = Ue(lB, on), { connectingFrom: O, connectingTo: L, clickConnecting: N, isPossibleEndHandle: z, connectionInProcess: R, clickConnectionInProcess: T, valid: U } = Ue(cB(y, b, n), on);
  y || (D = (X = S.getState()).onError) == null || D.call(X, "010", vr.error010());
  const B = (V) => {
    const { defaultEdgeOptions: H, onConnect: j, hasDefaultEdges: K } = S.getState(), F = {
      ...H,
      ...V
    };
    if (K) {
      const { edges: q, setEdges: it } = S.getState();
      it(UE(F, q));
    }
    j == null || j(F), u == null || u(F);
  }, I = (V) => {
    if (!y)
      return;
    const H = RE(V.nativeEvent);
    if (a && (H && V.button === 0 || !H)) {
      const j = S.getState();
      u0.onPointerDown(V.nativeEvent, {
        handleDomNode: V.currentTarget,
        autoPanOnConnect: j.autoPanOnConnect,
        connectionMode: j.connectionMode,
        connectionRadius: j.connectionRadius,
        domNode: j.domNode,
        nodeLookup: j.nodeLookup,
        lib: j.lib,
        isTarget: E,
        handleId: b,
        nodeId: y,
        flowId: j.rfId,
        panBy: j.panBy,
        cancelConnection: j.cancelConnection,
        onConnectStart: j.onConnectStart,
        onConnectEnd: (...K) => {
          var F, q;
          return (q = (F = S.getState()).onConnectEnd) == null ? void 0 : q.call(F, ...K);
        },
        updateConnection: j.updateConnection,
        onConnect: B,
        isValidConnection: e || ((...K) => {
          var F, q;
          return ((q = (F = S.getState()).isValidConnection) == null ? void 0 : q.call(F, ...K)) ?? !0;
        }),
        getTransform: () => S.getState().transform,
        getFromHandle: () => S.getState().connection.fromHandle,
        autoPanSpeed: j.autoPanSpeed,
        dragThreshold: j.connectionDragThreshold
      });
    }
    H ? p == null || p(V) : m == null || m(V);
  }, C = (V) => {
    const { onClickConnectStart: H, onClickConnectEnd: j, connectionClickStartHandle: K, connectionMode: F, isValidConnection: q, lib: it, rfId: G, nodeLookup: k, connection: $ } = S.getState();
    if (!y || !K && !a)
      return;
    if (!K) {
      H == null || H(V.nativeEvent, { nodeId: y, handleId: b, handleType: n }), S.setState({ connectionClickStartHandle: { nodeId: y, type: n, id: b } });
      return;
    }
    const Q = AE(V.target), et = e || q, { connection: st, isValid: _t } = u0.isValid(V.nativeEvent, {
      handle: {
        nodeId: y,
        id: b,
        type: n
      },
      connectionMode: F,
      fromNodeId: K.nodeId,
      fromHandleId: K.id || null,
      fromType: K.type,
      isValidConnection: et,
      flowId: G,
      doc: Q,
      lib: it,
      nodeLookup: k
    });
    _t && st && B(st);
    const Mt = structuredClone($);
    delete Mt.inProgress, Mt.toPosition = Mt.toHandle ? Mt.toHandle.position : null, j == null || j(V, Mt), S.setState({ connectionClickStartHandle: null });
  };
  return J.jsx("div", { "data-handleid": b, "data-nodeid": y, "data-handlepos": t, "data-id": `${M}-${y}-${b}-${n}`, className: En([
    "react-flow__handle",
    `react-flow__handle-${t}`,
    "nodrag",
    w,
    h,
    {
      source: !E,
      target: E,
      connectable: r,
      connectablestart: a,
      connectableend: o,
      clickconnecting: N,
      connectingfrom: O,
      connectingto: L,
      valid: U,
      /*
       * shows where you can start a connection from
       * and where you can end it while connecting
       */
      connectionindicator: r && (!R || z) && (R || T ? o : a)
    }
  ]), onMouseDown: I, onTouchStart: I, onClick: A ? C : void 0, ref: _, ...g, children: d });
}
const pl = ct.memo(tw(uB));
function fB({ data: n, isConnectable: t, sourcePosition: e = re.Bottom }) {
  return J.jsxs(J.Fragment, { children: [n == null ? void 0 : n.label, J.jsx(pl, { type: "source", position: e, isConnectable: t })] });
}
function dB({ data: n, isConnectable: t, targetPosition: e = re.Top, sourcePosition: r = re.Bottom }) {
  return J.jsxs(J.Fragment, { children: [J.jsx(pl, { type: "target", position: e, isConnectable: t }), n == null ? void 0 : n.label, J.jsx(pl, { type: "source", position: r, isConnectable: t })] });
}
function hB() {
  return null;
}
function pB({ data: n, isConnectable: t, targetPosition: e = re.Top }) {
  return J.jsxs(J.Fragment, { children: [J.jsx(pl, { type: "target", position: e, isConnectable: t }), n == null ? void 0 : n.label] });
}
const Cd = {
  ArrowUp: { x: 0, y: -1 },
  ArrowDown: { x: 0, y: 1 },
  ArrowLeft: { x: -1, y: 0 },
  ArrowRight: { x: 1, y: 0 }
}, v1 = {
  input: fB,
  default: dB,
  output: pB,
  group: hB
};
function mB(n) {
  var t, e, r, a;
  return n.internals.handleBounds === void 0 ? {
    width: n.width ?? n.initialWidth ?? ((t = n.style) == null ? void 0 : t.width),
    height: n.height ?? n.initialHeight ?? ((e = n.style) == null ? void 0 : e.height)
  } : {
    width: n.width ?? ((r = n.style) == null ? void 0 : r.width),
    height: n.height ?? ((a = n.style) == null ? void 0 : a.height)
  };
}
const gB = (n) => {
  const { width: t, height: e, x: r, y: a } = $c(n.nodeLookup, {
    filter: (o) => !!o.selected
  });
  return {
    width: Ji(t) ? t : null,
    height: Ji(e) ? e : null,
    userSelectionActive: n.userSelectionActive,
    transformString: `translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]}) translate(${r}px,${a}px)`
  };
};
function vB({ onSelectionContextMenu: n, noPanClassName: t, disableKeyboardA11y: e }) {
  const r = ln(), { width: a, height: o, transformString: c, userSelectionActive: u } = Ue(gB, on), d = iw(), h = ct.useRef(null);
  ct.useEffect(() => {
    var _;
    e || (_ = h.current) == null || _.focus({
      preventScroll: !0
    });
  }, [e]);
  const p = !u && a !== null && o !== null;
  if (nw({
    nodeRef: h,
    disabled: !p
  }), !p)
    return null;
  const m = n ? (_) => {
    const b = r.getState().nodes.filter((E) => E.selected);
    n(_, b);
  } : void 0, g = (_) => {
    Object.prototype.hasOwnProperty.call(Cd, _.key) && (_.preventDefault(), d({
      direction: Cd[_.key],
      factor: _.shiftKey ? 4 : 1
    }));
  };
  return J.jsx("div", { className: En(["react-flow__nodesselection", "react-flow__container", t]), style: {
    transform: c
  }, children: J.jsx("div", { ref: h, className: "react-flow__nodesselection-rect", onContextMenu: m, tabIndex: e ? void 0 : -1, onKeyDown: e ? void 0 : g, style: {
    width: a,
    height: o
  } }) });
}
const _1 = typeof window < "u" ? window : void 0, _B = (n) => ({ nodesSelectionActive: n.nodesSelectionActive, userSelectionActive: n.userSelectionActive });
function sw({ children: n, onPaneClick: t, onPaneMouseEnter: e, onPaneMouseMove: r, onPaneMouseLeave: a, onPaneContextMenu: o, onPaneScroll: c, paneClickDistance: u, deleteKeyCode: d, selectionKeyCode: h, selectionOnDrag: p, selectionMode: m, onSelectionStart: g, onSelectionEnd: _, multiSelectionKeyCode: b, panActivationKeyCode: E, zoomActivationKeyCode: S, elementsSelectable: y, zoomOnScroll: A, zoomOnPinch: w, panOnScroll: M, panOnScrollSpeed: O, panOnScrollMode: L, zoomOnDoubleClick: N, panOnDrag: z, defaultViewport: R, translateExtent: T, minZoom: U, maxZoom: B, preventScrolling: I, onSelectionContextMenu: C, noWheelClassName: X, noPanClassName: D, disableKeyboardA11y: V, onViewportChange: H, isControlledViewport: j }) {
  const { nodesSelectionActive: K, userSelectionActive: F } = Ue(_B, on), q = Hc(h, { target: _1 }), it = Hc(E, { target: _1 }), G = it || z, k = it || M, $ = p && G !== !0, Q = q || F || $;
  return Q4({ deleteKeyCode: d, multiSelectionKeyCode: b }), J.jsx(eB, { onPaneContextMenu: o, elementsSelectable: y, zoomOnScroll: A, zoomOnPinch: w, panOnScroll: k, panOnScrollSpeed: O, panOnScrollMode: L, zoomOnDoubleClick: N, panOnDrag: !q && G, defaultViewport: R, translateExtent: T, minZoom: U, maxZoom: B, zoomActivationKeyCode: S, preventScrolling: I, noWheelClassName: X, noPanClassName: D, onViewportChange: H, isControlledViewport: j, paneClickDistance: u, selectionOnDrag: $, children: J.jsxs(sB, { onSelectionStart: g, onSelectionEnd: _, onPaneClick: t, onPaneMouseEnter: e, onPaneMouseMove: r, onPaneMouseLeave: a, onPaneContextMenu: o, onPaneScroll: c, panOnDrag: G, isSelecting: !!Q, selectionMode: m, selectionKeyPressed: q, paneClickDistance: u, selectionOnDrag: $, children: [n, K && J.jsx(vB, { onSelectionContextMenu: C, noPanClassName: D, disableKeyboardA11y: V })] }) });
}
sw.displayName = "FlowRenderer";
const yB = ct.memo(sw), xB = (n) => (t) => n ? X0(t.nodeLookup, { x: 0, y: 0, width: t.width, height: t.height }, t.transform, !0).map((e) => e.id) : Array.from(t.nodeLookup.keys());
function SB(n) {
  return Ue(ct.useCallback(xB(n), [n]), on);
}
const bB = (n) => n.updateNodeInternals;
function MB() {
  const n = Ue(bB), [t] = ct.useState(() => typeof ResizeObserver > "u" ? null : new ResizeObserver((e) => {
    const r = /* @__PURE__ */ new Map();
    e.forEach((a) => {
      const o = a.target.getAttribute("data-id");
      r.set(o, {
        id: o,
        nodeElement: a.target,
        force: !0
      });
    }), n(r);
  }));
  return ct.useEffect(() => () => {
    t == null || t.disconnect();
  }, [t]), t;
}
function EB({ node: n, nodeType: t, hasDimensions: e, resizeObserver: r }) {
  const a = ln(), o = ct.useRef(null), c = ct.useRef(null), u = ct.useRef(n.sourcePosition), d = ct.useRef(n.targetPosition), h = ct.useRef(t), p = e && !!n.internals.handleBounds;
  return ct.useEffect(() => {
    o.current && !n.hidden && (!p || c.current !== o.current) && (c.current && (r == null || r.unobserve(c.current)), r == null || r.observe(o.current), c.current = o.current);
  }, [p, n.hidden]), ct.useEffect(() => () => {
    c.current && (r == null || r.unobserve(c.current), c.current = null);
  }, []), ct.useEffect(() => {
    if (o.current) {
      const m = h.current !== t, g = u.current !== n.sourcePosition, _ = d.current !== n.targetPosition;
      (m || g || _) && (h.current = t, u.current = n.sourcePosition, d.current = n.targetPosition, a.getState().updateNodeInternals(/* @__PURE__ */ new Map([[n.id, { id: n.id, nodeElement: o.current, force: !0 }]])));
    }
  }, [n.id, t, n.sourcePosition, n.targetPosition]), o;
}
function wB({ id: n, onClick: t, onMouseEnter: e, onMouseMove: r, onMouseLeave: a, onContextMenu: o, onDoubleClick: c, nodesDraggable: u, elementsSelectable: d, nodesConnectable: h, nodesFocusable: p, resizeObserver: m, noDragClassName: g, noPanClassName: _, disableKeyboardA11y: b, rfId: E, nodeTypes: S, nodeClickDistance: y, onError: A }) {
  const { node: w, internals: M, isParent: O } = Ue((et) => {
    const st = et.nodeLookup.get(n), _t = et.parentLookup.has(n);
    return {
      node: st,
      internals: st.internals,
      isParent: _t
    };
  }, on);
  let L = w.type || "default", N = (S == null ? void 0 : S[L]) || v1[L];
  N === void 0 && (A == null || A("003", vr.error003(L)), L = "default", N = (S == null ? void 0 : S.default) || v1.default);
  const z = !!(w.draggable || u && typeof w.draggable > "u"), R = !!(w.selectable || d && typeof w.selectable > "u"), T = !!(w.connectable || h && typeof w.connectable > "u"), U = !!(w.focusable || p && typeof w.focusable > "u"), B = ln(), I = wE(w), C = EB({ node: w, nodeType: L, hasDimensions: I, resizeObserver: m }), X = nw({
    nodeRef: C,
    disabled: w.hidden || !z,
    noDragClassName: g,
    handleSelector: w.dragHandle,
    nodeId: n,
    isSelectable: R,
    nodeClickDistance: y
  }), D = iw();
  if (w.hidden)
    return null;
  const V = is(w), H = mB(w), j = R || z || t || e || r || a, K = e ? (et) => e(et, { ...M.userNode }) : void 0, F = r ? (et) => r(et, { ...M.userNode }) : void 0, q = a ? (et) => a(et, { ...M.userNode }) : void 0, it = o ? (et) => o(et, { ...M.userNode }) : void 0, G = c ? (et) => c(et, { ...M.userNode }) : void 0, k = (et) => {
    const { selectNodesOnDrag: st, nodeDragThreshold: _t } = B.getState();
    R && (!st || !z || _t > 0) && f0({
      id: n,
      store: B,
      nodeRef: C
    }), t && t(et, { ...M.userNode });
  }, $ = (et) => {
    if (!(CE(et.nativeEvent) || b)) {
      if (gE.includes(et.key) && R) {
        const st = et.key === "Escape";
        f0({
          id: n,
          store: B,
          unselect: st,
          nodeRef: C
        });
      } else if (z && w.selected && Object.prototype.hasOwnProperty.call(Cd, et.key)) {
        et.preventDefault();
        const { ariaLabelConfig: st } = B.getState();
        B.setState({
          ariaLiveMessage: st["node.a11yDescription.ariaLiveMessage"]({
            direction: et.key.replace("Arrow", "").toLowerCase(),
            x: ~~M.positionAbsolute.x,
            y: ~~M.positionAbsolute.y
          })
        }), D({
          direction: Cd[et.key],
          factor: et.shiftKey ? 4 : 1
        });
      }
    }
  }, Q = () => {
    var nt;
    if (b || !((nt = C.current) != null && nt.matches(":focus-visible")))
      return;
    const { transform: et, width: st, height: _t, autoPanOnNodeFocus: Mt, setCenter: Rt } = B.getState();
    if (!Mt)
      return;
    X0(/* @__PURE__ */ new Map([[n, w]]), { x: 0, y: 0, width: st, height: _t }, et, !0).length > 0 || Rt(w.position.x + V.width / 2, w.position.y + V.height / 2, {
      zoom: et[2]
    });
  };
  return J.jsx("div", { className: En([
    "react-flow__node",
    `react-flow__node-${L}`,
    {
      // this is overwritable by passing `nopan` as a class name
      [_]: z
    },
    w.className,
    {
      selected: w.selected,
      selectable: R,
      parent: O,
      draggable: z,
      dragging: X
    }
  ]), ref: C, style: {
    zIndex: M.z,
    transform: `translate(${M.positionAbsolute.x}px,${M.positionAbsolute.y}px)`,
    pointerEvents: j ? "all" : "none",
    visibility: I ? "visible" : "hidden",
    ...w.style,
    ...H
  }, "data-id": n, "data-testid": `rf__node-${n}`, onMouseEnter: K, onMouseMove: F, onMouseLeave: q, onContextMenu: it, onClick: k, onDoubleClick: G, onKeyDown: U ? $ : void 0, tabIndex: U ? 0 : void 0, onFocus: U ? Q : void 0, role: w.ariaRole ?? (U ? "group" : void 0), "aria-roledescription": "node", "aria-describedby": b ? void 0 : `${qE}-${E}`, "aria-label": w.ariaLabel, ...w.domAttributes, children: J.jsx(oB, { value: n, children: J.jsx(N, { id: n, data: w.data, type: L, positionAbsoluteX: M.positionAbsolute.x, positionAbsoluteY: M.positionAbsolute.y, selected: w.selected ?? !1, selectable: R, draggable: z, deletable: w.deletable ?? !0, isConnectable: T, sourcePosition: w.sourcePosition, targetPosition: w.targetPosition, dragging: X, dragHandle: w.dragHandle, zIndex: M.z, parentId: w.parentId, ...V }) }) });
}
var TB = ct.memo(wB);
const AB = (n) => ({
  nodesDraggable: n.nodesDraggable,
  nodesConnectable: n.nodesConnectable,
  nodesFocusable: n.nodesFocusable,
  elementsSelectable: n.elementsSelectable,
  onError: n.onError
});
function aw(n) {
  const { nodesDraggable: t, nodesConnectable: e, nodesFocusable: r, elementsSelectable: a, onError: o } = Ue(AB, on), c = SB(n.onlyRenderVisibleElements), u = MB();
  return J.jsx("div", { className: "react-flow__nodes", style: jd, children: c.map((d) => (
    /*
     * The split of responsibilities between NodeRenderer and
     * NodeComponentWrapper may appear weird. However, it’s designed to
     * minimize the cost of updates when individual nodes change.
     *
     * For example, when you’re dragging a single node, that node gets
     * updated multiple times per second. If `NodeRenderer` were to update
     * every time, it would have to re-run the `nodes.map()` loop every
     * time. This gets pricey with hundreds of nodes, especially if every
     * loop cycle does more than just rendering a JSX element!
     *
     * As a result of this choice, we took the following implementation
     * decisions:
     * - NodeRenderer subscribes *only* to node IDs – and therefore
     *   rerender *only* when visible nodes are added or removed.
     * - NodeRenderer performs all operations the result of which can be
     *   shared between nodes (such as creating the `ResizeObserver`
     *   instance, or subscribing to `selector`). This means extra prop
     *   drilling into `NodeComponentWrapper`, but it means we need to run
     *   these operations only once – instead of once per node.
     * - Any operations that you’d normally write inside `nodes.map` are
     *   moved into `NodeComponentWrapper`. This ensures they are
     *   memorized – so if `NodeRenderer` *has* to rerender, it only
     *   needs to regenerate the list of nodes, nothing else.
     */
    J.jsx(TB, { id: d, nodeTypes: n.nodeTypes, nodeExtent: n.nodeExtent, onClick: n.onNodeClick, onMouseEnter: n.onNodeMouseEnter, onMouseMove: n.onNodeMouseMove, onMouseLeave: n.onNodeMouseLeave, onContextMenu: n.onNodeContextMenu, onDoubleClick: n.onNodeDoubleClick, noDragClassName: n.noDragClassName, noPanClassName: n.noPanClassName, rfId: n.rfId, disableKeyboardA11y: n.disableKeyboardA11y, resizeObserver: u, nodesDraggable: t, nodesConnectable: e, nodesFocusable: r, elementsSelectable: a, nodeClickDistance: n.nodeClickDistance, onError: o }, d)
  )) });
}
aw.displayName = "NodeRenderer";
const CB = ct.memo(aw);
function RB(n) {
  return Ue(ct.useCallback((e) => {
    if (!n)
      return e.edges.map((a) => a.id);
    const r = [];
    if (e.width && e.height)
      for (const a of e.edges) {
        const o = e.nodeLookup.get(a.source), c = e.nodeLookup.get(a.target);
        o && c && CI({
          sourceNode: o,
          targetNode: c,
          width: e.width,
          height: e.height,
          transform: e.transform
        }) && r.push(a.id);
      }
    return r;
  }, [n]), on);
}
const DB = ({ color: n = "none", strokeWidth: t = 1 }) => {
  const e = {
    strokeWidth: t,
    ...n && { stroke: n }
  };
  return J.jsx("polyline", { className: "arrow", style: e, strokeLinecap: "round", fill: "none", strokeLinejoin: "round", points: "-5,-4 0,0 -5,4" });
}, NB = ({ color: n = "none", strokeWidth: t = 1 }) => {
  const e = {
    strokeWidth: t,
    ...n && { stroke: n, fill: n }
  };
  return J.jsx("polyline", { className: "arrowclosed", style: e, strokeLinecap: "round", strokeLinejoin: "round", points: "-5,-4 0,0 -5,4 -5,-4" });
}, y1 = {
  [wd.Arrow]: DB,
  [wd.ArrowClosed]: NB
};
function LB(n) {
  const t = ln();
  return ct.useMemo(() => {
    var a, o;
    return Object.prototype.hasOwnProperty.call(y1, n) ? y1[n] : ((o = (a = t.getState()).onError) == null || o.call(a, "009", vr.error009(n)), null);
  }, [n]);
}
const UB = ({ id: n, type: t, color: e, width: r = 12.5, height: a = 12.5, markerUnits: o = "strokeWidth", strokeWidth: c, orient: u = "auto-start-reverse" }) => {
  const d = LB(t);
  return d ? J.jsx("marker", { className: "react-flow__arrowhead", id: n, markerWidth: `${r}`, markerHeight: `${a}`, viewBox: "-10 -10 20 20", markerUnits: o, orient: u, refX: "0", refY: "0", children: J.jsx(d, { color: e, strokeWidth: c }) }) : null;
}, ow = ({ defaultColor: n, rfId: t }) => {
  const e = Ue((o) => o.edges), r = Ue((o) => o.defaultEdgeOptions), a = ct.useMemo(() => PI(e, {
    id: t,
    defaultColor: n,
    defaultMarkerStart: r == null ? void 0 : r.markerStart,
    defaultMarkerEnd: r == null ? void 0 : r.markerEnd
  }), [e, r, t, n]);
  return a.length ? J.jsx("svg", { className: "react-flow__marker", "aria-hidden": "true", children: J.jsx("defs", { children: a.map((o) => J.jsx(UB, { id: o.id, type: o.type, color: o.color, width: o.width, height: o.height, markerUnits: o.markerUnits, strokeWidth: o.strokeWidth, orient: o.orient }, o.id)) }) }) : null;
};
ow.displayName = "MarkerDefinitions";
var OB = ct.memo(ow);
function lw({ x: n, y: t, label: e, labelStyle: r, labelShowBg: a = !0, labelBgStyle: o, labelBgPadding: c = [2, 4], labelBgBorderRadius: u = 2, children: d, className: h, ...p }) {
  const [m, g] = ct.useState({ x: 1, y: 0, width: 0, height: 0 }), _ = En(["react-flow__edge-textwrapper", h]), b = ct.useRef(null);
  return ct.useEffect(() => {
    if (b.current) {
      const E = b.current.getBBox();
      g({
        x: E.x,
        y: E.y,
        width: E.width,
        height: E.height
      });
    }
  }, [e]), e ? J.jsxs("g", { transform: `translate(${n - m.width / 2} ${t - m.height / 2})`, className: _, visibility: m.width ? "visible" : "hidden", ...p, children: [a && J.jsx("rect", { width: m.width + 2 * c[0], x: -c[0], y: -c[1], height: m.height + 2 * c[1], className: "react-flow__edge-textbg", style: o, rx: u, ry: u }), J.jsx("text", { className: "react-flow__edge-text", y: m.height / 2, dy: "0.3em", ref: b, style: r, children: e }), d] }) : null;
}
lw.displayName = "EdgeText";
const PB = ct.memo(lw);
function Wd({ path: n, labelX: t, labelY: e, label: r, labelStyle: a, labelShowBg: o, labelBgStyle: c, labelBgPadding: u, labelBgBorderRadius: d, interactionWidth: h = 20, ...p }) {
  return J.jsxs(J.Fragment, { children: [J.jsx("path", { ...p, d: n, fill: "none", className: En(["react-flow__edge-path", p.className]) }), h ? J.jsx("path", { d: n, fill: "none", strokeOpacity: 0, strokeWidth: h, className: "react-flow__edge-interaction" }) : null, r && Ji(t) && Ji(e) ? J.jsx(PB, { x: t, y: e, label: r, labelStyle: a, labelShowBg: o, labelBgStyle: c, labelBgPadding: u, labelBgBorderRadius: d }) : null] });
}
function x1({ pos: n, x1: t, y1: e, x2: r, y2: a }) {
  return n === re.Left || n === re.Right ? [0.5 * (t + r), e] : [t, 0.5 * (e + a)];
}
function cw({ sourceX: n, sourceY: t, sourcePosition: e = re.Bottom, targetX: r, targetY: a, targetPosition: o = re.Top }) {
  const [c, u] = x1({
    pos: e,
    x1: n,
    y1: t,
    x2: r,
    y2: a
  }), [d, h] = x1({
    pos: o,
    x1: r,
    y1: a,
    x2: n,
    y2: t
  }), [p, m, g, _] = DE({
    sourceX: n,
    sourceY: t,
    targetX: r,
    targetY: a,
    sourceControlX: c,
    sourceControlY: u,
    targetControlX: d,
    targetControlY: h
  });
  return [
    `M${n},${t} C${c},${u} ${d},${h} ${r},${a}`,
    p,
    m,
    g,
    _
  ];
}
function uw(n) {
  return ct.memo(({ id: t, sourceX: e, sourceY: r, targetX: a, targetY: o, sourcePosition: c, targetPosition: u, label: d, labelStyle: h, labelShowBg: p, labelBgStyle: m, labelBgPadding: g, labelBgBorderRadius: _, style: b, markerEnd: E, markerStart: S, interactionWidth: y }) => {
    const [A, w, M] = cw({
      sourceX: e,
      sourceY: r,
      sourcePosition: c,
      targetX: a,
      targetY: o,
      targetPosition: u
    }), O = n.isInternal ? void 0 : t;
    return J.jsx(Wd, { id: O, path: A, labelX: w, labelY: M, label: d, labelStyle: h, labelShowBg: p, labelBgStyle: m, labelBgPadding: g, labelBgBorderRadius: _, style: b, markerEnd: E, markerStart: S, interactionWidth: y });
  });
}
const zB = uw({ isInternal: !1 }), fw = uw({ isInternal: !0 });
zB.displayName = "SimpleBezierEdge";
fw.displayName = "SimpleBezierEdgeInternal";
function dw(n) {
  return ct.memo(({ id: t, sourceX: e, sourceY: r, targetX: a, targetY: o, label: c, labelStyle: u, labelShowBg: d, labelBgStyle: h, labelBgPadding: p, labelBgBorderRadius: m, style: g, sourcePosition: _ = re.Bottom, targetPosition: b = re.Top, markerEnd: E, markerStart: S, pathOptions: y, interactionWidth: A }) => {
    const [w, M, O] = o0({
      sourceX: e,
      sourceY: r,
      sourcePosition: _,
      targetX: a,
      targetY: o,
      targetPosition: b,
      borderRadius: y == null ? void 0 : y.borderRadius,
      offset: y == null ? void 0 : y.offset,
      stepPosition: y == null ? void 0 : y.stepPosition
    }), L = n.isInternal ? void 0 : t;
    return J.jsx(Wd, { id: L, path: w, labelX: M, labelY: O, label: c, labelStyle: u, labelShowBg: d, labelBgStyle: h, labelBgPadding: p, labelBgBorderRadius: m, style: g, markerEnd: E, markerStart: S, interactionWidth: A });
  });
}
const hw = dw({ isInternal: !1 }), pw = dw({ isInternal: !0 });
hw.displayName = "SmoothStepEdge";
pw.displayName = "SmoothStepEdgeInternal";
function mw(n) {
  return ct.memo(({ id: t, ...e }) => {
    var a;
    const r = n.isInternal ? void 0 : t;
    return J.jsx(hw, { ...e, id: r, pathOptions: ct.useMemo(() => {
      var o;
      return { borderRadius: 0, offset: (o = e.pathOptions) == null ? void 0 : o.offset };
    }, [(a = e.pathOptions) == null ? void 0 : a.offset]) });
  });
}
const IB = mw({ isInternal: !1 }), gw = mw({ isInternal: !0 });
IB.displayName = "StepEdge";
gw.displayName = "StepEdgeInternal";
function vw(n) {
  return ct.memo(({ id: t, sourceX: e, sourceY: r, targetX: a, targetY: o, label: c, labelStyle: u, labelShowBg: d, labelBgStyle: h, labelBgPadding: p, labelBgBorderRadius: m, style: g, markerEnd: _, markerStart: b, interactionWidth: E }) => {
    const [S, y, A] = OE({ sourceX: e, sourceY: r, targetX: a, targetY: o }), w = n.isInternal ? void 0 : t;
    return J.jsx(Wd, { id: w, path: S, labelX: y, labelY: A, label: c, labelStyle: u, labelShowBg: d, labelBgStyle: h, labelBgPadding: p, labelBgBorderRadius: m, style: g, markerEnd: _, markerStart: b, interactionWidth: E });
  });
}
const BB = vw({ isInternal: !1 }), _w = vw({ isInternal: !0 });
BB.displayName = "StraightEdge";
_w.displayName = "StraightEdgeInternal";
function yw(n) {
  return ct.memo(({ id: t, sourceX: e, sourceY: r, targetX: a, targetY: o, sourcePosition: c = re.Bottom, targetPosition: u = re.Top, label: d, labelStyle: h, labelShowBg: p, labelBgStyle: m, labelBgPadding: g, labelBgBorderRadius: _, style: b, markerEnd: E, markerStart: S, pathOptions: y, interactionWidth: A }) => {
    const [w, M, O] = NE({
      sourceX: e,
      sourceY: r,
      sourcePosition: c,
      targetX: a,
      targetY: o,
      targetPosition: u,
      curvature: y == null ? void 0 : y.curvature
    }), L = n.isInternal ? void 0 : t;
    return J.jsx(Wd, { id: L, path: w, labelX: M, labelY: O, label: d, labelStyle: h, labelShowBg: p, labelBgStyle: m, labelBgPadding: g, labelBgBorderRadius: _, style: b, markerEnd: E, markerStart: S, interactionWidth: A });
  });
}
const FB = yw({ isInternal: !1 }), xw = yw({ isInternal: !0 });
FB.displayName = "BezierEdge";
xw.displayName = "BezierEdgeInternal";
const S1 = {
  default: xw,
  straight: _w,
  step: gw,
  smoothstep: pw,
  simplebezier: fw
}, b1 = {
  sourceX: null,
  sourceY: null,
  targetX: null,
  targetY: null,
  sourcePosition: null,
  targetPosition: null
}, HB = (n, t, e) => e === re.Left ? n - t : e === re.Right ? n + t : n, VB = (n, t, e) => e === re.Top ? n - t : e === re.Bottom ? n + t : n, M1 = "react-flow__edgeupdater";
function E1({ position: n, centerX: t, centerY: e, radius: r = 10, onMouseDown: a, onMouseEnter: o, onMouseOut: c, type: u }) {
  return J.jsx("circle", { onMouseDown: a, onMouseEnter: o, onMouseOut: c, className: En([M1, `${M1}-${u}`]), cx: HB(t, r, n), cy: VB(e, r, n), r, stroke: "transparent", fill: "transparent" });
}
function kB({ isReconnectable: n, reconnectRadius: t, edge: e, sourceX: r, sourceY: a, targetX: o, targetY: c, sourcePosition: u, targetPosition: d, onReconnect: h, onReconnectStart: p, onReconnectEnd: m, setReconnecting: g, setUpdateHover: _ }) {
  const b = ln(), E = (M, O) => {
    if (M.button !== 0)
      return;
    const { autoPanOnConnect: L, domNode: N, connectionMode: z, connectionRadius: R, lib: T, onConnectStart: U, cancelConnection: B, nodeLookup: I, rfId: C, panBy: X, updateConnection: D } = b.getState(), V = O.type === "target", H = (F, q) => {
      g(!1), m == null || m(F, e, O.type, q);
    }, j = (F) => h == null ? void 0 : h(e, F), K = (F, q) => {
      g(!0), p == null || p(M, e, O.type), U == null || U(F, q);
    };
    u0.onPointerDown(M.nativeEvent, {
      autoPanOnConnect: L,
      connectionMode: z,
      connectionRadius: R,
      domNode: N,
      handleId: O.id,
      nodeId: O.nodeId,
      nodeLookup: I,
      isTarget: V,
      edgeUpdaterType: O.type,
      lib: T,
      flowId: C,
      cancelConnection: B,
      panBy: X,
      isValidConnection: (...F) => {
        var q, it;
        return ((it = (q = b.getState()).isValidConnection) == null ? void 0 : it.call(q, ...F)) ?? !0;
      },
      onConnect: j,
      onConnectStart: K,
      onConnectEnd: (...F) => {
        var q, it;
        return (it = (q = b.getState()).onConnectEnd) == null ? void 0 : it.call(q, ...F);
      },
      onReconnectEnd: H,
      updateConnection: D,
      getTransform: () => b.getState().transform,
      getFromHandle: () => b.getState().connection.fromHandle,
      dragThreshold: b.getState().connectionDragThreshold,
      handleDomNode: M.currentTarget
    });
  }, S = (M) => E(M, { nodeId: e.target, id: e.targetHandle ?? null, type: "target" }), y = (M) => E(M, { nodeId: e.source, id: e.sourceHandle ?? null, type: "source" }), A = () => _(!0), w = () => _(!1);
  return J.jsxs(J.Fragment, { children: [(n === !0 || n === "source") && J.jsx(E1, { position: u, centerX: r, centerY: a, radius: t, onMouseDown: S, onMouseEnter: A, onMouseOut: w, type: "source" }), (n === !0 || n === "target") && J.jsx(E1, { position: d, centerX: o, centerY: c, radius: t, onMouseDown: y, onMouseEnter: A, onMouseOut: w, type: "target" })] });
}
function GB({ id: n, edgesFocusable: t, edgesReconnectable: e, elementsSelectable: r, onClick: a, onDoubleClick: o, onContextMenu: c, onMouseEnter: u, onMouseMove: d, onMouseLeave: h, reconnectRadius: p, onReconnect: m, onReconnectStart: g, onReconnectEnd: _, rfId: b, edgeTypes: E, noPanClassName: S, onError: y, disableKeyboardA11y: A }) {
  let w = Ue((Rt) => Rt.edgeLookup.get(n));
  const M = Ue((Rt) => Rt.defaultEdgeOptions);
  w = M ? { ...M, ...w } : w;
  let O = w.type || "default", L = (E == null ? void 0 : E[O]) || S1[O];
  L === void 0 && (y == null || y("011", vr.error011(O)), O = "default", L = (E == null ? void 0 : E.default) || S1.default);
  const N = !!(w.focusable || t && typeof w.focusable > "u"), z = typeof m < "u" && (w.reconnectable || e && typeof w.reconnectable > "u"), R = !!(w.selectable || r && typeof w.selectable > "u"), T = ct.useRef(null), [U, B] = ct.useState(!1), [I, C] = ct.useState(!1), X = ln(), { zIndex: D, sourceX: V, sourceY: H, targetX: j, targetY: K, sourcePosition: F, targetPosition: q } = Ue(ct.useCallback((Rt) => {
    const Ot = Rt.nodeLookup.get(w.source), nt = Rt.nodeLookup.get(w.target);
    if (!Ot || !nt)
      return {
        zIndex: w.zIndex,
        ...b1
      };
    const Jt = OI({
      id: n,
      sourceNode: Ot,
      targetNode: nt,
      sourceHandle: w.sourceHandle || null,
      targetHandle: w.targetHandle || null,
      connectionMode: Rt.connectionMode,
      onError: y
    });
    return {
      zIndex: AI({
        selected: w.selected,
        zIndex: w.zIndex,
        sourceNode: Ot,
        targetNode: nt,
        elevateOnSelect: Rt.elevateEdgesOnSelect,
        zIndexMode: Rt.zIndexMode
      }),
      ...Jt || b1
    };
  }, [w.source, w.target, w.sourceHandle, w.targetHandle, w.selected, w.zIndex]), on), it = ct.useMemo(() => w.markerStart ? `url('#${l0(w.markerStart, b)}')` : void 0, [w.markerStart, b]), G = ct.useMemo(() => w.markerEnd ? `url('#${l0(w.markerEnd, b)}')` : void 0, [w.markerEnd, b]);
  if (w.hidden || V === null || H === null || j === null || K === null)
    return null;
  const k = (Rt) => {
    var Ft;
    const { addSelectedEdges: Ot, unselectNodesAndEdges: nt, multiSelectionActive: Jt } = X.getState();
    R && (X.setState({ nodesSelectionActive: !1 }), w.selected && Jt ? (nt({ nodes: [], edges: [w] }), (Ft = T.current) == null || Ft.blur()) : Ot([n])), a && a(Rt, w);
  }, $ = o ? (Rt) => {
    o(Rt, { ...w });
  } : void 0, Q = c ? (Rt) => {
    c(Rt, { ...w });
  } : void 0, et = u ? (Rt) => {
    u(Rt, { ...w });
  } : void 0, st = d ? (Rt) => {
    d(Rt, { ...w });
  } : void 0, _t = h ? (Rt) => {
    h(Rt, { ...w });
  } : void 0, Mt = (Rt) => {
    var Ot;
    if (!A && gE.includes(Rt.key) && R) {
      const { unselectNodesAndEdges: nt, addSelectedEdges: Jt } = X.getState();
      Rt.key === "Escape" ? ((Ot = T.current) == null || Ot.blur(), nt({ edges: [w] })) : Jt([n]);
    }
  };
  return J.jsx("svg", { style: { zIndex: D }, children: J.jsxs("g", { className: En([
    "react-flow__edge",
    `react-flow__edge-${O}`,
    w.className,
    S,
    {
      selected: w.selected,
      animated: w.animated,
      inactive: !R && !a,
      updating: U,
      selectable: R
    }
  ]), onClick: k, onDoubleClick: $, onContextMenu: Q, onMouseEnter: et, onMouseMove: st, onMouseLeave: _t, onKeyDown: N ? Mt : void 0, tabIndex: N ? 0 : void 0, role: w.ariaRole ?? (N ? "group" : "img"), "aria-roledescription": "edge", "data-id": n, "data-testid": `rf__edge-${n}`, "aria-label": w.ariaLabel === null ? void 0 : w.ariaLabel || `Edge from ${w.source} to ${w.target}`, "aria-describedby": N ? `${ZE}-${b}` : void 0, ref: T, ...w.domAttributes, children: [!I && J.jsx(L, { id: n, source: w.source, target: w.target, type: w.type, selected: w.selected, animated: w.animated, selectable: R, deletable: w.deletable ?? !0, label: w.label, labelStyle: w.labelStyle, labelShowBg: w.labelShowBg, labelBgStyle: w.labelBgStyle, labelBgPadding: w.labelBgPadding, labelBgBorderRadius: w.labelBgBorderRadius, sourceX: V, sourceY: H, targetX: j, targetY: K, sourcePosition: F, targetPosition: q, data: w.data, style: w.style, sourceHandleId: w.sourceHandle, targetHandleId: w.targetHandle, markerStart: it, markerEnd: G, pathOptions: "pathOptions" in w ? w.pathOptions : void 0, interactionWidth: w.interactionWidth }), z && J.jsx(kB, { edge: w, isReconnectable: z, reconnectRadius: p, onReconnect: m, onReconnectStart: g, onReconnectEnd: _, sourceX: V, sourceY: H, targetX: j, targetY: K, sourcePosition: F, targetPosition: q, setUpdateHover: B, setReconnecting: C })] }) });
}
var XB = ct.memo(GB);
const jB = (n) => ({
  edgesFocusable: n.edgesFocusable,
  edgesReconnectable: n.edgesReconnectable,
  elementsSelectable: n.elementsSelectable,
  connectionMode: n.connectionMode,
  onError: n.onError
});
function Sw({ defaultMarkerColor: n, onlyRenderVisibleElements: t, rfId: e, edgeTypes: r, noPanClassName: a, onReconnect: o, onEdgeContextMenu: c, onEdgeMouseEnter: u, onEdgeMouseMove: d, onEdgeMouseLeave: h, onEdgeClick: p, reconnectRadius: m, onEdgeDoubleClick: g, onReconnectStart: _, onReconnectEnd: b, disableKeyboardA11y: E }) {
  const { edgesFocusable: S, edgesReconnectable: y, elementsSelectable: A, onError: w } = Ue(jB, on), M = RB(t);
  return J.jsxs("div", { className: "react-flow__edges", children: [J.jsx(OB, { defaultColor: n, rfId: e }), M.map((O) => J.jsx(XB, { id: O, edgesFocusable: S, edgesReconnectable: y, elementsSelectable: A, noPanClassName: a, onReconnect: o, onContextMenu: c, onMouseEnter: u, onMouseMove: d, onMouseLeave: h, onClick: p, reconnectRadius: m, onDoubleClick: g, onReconnectStart: _, onReconnectEnd: b, rfId: e, onError: w, edgeTypes: r, disableKeyboardA11y: E }, O))] });
}
Sw.displayName = "EdgeRenderer";
const WB = ct.memo(Sw), YB = (n) => `translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]})`;
function qB({ children: n }) {
  const t = Ue(YB);
  return J.jsx("div", { className: "react-flow__viewport xyflow__viewport react-flow__container", style: { transform: t }, children: n });
}
function ZB(n) {
  const t = Vc(), e = ct.useRef(!1);
  ct.useEffect(() => {
    !e.current && t.viewportInitialized && n && (setTimeout(() => n(t), 1), e.current = !0);
  }, [n, t.viewportInitialized]);
}
const $B = (n) => {
  var t;
  return (t = n.panZoom) == null ? void 0 : t.syncViewport;
};
function KB(n) {
  const t = Ue($B), e = ln();
  return ct.useEffect(() => {
    n && (t == null || t(n), e.setState({ transform: [n.x, n.y, n.zoom] }));
  }, [n, t]), null;
}
function QB(n) {
  return n.connection.inProgress ? { ...n.connection, to: Qc(n.connection.to, n.transform) } : { ...n.connection };
}
function JB(n) {
  return QB;
}
function t5(n) {
  const t = JB();
  return Ue(t, on);
}
const e5 = (n) => ({
  nodesConnectable: n.nodesConnectable,
  isValid: n.connection.isValid,
  inProgress: n.connection.inProgress,
  width: n.width,
  height: n.height
});
function n5({ containerStyle: n, style: t, type: e, component: r }) {
  const { nodesConnectable: a, width: o, height: c, isValid: u, inProgress: d } = Ue(e5, on);
  return !(o && a && d) ? null : J.jsx("svg", { style: n, width: o, height: c, className: "react-flow__connectionline react-flow__container", children: J.jsx("g", { className: En(["react-flow__connection", yE(u)]), children: J.jsx(bw, { style: t, type: e, CustomComponent: r, isValid: u }) }) });
}
const bw = ({ style: n, type: t = Hs.Bezier, CustomComponent: e, isValid: r }) => {
  const { inProgress: a, from: o, fromNode: c, fromHandle: u, fromPosition: d, to: h, toNode: p, toHandle: m, toPosition: g, pointer: _ } = t5();
  if (!a)
    return;
  if (e)
    return J.jsx(e, { connectionLineType: t, connectionLineStyle: n, fromNode: c, fromHandle: u, fromX: o.x, fromY: o.y, toX: h.x, toY: h.y, fromPosition: d, toPosition: g, connectionStatus: yE(r), toNode: p, toHandle: m, pointer: _ });
  let b = "";
  const E = {
    sourceX: o.x,
    sourceY: o.y,
    sourcePosition: d,
    targetX: h.x,
    targetY: h.y,
    targetPosition: g
  };
  switch (t) {
    case Hs.Bezier:
      [b] = NE(E);
      break;
    case Hs.SimpleBezier:
      [b] = cw(E);
      break;
    case Hs.Step:
      [b] = o0({
        ...E,
        borderRadius: 0
      });
      break;
    case Hs.SmoothStep:
      [b] = o0(E);
      break;
    default:
      [b] = OE(E);
  }
  return J.jsx("path", { d: b, fill: "none", className: "react-flow__connection-path", style: n });
};
bw.displayName = "ConnectionLine";
const i5 = {};
function w1(n = i5) {
  ct.useRef(n), ln(), ct.useEffect(() => {
  }, [n]);
}
function r5() {
  ln(), ct.useRef(!1), ct.useEffect(() => {
  }, []);
}
function Mw({ nodeTypes: n, edgeTypes: t, onInit: e, onNodeClick: r, onEdgeClick: a, onNodeDoubleClick: o, onEdgeDoubleClick: c, onNodeMouseEnter: u, onNodeMouseMove: d, onNodeMouseLeave: h, onNodeContextMenu: p, onSelectionContextMenu: m, onSelectionStart: g, onSelectionEnd: _, connectionLineType: b, connectionLineStyle: E, connectionLineComponent: S, connectionLineContainerStyle: y, selectionKeyCode: A, selectionOnDrag: w, selectionMode: M, multiSelectionKeyCode: O, panActivationKeyCode: L, zoomActivationKeyCode: N, deleteKeyCode: z, onlyRenderVisibleElements: R, elementsSelectable: T, defaultViewport: U, translateExtent: B, minZoom: I, maxZoom: C, preventScrolling: X, defaultMarkerColor: D, zoomOnScroll: V, zoomOnPinch: H, panOnScroll: j, panOnScrollSpeed: K, panOnScrollMode: F, zoomOnDoubleClick: q, panOnDrag: it, onPaneClick: G, onPaneMouseEnter: k, onPaneMouseMove: $, onPaneMouseLeave: Q, onPaneScroll: et, onPaneContextMenu: st, paneClickDistance: _t, nodeClickDistance: Mt, onEdgeContextMenu: Rt, onEdgeMouseEnter: Ot, onEdgeMouseMove: nt, onEdgeMouseLeave: Jt, reconnectRadius: Ft, onReconnect: ne, onReconnectStart: jt, onReconnectEnd: xe, noDragClassName: qt, noWheelClassName: tt, noPanClassName: W, disableKeyboardA11y: mt, nodeExtent: Et, rfId: Dt, viewport: wt, onViewportChange: Zt }) {
  return w1(n), w1(t), r5(), ZB(e), KB(wt), J.jsx(yB, { onPaneClick: G, onPaneMouseEnter: k, onPaneMouseMove: $, onPaneMouseLeave: Q, onPaneContextMenu: st, onPaneScroll: et, paneClickDistance: _t, deleteKeyCode: z, selectionKeyCode: A, selectionOnDrag: w, selectionMode: M, onSelectionStart: g, onSelectionEnd: _, multiSelectionKeyCode: O, panActivationKeyCode: L, zoomActivationKeyCode: N, elementsSelectable: T, zoomOnScroll: V, zoomOnPinch: H, zoomOnDoubleClick: q, panOnScroll: j, panOnScrollSpeed: K, panOnScrollMode: F, panOnDrag: it, defaultViewport: U, translateExtent: B, minZoom: I, maxZoom: C, onSelectionContextMenu: m, preventScrolling: X, noDragClassName: qt, noWheelClassName: tt, noPanClassName: W, disableKeyboardA11y: mt, onViewportChange: Zt, isControlledViewport: !!wt, children: J.jsxs(qB, { children: [J.jsx(WB, { edgeTypes: t, onEdgeClick: a, onEdgeDoubleClick: c, onReconnect: ne, onReconnectStart: jt, onReconnectEnd: xe, onlyRenderVisibleElements: R, onEdgeContextMenu: Rt, onEdgeMouseEnter: Ot, onEdgeMouseMove: nt, onEdgeMouseLeave: Jt, reconnectRadius: Ft, defaultMarkerColor: D, noPanClassName: W, disableKeyboardA11y: mt, rfId: Dt }), J.jsx(n5, { style: E, type: b, component: S, containerStyle: y }), J.jsx("div", { className: "react-flow__edgelabel-renderer" }), J.jsx(CB, { nodeTypes: n, onNodeClick: r, onNodeDoubleClick: o, onNodeMouseEnter: u, onNodeMouseMove: d, onNodeMouseLeave: h, onNodeContextMenu: p, nodeClickDistance: Mt, onlyRenderVisibleElements: R, noPanClassName: W, noDragClassName: qt, disableKeyboardA11y: mt, nodeExtent: Et, rfId: Dt }), J.jsx("div", { className: "react-flow__viewport-portal" })] }) });
}
Mw.displayName = "GraphView";
const s5 = ct.memo(Mw), T1 = ({ nodes: n, edges: t, defaultNodes: e, defaultEdges: r, width: a, height: o, fitView: c, fitViewOptions: u, minZoom: d = 0.5, maxZoom: h = 2, nodeOrigin: p, nodeExtent: m, zIndexMode: g = "basic" } = {}) => {
  const _ = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), y = r ?? t ?? [], A = e ?? n ?? [], w = p ?? [0, 0], M = m ?? zc;
  IE(E, S, y);
  const O = c0(A, _, b, {
    nodeOrigin: w,
    nodeExtent: M,
    zIndexMode: g
  });
  let L = [0, 0, 1];
  if (c && a && o) {
    const N = $c(_, {
      filter: (U) => !!((U.width || U.initialWidth) && (U.height || U.initialHeight))
    }), { x: z, y: R, zoom: T } = j0(N, a, o, d, h, (u == null ? void 0 : u.padding) ?? 0.1);
    L = [z, R, T];
  }
  return {
    rfId: "1",
    width: a ?? 0,
    height: o ?? 0,
    transform: L,
    nodes: A,
    nodesInitialized: O,
    nodeLookup: _,
    parentLookup: b,
    edges: y,
    edgeLookup: S,
    connectionLookup: E,
    onNodesChange: null,
    onEdgesChange: null,
    hasDefaultNodes: e !== void 0,
    hasDefaultEdges: r !== void 0,
    panZoom: null,
    minZoom: d,
    maxZoom: h,
    translateExtent: zc,
    nodeExtent: M,
    nodesSelectionActive: !1,
    userSelectionActive: !1,
    userSelectionRect: null,
    connectionMode: cl.Strict,
    domNode: null,
    paneDragging: !1,
    noPanClassName: "nopan",
    nodeOrigin: w,
    nodeDragThreshold: 1,
    connectionDragThreshold: 1,
    snapGrid: [15, 15],
    snapToGrid: !1,
    nodesDraggable: !0,
    nodesConnectable: !0,
    nodesFocusable: !0,
    edgesFocusable: !0,
    edgesReconnectable: !0,
    elementsSelectable: !0,
    elevateNodesOnSelect: !0,
    elevateEdgesOnSelect: !0,
    selectNodesOnDrag: !0,
    multiSelectionActive: !1,
    fitViewQueued: c ?? !1,
    fitViewOptions: u,
    fitViewResolver: null,
    connection: { ..._E },
    connectionClickStartHandle: null,
    connectOnClick: !0,
    ariaLiveMessage: "",
    autoPanOnConnect: !0,
    autoPanOnNodeDrag: !0,
    autoPanOnNodeFocus: !0,
    autoPanSpeed: 15,
    connectionRadius: 20,
    onError: SI,
    isValidConnection: void 0,
    onSelectionChangeHandlers: [],
    lib: "react",
    debug: !1,
    ariaLabelConfig: vE,
    zIndexMode: g,
    onNodesChangeMiddlewareMap: /* @__PURE__ */ new Map(),
    onEdgesChangeMiddlewareMap: /* @__PURE__ */ new Map()
  };
}, a5 = ({ nodes: n, edges: t, defaultNodes: e, defaultEdges: r, width: a, height: o, fitView: c, fitViewOptions: u, minZoom: d, maxZoom: h, nodeOrigin: p, nodeExtent: m, zIndexMode: g }) => E4((_, b) => {
  async function E() {
    const { nodeLookup: S, panZoom: y, fitViewOptions: A, fitViewResolver: w, width: M, height: O, minZoom: L, maxZoom: N } = b();
    y && (await yI({
      nodes: S,
      width: M,
      height: O,
      panZoom: y,
      minZoom: L,
      maxZoom: N
    }, A), w == null || w.resolve(!0), _({ fitViewResolver: null }));
  }
  return {
    ...T1({
      nodes: n,
      edges: t,
      width: a,
      height: o,
      fitView: c,
      fitViewOptions: u,
      minZoom: d,
      maxZoom: h,
      nodeOrigin: p,
      nodeExtent: m,
      defaultNodes: e,
      defaultEdges: r,
      zIndexMode: g
    }),
    setNodes: (S) => {
      const { nodeLookup: y, parentLookup: A, nodeOrigin: w, elevateNodesOnSelect: M, fitViewQueued: O, zIndexMode: L } = b(), N = c0(S, y, A, {
        nodeOrigin: w,
        nodeExtent: m,
        elevateNodesOnSelect: M,
        checkEquality: !0,
        zIndexMode: L
      });
      O && N ? (E(), _({ nodes: S, nodesInitialized: N, fitViewQueued: !1, fitViewOptions: void 0 })) : _({ nodes: S, nodesInitialized: N });
    },
    setEdges: (S) => {
      const { connectionLookup: y, edgeLookup: A } = b();
      IE(y, A, S), _({ edges: S });
    },
    setDefaultNodesAndEdges: (S, y) => {
      if (S) {
        const { setNodes: A } = b();
        A(S), _({ hasDefaultNodes: !0 });
      }
      if (y) {
        const { setEdges: A } = b();
        A(y), _({ hasDefaultEdges: !0 });
      }
    },
    /*
     * Every node gets registerd at a ResizeObserver. Whenever a node
     * changes its dimensions, this function is called to measure the
     * new dimensions and update the nodes.
     */
    updateNodeInternals: (S) => {
      const { triggerNodeChanges: y, nodeLookup: A, parentLookup: w, domNode: M, nodeOrigin: O, nodeExtent: L, debug: N, fitViewQueued: z, zIndexMode: R } = b(), { changes: T, updatedInternals: U } = kI(S, A, w, M, O, L, R);
      U && (BI(A, w, { nodeOrigin: O, nodeExtent: L, zIndexMode: R }), z ? (E(), _({ fitViewQueued: !1, fitViewOptions: void 0 })) : _({}), (T == null ? void 0 : T.length) > 0 && (N && console.log("React Flow: trigger node changes", T), y == null || y(T)));
    },
    updateNodePositions: (S, y = !1) => {
      const A = [];
      let w = [];
      const { nodeLookup: M, triggerNodeChanges: O, connection: L, updateConnection: N, onNodesChangeMiddlewareMap: z } = b();
      for (const [R, T] of S) {
        const U = M.get(R), B = !!(U != null && U.expandParent && (U != null && U.parentId) && (T != null && T.position)), I = {
          id: R,
          type: "position",
          position: B ? {
            x: Math.max(0, T.position.x),
            y: Math.max(0, T.position.y)
          } : T.position,
          dragging: y
        };
        if (U && L.inProgress && L.fromNode.id === U.id) {
          const C = za(U, L.fromHandle, re.Left, !0);
          N({ ...L, from: C });
        }
        B && U.parentId && A.push({
          id: R,
          parentId: U.parentId,
          rect: {
            ...T.internals.positionAbsolute,
            width: T.measured.width ?? 0,
            height: T.measured.height ?? 0
          }
        }), w.push(I);
      }
      if (A.length > 0) {
        const { parentLookup: R, nodeOrigin: T } = b(), U = K0(A, M, R, T);
        w.push(...U);
      }
      for (const R of z.values())
        w = R(w);
      O(w);
    },
    triggerNodeChanges: (S) => {
      const { onNodesChange: y, setNodes: A, nodes: w, hasDefaultNodes: M, debug: O } = b();
      if (S != null && S.length) {
        if (M) {
          const L = QE(S, w);
          A(L);
        }
        O && console.log("React Flow: trigger node changes", S), y == null || y(S);
      }
    },
    triggerEdgeChanges: (S) => {
      const { onEdgesChange: y, setEdges: A, edges: w, hasDefaultEdges: M, debug: O } = b();
      if (S != null && S.length) {
        if (M) {
          const L = JE(S, w);
          A(L);
        }
        O && console.log("React Flow: trigger edge changes", S), y == null || y(S);
      }
    },
    addSelectedNodes: (S) => {
      const { multiSelectionActive: y, edgeLookup: A, nodeLookup: w, triggerNodeChanges: M, triggerEdgeChanges: O } = b();
      if (y) {
        const L = S.map((N) => Sa(N, !0));
        M(L);
        return;
      }
      M(Yo(w, /* @__PURE__ */ new Set([...S]), !0)), O(Yo(A));
    },
    addSelectedEdges: (S) => {
      const { multiSelectionActive: y, edgeLookup: A, nodeLookup: w, triggerNodeChanges: M, triggerEdgeChanges: O } = b();
      if (y) {
        const L = S.map((N) => Sa(N, !0));
        O(L);
        return;
      }
      O(Yo(A, /* @__PURE__ */ new Set([...S]))), M(Yo(w, /* @__PURE__ */ new Set(), !0));
    },
    unselectNodesAndEdges: ({ nodes: S, edges: y } = {}) => {
      const { edges: A, nodes: w, nodeLookup: M, triggerNodeChanges: O, triggerEdgeChanges: L } = b(), N = S || w, z = y || A, R = [];
      for (const U of N) {
        if (!U.selected)
          continue;
        const B = M.get(U.id);
        B && (B.selected = !1), R.push(Sa(U.id, !1));
      }
      const T = [];
      for (const U of z)
        U.selected && T.push(Sa(U.id, !1));
      O(R), L(T);
    },
    setMinZoom: (S) => {
      const { panZoom: y, maxZoom: A } = b();
      y == null || y.setScaleExtent([S, A]), _({ minZoom: S });
    },
    setMaxZoom: (S) => {
      const { panZoom: y, minZoom: A } = b();
      y == null || y.setScaleExtent([A, S]), _({ maxZoom: S });
    },
    setTranslateExtent: (S) => {
      var y;
      (y = b().panZoom) == null || y.setTranslateExtent(S), _({ translateExtent: S });
    },
    resetSelectedElements: () => {
      const { edges: S, nodes: y, triggerNodeChanges: A, triggerEdgeChanges: w, elementsSelectable: M } = b();
      if (!M)
        return;
      const O = y.reduce((N, z) => z.selected ? [...N, Sa(z.id, !1)] : N, []), L = S.reduce((N, z) => z.selected ? [...N, Sa(z.id, !1)] : N, []);
      A(O), w(L);
    },
    setNodeExtent: (S) => {
      const { nodes: y, nodeLookup: A, parentLookup: w, nodeOrigin: M, elevateNodesOnSelect: O, nodeExtent: L, zIndexMode: N } = b();
      S[0][0] === L[0][0] && S[0][1] === L[0][1] && S[1][0] === L[1][0] && S[1][1] === L[1][1] || (c0(y, A, w, {
        nodeOrigin: M,
        nodeExtent: S,
        elevateNodesOnSelect: O,
        checkEquality: !1,
        zIndexMode: N
      }), _({ nodeExtent: S }));
    },
    panBy: (S) => {
      const { transform: y, width: A, height: w, panZoom: M, translateExtent: O } = b();
      return GI({ delta: S, panZoom: M, transform: y, translateExtent: O, width: A, height: w });
    },
    setCenter: async (S, y, A) => {
      const { width: w, height: M, maxZoom: O, panZoom: L } = b();
      if (!L)
        return Promise.resolve(!1);
      const N = typeof (A == null ? void 0 : A.zoom) < "u" ? A.zoom : O;
      return await L.setViewport({
        x: w / 2 - S * N,
        y: M / 2 - y * N,
        zoom: N
      }, { duration: A == null ? void 0 : A.duration, ease: A == null ? void 0 : A.ease, interpolate: A == null ? void 0 : A.interpolate }), Promise.resolve(!0);
    },
    cancelConnection: () => {
      _({
        connection: { ..._E }
      });
    },
    updateConnection: (S) => {
      _({ connection: S });
    },
    reset: () => _({ ...T1() })
  };
}, Object.is);
function Ew({ initialNodes: n, initialEdges: t, defaultNodes: e, defaultEdges: r, initialWidth: a, initialHeight: o, initialMinZoom: c, initialMaxZoom: u, initialFitViewOptions: d, fitView: h, nodeOrigin: p, nodeExtent: m, zIndexMode: g, children: _ }) {
  const [b] = ct.useState(() => a5({
    nodes: n,
    edges: t,
    defaultNodes: e,
    defaultEdges: r,
    width: a,
    height: o,
    fitView: h,
    minZoom: c,
    maxZoom: u,
    fitViewOptions: d,
    nodeOrigin: p,
    nodeExtent: m,
    zIndexMode: g
  }));
  return J.jsx(w4, { value: b, children: J.jsx(q4, { children: _ }) });
}
function o5({ children: n, nodes: t, edges: e, defaultNodes: r, defaultEdges: a, width: o, height: c, fitView: u, fitViewOptions: d, minZoom: h, maxZoom: p, nodeOrigin: m, nodeExtent: g, zIndexMode: _ }) {
  return ct.useContext(Gd) ? J.jsx(J.Fragment, { children: n }) : J.jsx(Ew, { initialNodes: t, initialEdges: e, defaultNodes: r, defaultEdges: a, initialWidth: o, initialHeight: c, fitView: u, initialFitViewOptions: d, initialMinZoom: h, initialMaxZoom: p, nodeOrigin: m, nodeExtent: g, zIndexMode: _, children: n });
}
const l5 = {
  width: "100%",
  height: "100%",
  overflow: "hidden",
  position: "relative",
  zIndex: 0
};
function c5({ nodes: n, edges: t, defaultNodes: e, defaultEdges: r, className: a, nodeTypes: o, edgeTypes: c, onNodeClick: u, onEdgeClick: d, onInit: h, onMove: p, onMoveStart: m, onMoveEnd: g, onConnect: _, onConnectStart: b, onConnectEnd: E, onClickConnectStart: S, onClickConnectEnd: y, onNodeMouseEnter: A, onNodeMouseMove: w, onNodeMouseLeave: M, onNodeContextMenu: O, onNodeDoubleClick: L, onNodeDragStart: N, onNodeDrag: z, onNodeDragStop: R, onNodesDelete: T, onEdgesDelete: U, onDelete: B, onSelectionChange: I, onSelectionDragStart: C, onSelectionDrag: X, onSelectionDragStop: D, onSelectionContextMenu: V, onSelectionStart: H, onSelectionEnd: j, onBeforeDelete: K, connectionMode: F, connectionLineType: q = Hs.Bezier, connectionLineStyle: it, connectionLineComponent: G, connectionLineContainerStyle: k, deleteKeyCode: $ = "Backspace", selectionKeyCode: Q = "Shift", selectionOnDrag: et = !1, selectionMode: st = Ic.Full, panActivationKeyCode: _t = "Space", multiSelectionKeyCode: Mt = Fc() ? "Meta" : "Control", zoomActivationKeyCode: Rt = Fc() ? "Meta" : "Control", snapToGrid: Ot, snapGrid: nt, onlyRenderVisibleElements: Jt = !1, selectNodesOnDrag: Ft, nodesDraggable: ne, autoPanOnNodeFocus: jt, nodesConnectable: xe, nodesFocusable: qt, nodeOrigin: tt = $E, edgesFocusable: W, edgesReconnectable: mt, elementsSelectable: Et = !0, defaultViewport: Dt = B4, minZoom: wt = 0.5, maxZoom: Zt = 2, translateExtent: Pt = zc, preventScrolling: Wt = !0, nodeExtent: _e, defaultMarkerColor: Ut = "#b1b1b7", zoomOnScroll: Yt = !0, zoomOnPinch: te = !0, panOnScroll: Kt = !1, panOnScrollSpeed: Gt = 0.5, panOnScrollMode: le = Da.Free, zoomOnDoubleClick: he = !0, panOnDrag: Fe = !0, onPaneClick: ut, onPaneMouseEnter: zt, onPaneMouseMove: St, onPaneMouseLeave: Ct, onPaneScroll: It, onPaneContextMenu: Ht, paneClickDistance: ue = 1, nodeClickDistance: tn = 0, children: dn, onReconnect: De, onReconnectStart: wn, onReconnectEnd: mi, onEdgeContextMenu: Ys, onEdgeDoubleClick: qs, onEdgeMouseEnter: Di, onEdgeMouseMove: Sr, onEdgeMouseLeave: rs, reconnectRadius: Zs = 10, onNodesChange: br, onEdgesChange: gi, noDragClassName: sn = "nodrag", noWheelClassName: Tn = "nowheel", noPanClassName: Ni = "nopan", fitView: ss, fitViewOptions: Fa, connectOnClick: gl, attributionPosition: Ha, proOptions: Mr, defaultEdgeOptions: $s, elevateNodesOnSelect: Z = !0, elevateEdgesOnSelect: ft = !1, disableKeyboardA11y: gt = !1, autoPanOnConnect: yt, autoPanOnNodeDrag: lt, autoPanSpeed: Lt, connectionRadius: Vt, isValidConnection: kt, onError: Xt, style: fe, id: ce, nodeDragThreshold: ee, connectionDragThreshold: Ee, viewport: we, onViewportChange: Qe, width: Le, height: de, colorMode: ie = "light", debug: hn, onScroll: Se, ariaLabelConfig: Zn, zIndexMode: ii = "basic", ...In }, gn) {
  const Oe = ce || "1", Bn = k4(ie), On = ct.useCallback((en) => {
    en.currentTarget.scrollTo({ top: 0, left: 0, behavior: "instant" }), Se == null || Se(en);
  }, [Se]);
  return J.jsx("div", { "data-testid": "rf__wrapper", ...In, onScroll: On, style: { ...fe, ...l5 }, ref: gn, className: En(["react-flow", a, Bn]), id: ce, role: "application", children: J.jsxs(o5, { nodes: n, edges: t, width: Le, height: de, fitView: ss, fitViewOptions: Fa, minZoom: wt, maxZoom: Zt, nodeOrigin: tt, nodeExtent: _e, zIndexMode: ii, children: [J.jsx(s5, { onInit: h, onNodeClick: u, onEdgeClick: d, onNodeMouseEnter: A, onNodeMouseMove: w, onNodeMouseLeave: M, onNodeContextMenu: O, onNodeDoubleClick: L, nodeTypes: o, edgeTypes: c, connectionLineType: q, connectionLineStyle: it, connectionLineComponent: G, connectionLineContainerStyle: k, selectionKeyCode: Q, selectionOnDrag: et, selectionMode: st, deleteKeyCode: $, multiSelectionKeyCode: Mt, panActivationKeyCode: _t, zoomActivationKeyCode: Rt, onlyRenderVisibleElements: Jt, defaultViewport: Dt, translateExtent: Pt, minZoom: wt, maxZoom: Zt, preventScrolling: Wt, zoomOnScroll: Yt, zoomOnPinch: te, zoomOnDoubleClick: he, panOnScroll: Kt, panOnScrollSpeed: Gt, panOnScrollMode: le, panOnDrag: Fe, onPaneClick: ut, onPaneMouseEnter: zt, onPaneMouseMove: St, onPaneMouseLeave: Ct, onPaneScroll: It, onPaneContextMenu: Ht, paneClickDistance: ue, nodeClickDistance: tn, onSelectionContextMenu: V, onSelectionStart: H, onSelectionEnd: j, onReconnect: De, onReconnectStart: wn, onReconnectEnd: mi, onEdgeContextMenu: Ys, onEdgeDoubleClick: qs, onEdgeMouseEnter: Di, onEdgeMouseMove: Sr, onEdgeMouseLeave: rs, reconnectRadius: Zs, defaultMarkerColor: Ut, noDragClassName: sn, noWheelClassName: Tn, noPanClassName: Ni, rfId: Oe, disableKeyboardA11y: gt, nodeExtent: _e, viewport: we, onViewportChange: Qe }), J.jsx(V4, { nodes: n, edges: t, defaultNodes: e, defaultEdges: r, onConnect: _, onConnectStart: b, onConnectEnd: E, onClickConnectStart: S, onClickConnectEnd: y, nodesDraggable: ne, autoPanOnNodeFocus: jt, nodesConnectable: xe, nodesFocusable: qt, edgesFocusable: W, edgesReconnectable: mt, elementsSelectable: Et, elevateNodesOnSelect: Z, elevateEdgesOnSelect: ft, minZoom: wt, maxZoom: Zt, nodeExtent: _e, onNodesChange: br, onEdgesChange: gi, snapToGrid: Ot, snapGrid: nt, connectionMode: F, translateExtent: Pt, connectOnClick: gl, defaultEdgeOptions: $s, fitView: ss, fitViewOptions: Fa, onNodesDelete: T, onEdgesDelete: U, onDelete: B, onNodeDragStart: N, onNodeDrag: z, onNodeDragStop: R, onSelectionDrag: X, onSelectionDragStart: C, onSelectionDragStop: D, onMove: p, onMoveStart: m, onMoveEnd: g, noPanClassName: Ni, nodeOrigin: tt, rfId: Oe, autoPanOnConnect: yt, autoPanOnNodeDrag: lt, autoPanSpeed: Lt, onError: Xt, connectionRadius: Vt, isValidConnection: kt, selectNodesOnDrag: Ft, nodeDragThreshold: ee, connectionDragThreshold: Ee, onBeforeDelete: K, debug: hn, ariaLabelConfig: Zn, zIndexMode: ii }), J.jsx(I4, { onSelectionChange: I }), dn, J.jsx(L4, { proOptions: Mr, position: Ha }), J.jsx(N4, { rfId: Oe, disableKeyboardA11y: gt })] }) });
}
var u5 = tw(c5);
function f5({ dimensions: n, lineWidth: t, variant: e, className: r }) {
  return J.jsx("path", { strokeWidth: t, d: `M${n[0] / 2} 0 V${n[1]} M0 ${n[1] / 2} H${n[0]}`, className: En(["react-flow__background-pattern", e, r]) });
}
function d5({ radius: n, className: t }) {
  return J.jsx("circle", { cx: n, cy: n, r: n, className: En(["react-flow__background-pattern", "dots", t]) });
}
var ts;
(function(n) {
  n.Lines = "lines", n.Dots = "dots", n.Cross = "cross";
})(ts || (ts = {}));
const h5 = {
  [ts.Dots]: 1,
  [ts.Lines]: 1,
  [ts.Cross]: 6
}, p5 = (n) => ({ transform: n.transform, patternId: `pattern-${n.rfId}` });
function ww({
  id: n,
  variant: t = ts.Dots,
  // only used for dots and cross
  gap: e = 20,
  // only used for lines and cross
  size: r,
  lineWidth: a = 1,
  offset: o = 0,
  color: c,
  bgColor: u,
  style: d,
  className: h,
  patternClassName: p
}) {
  const m = ct.useRef(null), { transform: g, patternId: _ } = Ue(p5, on), b = r || h5[t], E = t === ts.Dots, S = t === ts.Cross, y = Array.isArray(e) ? e : [e, e], A = [y[0] * g[2] || 1, y[1] * g[2] || 1], w = b * g[2], M = Array.isArray(o) ? o : [o, o], O = S ? [w, w] : A, L = [
    M[0] * g[2] || 1 + O[0] / 2,
    M[1] * g[2] || 1 + O[1] / 2
  ], N = `${_}${n || ""}`;
  return J.jsxs("svg", { className: En(["react-flow__background", h]), style: {
    ...d,
    ...jd,
    "--xy-background-color-props": u,
    "--xy-background-pattern-color-props": c
  }, ref: m, "data-testid": "rf__background", children: [J.jsx("pattern", { id: N, x: g[0] % A[0], y: g[1] % A[1], width: A[0], height: A[1], patternUnits: "userSpaceOnUse", patternTransform: `translate(-${L[0]},-${L[1]})`, children: E ? J.jsx(d5, { radius: w / 2, className: p }) : J.jsx(f5, { dimensions: O, lineWidth: a, variant: t, className: p }) }), J.jsx("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: `url(#${N})` })] });
}
ww.displayName = "Background";
const m5 = ct.memo(ww);
function g5() {
  return J.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 32", children: J.jsx("path", { d: "M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z" }) });
}
function v5() {
  return J.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 5", children: J.jsx("path", { d: "M0 0h32v4.2H0z" }) });
}
function _5() {
  return J.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 30", children: J.jsx("path", { d: "M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z" }) });
}
function y5() {
  return J.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 25 32", children: J.jsx("path", { d: "M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z" }) });
}
function x5() {
  return J.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 25 32", children: J.jsx("path", { d: "M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z" }) });
}
function Qf({ children: n, className: t, ...e }) {
  return J.jsx("button", { type: "button", className: En(["react-flow__controls-button", t]), ...e, children: n });
}
const S5 = (n) => ({
  isInteractive: n.nodesDraggable || n.nodesConnectable || n.elementsSelectable,
  minZoomReached: n.transform[2] <= n.minZoom,
  maxZoomReached: n.transform[2] >= n.maxZoom,
  ariaLabelConfig: n.ariaLabelConfig
});
function Tw({ style: n, showZoom: t = !0, showFitView: e = !0, showInteractive: r = !0, fitViewOptions: a, onZoomIn: o, onZoomOut: c, onFitView: u, onInteractiveChange: d, className: h, children: p, position: m = "bottom-left", orientation: g = "vertical", "aria-label": _ }) {
  const b = ln(), { isInteractive: E, minZoomReached: S, maxZoomReached: y, ariaLabelConfig: A } = Ue(S5, on), { zoomIn: w, zoomOut: M, fitView: O } = Vc(), L = () => {
    w(), o == null || o();
  }, N = () => {
    M(), c == null || c();
  }, z = () => {
    O(a), u == null || u();
  }, R = () => {
    b.setState({
      nodesDraggable: !E,
      nodesConnectable: !E,
      elementsSelectable: !E
    }), d == null || d(!E);
  }, T = g === "horizontal" ? "horizontal" : "vertical";
  return J.jsxs(Xd, { className: En(["react-flow__controls", T, h]), position: m, style: n, "data-testid": "rf__controls", "aria-label": _ ?? A["controls.ariaLabel"], children: [t && J.jsxs(J.Fragment, { children: [J.jsx(Qf, { onClick: L, className: "react-flow__controls-zoomin", title: A["controls.zoomIn.ariaLabel"], "aria-label": A["controls.zoomIn.ariaLabel"], disabled: y, children: J.jsx(g5, {}) }), J.jsx(Qf, { onClick: N, className: "react-flow__controls-zoomout", title: A["controls.zoomOut.ariaLabel"], "aria-label": A["controls.zoomOut.ariaLabel"], disabled: S, children: J.jsx(v5, {}) })] }), e && J.jsx(Qf, { className: "react-flow__controls-fitview", onClick: z, title: A["controls.fitView.ariaLabel"], "aria-label": A["controls.fitView.ariaLabel"], children: J.jsx(_5, {}) }), r && J.jsx(Qf, { className: "react-flow__controls-interactive", onClick: R, title: A["controls.interactive.ariaLabel"], "aria-label": A["controls.interactive.ariaLabel"], children: E ? J.jsx(x5, {}) : J.jsx(y5, {}) }), p] });
}
Tw.displayName = "Controls";
const b5 = ct.memo(Tw);
function M5({ id: n, x: t, y: e, width: r, height: a, style: o, color: c, strokeColor: u, strokeWidth: d, className: h, borderRadius: p, shapeRendering: m, selected: g, onClick: _ }) {
  const { background: b, backgroundColor: E } = o || {}, S = c || b || E;
  return J.jsx("rect", { className: En(["react-flow__minimap-node", { selected: g }, h]), x: t, y: e, rx: p, ry: p, width: r, height: a, style: {
    fill: S,
    stroke: u,
    strokeWidth: d
  }, shapeRendering: m, onClick: _ ? (y) => _(y, n) : void 0 });
}
const E5 = ct.memo(M5), w5 = (n) => n.nodes.map((t) => t.id), eg = (n) => n instanceof Function ? n : () => n;
function T5({
  nodeStrokeColor: n,
  nodeColor: t,
  nodeClassName: e = "",
  nodeBorderRadius: r = 5,
  nodeStrokeWidth: a,
  /*
   * We need to rename the prop to be `CapitalCase` so that JSX will render it as
   * a component properly.
   */
  nodeComponent: o = E5,
  onClick: c
}) {
  const u = Ue(w5, on), d = eg(t), h = eg(n), p = eg(e), m = typeof window > "u" || window.chrome ? "crispEdges" : "geometricPrecision";
  return J.jsx(J.Fragment, { children: u.map((g) => (
    /*
     * The split of responsibilities between MiniMapNodes and
     * NodeComponentWrapper may appear weird. However, it’s designed to
     * minimize the cost of updates when individual nodes change.
     *
     * For more details, see a similar commit in `NodeRenderer/index.tsx`.
     */
    J.jsx(C5, { id: g, nodeColorFunc: d, nodeStrokeColorFunc: h, nodeClassNameFunc: p, nodeBorderRadius: r, nodeStrokeWidth: a, NodeComponent: o, onClick: c, shapeRendering: m }, g)
  )) });
}
function A5({ id: n, nodeColorFunc: t, nodeStrokeColorFunc: e, nodeClassNameFunc: r, nodeBorderRadius: a, nodeStrokeWidth: o, shapeRendering: c, NodeComponent: u, onClick: d }) {
  const { node: h, x: p, y: m, width: g, height: _ } = Ue((b) => {
    const E = b.nodeLookup.get(n);
    if (!E)
      return { node: void 0, x: 0, y: 0, width: 0, height: 0 };
    const S = E.internals.userNode, { x: y, y: A } = E.internals.positionAbsolute, { width: w, height: M } = is(S);
    return {
      node: S,
      x: y,
      y: A,
      width: w,
      height: M
    };
  }, on);
  return !h || h.hidden || !wE(h) ? null : J.jsx(u, { x: p, y: m, width: g, height: _, style: h.style, selected: !!h.selected, className: r(h), color: t(h), borderRadius: a, strokeColor: e(h), strokeWidth: o, shapeRendering: c, onClick: d, id: h.id });
}
const C5 = ct.memo(A5);
var R5 = ct.memo(T5);
const D5 = 200, N5 = 150, L5 = (n) => !n.hidden, U5 = (n) => {
  const t = {
    x: -n.transform[0] / n.transform[2],
    y: -n.transform[1] / n.transform[2],
    width: n.width / n.transform[2],
    height: n.height / n.transform[2]
  };
  return {
    viewBB: t,
    boundingRect: n.nodeLookup.size > 0 ? EE($c(n.nodeLookup, { filter: L5 }), t) : t,
    rfId: n.rfId,
    panZoom: n.panZoom,
    translateExtent: n.translateExtent,
    flowWidth: n.width,
    flowHeight: n.height,
    ariaLabelConfig: n.ariaLabelConfig
  };
}, O5 = "react-flow__minimap-desc";
function Aw({
  style: n,
  className: t,
  nodeStrokeColor: e,
  nodeColor: r,
  nodeClassName: a = "",
  nodeBorderRadius: o = 5,
  nodeStrokeWidth: c,
  /*
   * We need to rename the prop to be `CapitalCase` so that JSX will render it as
   * a component properly.
   */
  nodeComponent: u,
  bgColor: d,
  maskColor: h,
  maskStrokeColor: p,
  maskStrokeWidth: m,
  position: g = "bottom-right",
  onClick: _,
  onNodeClick: b,
  pannable: E = !1,
  zoomable: S = !1,
  ariaLabel: y,
  inversePan: A,
  zoomStep: w = 1,
  offsetScale: M = 5
}) {
  const O = ln(), L = ct.useRef(null), { boundingRect: N, viewBB: z, rfId: R, panZoom: T, translateExtent: U, flowWidth: B, flowHeight: I, ariaLabelConfig: C } = Ue(U5, on), X = (n == null ? void 0 : n.width) ?? D5, D = (n == null ? void 0 : n.height) ?? N5, V = N.width / X, H = N.height / D, j = Math.max(V, H), K = j * X, F = j * D, q = M * j, it = N.x - (K - N.width) / 2 - q, G = N.y - (F - N.height) / 2 - q, k = K + q * 2, $ = F + q * 2, Q = `${O5}-${R}`, et = ct.useRef(0), st = ct.useRef();
  et.current = j, ct.useEffect(() => {
    if (L.current && T)
      return st.current = QI({
        domNode: L.current,
        panZoom: T,
        getTransform: () => O.getState().transform,
        getViewScale: () => et.current
      }), () => {
        var Ot;
        (Ot = st.current) == null || Ot.destroy();
      };
  }, [T]), ct.useEffect(() => {
    var Ot;
    (Ot = st.current) == null || Ot.update({
      translateExtent: U,
      width: B,
      height: I,
      inversePan: A,
      pannable: E,
      zoomStep: w,
      zoomable: S
    });
  }, [E, S, A, w, U, B, I]);
  const _t = _ ? (Ot) => {
    var Ft;
    const [nt, Jt] = ((Ft = st.current) == null ? void 0 : Ft.pointer(Ot)) || [0, 0];
    _(Ot, { x: nt, y: Jt });
  } : void 0, Mt = b ? ct.useCallback((Ot, nt) => {
    const Jt = O.getState().nodeLookup.get(nt).internals.userNode;
    b(Ot, Jt);
  }, []) : void 0, Rt = y ?? C["minimap.ariaLabel"];
  return J.jsx(Xd, { position: g, style: {
    ...n,
    "--xy-minimap-background-color-props": typeof d == "string" ? d : void 0,
    "--xy-minimap-mask-background-color-props": typeof h == "string" ? h : void 0,
    "--xy-minimap-mask-stroke-color-props": typeof p == "string" ? p : void 0,
    "--xy-minimap-mask-stroke-width-props": typeof m == "number" ? m * j : void 0,
    "--xy-minimap-node-background-color-props": typeof r == "string" ? r : void 0,
    "--xy-minimap-node-stroke-color-props": typeof e == "string" ? e : void 0,
    "--xy-minimap-node-stroke-width-props": typeof c == "number" ? c : void 0
  }, className: En(["react-flow__minimap", t]), "data-testid": "rf__minimap", children: J.jsxs("svg", { width: X, height: D, viewBox: `${it} ${G} ${k} ${$}`, className: "react-flow__minimap-svg", role: "img", "aria-labelledby": Q, ref: L, onClick: _t, children: [Rt && J.jsx("title", { id: Q, children: Rt }), J.jsx(R5, { onClick: Mt, nodeColor: r, nodeStrokeColor: e, nodeBorderRadius: o, nodeClassName: a, nodeStrokeWidth: c, nodeComponent: u }), J.jsx("path", { className: "react-flow__minimap-mask", d: `M${it - q},${G - q}h${k + q * 2}v${$ + q * 2}h${-k - q * 2}z
        M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`, fillRule: "evenodd", pointerEvents: "none" })] }) });
}
Aw.displayName = "MiniMap";
const P5 = ct.memo(Aw), z5 = (n) => (t) => n ? `${Math.max(1 / t.transform[2], 1)}` : void 0, I5 = {
  [hl.Line]: "right",
  [hl.Handle]: "bottom-right"
};
function B5({ nodeId: n, position: t, variant: e = hl.Handle, className: r, style: a = void 0, children: o, color: c, minWidth: u = 10, minHeight: d = 10, maxWidth: h = Number.MAX_VALUE, maxHeight: p = Number.MAX_VALUE, keepAspectRatio: m = !1, resizeDirection: g, autoScale: _ = !0, shouldResize: b, onResizeStart: E, onResize: S, onResizeEnd: y }) {
  const A = rw(), w = typeof n == "string" ? n : A, M = ln(), O = ct.useRef(null), L = e === hl.Handle, N = Ue(ct.useCallback(z5(L && _), [L, _]), on), z = ct.useRef(null), R = t ?? I5[e];
  ct.useEffect(() => {
    if (!(!O.current || !w))
      return z.current || (z.current = d4({
        domNode: O.current,
        nodeId: w,
        getStoreItems: () => {
          const { nodeLookup: U, transform: B, snapGrid: I, snapToGrid: C, nodeOrigin: X, domNode: D } = M.getState();
          return {
            nodeLookup: U,
            transform: B,
            snapGrid: I,
            snapToGrid: C,
            nodeOrigin: X,
            paneDomNode: D
          };
        },
        onChange: (U, B) => {
          const { triggerNodeChanges: I, nodeLookup: C, parentLookup: X, nodeOrigin: D } = M.getState(), V = [], H = { x: U.x, y: U.y }, j = C.get(w);
          if (j && j.expandParent && j.parentId) {
            const K = j.origin ?? D, F = U.width ?? j.measured.width ?? 0, q = U.height ?? j.measured.height ?? 0, it = {
              id: j.id,
              parentId: j.parentId,
              rect: {
                width: F,
                height: q,
                ...TE({
                  x: U.x ?? j.position.x,
                  y: U.y ?? j.position.y
                }, { width: F, height: q }, j.parentId, C, K)
              }
            }, G = K0([it], C, X, D);
            V.push(...G), H.x = U.x ? Math.max(K[0] * F, U.x) : void 0, H.y = U.y ? Math.max(K[1] * q, U.y) : void 0;
          }
          if (H.x !== void 0 && H.y !== void 0) {
            const K = {
              id: w,
              type: "position",
              position: { ...H }
            };
            V.push(K);
          }
          if (U.width !== void 0 && U.height !== void 0) {
            const F = {
              id: w,
              type: "dimensions",
              resizing: !0,
              setAttributes: g ? g === "horizontal" ? "width" : "height" : !0,
              dimensions: {
                width: U.width,
                height: U.height
              }
            };
            V.push(F);
          }
          for (const K of B) {
            const F = {
              ...K,
              type: "position"
            };
            V.push(F);
          }
          I(V);
        },
        onEnd: ({ width: U, height: B }) => {
          const I = {
            id: w,
            type: "dimensions",
            resizing: !1,
            dimensions: {
              width: U,
              height: B
            }
          };
          M.getState().triggerNodeChanges([I]);
        }
      })), z.current.update({
        controlPosition: R,
        boundaries: {
          minWidth: u,
          minHeight: d,
          maxWidth: h,
          maxHeight: p
        },
        keepAspectRatio: m,
        resizeDirection: g,
        onResizeStart: E,
        onResize: S,
        onResizeEnd: y,
        shouldResize: b
      }), () => {
        var U;
        (U = z.current) == null || U.destroy();
      };
  }, [
    R,
    u,
    d,
    h,
    p,
    m,
    E,
    S,
    y,
    b
  ]);
  const T = R.split("-");
  return J.jsx("div", { className: En(["react-flow__resize-control", "nodrag", ...T, e, r]), ref: O, style: {
    ...a,
    scale: N,
    ...c && { [L ? "backgroundColor" : "borderColor"]: c }
  }, children: o });
}
ct.memo(B5);
const A1 = (n) => {
  let t;
  const e = /* @__PURE__ */ new Set(), r = (h, p) => {
    const m = typeof h == "function" ? h(t) : h;
    if (!Object.is(m, t)) {
      const g = t;
      t = p ?? (typeof m != "object" || m === null) ? m : Object.assign({}, t, m), e.forEach((_) => _(t, g));
    }
  }, a = () => t, u = { setState: r, getState: a, getInitialState: () => d, subscribe: (h) => (e.add(h), () => e.delete(h)) }, d = t = n(r, a, u);
  return u;
}, F5 = ((n) => n ? A1(n) : A1), H5 = (n) => n;
function V5(n, t = H5) {
  const e = xc.useSyncExternalStore(
    n.subscribe,
    xc.useCallback(() => t(n.getState()), [n, t]),
    xc.useCallback(() => t(n.getInitialState()), [n, t])
  );
  return xc.useDebugValue(e), e;
}
const C1 = (n) => {
  const t = F5(n), e = (r) => V5(t, r);
  return Object.assign(e, t), e;
}, k5 = ((n) => n ? C1(n) : C1), Cw = {
  particle: "#3b82f6",
  // blue
  bond: "#f59e0b",
  // amber
  cell: "#10b981",
  // emerald
  label: "#8b5cf6",
  // violet
  mesh: "#6b7280",
  // gray
  trajectory: "#ec4899",
  // pink
  vector: "#ef4444"
  // red
}, Rw = {
  load_structure: "Load Structure",
  load_trajectory: "Load Trajectory",
  load_vector: "Load Vector",
  add_bond: "Add Bond",
  viewport: "Viewport",
  filter: "Filter",
  modify: "Modify",
  label_generator: "Labels",
  polyhedron_generator: "Polyhedra",
  vector_overlay: "Vectors"
}, G5 = {
  load_structure: "data_load",
  load_trajectory: "data_load",
  load_vector: "data_load",
  add_bond: "bond",
  filter: "filter",
  modify: "modify",
  label_generator: "overlay",
  polyhedron_generator: "overlay",
  vector_overlay: "overlay",
  viewport: "viewport"
}, Dw = {
  data_load: "#3b82f6",
  // blue
  bond: "#f59e0b",
  // amber
  filter: "#10b981",
  // green
  modify: "#8b5cf6",
  // purple
  overlay: "#ec4899",
  // pink
  viewport: "#64748b"
  // slate
}, kc = {
  load_structure: {
    inputs: [],
    outputs: [
      { name: "particle", dataType: "particle", label: "Particle" },
      { name: "trajectory", dataType: "trajectory", label: "Trajectory" },
      { name: "cell", dataType: "cell", label: "Cell" }
    ]
  },
  load_trajectory: {
    inputs: [
      { name: "particle", dataType: "particle", label: "Particle" }
    ],
    outputs: [
      { name: "trajectory", dataType: "trajectory", label: "Trajectory" }
    ]
  },
  load_vector: {
    inputs: [],
    outputs: [
      { name: "vector", dataType: "vector", label: "Vector" }
    ]
  },
  add_bond: {
    inputs: [
      { name: "particle", dataType: "particle", label: "Particle" }
    ],
    outputs: [
      { name: "bond", dataType: "bond", label: "Bond" }
    ]
  },
  viewport: {
    inputs: [
      { name: "particle", dataType: "particle", label: "Particle" },
      { name: "bond", dataType: "bond", label: "Bond" },
      { name: "cell", dataType: "cell", label: "Cell" },
      { name: "trajectory", dataType: "trajectory", label: "Trajectory" },
      { name: "label", dataType: "label", label: "Label" },
      { name: "mesh", dataType: "mesh", label: "Mesh" },
      { name: "vector", dataType: "vector", label: "Vector" }
    ],
    outputs: []
  },
  filter: {
    inputs: [{ name: "in", dataType: "particle", label: "In" }],
    outputs: [{ name: "out", dataType: "particle", label: "Out" }]
  },
  modify: {
    inputs: [{ name: "in", dataType: "particle", label: "In" }],
    outputs: [{ name: "out", dataType: "particle", label: "Out" }]
  },
  label_generator: {
    inputs: [{ name: "particle", dataType: "particle", label: "Particle" }],
    outputs: [{ name: "label", dataType: "label", label: "Label" }]
  },
  polyhedron_generator: {
    inputs: [{ name: "particle", dataType: "particle", label: "Particle" }],
    outputs: [{ name: "mesh", dataType: "mesh", label: "Mesh" }]
  },
  vector_overlay: {
    inputs: [{ name: "vector", dataType: "vector", label: "Vector" }],
    outputs: [{ name: "vector", dataType: "vector", label: "Vector" }]
  }
}, X5 = {
  filter: ["particle", "bond"],
  modify: ["particle", "bond"]
};
function Nw(n) {
  switch (n) {
    case "load_structure":
      return { type: n, fileName: null, hasTrajectory: !1, hasCell: !1 };
    case "load_trajectory":
      return { type: n, fileName: null };
    case "load_vector":
      return { type: n, fileName: null };
    case "add_bond":
      return { type: n, bondSource: "distance" };
    case "viewport":
      return { type: n, perspective: !1, cellAxesVisible: !0 };
    case "filter":
      return { type: n, query: "" };
    case "modify":
      return { type: n, scale: 1, opacity: 1 };
    case "label_generator":
      return { type: n, source: "element" };
    case "polyhedron_generator":
      return {
        type: n,
        centerElements: [],
        ligandElements: [8],
        // oxygen by default
        maxDistance: 2.5,
        opacity: 0.5,
        showEdges: !1,
        edgeColor: "#dddddd",
        edgeWidth: 3
      };
    case "vector_overlay":
      return { type: n, scale: 1 };
  }
}
function Lw(n, t, e, r) {
  if (!t || !r) return !1;
  const a = kc[n], o = kc[e], c = a.outputs.find((h) => h.name === t), u = o.inputs.find((h) => h.name === r);
  if (!c || !u) return !1;
  const d = X5[e];
  return d ? d.includes(c.dataType) : c.dataType === u.dataType;
}
const fd = {
  particles: [],
  bonds: [],
  cells: [],
  trajectories: [],
  labels: [],
  meshes: [],
  vectors: [],
  perspective: !1,
  cellAxesVisible: !0
};
function j5(n, t) {
  var c;
  const e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
  for (const u of n)
    e.set(u.id, 0), r.set(u.id, []);
  for (const u of t) {
    const d = e.get(u.target) ?? 0;
    e.set(u.target, d + 1), (c = r.get(u.source)) == null || c.push(u.target);
  }
  const a = [];
  for (const [u, d] of e)
    d === 0 && a.push(u);
  const o = [];
  for (; a.length > 0; ) {
    const u = a.shift();
    o.push(u);
    for (const d of r.get(u) ?? []) {
      const h = (e.get(d) ?? 1) - 1;
      e.set(d, h), h === 0 && a.push(d);
    }
  }
  return o;
}
function R1(n, t, e) {
  const r = /* @__PURE__ */ new Map();
  for (const a of t) {
    if (a.target !== n) continue;
    const o = a.sourceHandle, c = a.targetHandle;
    if (!o || !c) continue;
    const u = e.get(a.source);
    if (!u) continue;
    const d = u.get(o);
    d && (r.has(c) || r.set(c, []), r.get(c).push(d));
  }
  return r;
}
function W5(n, t, e, r) {
  const a = /* @__PURE__ */ new Map();
  if (!t) return a;
  const o = {
    type: "particle",
    source: t,
    indices: null,
    scaleOverrides: null,
    opacityOverrides: null
  };
  if (a.set("particle", o), e && e.length > 0 && r) {
    const c = {
      type: "trajectory",
      frames: e,
      meta: r,
      source: "structure"
    };
    a.set("trajectory", c);
  }
  if (t.box) {
    const c = {
      type: "cell",
      box: t.box,
      visible: !0,
      axesVisible: !0
    };
    a.set("cell", c);
  }
  return a;
}
function Y5(n, t, e, r) {
  const a = /* @__PURE__ */ new Map();
  if (e && e.length > 0 && r) {
    const o = {
      type: "trajectory",
      frames: e,
      meta: r,
      source: "file"
    };
    a.set("trajectory", o);
  }
  return a;
}
function J0(n) {
  const [t, e, r, a, o, c, u, d, h] = n, p = t * (o * h - c * d) - e * (a * h - c * u) + r * (a * d - o * u);
  if (Math.abs(p) < 1e-20) return null;
  const m = 1 / p;
  return new Float32Array([
    (o * h - c * d) * m,
    (r * d - e * h) * m,
    (e * c - r * o) * m,
    (c * u - a * h) * m,
    (t * h - r * u) * m,
    (r * a - t * c) * m,
    (a * d - o * u) * m,
    (e * u - t * d) * m,
    (t * o - e * a) * m
  ]);
}
const q5 = 0.6, D1 = 0.4, Yr = 2;
function Uw(n, t, e, r = q5, a = null) {
  if (e < 2) return new Uint32Array(0);
  const o = a !== null && a.some((y) => y !== 0), c = o ? J0(a) : null, u = o && c !== null;
  let d, h, p;
  if (u) {
    const y = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]), A = Math.sqrt(a[3] * a[3] + a[4] * a[4] + a[5] * a[5]), w = Math.sqrt(a[6] * a[6] + a[7] * a[7] + a[8] * a[8]);
    d = Math.max(1, Math.floor(y / Yr)), h = Math.max(1, Math.floor(A / Yr)), p = Math.max(1, Math.floor(w / Yr));
  } else {
    let y = 1 / 0, A = 1 / 0, w = 1 / 0, M = -1 / 0, O = -1 / 0, L = -1 / 0;
    for (let N = 0; N < e; N++) {
      const z = n[N * 3], R = n[N * 3 + 1], T = n[N * 3 + 2];
      z < y && (y = z), R < A && (A = R), T < w && (w = T), z > M && (M = z), R > O && (O = R), T > L && (L = T);
    }
    d = Math.max(1, Math.floor((M - y) / Yr) + 1), h = Math.max(1, Math.floor((O - A) / Yr) + 1), p = Math.max(1, Math.floor((L - w) / Yr) + 1);
  }
  const m = d * h * p, g = new Array(m);
  for (let y = 0; y < m; y++) g[y] = [];
  if (u)
    for (let y = 0; y < e; y++) {
      const A = n[y * 3], w = n[y * 3 + 1], M = n[y * 3 + 2];
      let O = c[0] * A + c[3] * w + c[6] * M, L = c[1] * A + c[4] * w + c[7] * M, N = c[2] * A + c[5] * w + c[8] * M;
      O = O - Math.floor(O), L = L - Math.floor(L), N = N - Math.floor(N);
      const z = Math.min(Math.floor(O * d), d - 1), R = Math.min(Math.floor(L * h), h - 1), T = Math.min(Math.floor(N * p), p - 1);
      g[z * h * p + R * p + T].push(y);
    }
  else {
    let y = 1 / 0, A = 1 / 0, w = 1 / 0;
    for (let M = 0; M < e; M++)
      n[M * 3] < y && (y = n[M * 3]), n[M * 3 + 1] < A && (A = n[M * 3 + 1]), n[M * 3 + 2] < w && (w = n[M * 3 + 2]);
    for (let M = 0; M < e; M++) {
      const O = Math.min(Math.floor((n[M * 3] - y) / Yr), d - 1), L = Math.min(Math.floor((n[M * 3 + 1] - A) / Yr), h - 1), N = Math.min(Math.floor((n[M * 3 + 2] - w) / Yr), p - 1);
      g[O * h * p + L * p + N].push(M);
    }
  }
  const _ = [
    [0, 0, 1],
    [0, 1, -1],
    [0, 1, 0],
    [0, 1, 1],
    [1, -1, -1],
    [1, -1, 0],
    [1, -1, 1],
    [1, 0, -1],
    [1, 0, 0],
    [1, 0, 1],
    [1, 1, -1],
    [1, 1, 0],
    [1, 1, 1]
  ], b = D1 * D1, E = [];
  function S(y, A) {
    const w = $g[t[y]] ?? Kg, M = $g[t[A]] ?? Kg, O = (w + M) * r, L = O * O;
    let N = n[A * 3] - n[y * 3], z = n[A * 3 + 1] - n[y * 3 + 1], R = n[A * 3 + 2] - n[y * 3 + 2];
    if (u) {
      let U = c[0] * N + c[3] * z + c[6] * R, B = c[1] * N + c[4] * z + c[7] * R, I = c[2] * N + c[5] * z + c[8] * R;
      U -= Math.round(U), B -= Math.round(B), I -= Math.round(I), N = a[0] * U + a[3] * B + a[6] * I, z = a[1] * U + a[4] * B + a[7] * I, R = a[2] * U + a[5] * B + a[8] * I;
    }
    const T = N * N + z * z + R * R;
    if (T > b && T <= L) {
      const U = y < A ? y : A, B = y < A ? A : y;
      E.push(U, B);
    }
  }
  for (let y = 0; y < d; y++)
    for (let A = 0; A < h; A++)
      for (let w = 0; w < p; w++) {
        const M = y * h * p + A * p + w, O = g[M];
        for (let L = 0; L < O.length; L++)
          for (let N = L + 1; N < O.length; N++)
            S(O[L], O[N]);
        for (const [L, N, z] of _) {
          const R = y + L, T = A + N, U = w + z;
          if (u) {
            const B = (R % d + d) % d, I = (T % h + h) % h, C = (U % p + p) % p, X = B * h * p + I * p + C;
            if (X === M) continue;
            const D = g[X];
            for (const V of O)
              for (const H of D)
                S(V, H);
          } else {
            if (R < 0 || R >= d || T < 0 || T >= h || U < 0 || U >= p) continue;
            const B = R * h * p + T * p + U, I = g[B];
            for (const C of O)
              for (const X of I)
                S(C, X);
          }
        }
      }
  return new Uint32Array(E);
}
function d0(n, t, e, r, a, o) {
  if (!o || !o.some((z) => z !== 0))
    return { bondIndices: n, bondOrders: t, nBonds: n.length / 2, positions: null, elements: null, nAtoms: 0 };
  const c = J0(o);
  if (!c)
    return { bondIndices: n, bondOrders: t, nBonds: n.length / 2, positions: null, elements: null, nAtoms: 0 };
  const u = Math.sqrt(o[0] * o[0] + o[1] * o[1] + o[2] * o[2]), d = Math.sqrt(o[3] * o[3] + o[4] * o[4] + o[5] * o[5]), h = Math.sqrt(o[6] * o[6] + o[7] * o[7] + o[8] * o[8]), p = Math.min(u, d, h) / 2, m = p * p, g = n.length / 2;
  let _ = 0, b = 0;
  for (let z = 0; z < g; z++) {
    const R = n[z * 2], T = n[z * 2 + 1], U = e[T * 3] - e[R * 3], B = e[T * 3 + 1] - e[R * 3 + 1], I = e[T * 3 + 2] - e[R * 3 + 2];
    U * U + B * B + I * I > m ? b++ : _++;
  }
  if (b === 0)
    return { bondIndices: n, bondOrders: t, nBonds: g, positions: null, elements: null, nAtoms: 0 };
  const E = _ + b * 2, S = new Uint32Array(E * 2), y = t ? new Uint8Array(E) : null, A = [], w = [];
  let M = a, O = 0;
  for (let z = 0; z < g; z++) {
    const R = n[z * 2], T = n[z * 2 + 1], U = e[T * 3] - e[R * 3], B = e[T * 3 + 1] - e[R * 3 + 1], I = e[T * 3 + 2] - e[R * 3 + 2];
    if (U * U + B * B + I * I <= m)
      S[O * 2] = R, S[O * 2 + 1] = T, y && t && (y[O] = t[z]), O++;
    else {
      let X = c[0] * U + c[3] * B + c[6] * I, D = c[1] * U + c[4] * B + c[7] * I, V = c[2] * U + c[5] * B + c[8] * I;
      X -= Math.round(X), D -= Math.round(D), V -= Math.round(V);
      const H = o[0] * X + o[3] * D + o[6] * V, j = o[1] * X + o[4] * D + o[7] * V, K = o[2] * X + o[5] * D + o[8] * V;
      A.push(
        e[R * 3] + H,
        e[R * 3 + 1] + j,
        e[R * 3 + 2] + K
      ), w.push(r[T]), S[O * 2] = R, S[O * 2 + 1] = M, y && t && (y[O] = t[z]), O++, M++, A.push(
        e[T * 3] - H,
        e[T * 3 + 1] - j,
        e[T * 3 + 2] - K
      ), w.push(r[R]), S[O * 2] = T, S[O * 2 + 1] = M, y && t && (y[O] = t[z]), O++, M++;
    }
  }
  const L = new Float32Array(e.length + A.length);
  L.set(e), L.set(new Float32Array(A), e.length);
  const N = new Uint8Array(r.length + w.length);
  return N.set(r), N.set(new Uint8Array(w), r.length), {
    bondIndices: S,
    bondOrders: y,
    nBonds: E,
    positions: L,
    elements: N,
    nAtoms: M
  };
}
function Z5(n, t) {
  var o;
  const e = /* @__PURE__ */ new Map(), r = (o = t.get("particle")) == null ? void 0 : o[0];
  if (!r) return e;
  const a = r.source;
  if (n.bondSource === "structure") {
    if (a.nFileBonds > 0) {
      let c = a.bonds, u = a.bondOrders, d = a.nBonds, h = null, p = null, m = 0;
      const g = d0(
        c,
        u,
        a.positions,
        a.elements,
        a.nAtoms,
        a.box
      );
      if (c = g.bondIndices, u = g.bondOrders, d = g.nBonds, h = g.positions, p = g.elements, m = g.nAtoms, d > 0) {
        const _ = {
          type: "bond",
          bondIndices: c,
          bondOrders: u,
          nBonds: d,
          scale: 1,
          opacity: 1,
          positions: h,
          elements: p,
          nAtoms: m
        };
        e.set("bond", _);
      }
    }
  } else if (n.bondSource === "distance") {
    let c = Uw(
      a.positions,
      a.elements,
      a.nAtoms,
      0.6,
      a.box
    );
    if (c.length > 0) {
      let u = c.length / 2, d = null, h = null, p = 0;
      const m = d0(
        c,
        null,
        a.positions,
        a.elements,
        a.nAtoms,
        a.box
      );
      if (c = m.bondIndices, u = m.nBonds, d = m.positions, h = m.elements, p = m.nAtoms, u > 0) {
        const g = {
          type: "bond",
          bondIndices: c,
          bondOrders: null,
          nBonds: u,
          scale: 1,
          opacity: 1,
          positions: d,
          elements: h,
          nAtoms: p
        };
        e.set("bond", g);
      }
    }
  }
  return e;
}
const $5 = /* @__PURE__ */ new Set(["element", "index", "x", "y", "z", "resname", "mass"]);
function Ow(n) {
  const t = [];
  let e = 0;
  for (; e < n.length; ) {
    if (/\s/.test(n[e])) {
      e++;
      continue;
    }
    if (n[e] === "(") {
      t.push({ type: "lparen", value: "(" }), e++;
      continue;
    }
    if (n[e] === ")") {
      t.push({ type: "rparen", value: ")" }), e++;
      continue;
    }
    if (n.startsWith("==", e)) {
      t.push({ type: "op", value: "==" }), e += 2;
      continue;
    }
    if (n.startsWith("!=", e)) {
      t.push({ type: "op", value: "!=" }), e += 2;
      continue;
    }
    if (n.startsWith(">=", e)) {
      t.push({ type: "op", value: ">=" }), e += 2;
      continue;
    }
    if (n.startsWith("<=", e)) {
      t.push({ type: "op", value: "<=" }), e += 2;
      continue;
    }
    if (n[e] === ">") {
      t.push({ type: "op", value: ">" }), e++;
      continue;
    }
    if (n[e] === "<") {
      t.push({ type: "op", value: "<" }), e++;
      continue;
    }
    if (n[e] === '"' || n[e] === "'") {
      const r = n[e];
      let a = e + 1;
      for (; a < n.length && n[a] !== r; ) a++;
      if (a >= n.length) throw new Error(`Unterminated string at position ${e}`);
      t.push({ type: "string", value: n.slice(e + 1, a) }), e = a + 1;
      continue;
    }
    if (/[\d.]/.test(n[e]) || n[e] === "-" && e + 1 < n.length && /[\d.]/.test(n[e + 1])) {
      let r = e;
      for (n[r] === "-" && r++; r < n.length && /[\d.]/.test(n[r]); ) r++;
      t.push({ type: "number", value: n.slice(e, r) }), e = r;
      continue;
    }
    if (/[a-zA-Z_]/.test(n[e])) {
      let r = e;
      for (; r < n.length && /[a-zA-Z_0-9]/.test(n[r]); ) r++;
      const a = n.slice(e, r);
      if (a === "and") t.push({ type: "and", value: a });
      else if (a === "or") t.push({ type: "or", value: a });
      else if (a === "not") t.push({ type: "not", value: a });
      else if (a === "all") t.push({ type: "all", value: a });
      else if (a === "none") t.push({ type: "none", value: a });
      else if ($5.has(a)) t.push({ type: "field", value: a });
      else throw new Error(`Unknown identifier: "${a}"`);
      e = r;
      continue;
    }
    throw new Error(`Unexpected character: "${n[e]}" at position ${e}`);
  }
  return t.push({ type: "eof", value: "" }), t;
}
class Pw {
  constructor(t) {
    Nt(this, "tokens");
    Nt(this, "pos", 0);
    this.tokens = t;
  }
  peek() {
    return this.tokens[this.pos];
  }
  advance() {
    return this.tokens[this.pos++];
  }
  expect(t) {
    const e = this.peek();
    if (e.type !== t)
      throw new Error(`Expected ${t}, got ${e.type} ("${e.value}")`);
    return this.advance();
  }
  parse() {
    const t = this.parseOr();
    if (this.peek().type !== "eof")
      throw new Error(`Unexpected token: "${this.peek().value}"`);
    return t;
  }
  parseOr() {
    let t = this.parseAnd();
    for (; this.peek().type === "or"; ) {
      this.advance();
      const e = this.parseAnd();
      t = { kind: "or", left: t, right: e };
    }
    return t;
  }
  parseAnd() {
    let t = this.parseNot();
    for (; this.peek().type === "and"; ) {
      this.advance();
      const e = this.parseNot();
      t = { kind: "and", left: t, right: e };
    }
    return t;
  }
  parseNot() {
    return this.peek().type === "not" ? (this.advance(), { kind: "not", operand: this.parseNot() }) : this.parseAtom();
  }
  parseAtom() {
    const t = this.peek();
    if (t.type === "all")
      return this.advance(), { kind: "all" };
    if (t.type === "none")
      return this.advance(), { kind: "none" };
    if (t.type === "lparen") {
      this.advance();
      const e = this.parseOr();
      return this.expect("rparen"), e;
    }
    if (t.type === "field") {
      const e = this.advance().value, r = this.expect("op").value, a = this.peek();
      let o;
      if (a.type === "string")
        o = this.advance().value;
      else if (a.type === "number") {
        if (o = parseFloat(this.advance().value), isNaN(o)) throw new Error("Invalid number");
      } else
        throw new Error(`Expected value after operator, got ${a.type}`);
      return { kind: "comparison", field: e, op: r, value: o };
    }
    throw new Error(`Unexpected token: "${t.value}" (${t.type})`);
  }
}
function K5(n) {
  const t = n.match(/^([A-Za-z]+)/);
  return t ? t[1] : n;
}
function Go(n, t, e) {
  switch (n.kind) {
    case "all":
      return () => !0;
    case "none":
      return () => !1;
    case "not": {
      const r = Go(n.operand, t, e);
      return (a) => !r(a);
    }
    case "and": {
      const r = Go(n.left, t, e), a = Go(n.right, t, e);
      return (o) => r(o) && a(o);
    }
    case "or": {
      const r = Go(n.left, t, e), a = Go(n.right, t, e);
      return (o) => r(o) || a(o);
    }
    case "comparison": {
      const { field: r, op: a, value: o } = n;
      return (c) => {
        let u;
        switch (r) {
          case "element":
            u = P0(t.elements[c]);
            break;
          case "index":
            u = c;
            break;
          case "x":
            u = t.positions[c * 3];
            break;
          case "y":
            u = t.positions[c * 3 + 1];
            break;
          case "z":
            u = t.positions[c * 3 + 2];
            break;
          case "resname":
            u = e != null && e[c] ? K5(e[c]) : "";
            break;
          case "mass":
            u = nU(t.elements[c]);
            break;
          default:
            return !1;
        }
        switch (a) {
          case "==":
            return u === o;
          case "!=":
            return u !== o;
          case ">":
            return u > o;
          case "<":
            return u < o;
          case ">=":
            return u >= o;
          case "<=":
            return u <= o;
          default:
            return !1;
        }
      };
    }
  }
}
function Q5(n, t, e) {
  const r = n.trim();
  if (r === "" || r === "all") return null;
  const a = Ow(r), c = new Pw(a).parse();
  if (c.kind === "all") return null;
  if (c.kind === "none") return /* @__PURE__ */ new Set();
  const u = Go(c, t, e), d = /* @__PURE__ */ new Set();
  for (let h = 0; h < t.nAtoms; h++)
    u(h) && d.add(h);
  return d;
}
function J5(n) {
  const t = n.trim();
  if (t === "" || t === "all" || t === "none")
    return { valid: !0 };
  try {
    const e = Ow(t);
    return new Pw(e).parse(), { valid: !0 };
  } catch (e) {
    return { valid: !1, error: e.message };
  }
}
function tF(n, t, e) {
  var o;
  const r = /* @__PURE__ */ new Map(), a = (o = t.get("in")) == null ? void 0 : o[0];
  if (!a) return r;
  if (a.type === "particle") {
    const c = a;
    if (!n.query.trim())
      return r.set("out", c), r;
    try {
      const u = Q5(
        n.query,
        c.source,
        e
      );
      if (u === null)
        r.set("out", c);
      else {
        let d;
        if (c.indices === null)
          d = new Uint32Array(u);
        else {
          const p = new Set(c.indices), m = [...u].filter((g) => p.has(g));
          d = new Uint32Array(m);
        }
        const h = {
          ...c,
          indices: d,
          scaleOverrides: c.scaleOverrides,
          opacityOverrides: c.opacityOverrides
        };
        r.set("out", h);
      }
    } catch {
      r.set("out", c);
    }
  } else a.type === "bond" && r.set("out", a);
  return r;
}
function eF(n, t) {
  var a;
  const e = /* @__PURE__ */ new Map(), r = (a = t.get("in")) == null ? void 0 : a[0];
  if (!r) return e;
  if (r.type === "particle") {
    const o = r, c = o.source.nAtoms;
    let u = o.scaleOverrides;
    if (o.indices !== null && o.indices.length > 0) {
      u ? u = new Float32Array(u) : u = new Float32Array(c).fill(1);
      for (const p of o.indices)
        u[p] = n.scale;
    } else o.indices === null && n.scale !== 1 && (u = new Float32Array(c).fill(n.scale));
    let d = o.opacityOverrides;
    if (o.indices !== null && o.indices.length > 0) {
      d ? d = new Float32Array(d) : d = new Float32Array(c).fill(1);
      for (const p of o.indices)
        d[p] = n.opacity;
    } else o.indices === null && n.opacity !== 1 && (d = new Float32Array(c).fill(n.opacity));
    const h = {
      ...o,
      scaleOverrides: u,
      opacityOverrides: d
    };
    e.set("out", h);
  } else if (r.type === "bond") {
    const c = {
      ...r,
      scale: n.scale,
      opacity: n.opacity
    };
    e.set("out", c);
  }
  return e;
}
function nF(n, t, e) {
  var d;
  const r = /* @__PURE__ */ new Map(), a = (d = t.get("particle")) == null ? void 0 : d[0];
  if (!a) return r;
  const o = a.source;
  let c;
  switch (n.source) {
    case "element":
      c = Array.from(o.elements).map((h) => P0(h));
      break;
    case "resname":
      c = (e == null ? void 0 : e.slice(0, o.nAtoms)) ?? [];
      break;
    case "index":
      c = Array.from({ length: o.nAtoms }, (h, p) => String(p));
      break;
    default:
      c = [];
  }
  if (a.indices !== null) {
    const h = new Array(o.nAtoms).fill("");
    for (const p of a.indices)
      h[p] = c[p];
    c = h;
  }
  const u = {
    type: "label",
    labels: c,
    particleRef: a
  };
  return r.set("label", u), r;
}
function zw(n, t, e, r, a, o) {
  return [
    t * o - e * a,
    e * r - n * o,
    n * a - t * r
  ];
}
function yc(n, t, e, r, a) {
  const o = r[n * 3], c = r[n * 3 + 1], u = r[n * 3 + 2], d = r[t * 3], h = r[t * 3 + 1], p = r[t * 3 + 2], m = r[e * 3], g = r[e * 3 + 1], _ = r[e * 3 + 2], b = d - o, E = h - c, S = p - u, y = m - o, A = g - c, w = _ - u;
  let [M, O, L] = zw(b, E, S, y, A, w);
  const N = Math.sqrt(M * M + O * O + L * L);
  if (N < 1e-12)
    return { a: n, b: t, c: e, nx: 0, ny: 0, nz: 0, d: 0 };
  M /= N, O /= N, L /= N;
  const z = -(M * o + O * c + L * u);
  return M * a[0] + O * a[1] + L * a[2] + z > 0 ? (M = -M, O = -O, L = -L, { a: n, b: e, c: t, nx: M, ny: O, nz: L, d: -z }) : { a: n, b: t, c: e, nx: M, ny: O, nz: L, d: z };
}
function iF(n, t, e, r) {
  return n.nx * t + n.ny * e + n.nz * r + n.d;
}
function rF(n, t) {
  if (t < 4) return null;
  let e = 0, r = 1, a = -1;
  for (let U = 0; U < t; U++)
    for (let B = U + 1; B < t; B++) {
      const I = n[B * 3] - n[U * 3], C = n[B * 3 + 1] - n[U * 3 + 1], X = n[B * 3 + 2] - n[U * 3 + 2], D = I * I + C * C + X * X;
      D > a && (a = D, e = U, r = B);
    }
  if (a < 1e-20) return null;
  const o = n[r * 3] - n[e * 3], c = n[r * 3 + 1] - n[e * 3 + 1], u = n[r * 3 + 2] - n[e * 3 + 2], d = Math.sqrt(o * o + c * c + u * u), h = o / d, p = c / d, m = u / d;
  let g = -1, _ = -1;
  for (let U = 0; U < t; U++) {
    if (U === e || U === r) continue;
    const B = n[U * 3] - n[e * 3], I = n[U * 3 + 1] - n[e * 3 + 1], C = n[U * 3 + 2] - n[e * 3 + 2], X = B * h + I * p + C * m, D = B - X * h, V = I - X * p, H = C - X * m, j = D * D + V * V + H * H;
    j > _ && (_ = j, g = U);
  }
  if (g < 0 || _ < 1e-20) return null;
  const b = n[r * 3] - n[e * 3], E = n[r * 3 + 1] - n[e * 3 + 1], S = n[r * 3 + 2] - n[e * 3 + 2], y = n[g * 3] - n[e * 3], A = n[g * 3 + 1] - n[e * 3 + 1], w = n[g * 3 + 2] - n[e * 3 + 2];
  let [M, O, L] = zw(b, E, S, y, A, w);
  const N = Math.sqrt(M * M + O * O + L * L);
  if (N < 1e-12) return null;
  M /= N, O /= N, L /= N;
  const z = -(M * n[e * 3] + O * n[e * 3 + 1] + L * n[e * 3 + 2]);
  let R = -1, T = -1;
  for (let U = 0; U < t; U++) {
    if (U === e || U === r || U === g) continue;
    const B = Math.abs(M * n[U * 3] + O * n[U * 3 + 1] + L * n[U * 3 + 2] + z);
    B > T && (T = B, R = U);
  }
  return R < 0 || T < 1e-10 ? null : [e, r, g, R];
}
function sF(n, t) {
  if (t < 4) return null;
  const e = rF(n, t);
  if (!e) return null;
  const [r, a, o, c] = e, u = [
    (n[r * 3] + n[a * 3] + n[o * 3] + n[c * 3]) / 4,
    (n[r * 3 + 1] + n[a * 3 + 1] + n[o * 3 + 1] + n[c * 3 + 1]) / 4,
    (n[r * 3 + 2] + n[a * 3 + 2] + n[o * 3 + 2] + n[c * 3 + 2]) / 4
  ], d = [
    yc(r, a, o, n, u),
    yc(r, a, c, n, u),
    yc(r, o, c, n, u),
    yc(a, o, c, n, u)
  ], h = /* @__PURE__ */ new Set([r, a, o, c]);
  for (let y = 0; y < t; y++) {
    if (h.has(y)) continue;
    const A = n[y * 3], w = n[y * 3 + 1], M = n[y * 3 + 2], O = [];
    for (let R = 0; R < d.length; R++)
      iF(d[R], A, w, M) > 1e-10 && O.push(R);
    if (O.length === 0) continue;
    const L = [], N = new Set(O);
    for (const R of O) {
      const T = d[R], U = [
        [T.a, T.b],
        [T.b, T.c],
        [T.c, T.a]
      ];
      for (const [B, I] of U) {
        let C = !1;
        for (let X = 0; X < d.length; X++) {
          if (X === R || N.has(X)) continue;
          const D = d[X];
          if (D.a === I && D.b === B || D.b === I && D.c === B || D.c === I && D.a === B) {
            C = !0;
            break;
          }
        }
        C && L.push([B, I]);
      }
    }
    const z = [...O].sort((R, T) => T - R);
    for (const R of z)
      d.splice(R, 1);
    for (const [R, T] of L)
      d.push(yc(R, T, y, n, u));
  }
  const p = d.length, m = new Uint32Array(p * 3), g = new Float32Array(t * 3), _ = new Float32Array(t);
  for (let y = 0; y < p; y++) {
    const A = d[y];
    m[y * 3] = A.a, m[y * 3 + 1] = A.b, m[y * 3 + 2] = A.c;
    for (const w of [A.a, A.b, A.c])
      g[w * 3] += A.nx, g[w * 3 + 1] += A.ny, g[w * 3 + 2] += A.nz, _[w]++;
  }
  for (let y = 0; y < t; y++)
    if (_[y] > 0) {
      const A = Math.sqrt(
        g[y * 3] ** 2 + g[y * 3 + 1] ** 2 + g[y * 3 + 2] ** 2
      );
      A > 1e-12 && (g[y * 3] /= A, g[y * 3 + 1] /= A, g[y * 3 + 2] /= A);
    }
  const b = /* @__PURE__ */ new Set(), E = [];
  for (let y = 0; y < p; y++) {
    const A = d[y], w = [
      [A.a, A.b],
      [A.b, A.c],
      [A.c, A.a]
    ];
    for (const [M, O] of w) {
      const L = M < O ? `${M}-${O}` : `${O}-${M}`;
      b.has(L) || (b.add(L), E.push(M, O));
    }
  }
  const S = new Float32Array(E.length * 3);
  for (let y = 0; y < E.length; y++) {
    const A = E[y];
    S[y * 3] = n[A * 3], S[y * 3 + 1] = n[A * 3 + 1], S[y * 3 + 2] = n[A * 3 + 2];
  }
  return {
    vertices: new Float32Array(n.buffer, n.byteOffset, t * 3),
    indices: m,
    normals: g,
    edges: S
  };
}
function aF(n, t, e, r, a) {
  let o = a[0] * n + a[3] * t + a[6] * e, c = a[1] * n + a[4] * t + a[7] * e, u = a[2] * n + a[5] * t + a[8] * e;
  return o -= Math.round(o), c -= Math.round(c), u -= Math.round(u), [
    r[0] * o + r[3] * c + r[6] * u,
    r[1] * o + r[4] * c + r[7] * u,
    r[2] * o + r[5] * c + r[8] * u
  ];
}
function oF(n, t) {
  var L;
  const e = /* @__PURE__ */ new Map(), r = (L = t.get("particle")) == null ? void 0 : L[0];
  if (!r) return e;
  const a = r.source, { positions: o, elements: c, nAtoms: u } = a, d = new Set(n.centerElements), h = new Set(n.ligandElements);
  if (d.size === 0 || h.size === 0) return e;
  const p = [], m = [];
  for (let N = 0; N < u; N++)
    d.has(c[N]) && p.push(N), h.has(c[N]) && m.push(N);
  if (p.length === 0 || m.length === 0) return e;
  const g = a.box;
  let _ = null;
  g && g.some((N) => N !== 0) && (_ = J0(g));
  const b = n.maxDistance * n.maxDistance, E = [], S = [], y = [], A = [], w = [];
  let M = 0;
  for (const N of p) {
    const z = o[N * 3], R = o[N * 3 + 1], T = o[N * 3 + 2], U = [];
    for (const j of m) {
      let K = o[j * 3] - z, F = o[j * 3 + 1] - R, q = o[j * 3 + 2] - T;
      _ && g && ([K, F, q] = aF(K, F, q, g, _));
      const it = K * K + F * F + q * q;
      it <= b && it > 0.01 && U.push(z + K, R + F, T + q);
    }
    const B = U.length / 3;
    if (B < 4) continue;
    const I = new Float32Array(U), C = sF(I, B);
    if (!C) continue;
    const [X, D, V] = Nc(c[N]), H = C.vertices.length / 3;
    for (let j = 0; j < H; j++)
      E.push(C.vertices[j * 3], C.vertices[j * 3 + 1], C.vertices[j * 3 + 2]), y.push(C.normals[j * 3], C.normals[j * 3 + 1], C.normals[j * 3 + 2]), A.push(X, D, V, n.opacity);
    for (let j = 0; j < C.indices.length; j++)
      S.push(C.indices[j] + M);
    for (let j = 0; j < C.edges.length; j++)
      w.push(C.edges[j]);
    M += H;
  }
  if (S.length === 0) return e;
  const O = {
    type: "mesh",
    positions: new Float32Array(E),
    indices: new Uint32Array(S),
    normals: new Float32Array(y),
    colors: new Float32Array(A),
    opacity: n.opacity,
    showEdges: n.showEdges,
    edgePositions: n.showEdges ? new Float32Array(w) : null,
    edgeColor: n.edgeColor,
    edgeWidth: n.edgeWidth
  };
  return e.set("mesh", O), e;
}
function lF(n, t) {
  const e = /* @__PURE__ */ new Map();
  if (!n.fileName || !t || t.length === 0)
    return e;
  const r = t[0].vectors.length / 3, a = {
    type: "vector",
    frames: t,
    nAtoms: r,
    scale: 1
  };
  return e.set("vector", a), e;
}
function cF(n, t) {
  const e = /* @__PURE__ */ new Map(), r = t.get("vector");
  if (!r || r.length === 0) return e;
  const o = {
    ...r[0],
    scale: n.scale
  };
  return e.set("vector", o), e;
}
function uF(n, t) {
  const e = t.get("particle") ?? [], r = t.get("bond") ?? [], a = t.get("cell") ?? [], o = t.get("trajectory") ?? [], c = t.get("label") ?? [], u = t.get("mesh") ?? [], d = t.get("vector") ?? [], h = fF(r, e), p = [...o].sort((m, g) => m.source === "file" && g.source !== "file" ? -1 : m.source !== "file" && g.source === "file" ? 1 : 0);
  return {
    particles: e,
    bonds: h,
    cells: a,
    trajectories: p,
    labels: c,
    meshes: u,
    vectors: d,
    perspective: n.perspective,
    cellAxesVisible: n.cellAxesVisible
  };
}
function fF(n, t) {
  if (n.length === 0 || t.length === 0) return n;
  let e = null;
  for (const r of t) {
    if (r.indices === null)
      return n;
    if (!e)
      e = new Set(r.indices);
    else
      for (const a of r.indices)
        e.add(a);
  }
  return e ? n.map((r) => {
    const a = [], o = [];
    for (let c = 0; c < r.nBonds; c++) {
      const u = r.bondIndices[c * 2], d = r.bondIndices[c * 2 + 1];
      e.has(u) && e.has(d) && (a.push(u, d), r.bondOrders && o.push(r.bondOrders[c]));
    }
    return a.length === r.nBonds * 2 ? r : {
      ...r,
      bondIndices: new Uint32Array(a),
      bondOrders: r.bondOrders ? new Uint8Array(o) : null,
      nBonds: a.length / 2
    };
  }) : n;
}
function dF(n, t, e = {}) {
  const r = j5(n, t), a = new Map(n.map((u) => [u.id, u])), o = /* @__PURE__ */ new Map();
  let c = { ...fd };
  for (const u of r) {
    const d = a.get(u);
    if (!d) continue;
    const h = d.data;
    if (!h.enabled) {
      const m = R1(u, t, o), g = /* @__PURE__ */ new Map(), _ = h.params.type, b = kc[_];
      for (const [E, S] of m)
        if (S.length > 0) {
          const y = b.outputs.find((A) => {
            const w = b.inputs.find((M) => M.name === E);
            return w && A.dataType === w.dataType;
          });
          y && g.set(y.name, S[0]);
        }
      o.set(u, g);
      continue;
    }
    const p = R1(u, t, o);
    switch (h.params.type) {
      case "load_structure": {
        const m = W5(
          h.params,
          e.snapshot ?? null,
          e.structureFrames ?? null,
          e.structureMeta ?? null
        );
        o.set(u, m);
        break;
      }
      case "load_vector": {
        const m = lF(
          h.params,
          e.fileVectors ?? null
        );
        o.set(u, m);
        break;
      }
      case "load_trajectory": {
        const m = Y5(
          h.params,
          p,
          e.fileFrames ?? null,
          e.fileMeta ?? null
        );
        o.set(u, m);
        break;
      }
      case "add_bond": {
        const m = Z5(
          h.params,
          p
        );
        o.set(u, m);
        break;
      }
      case "filter": {
        const m = tF(
          h.params,
          p,
          e.atomLabels ?? null
        );
        o.set(u, m);
        break;
      }
      case "modify": {
        const m = eF(
          h.params,
          p
        );
        o.set(u, m);
        break;
      }
      case "label_generator": {
        const m = nF(
          h.params,
          p,
          e.atomLabels ?? null
        );
        o.set(u, m);
        break;
      }
      case "polyhedron_generator": {
        const m = oF(
          h.params,
          p
        );
        o.set(u, m);
        break;
      }
      case "vector_overlay": {
        const m = cF(
          h.params,
          p
        );
        o.set(u, m);
        break;
      }
      case "viewport": {
        c = uF(
          h.params,
          p
        );
        break;
      }
    }
  }
  return c;
}
const hF = /* @__PURE__ */ new Set([
  "load_structure",
  "load_trajectory",
  "load_vector",
  "add_bond",
  "viewport",
  "filter",
  "modify",
  "label_generator",
  "polyhedron_generator",
  "vector_overlay"
]);
function pF(n, t) {
  return {
    version: 3,
    nodes: n.map((e) => ({
      ...e.data.params,
      id: e.id,
      position: e.position,
      enabled: e.data.enabled
    })),
    edges: t.map((e) => ({
      source: e.source,
      target: e.target,
      sourceHandle: e.sourceHandle ?? "",
      targetHandle: e.targetHandle ?? ""
    }))
  };
}
function mF(n) {
  if (n.version !== 3)
    throw new Error(`Unsupported pipeline version: ${n.version}`);
  const t = n.nodes.map((r) => {
    if (!hF.has(r.type))
      throw new Error(`Unknown node type: ${r.type}`);
    const a = r.type, o = Nw(a), { id: c, position: u, enabled: d, ...h } = r, p = { ...o, ...h, type: a };
    return {
      id: c,
      type: a,
      position: u ?? { x: 0, y: 0 },
      data: {
        params: p,
        enabled: d !== !1
      }
    };
  }), e = (n.edges ?? []).map((r, a) => ({
    id: `e-${r.source}-${r.sourceHandle}-${r.target}-${r.targetHandle}-${a}`,
    source: r.source,
    target: r.target,
    sourceHandle: r.sourceHandle || null,
    targetHandle: r.targetHandle || null
  }));
  return { nodes: t, edges: e };
}
function gF() {
  return {
    nodes: [
      // Row 0: Source
      {
        id: "loader-1",
        type: "load_structure",
        position: { x: 425, y: 0 },
        data: {
          params: {
            type: "load_structure",
            fileName: "caffeine_water.pdb",
            hasTrajectory: !1,
            hasCell: !0
          },
          enabled: !0
        }
      },
      // Row 1: Data loading & filtering
      {
        id: "traj-1",
        type: "load_trajectory",
        position: { x: -85, y: 310 },
        data: {
          params: {
            type: "load_trajectory",
            fileName: "caffeine_water_vibration.xtc"
          },
          enabled: !0
        }
      },
      {
        id: "addbond-1",
        type: "add_bond",
        position: { x: 255, y: 310 },
        data: {
          params: {
            type: "add_bond",
            bondSource: "structure"
          },
          enabled: !0
        }
      },
      {
        id: "filter-caf",
        type: "filter",
        position: { x: 595, y: 310 },
        data: {
          params: {
            type: "filter",
            query: "index < 24"
          },
          enabled: !0
        }
      },
      {
        id: "filter-sol",
        type: "filter",
        position: { x: 935, y: 310 },
        data: {
          params: {
            type: "filter",
            query: "index >= 24"
          },
          enabled: !0
        }
      },
      // Row 2: Processing (labels, modify)
      {
        id: "labels-1",
        type: "label_generator",
        position: { x: 425, y: 615 },
        data: {
          params: {
            type: "label_generator",
            source: "element"
          },
          enabled: !0
        }
      },
      {
        id: "modify-caf",
        type: "modify",
        position: { x: 680, y: 615 },
        data: {
          params: {
            type: "modify",
            scale: 1.3,
            opacity: 1
          },
          enabled: !0
        }
      },
      {
        id: "modify-sol",
        type: "modify",
        position: { x: 970, y: 615 },
        data: {
          params: {
            type: "modify",
            scale: 1,
            opacity: 0.15
          },
          enabled: !0
        }
      },
      // Row 3: Sink
      {
        id: "viewport-1",
        type: "viewport",
        position: { x: 510, y: 920 },
        data: {
          params: {
            type: "viewport",
            perspective: !1,
            cellAxesVisible: !0
          },
          enabled: !0
        }
      }
    ],
    edges: [
      { id: "e1", source: "loader-1", target: "filter-caf", sourceHandle: "particle", targetHandle: "in" },
      { id: "e2", source: "loader-1", target: "filter-sol", sourceHandle: "particle", targetHandle: "in" },
      { id: "e3", source: "filter-caf", target: "modify-caf", sourceHandle: "out", targetHandle: "in" },
      { id: "e4", source: "filter-sol", target: "modify-sol", sourceHandle: "out", targetHandle: "in" },
      { id: "e5", source: "modify-sol", target: "viewport-1", sourceHandle: "out", targetHandle: "particle" },
      { id: "e6", source: "loader-1", target: "addbond-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e7", source: "addbond-1", target: "viewport-1", sourceHandle: "bond", targetHandle: "bond" },
      { id: "e8", source: "loader-1", target: "viewport-1", sourceHandle: "cell", targetHandle: "cell" },
      { id: "e9", source: "loader-1", target: "traj-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e10", source: "traj-1", target: "viewport-1", sourceHandle: "trajectory", targetHandle: "trajectory" },
      { id: "e11", source: "modify-caf", target: "viewport-1", sourceHandle: "out", targetHandle: "particle" },
      { id: "e12", source: "filter-caf", target: "labels-1", sourceHandle: "out", targetHandle: "particle" },
      { id: "e13", source: "labels-1", target: "viewport-1", sourceHandle: "label", targetHandle: "label" }
    ]
  };
}
function vF() {
  return {
    nodes: [
      {
        id: "loader-1",
        type: "load_structure",
        position: { x: 425, y: 0 },
        data: {
          params: {
            type: "load_structure",
            fileName: "",
            hasTrajectory: !1,
            hasCell: !1
          },
          enabled: !0
        }
      },
      {
        id: "addbond-1",
        type: "add_bond",
        position: { x: 425, y: 255 },
        data: {
          params: {
            type: "add_bond",
            bondSource: "structure"
          },
          enabled: !0
        }
      },
      {
        id: "viewport-1",
        type: "viewport",
        position: { x: 425, y: 510 },
        data: {
          params: {
            type: "viewport",
            perspective: !1,
            cellAxesVisible: !0
          },
          enabled: !0
        }
      }
    ],
    edges: [
      { id: "e1", source: "loader-1", target: "addbond-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e2", source: "addbond-1", target: "viewport-1", sourceHandle: "bond", targetHandle: "bond" },
      { id: "e3", source: "loader-1", target: "viewport-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e4", source: "loader-1", target: "viewport-1", sourceHandle: "cell", targetHandle: "cell" }
    ]
  };
}
function _F() {
  return {
    nodes: [
      {
        id: "loader-1",
        type: "load_structure",
        position: { x: 425, y: 0 },
        data: {
          params: {
            type: "load_structure",
            fileName: "protein.pdb",
            hasTrajectory: !1,
            hasCell: !1
          },
          enabled: !0
        }
      },
      {
        id: "addbond-1",
        type: "add_bond",
        position: { x: 425, y: 255 },
        data: {
          params: {
            type: "add_bond",
            bondSource: "structure"
          },
          enabled: !0
        }
      },
      {
        id: "filter-1",
        type: "filter",
        position: { x: 85, y: 425 },
        data: {
          params: {
            type: "filter",
            query: 'element == "C"'
          },
          enabled: !0
        }
      },
      {
        id: "modify-1",
        type: "modify",
        position: { x: 85, y: 765 },
        data: {
          params: {
            type: "modify",
            scale: 1.5,
            opacity: 0.8
          },
          enabled: !0
        }
      },
      {
        id: "filter-2",
        type: "filter",
        position: { x: 765, y: 425 },
        data: {
          params: {
            type: "filter",
            query: 'element == "N"'
          },
          enabled: !0
        }
      },
      {
        id: "modify-2",
        type: "modify",
        position: { x: 765, y: 765 },
        data: {
          params: {
            type: "modify",
            scale: 0.5,
            opacity: 0.6
          },
          enabled: !0
        }
      },
      {
        id: "viewport-1",
        type: "viewport",
        position: { x: 425, y: 1190 },
        data: {
          params: {
            type: "viewport",
            perspective: !1,
            cellAxesVisible: !0
          },
          enabled: !0
        }
      }
    ],
    edges: [
      { id: "e1", source: "loader-1", target: "filter-1", sourceHandle: "particle", targetHandle: "in" },
      { id: "e2", source: "filter-1", target: "modify-1", sourceHandle: "out", targetHandle: "in" },
      { id: "e3", source: "loader-1", target: "filter-2", sourceHandle: "particle", targetHandle: "in" },
      { id: "e4", source: "filter-2", target: "modify-2", sourceHandle: "out", targetHandle: "in" },
      { id: "e5", source: "modify-1", target: "viewport-1", sourceHandle: "out", targetHandle: "particle" },
      { id: "e6", source: "modify-2", target: "viewport-1", sourceHandle: "out", targetHandle: "particle" },
      { id: "e7", source: "loader-1", target: "addbond-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e8", source: "addbond-1", target: "viewport-1", sourceHandle: "bond", targetHandle: "bond" }
    ]
  };
}
function yF() {
  return {
    nodes: [
      {
        id: "loader-1",
        type: "load_structure",
        position: { x: 425, y: 0 },
        data: {
          params: {
            type: "load_structure",
            fileName: "caffeine_water.pdb",
            hasTrajectory: !1,
            hasCell: !0
          },
          enabled: !0
        }
      },
      {
        id: "traj-1",
        type: "load_trajectory",
        position: { x: 85, y: 310 },
        data: {
          params: {
            type: "load_trajectory",
            fileName: "caffeine_water_vibration.xtc"
          },
          enabled: !0
        }
      },
      {
        id: "addbond-1",
        type: "add_bond",
        position: { x: 425, y: 310 },
        data: {
          params: {
            type: "add_bond",
            bondSource: "structure"
          },
          enabled: !0
        }
      },
      {
        id: "viewport-1",
        type: "viewport",
        position: { x: 425, y: 615 },
        data: {
          params: {
            type: "viewport",
            perspective: !1,
            cellAxesVisible: !0
          },
          enabled: !0
        }
      }
    ],
    edges: [
      { id: "e1", source: "loader-1", target: "addbond-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e2", source: "loader-1", target: "traj-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e3", source: "loader-1", target: "viewport-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e4", source: "loader-1", target: "viewport-1", sourceHandle: "cell", targetHandle: "cell" },
      { id: "e5", source: "addbond-1", target: "viewport-1", sourceHandle: "bond", targetHandle: "bond" },
      { id: "e6", source: "traj-1", target: "viewport-1", sourceHandle: "trajectory", targetHandle: "trajectory" }
    ]
  };
}
function xF() {
  return {
    nodes: [
      {
        id: "loader-1",
        type: "load_structure",
        position: { x: 425, y: 0 },
        data: {
          params: {
            type: "load_structure",
            fileName: "perovskite_srtio3_3x3x3.xyz",
            hasTrajectory: !1,
            hasCell: !0
          },
          enabled: !0
        }
      },
      {
        id: "addbond-1",
        type: "add_bond",
        position: { x: 170, y: 310 },
        data: {
          params: {
            type: "add_bond",
            bondSource: "distance"
          },
          enabled: !0
        }
      },
      {
        id: "polyhedron-1",
        type: "polyhedron_generator",
        position: { x: 680, y: 310 },
        data: {
          params: {
            type: "polyhedron_generator",
            centerElements: [22],
            // Ti
            ligandElements: [8],
            // O
            maxDistance: 2.5,
            opacity: 0.5,
            showEdges: !1,
            edgeColor: "#dddddd",
            edgeWidth: 3
          },
          enabled: !0
        }
      },
      {
        id: "viewport-1",
        type: "viewport",
        position: { x: 425, y: 615 },
        data: {
          params: {
            type: "viewport",
            perspective: !1,
            cellAxesVisible: !0
          },
          enabled: !0
        }
      }
    ],
    edges: [
      { id: "e1", source: "loader-1", target: "addbond-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e2", source: "loader-1", target: "polyhedron-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e3", source: "loader-1", target: "viewport-1", sourceHandle: "particle", targetHandle: "particle" },
      { id: "e4", source: "loader-1", target: "viewport-1", sourceHandle: "cell", targetHandle: "cell" },
      { id: "e5", source: "addbond-1", target: "viewport-1", sourceHandle: "bond", targetHandle: "bond" },
      { id: "e6", source: "polyhedron-1", target: "viewport-1", sourceHandle: "mesh", targetHandle: "mesh" }
    ]
  };
}
const Iw = [
  {
    id: "molecule",
    label: "Molecule",
    description: "Caffeine with bonds and trajectory",
    create: yF
  },
  {
    id: "solid",
    label: "Solid",
    description: "Perovskite with coordination polyhedra",
    create: xF
  }
];
var Xe = (n, t) => () => (t || n((t = { exports: {} }).exports, t), t.exports), er = Xe((n, t) => {
  var e = Object.defineProperty, r = (I, C, X) => C in I ? e(I, C, { enumerable: !0, configurable: !0, writable: !0, value: X }) : I[C] = X, a = (I, C) => () => (C || I((C = { exports: {} }).exports, C), C.exports), o = (I, C, X) => r(I, typeof C != "symbol" ? C + "" : C, X), c = a((I, C) => {
    var X = "\0", D = "\0", V = "", H = class {
      constructor(G) {
        o(this, "_isDirected", !0), o(this, "_isMultigraph", !1), o(this, "_isCompound", !1), o(this, "_label"), o(this, "_defaultNodeLabelFn", () => {
        }), o(this, "_defaultEdgeLabelFn", () => {
        }), o(this, "_nodes", {}), o(this, "_in", {}), o(this, "_preds", {}), o(this, "_out", {}), o(this, "_sucs", {}), o(this, "_edgeObjs", {}), o(this, "_edgeLabels", {}), o(this, "_nodeCount", 0), o(this, "_edgeCount", 0), o(this, "_parent"), o(this, "_children"), G && (this._isDirected = Object.hasOwn(G, "directed") ? G.directed : !0, this._isMultigraph = Object.hasOwn(G, "multigraph") ? G.multigraph : !1, this._isCompound = Object.hasOwn(G, "compound") ? G.compound : !1), this._isCompound && (this._parent = {}, this._children = {}, this._children[D] = {});
      }
      isDirected() {
        return this._isDirected;
      }
      isMultigraph() {
        return this._isMultigraph;
      }
      isCompound() {
        return this._isCompound;
      }
      setGraph(G) {
        return this._label = G, this;
      }
      graph() {
        return this._label;
      }
      setDefaultNodeLabel(G) {
        return this._defaultNodeLabelFn = G, typeof G != "function" && (this._defaultNodeLabelFn = () => G), this;
      }
      nodeCount() {
        return this._nodeCount;
      }
      nodes() {
        return Object.keys(this._nodes);
      }
      sources() {
        var G = this;
        return this.nodes().filter((k) => Object.keys(G._in[k]).length === 0);
      }
      sinks() {
        var G = this;
        return this.nodes().filter((k) => Object.keys(G._out[k]).length === 0);
      }
      setNodes(G, k) {
        var $ = arguments, Q = this;
        return G.forEach(function(et) {
          $.length > 1 ? Q.setNode(et, k) : Q.setNode(et);
        }), this;
      }
      setNode(G, k) {
        return Object.hasOwn(this._nodes, G) ? (arguments.length > 1 && (this._nodes[G] = k), this) : (this._nodes[G] = arguments.length > 1 ? k : this._defaultNodeLabelFn(G), this._isCompound && (this._parent[G] = D, this._children[G] = {}, this._children[D][G] = !0), this._in[G] = {}, this._preds[G] = {}, this._out[G] = {}, this._sucs[G] = {}, ++this._nodeCount, this);
      }
      node(G) {
        return this._nodes[G];
      }
      hasNode(G) {
        return Object.hasOwn(this._nodes, G);
      }
      removeNode(G) {
        var k = this;
        if (Object.hasOwn(this._nodes, G)) {
          var $ = (Q) => k.removeEdge(k._edgeObjs[Q]);
          delete this._nodes[G], this._isCompound && (this._removeFromParentsChildList(G), delete this._parent[G], this.children(G).forEach(function(Q) {
            k.setParent(Q);
          }), delete this._children[G]), Object.keys(this._in[G]).forEach($), delete this._in[G], delete this._preds[G], Object.keys(this._out[G]).forEach($), delete this._out[G], delete this._sucs[G], --this._nodeCount;
        }
        return this;
      }
      setParent(G, k) {
        if (!this._isCompound) throw new Error("Cannot set parent in a non-compound graph");
        if (k === void 0) k = D;
        else {
          k += "";
          for (var $ = k; $ !== void 0; $ = this.parent($)) if ($ === G) throw new Error("Setting " + k + " as parent of " + G + " would create a cycle");
          this.setNode(k);
        }
        return this.setNode(G), this._removeFromParentsChildList(G), this._parent[G] = k, this._children[k][G] = !0, this;
      }
      _removeFromParentsChildList(G) {
        delete this._children[this._parent[G]][G];
      }
      parent(G) {
        if (this._isCompound) {
          var k = this._parent[G];
          if (k !== D) return k;
        }
      }
      children(G = D) {
        if (this._isCompound) {
          var k = this._children[G];
          if (k) return Object.keys(k);
        } else {
          if (G === D) return this.nodes();
          if (this.hasNode(G)) return [];
        }
      }
      predecessors(G) {
        var k = this._preds[G];
        if (k) return Object.keys(k);
      }
      successors(G) {
        var k = this._sucs[G];
        if (k) return Object.keys(k);
      }
      neighbors(G) {
        var k = this.predecessors(G);
        if (k) {
          let Q = new Set(k);
          for (var $ of this.successors(G)) Q.add($);
          return Array.from(Q.values());
        }
      }
      isLeaf(G) {
        var k;
        return this.isDirected() ? k = this.successors(G) : k = this.neighbors(G), k.length === 0;
      }
      filterNodes(G) {
        var k = new this.constructor({ directed: this._isDirected, multigraph: this._isMultigraph, compound: this._isCompound });
        k.setGraph(this.graph());
        var $ = this;
        Object.entries(this._nodes).forEach(function([st, _t]) {
          G(st) && k.setNode(st, _t);
        }), Object.values(this._edgeObjs).forEach(function(st) {
          k.hasNode(st.v) && k.hasNode(st.w) && k.setEdge(st, $.edge(st));
        });
        var Q = {};
        function et(st) {
          var _t = $.parent(st);
          return _t === void 0 || k.hasNode(_t) ? (Q[st] = _t, _t) : _t in Q ? Q[_t] : et(_t);
        }
        return this._isCompound && k.nodes().forEach((st) => k.setParent(st, et(st))), k;
      }
      setDefaultEdgeLabel(G) {
        return this._defaultEdgeLabelFn = G, typeof G != "function" && (this._defaultEdgeLabelFn = () => G), this;
      }
      edgeCount() {
        return this._edgeCount;
      }
      edges() {
        return Object.values(this._edgeObjs);
      }
      setPath(G, k) {
        var $ = this, Q = arguments;
        return G.reduce(function(et, st) {
          return Q.length > 1 ? $.setEdge(et, st, k) : $.setEdge(et, st), st;
        }), this;
      }
      setEdge() {
        var G, k, $, Q, et = !1, st = arguments[0];
        typeof st == "object" && st !== null && "v" in st ? (G = st.v, k = st.w, $ = st.name, arguments.length === 2 && (Q = arguments[1], et = !0)) : (G = st, k = arguments[1], $ = arguments[3], arguments.length > 2 && (Q = arguments[2], et = !0)), G = "" + G, k = "" + k, $ !== void 0 && ($ = "" + $);
        var _t = F(this._isDirected, G, k, $);
        if (Object.hasOwn(this._edgeLabels, _t)) return et && (this._edgeLabels[_t] = Q), this;
        if ($ !== void 0 && !this._isMultigraph) throw new Error("Cannot set a named edge when isMultigraph = false");
        this.setNode(G), this.setNode(k), this._edgeLabels[_t] = et ? Q : this._defaultEdgeLabelFn(G, k, $);
        var Mt = q(this._isDirected, G, k, $);
        return G = Mt.v, k = Mt.w, Object.freeze(Mt), this._edgeObjs[_t] = Mt, j(this._preds[k], G), j(this._sucs[G], k), this._in[k][_t] = Mt, this._out[G][_t] = Mt, this._edgeCount++, this;
      }
      edge(G, k, $) {
        var Q = arguments.length === 1 ? it(this._isDirected, arguments[0]) : F(this._isDirected, G, k, $);
        return this._edgeLabels[Q];
      }
      edgeAsObj() {
        let G = this.edge(...arguments);
        return typeof G != "object" ? { label: G } : G;
      }
      hasEdge(G, k, $) {
        var Q = arguments.length === 1 ? it(this._isDirected, arguments[0]) : F(this._isDirected, G, k, $);
        return Object.hasOwn(this._edgeLabels, Q);
      }
      removeEdge(G, k, $) {
        var Q = arguments.length === 1 ? it(this._isDirected, arguments[0]) : F(this._isDirected, G, k, $), et = this._edgeObjs[Q];
        return et && (G = et.v, k = et.w, delete this._edgeLabels[Q], delete this._edgeObjs[Q], K(this._preds[k], G), K(this._sucs[G], k), delete this._in[k][Q], delete this._out[G][Q], this._edgeCount--), this;
      }
      inEdges(G, k) {
        return this.isDirected() ? this.filterEdges(this._in[G], G, k) : this.nodeEdges(G, k);
      }
      outEdges(G, k) {
        return this.isDirected() ? this.filterEdges(this._out[G], G, k) : this.nodeEdges(G, k);
      }
      nodeEdges(G, k) {
        if (G in this._nodes) return this.filterEdges({ ...this._in[G], ...this._out[G] }, G, k);
      }
      filterEdges(G, k, $) {
        if (G) {
          var Q = Object.values(G);
          return $ ? Q.filter(function(et) {
            return et.v === k && et.w === $ || et.v === $ && et.w === k;
          }) : Q;
        }
      }
    };
    function j(G, k) {
      G[k] ? G[k]++ : G[k] = 1;
    }
    function K(G, k) {
      --G[k] || delete G[k];
    }
    function F(G, k, $, Q) {
      var et = "" + k, st = "" + $;
      if (!G && et > st) {
        var _t = et;
        et = st, st = _t;
      }
      return et + V + st + V + (Q === void 0 ? X : Q);
    }
    function q(G, k, $, Q) {
      var et = "" + k, st = "" + $;
      if (!G && et > st) {
        var _t = et;
        et = st, st = _t;
      }
      var Mt = { v: et, w: st };
      return Q && (Mt.name = Q), Mt;
    }
    function it(G, k) {
      return F(G, k.v, k.w, k.name);
    }
    C.exports = H;
  }), u = a((I, C) => {
    C.exports = "3.0.2";
  }), d = a((I, C) => {
    C.exports = { Graph: c(), version: u() };
  }), h = a((I, C) => {
    var X = c();
    C.exports = { write: D, read: j };
    function D(K) {
      var F = { options: { directed: K.isDirected(), multigraph: K.isMultigraph(), compound: K.isCompound() }, nodes: V(K), edges: H(K) };
      return K.graph() !== void 0 && (F.value = structuredClone(K.graph())), F;
    }
    function V(K) {
      return K.nodes().map(function(F) {
        var q = K.node(F), it = K.parent(F), G = { v: F };
        return q !== void 0 && (G.value = q), it !== void 0 && (G.parent = it), G;
      });
    }
    function H(K) {
      return K.edges().map(function(F) {
        var q = K.edge(F), it = { v: F.v, w: F.w };
        return F.name !== void 0 && (it.name = F.name), q !== void 0 && (it.value = q), it;
      });
    }
    function j(K) {
      var F = new X(K.options).setGraph(K.value);
      return K.nodes.forEach(function(q) {
        F.setNode(q.v, q.value), q.parent && F.setParent(q.v, q.parent);
      }), K.edges.forEach(function(q) {
        F.setEdge({ v: q.v, w: q.w, name: q.name }, q.value);
      }), F;
    }
  }), p = a((I, C) => {
    C.exports = D;
    var X = () => 1;
    function D(H, j, K, F) {
      return V(H, String(j), K || X, F || function(q) {
        return H.outEdges(q);
      });
    }
    function V(H, j, K, F) {
      var q = {}, it = !0, G = 0, k = H.nodes(), $ = function(_t) {
        var Mt = K(_t);
        q[_t.v].distance + Mt < q[_t.w].distance && (q[_t.w] = { distance: q[_t.v].distance + Mt, predecessor: _t.v }, it = !0);
      }, Q = function() {
        k.forEach(function(_t) {
          F(_t).forEach(function(Mt) {
            var Rt = Mt.v === _t ? Mt.v : Mt.w, Ot = Rt === Mt.v ? Mt.w : Mt.v;
            $({ v: Rt, w: Ot });
          });
        });
      };
      k.forEach(function(_t) {
        var Mt = _t === j ? 0 : Number.POSITIVE_INFINITY;
        q[_t] = { distance: Mt };
      });
      for (var et = k.length, st = 1; st < et && (it = !1, G++, Q(), !!it); st++) ;
      if (G === et - 1 && (it = !1, Q(), it)) throw new Error("The graph contains a negative weight cycle");
      return q;
    }
  }), m = a((I, C) => {
    C.exports = X;
    function X(D) {
      var V = {}, H = [], j;
      function K(F) {
        Object.hasOwn(V, F) || (V[F] = !0, j.push(F), D.successors(F).forEach(K), D.predecessors(F).forEach(K));
      }
      return D.nodes().forEach(function(F) {
        j = [], K(F), j.length && H.push(j);
      }), H;
    }
  }), g = a((I, C) => {
    var X = class {
      constructor() {
        o(this, "_arr", []), o(this, "_keyIndices", {});
      }
      size() {
        return this._arr.length;
      }
      keys() {
        return this._arr.map(function(D) {
          return D.key;
        });
      }
      has(D) {
        return Object.hasOwn(this._keyIndices, D);
      }
      priority(D) {
        var V = this._keyIndices[D];
        if (V !== void 0) return this._arr[V].priority;
      }
      min() {
        if (this.size() === 0) throw new Error("Queue underflow");
        return this._arr[0].key;
      }
      add(D, V) {
        var H = this._keyIndices;
        if (D = String(D), !Object.hasOwn(H, D)) {
          var j = this._arr, K = j.length;
          return H[D] = K, j.push({ key: D, priority: V }), this._decrease(K), !0;
        }
        return !1;
      }
      removeMin() {
        this._swap(0, this._arr.length - 1);
        var D = this._arr.pop();
        return delete this._keyIndices[D.key], this._heapify(0), D.key;
      }
      decrease(D, V) {
        var H = this._keyIndices[D];
        if (V > this._arr[H].priority) throw new Error("New priority is greater than current priority. Key: " + D + " Old: " + this._arr[H].priority + " New: " + V);
        this._arr[H].priority = V, this._decrease(H);
      }
      _heapify(D) {
        var V = this._arr, H = 2 * D, j = H + 1, K = D;
        H < V.length && (K = V[H].priority < V[K].priority ? H : K, j < V.length && (K = V[j].priority < V[K].priority ? j : K), K !== D && (this._swap(D, K), this._heapify(K)));
      }
      _decrease(D) {
        for (var V = this._arr, H = V[D].priority, j; D !== 0 && (j = D >> 1, !(V[j].priority < H)); ) this._swap(D, j), D = j;
      }
      _swap(D, V) {
        var H = this._arr, j = this._keyIndices, K = H[D], F = H[V];
        H[D] = F, H[V] = K, j[F.key] = D, j[K.key] = V;
      }
    };
    C.exports = X;
  }), _ = a((I, C) => {
    var X = g();
    C.exports = V;
    var D = () => 1;
    function V(j, K, F, q) {
      var it = function(G) {
        return j.outEdges(G);
      };
      return H(j, String(K), F || D, q || it);
    }
    function H(j, K, F, q) {
      var it = {}, G = new X(), k, $, Q = function(et) {
        var st = et.v !== k ? et.v : et.w, _t = it[st], Mt = F(et), Rt = $.distance + Mt;
        if (Mt < 0) throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + et + " Weight: " + Mt);
        Rt < _t.distance && (_t.distance = Rt, _t.predecessor = k, G.decrease(st, Rt));
      };
      for (j.nodes().forEach(function(et) {
        var st = et === K ? 0 : Number.POSITIVE_INFINITY;
        it[et] = { distance: st }, G.add(et, st);
      }); G.size() > 0 && (k = G.removeMin(), $ = it[k], $.distance !== Number.POSITIVE_INFINITY); ) q(k).forEach(Q);
      return it;
    }
  }), b = a((I, C) => {
    var X = _();
    C.exports = D;
    function D(V, H, j) {
      return V.nodes().reduce(function(K, F) {
        return K[F] = X(V, F, H, j), K;
      }, {});
    }
  }), E = a((I, C) => {
    C.exports = X;
    function X(V, H, j) {
      if (V[H].predecessor !== void 0) throw new Error("Invalid source vertex");
      if (V[j].predecessor === void 0 && j !== H) throw new Error("Invalid destination vertex");
      return { weight: V[j].distance, path: D(V, H, j) };
    }
    function D(V, H, j) {
      for (var K = [], F = j; F !== H; ) K.push(F), F = V[F].predecessor;
      return K.push(H), K.reverse();
    }
  }), S = a((I, C) => {
    C.exports = X;
    function X(D) {
      var V = 0, H = [], j = {}, K = [];
      function F(q) {
        var it = j[q] = { onStack: !0, lowlink: V, index: V++ };
        if (H.push(q), D.successors(q).forEach(function($) {
          Object.hasOwn(j, $) ? j[$].onStack && (it.lowlink = Math.min(it.lowlink, j[$].index)) : (F($), it.lowlink = Math.min(it.lowlink, j[$].lowlink));
        }), it.lowlink === it.index) {
          var G = [], k;
          do
            k = H.pop(), j[k].onStack = !1, G.push(k);
          while (q !== k);
          K.push(G);
        }
      }
      return D.nodes().forEach(function(q) {
        Object.hasOwn(j, q) || F(q);
      }), K;
    }
  }), y = a((I, C) => {
    var X = S();
    C.exports = D;
    function D(V) {
      return X(V).filter(function(H) {
        return H.length > 1 || H.length === 1 && V.hasEdge(H[0], H[0]);
      });
    }
  }), A = a((I, C) => {
    C.exports = D;
    var X = () => 1;
    function D(H, j, K) {
      return V(H, j || X, K || function(F) {
        return H.outEdges(F);
      });
    }
    function V(H, j, K) {
      var F = {}, q = H.nodes();
      return q.forEach(function(it) {
        F[it] = {}, F[it][it] = { distance: 0 }, q.forEach(function(G) {
          it !== G && (F[it][G] = { distance: Number.POSITIVE_INFINITY });
        }), K(it).forEach(function(G) {
          var k = G.v === it ? G.w : G.v, $ = j(G);
          F[it][k] = { distance: $, predecessor: it };
        });
      }), q.forEach(function(it) {
        var G = F[it];
        q.forEach(function(k) {
          var $ = F[k];
          q.forEach(function(Q) {
            var et = $[it], st = G[Q], _t = $[Q], Mt = et.distance + st.distance;
            Mt < _t.distance && (_t.distance = Mt, _t.predecessor = st.predecessor);
          });
        });
      }), F;
    }
  }), w = a((I, C) => {
    function X(V) {
      var H = {}, j = {}, K = [];
      function F(q) {
        if (Object.hasOwn(j, q)) throw new D();
        Object.hasOwn(H, q) || (j[q] = !0, H[q] = !0, V.predecessors(q).forEach(F), delete j[q], K.push(q));
      }
      if (V.sinks().forEach(F), Object.keys(H).length !== V.nodeCount()) throw new D();
      return K;
    }
    var D = class extends Error {
      constructor() {
        super(...arguments);
      }
    };
    C.exports = X, X.CycleException = D;
  }), M = a((I, C) => {
    var X = w();
    C.exports = D;
    function D(V) {
      try {
        X(V);
      } catch (H) {
        if (H instanceof X.CycleException) return !1;
        throw H;
      }
      return !0;
    }
  }), O = a((I, C) => {
    C.exports = X;
    function X(V, H, j, K, F) {
      Array.isArray(H) || (H = [H]);
      var q = (V.isDirected() ? V.successors : V.neighbors).bind(V), it = {};
      return H.forEach(function(G) {
        if (!V.hasNode(G)) throw new Error("Graph does not have node: " + G);
        F = D(V, G, j === "post", it, q, K, F);
      }), F;
    }
    function D(V, H, j, K, F, q, it) {
      return Object.hasOwn(K, H) || (K[H] = !0, j || (it = q(it, H)), F(H).forEach(function(G) {
        it = D(V, G, j, K, F, q, it);
      }), j && (it = q(it, H))), it;
    }
  }), L = a((I, C) => {
    var X = O();
    C.exports = D;
    function D(V, H, j) {
      return X(V, H, j, function(K, F) {
        return K.push(F), K;
      }, []);
    }
  }), N = a((I, C) => {
    var X = L();
    C.exports = D;
    function D(V, H) {
      return X(V, H, "post");
    }
  }), z = a((I, C) => {
    var X = L();
    C.exports = D;
    function D(V, H) {
      return X(V, H, "pre");
    }
  }), R = a((I, C) => {
    var X = c(), D = g();
    C.exports = V;
    function V(H, j) {
      var K = new X(), F = {}, q = new D(), it;
      function G($) {
        var Q = $.v === it ? $.w : $.v, et = q.priority(Q);
        if (et !== void 0) {
          var st = j($);
          st < et && (F[Q] = it, q.decrease(Q, st));
        }
      }
      if (H.nodeCount() === 0) return K;
      H.nodes().forEach(function($) {
        q.add($, Number.POSITIVE_INFINITY), K.setNode($);
      }), q.decrease(H.nodes()[0], 0);
      for (var k = !1; q.size() > 0; ) {
        if (it = q.removeMin(), Object.hasOwn(F, it)) K.setEdge(it, F[it]);
        else {
          if (k) throw new Error("Input graph is not connected: " + H);
          k = !0;
        }
        H.nodeEdges(it).forEach(G);
      }
      return K;
    }
  }), T = a((I, C) => {
    var X = _(), D = p();
    C.exports = V;
    function V(j, K, F, q) {
      return H(j, K, F, q || function(it) {
        return j.outEdges(it);
      });
    }
    function H(j, K, F, q) {
      if (F === void 0) return X(j, K, F, q);
      for (var it = !1, G = j.nodes(), k = 0; k < G.length; k++) {
        for (var $ = q(G[k]), Q = 0; Q < $.length; Q++) {
          var et = $[Q], st = et.v === G[k] ? et.v : et.w, _t = st === et.v ? et.w : et.v;
          F({ v: st, w: _t }) < 0 && (it = !0);
        }
        if (it) return D(j, K, F, q);
      }
      return X(j, K, F, q);
    }
  }), U = a((I, C) => {
    C.exports = { bellmanFord: p(), components: m(), dijkstra: _(), dijkstraAll: b(), extractPath: E(), findCycles: y(), floydWarshall: A(), isAcyclic: M(), postorder: N(), preorder: z(), prim: R(), shortestPaths: T(), reduce: O(), tarjan: S(), topsort: w() };
  }), B = d();
  t.exports = { Graph: B.Graph, json: h(), alg: U(), version: B.version };
}), SF = Xe((n, t) => {
  var e = class {
    constructor() {
      let o = {};
      o._next = o._prev = o, this._sentinel = o;
    }
    dequeue() {
      let o = this._sentinel, c = o._prev;
      if (c !== o) return r(c), c;
    }
    enqueue(o) {
      let c = this._sentinel;
      o._prev && o._next && r(o), o._next = c._next, c._next._prev = o, c._next = o, o._prev = c;
    }
    toString() {
      let o = [], c = this._sentinel, u = c._prev;
      for (; u !== c; ) o.push(JSON.stringify(u, a)), u = u._prev;
      return "[" + o.join(", ") + "]";
    }
  };
  function r(o) {
    o._prev._next = o._next, o._next._prev = o._prev, delete o._next, delete o._prev;
  }
  function a(o, c) {
    if (o !== "_next" && o !== "_prev") return c;
  }
  t.exports = e;
}), bF = Xe((n, t) => {
  var e = er().Graph, r = SF();
  t.exports = o;
  var a = () => 1;
  function o(m, g) {
    if (m.nodeCount() <= 1) return [];
    let _ = d(m, g || a);
    return c(_.graph, _.buckets, _.zeroIdx).flatMap((b) => m.outEdges(b.v, b.w));
  }
  function c(m, g, _) {
    let b = [], E = g[g.length - 1], S = g[0], y;
    for (; m.nodeCount(); ) {
      for (; y = S.dequeue(); ) u(m, g, _, y);
      for (; y = E.dequeue(); ) u(m, g, _, y);
      if (m.nodeCount()) {
        for (let A = g.length - 2; A > 0; --A) if (y = g[A].dequeue(), y) {
          b = b.concat(u(m, g, _, y, !0));
          break;
        }
      }
    }
    return b;
  }
  function u(m, g, _, b, E) {
    let S = E ? [] : void 0;
    return m.inEdges(b.v).forEach((y) => {
      let A = m.edge(y), w = m.node(y.v);
      E && S.push({ v: y.v, w: y.w }), w.out -= A, h(g, _, w);
    }), m.outEdges(b.v).forEach((y) => {
      let A = m.edge(y), w = y.w, M = m.node(w);
      M.in -= A, h(g, _, M);
    }), m.removeNode(b.v), S;
  }
  function d(m, g) {
    let _ = new e(), b = 0, E = 0;
    m.nodes().forEach((A) => {
      _.setNode(A, { v: A, in: 0, out: 0 });
    }), m.edges().forEach((A) => {
      let w = _.edge(A.v, A.w) || 0, M = g(A), O = w + M;
      _.setEdge(A.v, A.w, O), E = Math.max(E, _.node(A.v).out += M), b = Math.max(b, _.node(A.w).in += M);
    });
    let S = p(E + b + 3).map(() => new r()), y = b + 1;
    return _.nodes().forEach((A) => {
      h(S, y, _.node(A));
    }), { graph: _, buckets: S, zeroIdx: y };
  }
  function h(m, g, _) {
    _.out ? _.in ? m[_.out - _.in + g].enqueue(_) : m[m.length - 1].enqueue(_) : m[0].enqueue(_);
  }
  function p(m) {
    let g = [];
    for (let _ = 0; _ < m; _++) g.push(_);
    return g;
  }
}), Mn = Xe((n, t) => {
  var e = er().Graph;
  t.exports = { addBorderNode: g, addDummyNode: r, applyWithChunking: E, asNonCompoundGraph: o, buildLayerMatrix: h, intersectRect: d, mapValues: z, maxRank: S, normalizeRanks: p, notime: w, partition: y, pick: N, predecessorWeights: u, range: L, removeEmptyRanks: m, simplify: a, successorWeights: c, time: A, uniqueId: O, zipObject: R };
  function r(T, U, B, I) {
    for (var C = I; T.hasNode(C); ) C = O(I);
    return B.dummy = U, T.setNode(C, B), C;
  }
  function a(T) {
    let U = new e().setGraph(T.graph());
    return T.nodes().forEach((B) => U.setNode(B, T.node(B))), T.edges().forEach((B) => {
      let I = U.edge(B.v, B.w) || { weight: 0, minlen: 1 }, C = T.edge(B);
      U.setEdge(B.v, B.w, { weight: I.weight + C.weight, minlen: Math.max(I.minlen, C.minlen) });
    }), U;
  }
  function o(T) {
    let U = new e({ multigraph: T.isMultigraph() }).setGraph(T.graph());
    return T.nodes().forEach((B) => {
      T.children(B).length || U.setNode(B, T.node(B));
    }), T.edges().forEach((B) => {
      U.setEdge(B, T.edge(B));
    }), U;
  }
  function c(T) {
    let U = T.nodes().map((B) => {
      let I = {};
      return T.outEdges(B).forEach((C) => {
        I[C.w] = (I[C.w] || 0) + T.edge(C).weight;
      }), I;
    });
    return R(T.nodes(), U);
  }
  function u(T) {
    let U = T.nodes().map((B) => {
      let I = {};
      return T.inEdges(B).forEach((C) => {
        I[C.v] = (I[C.v] || 0) + T.edge(C).weight;
      }), I;
    });
    return R(T.nodes(), U);
  }
  function d(T, U) {
    let B = T.x, I = T.y, C = U.x - B, X = U.y - I, D = T.width / 2, V = T.height / 2;
    if (!C && !X) throw new Error("Not possible to find intersection inside of the rectangle");
    let H, j;
    return Math.abs(X) * D > Math.abs(C) * V ? (X < 0 && (V = -V), H = V * C / X, j = V) : (C < 0 && (D = -D), H = D, j = D * X / C), { x: B + H, y: I + j };
  }
  function h(T) {
    let U = L(S(T) + 1).map(() => []);
    return T.nodes().forEach((B) => {
      let I = T.node(B), C = I.rank;
      C !== void 0 && (U[C][I.order] = B);
    }), U;
  }
  function p(T) {
    let U = T.nodes().map((I) => {
      let C = T.node(I).rank;
      return C === void 0 ? Number.MAX_VALUE : C;
    }), B = E(Math.min, U);
    T.nodes().forEach((I) => {
      let C = T.node(I);
      Object.hasOwn(C, "rank") && (C.rank -= B);
    });
  }
  function m(T) {
    let U = T.nodes().map((D) => T.node(D).rank).filter((D) => D !== void 0), B = E(Math.min, U), I = [];
    T.nodes().forEach((D) => {
      let V = T.node(D).rank - B;
      I[V] || (I[V] = []), I[V].push(D);
    });
    let C = 0, X = T.graph().nodeRankFactor;
    Array.from(I).forEach((D, V) => {
      D === void 0 && V % X !== 0 ? --C : D !== void 0 && C && D.forEach((H) => T.node(H).rank += C);
    });
  }
  function g(T, U, B, I) {
    let C = { width: 0, height: 0 };
    return arguments.length >= 4 && (C.rank = B, C.order = I), r(T, "border", C, U);
  }
  function _(T, U = b) {
    let B = [];
    for (let I = 0; I < T.length; I += U) {
      let C = T.slice(I, I + U);
      B.push(C);
    }
    return B;
  }
  var b = 65535;
  function E(T, U) {
    if (U.length > b) {
      let B = _(U);
      return T.apply(null, B.map((I) => T.apply(null, I)));
    } else return T.apply(null, U);
  }
  function S(T) {
    let U = T.nodes().map((B) => {
      let I = T.node(B).rank;
      return I === void 0 ? Number.MIN_VALUE : I;
    });
    return E(Math.max, U);
  }
  function y(T, U) {
    let B = { lhs: [], rhs: [] };
    return T.forEach((I) => {
      U(I) ? B.lhs.push(I) : B.rhs.push(I);
    }), B;
  }
  function A(T, U) {
    let B = Date.now();
    try {
      return U();
    } finally {
      console.log(T + " time: " + (Date.now() - B) + "ms");
    }
  }
  function w(T, U) {
    return U();
  }
  var M = 0;
  function O(T) {
    var U = ++M;
    return T + ("" + U);
  }
  function L(T, U, B = 1) {
    U == null && (U = T, T = 0);
    let I = (X) => X < U;
    B < 0 && (I = (X) => U < X);
    let C = [];
    for (let X = T; I(X); X += B) C.push(X);
    return C;
  }
  function N(T, U) {
    let B = {};
    for (let I of U) T[I] !== void 0 && (B[I] = T[I]);
    return B;
  }
  function z(T, U) {
    let B = U;
    return typeof U == "string" && (B = (I) => I[U]), Object.entries(T).reduce((I, [C, X]) => (I[C] = B(X, C), I), {});
  }
  function R(T, U) {
    return T.reduce((B, I, C) => (B[I] = U[C], B), {});
  }
}), MF = Xe((n, t) => {
  var e = bF(), r = Mn().uniqueId;
  t.exports = { run: a, undo: c };
  function a(u) {
    (u.graph().acyclicer === "greedy" ? e(u, d(u)) : o(u)).forEach((h) => {
      let p = u.edge(h);
      u.removeEdge(h), p.forwardName = h.name, p.reversed = !0, u.setEdge(h.w, h.v, p, r("rev"));
    });
    function d(h) {
      return (p) => h.edge(p).weight;
    }
  }
  function o(u) {
    let d = [], h = {}, p = {};
    function m(g) {
      Object.hasOwn(p, g) || (p[g] = !0, h[g] = !0, u.outEdges(g).forEach((_) => {
        Object.hasOwn(h, _.w) ? d.push(_) : m(_.w);
      }), delete h[g]);
    }
    return u.nodes().forEach(m), d;
  }
  function c(u) {
    u.edges().forEach((d) => {
      let h = u.edge(d);
      if (h.reversed) {
        u.removeEdge(d);
        let p = h.forwardName;
        delete h.reversed, delete h.forwardName, u.setEdge(d.w, d.v, h, p);
      }
    });
  }
}), EF = Xe((n, t) => {
  var e = Mn();
  t.exports = { run: r, undo: o };
  function r(c) {
    c.graph().dummyChains = [], c.edges().forEach((u) => a(c, u));
  }
  function a(c, u) {
    let d = u.v, h = c.node(d).rank, p = u.w, m = c.node(p).rank, g = u.name, _ = c.edge(u), b = _.labelRank;
    if (m === h + 1) return;
    c.removeEdge(u);
    let E, S, y;
    for (y = 0, ++h; h < m; ++y, ++h) _.points = [], S = { width: 0, height: 0, edgeLabel: _, edgeObj: u, rank: h }, E = e.addDummyNode(c, "edge", S, "_d"), h === b && (S.width = _.width, S.height = _.height, S.dummy = "edge-label", S.labelpos = _.labelpos), c.setEdge(d, E, { weight: _.weight }, g), y === 0 && c.graph().dummyChains.push(E), d = E;
    c.setEdge(d, p, { weight: _.weight }, g);
  }
  function o(c) {
    c.graph().dummyChains.forEach((u) => {
      let d = c.node(u), h = d.edgeLabel, p;
      for (c.setEdge(d.edgeObj, h); d.dummy; ) p = c.successors(u)[0], c.removeNode(u), h.points.push({ x: d.x, y: d.y }), d.dummy === "edge-label" && (h.x = d.x, h.y = d.y, h.width = d.width, h.height = d.height), u = p, d = c.node(u);
    });
  }
}), Rd = Xe((n, t) => {
  var { applyWithChunking: e } = Mn();
  t.exports = { longestPath: r, slack: a };
  function r(o) {
    var c = {};
    function u(d) {
      var h = o.node(d);
      if (Object.hasOwn(c, d)) return h.rank;
      c[d] = !0;
      let p = o.outEdges(d).map((g) => g == null ? Number.POSITIVE_INFINITY : u(g.w) - o.edge(g).minlen);
      var m = e(Math.min, p);
      return m === Number.POSITIVE_INFINITY && (m = 0), h.rank = m;
    }
    o.sources().forEach(u);
  }
  function a(o, c) {
    return o.node(c.w).rank - o.node(c.v).rank - o.edge(c).minlen;
  }
}), Bw = Xe((n, t) => {
  var e = er().Graph, r = Rd().slack;
  t.exports = a;
  function a(d) {
    var h = new e({ directed: !1 }), p = d.nodes()[0], m = d.nodeCount();
    h.setNode(p, {});
    for (var g, _; o(h, d) < m; ) g = c(h, d), _ = h.hasNode(g.v) ? r(d, g) : -r(d, g), u(h, d, _);
    return h;
  }
  function o(d, h) {
    function p(m) {
      h.nodeEdges(m).forEach((g) => {
        var _ = g.v, b = m === _ ? g.w : _;
        !d.hasNode(b) && !r(h, g) && (d.setNode(b, {}), d.setEdge(m, b, {}), p(b));
      });
    }
    return d.nodes().forEach(p), d.nodeCount();
  }
  function c(d, h) {
    return h.edges().reduce((p, m) => {
      let g = Number.POSITIVE_INFINITY;
      return d.hasNode(m.v) !== d.hasNode(m.w) && (g = r(h, m)), g < p[0] ? [g, m] : p;
    }, [Number.POSITIVE_INFINITY, null])[1];
  }
  function u(d, h, p) {
    d.nodes().forEach((m) => h.node(m).rank += p);
  }
}), wF = Xe((n, t) => {
  var e = Bw(), r = Rd().slack, a = Rd().longestPath, o = er().alg.preorder, c = er().alg.postorder, u = Mn().simplify;
  t.exports = d, d.initLowLimValues = g, d.initCutValues = h, d.calcCutValue = m, d.leaveEdge = b, d.enterEdge = E, d.exchangeEdges = S;
  function d(M) {
    M = u(M), a(M);
    var O = e(M);
    g(O), h(O, M);
    for (var L, N; L = b(O); ) N = E(O, M, L), S(O, M, L, N);
  }
  function h(M, O) {
    var L = c(M, M.nodes());
    L = L.slice(0, L.length - 1), L.forEach((N) => p(M, O, N));
  }
  function p(M, O, L) {
    var N = M.node(L), z = N.parent;
    M.edge(L, z).cutvalue = m(M, O, L);
  }
  function m(M, O, L) {
    var N = M.node(L), z = N.parent, R = !0, T = O.edge(L, z), U = 0;
    return T || (R = !1, T = O.edge(z, L)), U = T.weight, O.nodeEdges(L).forEach((B) => {
      var I = B.v === L, C = I ? B.w : B.v;
      if (C !== z) {
        var X = I === R, D = O.edge(B).weight;
        if (U += X ? D : -D, A(M, L, C)) {
          var V = M.edge(L, C).cutvalue;
          U += X ? -V : V;
        }
      }
    }), U;
  }
  function g(M, O) {
    arguments.length < 2 && (O = M.nodes()[0]), _(M, {}, 1, O);
  }
  function _(M, O, L, N, z) {
    var R = L, T = M.node(N);
    return O[N] = !0, M.neighbors(N).forEach((U) => {
      Object.hasOwn(O, U) || (L = _(M, O, L, U, N));
    }), T.low = R, T.lim = L++, z ? T.parent = z : delete T.parent, L;
  }
  function b(M) {
    return M.edges().find((O) => M.edge(O).cutvalue < 0);
  }
  function E(M, O, L) {
    var N = L.v, z = L.w;
    O.hasEdge(N, z) || (N = L.w, z = L.v);
    var R = M.node(N), T = M.node(z), U = R, B = !1;
    R.lim > T.lim && (U = T, B = !0);
    var I = O.edges().filter((C) => B === w(M, M.node(C.v), U) && B !== w(M, M.node(C.w), U));
    return I.reduce((C, X) => r(O, X) < r(O, C) ? X : C);
  }
  function S(M, O, L, N) {
    var z = L.v, R = L.w;
    M.removeEdge(z, R), M.setEdge(N.v, N.w, {}), g(M), h(M, O), y(M, O);
  }
  function y(M, O) {
    var L = M.nodes().find((z) => !O.node(z).parent), N = o(M, L);
    N = N.slice(1), N.forEach((z) => {
      var R = M.node(z).parent, T = O.edge(z, R), U = !1;
      T || (T = O.edge(R, z), U = !0), O.node(z).rank = O.node(R).rank + (U ? T.minlen : -T.minlen);
    });
  }
  function A(M, O, L) {
    return M.hasEdge(O, L);
  }
  function w(M, O, L) {
    return L.low <= O.lim && O.lim <= L.lim;
  }
}), TF = Xe((n, t) => {
  var e = Rd(), r = e.longestPath, a = Bw(), o = wF();
  t.exports = c;
  function c(p) {
    var m = p.graph().ranker;
    if (m instanceof Function) return m(p);
    switch (p.graph().ranker) {
      case "network-simplex":
        h(p);
        break;
      case "tight-tree":
        d(p);
        break;
      case "longest-path":
        u(p);
        break;
      case "none":
        break;
      default:
        h(p);
    }
  }
  var u = r;
  function d(p) {
    r(p), a(p);
  }
  function h(p) {
    o(p);
  }
}), AF = Xe((n, t) => {
  t.exports = e;
  function e(o) {
    let c = a(o);
    o.graph().dummyChains.forEach((u) => {
      let d = o.node(u), h = d.edgeObj, p = r(o, c, h.v, h.w), m = p.path, g = p.lca, _ = 0, b = m[_], E = !0;
      for (; u !== h.w; ) {
        if (d = o.node(u), E) {
          for (; (b = m[_]) !== g && o.node(b).maxRank < d.rank; ) _++;
          b === g && (E = !1);
        }
        if (!E) {
          for (; _ < m.length - 1 && o.node(b = m[_ + 1]).minRank <= d.rank; ) _++;
          b = m[_];
        }
        o.setParent(u, b), u = o.successors(u)[0];
      }
    });
  }
  function r(o, c, u, d) {
    let h = [], p = [], m = Math.min(c[u].low, c[d].low), g = Math.max(c[u].lim, c[d].lim), _, b;
    _ = u;
    do
      _ = o.parent(_), h.push(_);
    while (_ && (c[_].low > m || g > c[_].lim));
    for (b = _, _ = d; (_ = o.parent(_)) !== b; ) p.push(_);
    return { path: h.concat(p.reverse()), lca: b };
  }
  function a(o) {
    let c = {}, u = 0;
    function d(h) {
      let p = u;
      o.children(h).forEach(d), c[h] = { low: p, lim: u++ };
    }
    return o.children().forEach(d), c;
  }
}), CF = Xe((n, t) => {
  var e = Mn();
  t.exports = { run: r, cleanup: u };
  function r(d) {
    let h = e.addDummyNode(d, "root", {}, "_root"), p = o(d), m = Object.values(p), g = e.applyWithChunking(Math.max, m) - 1, _ = 2 * g + 1;
    d.graph().nestingRoot = h, d.edges().forEach((E) => d.edge(E).minlen *= _);
    let b = c(d) + 1;
    d.children().forEach((E) => a(d, h, _, b, g, p, E)), d.graph().nodeRankFactor = _;
  }
  function a(d, h, p, m, g, _, b) {
    let E = d.children(b);
    if (!E.length) {
      b !== h && d.setEdge(h, b, { weight: 0, minlen: p });
      return;
    }
    let S = e.addBorderNode(d, "_bt"), y = e.addBorderNode(d, "_bb"), A = d.node(b);
    d.setParent(S, b), A.borderTop = S, d.setParent(y, b), A.borderBottom = y, E.forEach((w) => {
      a(d, h, p, m, g, _, w);
      let M = d.node(w), O = M.borderTop ? M.borderTop : w, L = M.borderBottom ? M.borderBottom : w, N = M.borderTop ? m : 2 * m, z = O !== L ? 1 : g - _[b] + 1;
      d.setEdge(S, O, { weight: N, minlen: z, nestingEdge: !0 }), d.setEdge(L, y, { weight: N, minlen: z, nestingEdge: !0 });
    }), d.parent(b) || d.setEdge(h, S, { weight: 0, minlen: g + _[b] });
  }
  function o(d) {
    var h = {};
    function p(m, g) {
      var _ = d.children(m);
      _ && _.length && _.forEach((b) => p(b, g + 1)), h[m] = g;
    }
    return d.children().forEach((m) => p(m, 1)), h;
  }
  function c(d) {
    return d.edges().reduce((h, p) => h + d.edge(p).weight, 0);
  }
  function u(d) {
    var h = d.graph();
    d.removeNode(h.nestingRoot), delete h.nestingRoot, d.edges().forEach((p) => {
      var m = d.edge(p);
      m.nestingEdge && d.removeEdge(p);
    });
  }
}), RF = Xe((n, t) => {
  var e = Mn();
  t.exports = r;
  function r(o) {
    function c(u) {
      let d = o.children(u), h = o.node(u);
      if (d.length && d.forEach(c), Object.hasOwn(h, "minRank")) {
        h.borderLeft = [], h.borderRight = [];
        for (let p = h.minRank, m = h.maxRank + 1; p < m; ++p) a(o, "borderLeft", "_bl", u, h, p), a(o, "borderRight", "_br", u, h, p);
      }
    }
    o.children().forEach(c);
  }
  function a(o, c, u, d, h, p) {
    let m = { width: 0, height: 0, rank: p, borderType: c }, g = h[c][p - 1], _ = e.addDummyNode(o, "border", m, u);
    h[c][p] = _, o.setParent(_, d), g && o.setEdge(g, _, { weight: 1 });
  }
}), DF = Xe((n, t) => {
  t.exports = { adjust: e, undo: r };
  function e(p) {
    let m = p.graph().rankdir.toLowerCase();
    (m === "lr" || m === "rl") && a(p);
  }
  function r(p) {
    let m = p.graph().rankdir.toLowerCase();
    (m === "bt" || m === "rl") && c(p), (m === "lr" || m === "rl") && (d(p), a(p));
  }
  function a(p) {
    p.nodes().forEach((m) => o(p.node(m))), p.edges().forEach((m) => o(p.edge(m)));
  }
  function o(p) {
    let m = p.width;
    p.width = p.height, p.height = m;
  }
  function c(p) {
    p.nodes().forEach((m) => u(p.node(m))), p.edges().forEach((m) => {
      let g = p.edge(m);
      g.points.forEach(u), Object.hasOwn(g, "y") && u(g);
    });
  }
  function u(p) {
    p.y = -p.y;
  }
  function d(p) {
    p.nodes().forEach((m) => h(p.node(m))), p.edges().forEach((m) => {
      let g = p.edge(m);
      g.points.forEach(h), Object.hasOwn(g, "x") && h(g);
    });
  }
  function h(p) {
    let m = p.x;
    p.x = p.y, p.y = m;
  }
}), NF = Xe((n, t) => {
  var e = Mn();
  t.exports = r;
  function r(a) {
    let o = {}, c = a.nodes().filter((m) => !a.children(m).length), u = c.map((m) => a.node(m).rank), d = e.applyWithChunking(Math.max, u), h = e.range(d + 1).map(() => []);
    function p(m) {
      if (o[m]) return;
      o[m] = !0;
      let g = a.node(m);
      h[g.rank].push(m), a.successors(m).forEach(p);
    }
    return c.sort((m, g) => a.node(m).rank - a.node(g).rank).forEach(p), h;
  }
}), LF = Xe((n, t) => {
  var e = Mn().zipObject;
  t.exports = r;
  function r(o, c) {
    let u = 0;
    for (let d = 1; d < c.length; ++d) u += a(o, c[d - 1], c[d]);
    return u;
  }
  function a(o, c, u) {
    let d = e(u, u.map((b, E) => E)), h = c.flatMap((b) => o.outEdges(b).map((E) => ({ pos: d[E.w], weight: o.edge(E).weight })).sort((E, S) => E.pos - S.pos)), p = 1;
    for (; p < u.length; ) p <<= 1;
    let m = 2 * p - 1;
    p -= 1;
    let g = new Array(m).fill(0), _ = 0;
    return h.forEach((b) => {
      let E = b.pos + p;
      g[E] += b.weight;
      let S = 0;
      for (; E > 0; ) E % 2 && (S += g[E + 1]), E = E - 1 >> 1, g[E] += b.weight;
      _ += b.weight * S;
    }), _;
  }
}), UF = Xe((n, t) => {
  t.exports = e;
  function e(r, a = []) {
    return a.map((o) => {
      let c = r.inEdges(o);
      if (c.length) {
        let u = c.reduce((d, h) => {
          let p = r.edge(h), m = r.node(h.v);
          return { sum: d.sum + p.weight * m.order, weight: d.weight + p.weight };
        }, { sum: 0, weight: 0 });
        return { v: o, barycenter: u.sum / u.weight, weight: u.weight };
      } else return { v: o };
    });
  }
}), OF = Xe((n, t) => {
  var e = Mn();
  t.exports = r;
  function r(c, u) {
    let d = {};
    c.forEach((p, m) => {
      let g = d[p.v] = { indegree: 0, in: [], out: [], vs: [p.v], i: m };
      p.barycenter !== void 0 && (g.barycenter = p.barycenter, g.weight = p.weight);
    }), u.edges().forEach((p) => {
      let m = d[p.v], g = d[p.w];
      m !== void 0 && g !== void 0 && (g.indegree++, m.out.push(d[p.w]));
    });
    let h = Object.values(d).filter((p) => !p.indegree);
    return a(h);
  }
  function a(c) {
    let u = [];
    function d(p) {
      return (m) => {
        m.merged || (m.barycenter === void 0 || p.barycenter === void 0 || m.barycenter >= p.barycenter) && o(p, m);
      };
    }
    function h(p) {
      return (m) => {
        m.in.push(p), --m.indegree === 0 && c.push(m);
      };
    }
    for (; c.length; ) {
      let p = c.pop();
      u.push(p), p.in.reverse().forEach(d(p)), p.out.forEach(h(p));
    }
    return u.filter((p) => !p.merged).map((p) => e.pick(p, ["vs", "i", "barycenter", "weight"]));
  }
  function o(c, u) {
    let d = 0, h = 0;
    c.weight && (d += c.barycenter * c.weight, h += c.weight), u.weight && (d += u.barycenter * u.weight, h += u.weight), c.vs = u.vs.concat(c.vs), c.barycenter = d / h, c.weight = h, c.i = Math.min(u.i, c.i), u.merged = !0;
  }
}), PF = Xe((n, t) => {
  var e = Mn();
  t.exports = r;
  function r(c, u) {
    let d = e.partition(c, (S) => Object.hasOwn(S, "barycenter")), h = d.lhs, p = d.rhs.sort((S, y) => y.i - S.i), m = [], g = 0, _ = 0, b = 0;
    h.sort(o(!!u)), b = a(m, p, b), h.forEach((S) => {
      b += S.vs.length, m.push(S.vs), g += S.barycenter * S.weight, _ += S.weight, b = a(m, p, b);
    });
    let E = { vs: m.flat(!0) };
    return _ && (E.barycenter = g / _, E.weight = _), E;
  }
  function a(c, u, d) {
    let h;
    for (; u.length && (h = u[u.length - 1]).i <= d; ) u.pop(), c.push(h.vs), d++;
    return d;
  }
  function o(c) {
    return (u, d) => u.barycenter < d.barycenter ? -1 : u.barycenter > d.barycenter ? 1 : c ? d.i - u.i : u.i - d.i;
  }
}), zF = Xe((n, t) => {
  var e = UF(), r = OF(), a = PF();
  t.exports = o;
  function o(d, h, p, m) {
    let g = d.children(h), _ = d.node(h), b = _ ? _.borderLeft : void 0, E = _ ? _.borderRight : void 0, S = {};
    b && (g = g.filter((M) => M !== b && M !== E));
    let y = e(d, g);
    y.forEach((M) => {
      if (d.children(M.v).length) {
        let O = o(d, M.v, p, m);
        S[M.v] = O, Object.hasOwn(O, "barycenter") && u(M, O);
      }
    });
    let A = r(y, p);
    c(A, S);
    let w = a(A, m);
    if (b && (w.vs = [b, w.vs, E].flat(!0), d.predecessors(b).length)) {
      let M = d.node(d.predecessors(b)[0]), O = d.node(d.predecessors(E)[0]);
      Object.hasOwn(w, "barycenter") || (w.barycenter = 0, w.weight = 0), w.barycenter = (w.barycenter * w.weight + M.order + O.order) / (w.weight + 2), w.weight += 2;
    }
    return w;
  }
  function c(d, h) {
    d.forEach((p) => {
      p.vs = p.vs.flatMap((m) => h[m] ? h[m].vs : m);
    });
  }
  function u(d, h) {
    d.barycenter !== void 0 ? (d.barycenter = (d.barycenter * d.weight + h.barycenter * h.weight) / (d.weight + h.weight), d.weight += h.weight) : (d.barycenter = h.barycenter, d.weight = h.weight);
  }
}), IF = Xe((n, t) => {
  var e = er().Graph, r = Mn();
  t.exports = a;
  function a(c, u, d, h) {
    h || (h = c.nodes());
    let p = o(c), m = new e({ compound: !0 }).setGraph({ root: p }).setDefaultNodeLabel((g) => c.node(g));
    return h.forEach((g) => {
      let _ = c.node(g), b = c.parent(g);
      (_.rank === u || _.minRank <= u && u <= _.maxRank) && (m.setNode(g), m.setParent(g, b || p), c[d](g).forEach((E) => {
        let S = E.v === g ? E.w : E.v, y = m.edge(S, g), A = y !== void 0 ? y.weight : 0;
        m.setEdge(S, g, { weight: c.edge(E).weight + A });
      }), Object.hasOwn(_, "minRank") && m.setNode(g, { borderLeft: _.borderLeft[u], borderRight: _.borderRight[u] }));
    }), m;
  }
  function o(c) {
    for (var u; c.hasNode(u = r.uniqueId("_root")); ) ;
    return u;
  }
}), BF = Xe((n, t) => {
  t.exports = e;
  function e(r, a, o) {
    let c = {}, u;
    o.forEach((d) => {
      let h = r.parent(d), p, m;
      for (; h; ) {
        if (p = r.parent(h), p ? (m = c[p], c[p] = h) : (m = u, u = h), m && m !== h) {
          a.setEdge(m, h);
          return;
        }
        h = p;
      }
    });
  }
}), FF = Xe((n, t) => {
  var e = NF(), r = LF(), a = zF(), o = IF(), c = BF(), u = er().Graph, d = Mn();
  t.exports = h;
  function h(_, b = {}) {
    if (typeof b.customOrder == "function") {
      b.customOrder(_, h);
      return;
    }
    let E = d.maxRank(_), S = p(_, d.range(1, E + 1), "inEdges"), y = p(_, d.range(E - 1, -1, -1), "outEdges"), A = e(_);
    if (g(_, A), b.disableOptimalOrderHeuristic) return;
    let w = Number.POSITIVE_INFINITY, M, O = b.constraints || [];
    for (let L = 0, N = 0; N < 4; ++L, ++N) {
      m(L % 2 ? S : y, L % 4 >= 2, O), A = d.buildLayerMatrix(_);
      let z = r(_, A);
      z < w ? (N = 0, M = Object.assign({}, A), w = z) : z === w && (M = structuredClone(A));
    }
    g(_, M);
  }
  function p(_, b, E) {
    let S = /* @__PURE__ */ new Map(), y = (A, w) => {
      S.has(A) || S.set(A, []), S.get(A).push(w);
    };
    for (let A of _.nodes()) {
      let w = _.node(A);
      if (typeof w.rank == "number" && y(w.rank, A), typeof w.minRank == "number" && typeof w.maxRank == "number") for (let M = w.minRank; M <= w.maxRank; M++) M !== w.rank && y(M, A);
    }
    return b.map(function(A) {
      return o(_, A, E, S.get(A) || []);
    });
  }
  function m(_, b, E) {
    let S = new u();
    _.forEach(function(y) {
      E.forEach((M) => S.setEdge(M.left, M.right));
      let A = y.graph().root, w = a(y, A, S, b);
      w.vs.forEach((M, O) => y.node(M).order = O), c(y, S, w.vs);
    });
  }
  function g(_, b) {
    Object.values(b).forEach((E) => E.forEach((S, y) => _.node(S).order = y));
  }
}), HF = Xe((n, t) => {
  var e = er().Graph, r = Mn();
  t.exports = { positionX: E, findType1Conflicts: a, findType2Conflicts: o, addConflict: u, hasConflict: d, verticalAlignment: h, horizontalCompaction: p, alignCoordinates: _, findSmallestWidthAlignment: g, balance: b };
  function a(A, w) {
    let M = {};
    function O(L, N) {
      let z = 0, R = 0, T = L.length, U = N[N.length - 1];
      return N.forEach((B, I) => {
        let C = c(A, B), X = C ? A.node(C).order : T;
        (C || B === U) && (N.slice(R, I + 1).forEach((D) => {
          A.predecessors(D).forEach((V) => {
            let H = A.node(V), j = H.order;
            (j < z || X < j) && !(H.dummy && A.node(D).dummy) && u(M, V, D);
          });
        }), R = I + 1, z = X);
      }), N;
    }
    return w.length && w.reduce(O), M;
  }
  function o(A, w) {
    let M = {};
    function O(N, z, R, T, U) {
      let B;
      r.range(z, R).forEach((I) => {
        B = N[I], A.node(B).dummy && A.predecessors(B).forEach((C) => {
          let X = A.node(C);
          X.dummy && (X.order < T || X.order > U) && u(M, C, B);
        });
      });
    }
    function L(N, z) {
      let R = -1, T, U = 0;
      return z.forEach((B, I) => {
        if (A.node(B).dummy === "border") {
          let C = A.predecessors(B);
          C.length && (T = A.node(C[0]).order, O(z, U, I, R, T), U = I, R = T);
        }
        O(z, U, z.length, T, N.length);
      }), z;
    }
    return w.length && w.reduce(L), M;
  }
  function c(A, w) {
    if (A.node(w).dummy) return A.predecessors(w).find((M) => A.node(M).dummy);
  }
  function u(A, w, M) {
    if (w > M) {
      let L = w;
      w = M, M = L;
    }
    let O = A[w];
    O || (A[w] = O = {}), O[M] = !0;
  }
  function d(A, w, M) {
    if (w > M) {
      let O = w;
      w = M, M = O;
    }
    return !!A[w] && Object.hasOwn(A[w], M);
  }
  function h(A, w, M, O) {
    let L = {}, N = {}, z = {};
    return w.forEach((R) => {
      R.forEach((T, U) => {
        L[T] = T, N[T] = T, z[T] = U;
      });
    }), w.forEach((R) => {
      let T = -1;
      R.forEach((U) => {
        let B = O(U);
        if (B.length) {
          B = B.sort((C, X) => z[C] - z[X]);
          let I = (B.length - 1) / 2;
          for (let C = Math.floor(I), X = Math.ceil(I); C <= X; ++C) {
            let D = B[C];
            N[U] === U && T < z[D] && !d(M, U, D) && (N[D] = U, N[U] = L[U] = L[D], T = z[D]);
          }
        }
      });
    }), { root: L, align: N };
  }
  function p(A, w, M, O, L) {
    let N = {}, z = m(A, w, M, L), R = L ? "borderLeft" : "borderRight";
    function T(I, C) {
      let X = z.nodes().slice(), D = {}, V = X.pop();
      for (; V; ) {
        if (D[V]) I(V);
        else {
          D[V] = !0, X.push(V);
          for (let H of C(V)) X.push(H);
        }
        V = X.pop();
      }
    }
    function U(I) {
      N[I] = z.inEdges(I).reduce((C, X) => Math.max(C, N[X.v] + z.edge(X)), 0);
    }
    function B(I) {
      let C = z.outEdges(I).reduce((D, V) => Math.min(D, N[V.w] - z.edge(V)), Number.POSITIVE_INFINITY), X = A.node(I);
      C !== Number.POSITIVE_INFINITY && X.borderType !== R && (N[I] = Math.max(N[I], C));
    }
    return T(U, z.predecessors.bind(z)), T(B, z.successors.bind(z)), Object.keys(O).forEach((I) => N[I] = N[M[I]]), N;
  }
  function m(A, w, M, O) {
    let L = new e(), N = A.graph(), z = S(N.nodesep, N.edgesep, O);
    return w.forEach((R) => {
      let T;
      R.forEach((U) => {
        let B = M[U];
        if (L.setNode(B), T) {
          var I = M[T], C = L.edge(I, B);
          L.setEdge(I, B, Math.max(z(A, U, T), C || 0));
        }
        T = U;
      });
    }), L;
  }
  function g(A, w) {
    return Object.values(w).reduce((M, O) => {
      let L = Number.NEGATIVE_INFINITY, N = Number.POSITIVE_INFINITY;
      Object.entries(O).forEach(([R, T]) => {
        let U = y(A, R) / 2;
        L = Math.max(T + U, L), N = Math.min(T - U, N);
      });
      let z = L - N;
      return z < M[0] && (M = [z, O]), M;
    }, [Number.POSITIVE_INFINITY, null])[1];
  }
  function _(A, w) {
    let M = Object.values(w), O = r.applyWithChunking(Math.min, M), L = r.applyWithChunking(Math.max, M);
    ["u", "d"].forEach((N) => {
      ["l", "r"].forEach((z) => {
        let R = N + z, T = A[R];
        if (T === w) return;
        let U = Object.values(T), B = O - r.applyWithChunking(Math.min, U);
        z !== "l" && (B = L - r.applyWithChunking(Math.max, U)), B && (A[R] = r.mapValues(T, (I) => I + B));
      });
    });
  }
  function b(A, w) {
    return r.mapValues(A.ul, (M, O) => {
      if (w) return A[w.toLowerCase()][O];
      {
        let L = Object.values(A).map((N) => N[O]).sort((N, z) => N - z);
        return (L[1] + L[2]) / 2;
      }
    });
  }
  function E(A) {
    let w = r.buildLayerMatrix(A), M = Object.assign(a(A, w), o(A, w)), O = {}, L;
    ["u", "d"].forEach((z) => {
      L = z === "u" ? w : Object.values(w).reverse(), ["l", "r"].forEach((R) => {
        R === "r" && (L = L.map((I) => Object.values(I).reverse()));
        let T = (z === "u" ? A.predecessors : A.successors).bind(A), U = h(A, L, M, T), B = p(A, L, U.root, U.align, R === "r");
        R === "r" && (B = r.mapValues(B, (I) => -I)), O[z + R] = B;
      });
    });
    let N = g(A, O);
    return _(O, N), b(O, A.graph().align);
  }
  function S(A, w, M) {
    return (O, L, N) => {
      let z = O.node(L), R = O.node(N), T = 0, U;
      if (T += z.width / 2, Object.hasOwn(z, "labelpos")) switch (z.labelpos.toLowerCase()) {
        case "l":
          U = -z.width / 2;
          break;
        case "r":
          U = z.width / 2;
          break;
      }
      if (U && (T += M ? U : -U), U = 0, T += (z.dummy ? w : A) / 2, T += (R.dummy ? w : A) / 2, T += R.width / 2, Object.hasOwn(R, "labelpos")) switch (R.labelpos.toLowerCase()) {
        case "l":
          U = R.width / 2;
          break;
        case "r":
          U = -R.width / 2;
          break;
      }
      return U && (T += M ? U : -U), U = 0, T;
    };
  }
  function y(A, w) {
    return A.node(w).width;
  }
}), VF = Xe((n, t) => {
  var e = Mn(), r = HF().positionX;
  t.exports = a;
  function a(c) {
    c = e.asNonCompoundGraph(c), o(c), Object.entries(r(c)).forEach(([u, d]) => c.node(u).x = d);
  }
  function o(c) {
    let u = e.buildLayerMatrix(c), d = c.graph().ranksep, h = c.graph().rankalign, p = 0;
    u.forEach((m) => {
      let g = m.reduce((_, b) => {
        let E = c.node(b).height;
        return _ > E ? _ : E;
      }, 0);
      m.forEach((_) => {
        let b = c.node(_);
        h === "top" ? b.y = p + b.height / 2 : h === "bottom" ? b.y = p + g - b.height / 2 : b.y = p + g / 2;
      }), p += g + d;
    });
  }
}), kF = Xe((n, t) => {
  var e = MF(), r = EF(), a = TF(), o = Mn().normalizeRanks, c = AF(), u = Mn().removeEmptyRanks, d = CF(), h = RF(), p = DF(), m = FF(), g = VF(), _ = Mn(), b = er().Graph;
  t.exports = E;
  function E(k, $ = {}) {
    let Q = $.debugTiming ? _.time : _.notime;
    return Q("layout", () => {
      let et = Q("  buildLayoutGraph", () => T(k));
      return Q("  runLayout", () => S(et, Q, $)), Q("  updateInputGraph", () => y(k, et)), et;
    });
  }
  function S(k, $, Q) {
    $("    makeSpaceForEdgeLabels", () => U(k)), $("    removeSelfEdges", () => K(k)), $("    acyclic", () => e.run(k)), $("    nestingGraph.run", () => d.run(k)), $("    rank", () => a(_.asNonCompoundGraph(k))), $("    injectEdgeLabelProxies", () => B(k)), $("    removeEmptyRanks", () => u(k)), $("    nestingGraph.cleanup", () => d.cleanup(k)), $("    normalizeRanks", () => o(k)), $("    assignRankMinMax", () => I(k)), $("    removeEdgeLabelProxies", () => C(k)), $("    normalize.run", () => r.run(k)), $("    parentDummyChains", () => c(k)), $("    addBorderSegments", () => h(k)), $("    order", () => m(k, Q)), $("    insertSelfEdges", () => F(k)), $("    adjustCoordinateSystem", () => p.adjust(k)), $("    position", () => g(k)), $("    positionSelfEdges", () => q(k)), $("    removeBorderNodes", () => j(k)), $("    normalize.undo", () => r.undo(k)), $("    fixupEdgeLabelCoords", () => V(k)), $("    undoCoordinateSystem", () => p.undo(k)), $("    translateGraph", () => X(k)), $("    assignNodeIntersects", () => D(k)), $("    reversePoints", () => H(k)), $("    acyclic.undo", () => e.undo(k));
  }
  function y(k, $) {
    k.nodes().forEach((Q) => {
      let et = k.node(Q), st = $.node(Q);
      et && (et.x = st.x, et.y = st.y, et.order = st.order, et.rank = st.rank, $.children(Q).length && (et.width = st.width, et.height = st.height));
    }), k.edges().forEach((Q) => {
      let et = k.edge(Q), st = $.edge(Q);
      et.points = st.points, Object.hasOwn(st, "x") && (et.x = st.x, et.y = st.y);
    }), k.graph().width = $.graph().width, k.graph().height = $.graph().height;
  }
  var A = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"], w = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb", rankalign: "center" }, M = ["acyclicer", "ranker", "rankdir", "align", "rankalign"], O = ["width", "height", "rank"], L = { width: 0, height: 0 }, N = ["minlen", "weight", "width", "height", "labeloffset"], z = { minlen: 1, weight: 1, width: 0, height: 0, labeloffset: 10, labelpos: "r" }, R = ["labelpos"];
  function T(k) {
    let $ = new b({ multigraph: !0, compound: !0 }), Q = G(k.graph());
    return $.setGraph(Object.assign({}, w, it(Q, A), _.pick(Q, M))), k.nodes().forEach((et) => {
      let st = G(k.node(et)), _t = it(st, O);
      Object.keys(L).forEach((Mt) => {
        _t[Mt] === void 0 && (_t[Mt] = L[Mt]);
      }), $.setNode(et, _t), $.setParent(et, k.parent(et));
    }), k.edges().forEach((et) => {
      let st = G(k.edge(et));
      $.setEdge(et, Object.assign({}, z, it(st, N), _.pick(st, R)));
    }), $;
  }
  function U(k) {
    let $ = k.graph();
    $.ranksep /= 2, k.edges().forEach((Q) => {
      let et = k.edge(Q);
      et.minlen *= 2, et.labelpos.toLowerCase() !== "c" && ($.rankdir === "TB" || $.rankdir === "BT" ? et.width += et.labeloffset : et.height += et.labeloffset);
    });
  }
  function B(k) {
    k.edges().forEach(($) => {
      let Q = k.edge($);
      if (Q.width && Q.height) {
        let et = k.node($.v), st = { rank: (k.node($.w).rank - et.rank) / 2 + et.rank, e: $ };
        _.addDummyNode(k, "edge-proxy", st, "_ep");
      }
    });
  }
  function I(k) {
    let $ = 0;
    k.nodes().forEach((Q) => {
      let et = k.node(Q);
      et.borderTop && (et.minRank = k.node(et.borderTop).rank, et.maxRank = k.node(et.borderBottom).rank, $ = Math.max($, et.maxRank));
    }), k.graph().maxRank = $;
  }
  function C(k) {
    k.nodes().forEach(($) => {
      let Q = k.node($);
      Q.dummy === "edge-proxy" && (k.edge(Q.e).labelRank = Q.rank, k.removeNode($));
    });
  }
  function X(k) {
    let $ = Number.POSITIVE_INFINITY, Q = 0, et = Number.POSITIVE_INFINITY, st = 0, _t = k.graph(), Mt = _t.marginx || 0, Rt = _t.marginy || 0;
    function Ot(nt) {
      let Jt = nt.x, Ft = nt.y, ne = nt.width, jt = nt.height;
      $ = Math.min($, Jt - ne / 2), Q = Math.max(Q, Jt + ne / 2), et = Math.min(et, Ft - jt / 2), st = Math.max(st, Ft + jt / 2);
    }
    k.nodes().forEach((nt) => Ot(k.node(nt))), k.edges().forEach((nt) => {
      let Jt = k.edge(nt);
      Object.hasOwn(Jt, "x") && Ot(Jt);
    }), $ -= Mt, et -= Rt, k.nodes().forEach((nt) => {
      let Jt = k.node(nt);
      Jt.x -= $, Jt.y -= et;
    }), k.edges().forEach((nt) => {
      let Jt = k.edge(nt);
      Jt.points.forEach((Ft) => {
        Ft.x -= $, Ft.y -= et;
      }), Object.hasOwn(Jt, "x") && (Jt.x -= $), Object.hasOwn(Jt, "y") && (Jt.y -= et);
    }), _t.width = Q - $ + Mt, _t.height = st - et + Rt;
  }
  function D(k) {
    k.edges().forEach(($) => {
      let Q = k.edge($), et = k.node($.v), st = k.node($.w), _t, Mt;
      Q.points ? (_t = Q.points[0], Mt = Q.points[Q.points.length - 1]) : (Q.points = [], _t = st, Mt = et), Q.points.unshift(_.intersectRect(et, _t)), Q.points.push(_.intersectRect(st, Mt));
    });
  }
  function V(k) {
    k.edges().forEach(($) => {
      let Q = k.edge($);
      if (Object.hasOwn(Q, "x")) switch ((Q.labelpos === "l" || Q.labelpos === "r") && (Q.width -= Q.labeloffset), Q.labelpos) {
        case "l":
          Q.x -= Q.width / 2 + Q.labeloffset;
          break;
        case "r":
          Q.x += Q.width / 2 + Q.labeloffset;
          break;
      }
    });
  }
  function H(k) {
    k.edges().forEach(($) => {
      let Q = k.edge($);
      Q.reversed && Q.points.reverse();
    });
  }
  function j(k) {
    k.nodes().forEach(($) => {
      if (k.children($).length) {
        let Q = k.node($), et = k.node(Q.borderTop), st = k.node(Q.borderBottom), _t = k.node(Q.borderLeft[Q.borderLeft.length - 1]), Mt = k.node(Q.borderRight[Q.borderRight.length - 1]);
        Q.width = Math.abs(Mt.x - _t.x), Q.height = Math.abs(st.y - et.y), Q.x = _t.x + Q.width / 2, Q.y = et.y + Q.height / 2;
      }
    }), k.nodes().forEach(($) => {
      k.node($).dummy === "border" && k.removeNode($);
    });
  }
  function K(k) {
    k.edges().forEach(($) => {
      if ($.v === $.w) {
        var Q = k.node($.v);
        Q.selfEdges || (Q.selfEdges = []), Q.selfEdges.push({ e: $, label: k.edge($) }), k.removeEdge($);
      }
    });
  }
  function F(k) {
    var $ = _.buildLayerMatrix(k);
    $.forEach((Q) => {
      var et = 0;
      Q.forEach((st, _t) => {
        var Mt = k.node(st);
        Mt.order = _t + et, (Mt.selfEdges || []).forEach((Rt) => {
          _.addDummyNode(k, "selfedge", { width: Rt.label.width, height: Rt.label.height, rank: Mt.rank, order: _t + ++et, e: Rt.e, label: Rt.label }, "_se");
        }), delete Mt.selfEdges;
      });
    });
  }
  function q(k) {
    k.nodes().forEach(($) => {
      var Q = k.node($);
      if (Q.dummy === "selfedge") {
        var et = k.node(Q.e.v), st = et.x + et.width / 2, _t = et.y, Mt = Q.x - st, Rt = et.height / 2;
        k.setEdge(Q.e, Q.label), k.removeNode($), Q.label.points = [{ x: st + 2 * Mt / 3, y: _t - Rt }, { x: st + 5 * Mt / 6, y: _t - Rt }, { x: st + Mt, y: _t }, { x: st + 5 * Mt / 6, y: _t + Rt }, { x: st + 2 * Mt / 3, y: _t + Rt }], Q.label.x = Q.x, Q.label.y = Q.y;
      }
    });
  }
  function it(k, $) {
    return _.mapValues(_.pick(k, $), Number);
  }
  function G(k) {
    var $ = {};
    return k && Object.entries(k).forEach(([Q, et]) => {
      typeof Q == "string" && (Q = Q.toLowerCase()), $[Q] = et;
    }), $;
  }
}), GF = Xe((n, t) => {
  var e = Mn(), r = er().Graph;
  t.exports = { debugOrdering: a };
  function a(o) {
    let c = e.buildLayerMatrix(o), u = new r({ compound: !0, multigraph: !0 }).setGraph({});
    return o.nodes().forEach((d) => {
      u.setNode(d, { label: d }), u.setParent(d, "layer" + o.node(d).rank);
    }), o.edges().forEach((d) => u.setEdge(d.v, d.w, {}, d.name)), c.forEach((d, h) => {
      let p = "layer" + h;
      u.setNode(p, { rank: "same" }), d.reduce((m, g) => (u.setEdge(m, g, { style: "invis" }), g));
    }), u;
  }
}), XF = Xe((n, t) => {
  t.exports = "2.0.4";
}), jF = Xe((n, t) => {
  t.exports = { graphlib: er(), layout: kF(), debug: GF(), util: { time: Mn().time, notime: Mn().notime }, version: XF() };
});
const N1 = jF();
/*! For license information please see dagre.esm.js.LEGAL.txt */
const ng = 380, L1 = 280, U1 = 30, WF = 80, O1 = 2;
function h0(n, t) {
  if (n.length === 0) return { nodes: n, edges: t };
  const e = new N1.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
  e.setGraph({ rankdir: "TB", nodesep: 30, ranksep: 80 });
  for (const d of n)
    e.setNode(d.id, { width: ng, height: L1 });
  for (const d of t)
    e.setEdge(d.source, d.target);
  N1.layout(e);
  const r = /* @__PURE__ */ new Map();
  for (const d of n) {
    const h = e.node(d.id), p = Math.round(h.y);
    r.has(p) || r.set(p, []), r.get(p).push(d.id);
  }
  const a = [...r.entries()].sort(([d], [h]) => d - h).map(
    ([, d]) => d.sort((h, p) => e.node(h).x - e.node(p).x)
  ), o = /* @__PURE__ */ new Map();
  let c = 0;
  for (const d of a)
    for (let h = 0; h < d.length; h += O1) {
      const p = d.slice(h, h + O1), g = -(p.length * ng + (p.length - 1) * U1) / 2;
      for (let _ = 0; _ < p.length; _++)
        o.set(p[_], {
          x: g + _ * (ng + U1),
          y: c
        });
      c += L1 + WF;
    }
  return { nodes: n.map((d) => ({
    ...d,
    position: o.get(d.id) ?? d.position
  })), edges: t };
}
let YF = 1;
function qF() {
  return `node-${YF++}`;
}
function Fw() {
  var t;
  return new URLSearchParams(((t = globalThis.location) == null ? void 0 : t.search) ?? "").has("demo") ? _F() : globalThis.__MEGANE_CONTEXT__ === "vscode" ? vF() : gF();
}
const P1 = Fw(), z1 = h0(P1.nodes, P1.edges), $e = k5((n, t) => ({
  nodes: z1.nodes,
  edges: z1.edges,
  viewportState: { ...fd },
  snapshot: null,
  atomLabels: null,
  structureFrames: null,
  structureMeta: null,
  fileFrames: null,
  fileMeta: null,
  fileVectors: null,
  setSnapshot: (e) => {
    n({ snapshot: e }), t().execute();
  },
  setAtomLabels: (e) => {
    n({ atomLabels: e }), t().execute();
  },
  setStructureFrames: (e, r) => {
    n({ structureFrames: e, structureMeta: r }), t().execute();
  },
  setFileFrames: (e, r) => {
    n({ fileFrames: e, fileMeta: r }), t().execute();
  },
  setFileVectors: (e) => {
    n({ fileVectors: e }), t().execute();
  },
  onNodesChange: (e) => {
    const { nodes: r } = t(), a = e.filter((o) => {
      if (o.type === "remove") {
        const c = r.find((u) => u.id === o.id);
        if ((c == null ? void 0 : c.type) === "viewport") return !1;
      }
      return !0;
    });
    a.length !== 0 && (n((o) => ({
      nodes: QE(a, o.nodes)
    })), t().execute());
  },
  onEdgesChange: (e) => {
    n((r) => ({
      edges: JE(e, r.edges)
    })), t().execute();
  },
  onConnect: (e) => {
    const { nodes: r } = t(), a = r.find((c) => c.id === e.source), o = r.find((c) => c.id === e.target);
    !(a != null && a.type) || !(o != null && o.type) || Lw(
      a.type,
      e.sourceHandle ?? null,
      o.type,
      e.targetHandle ?? null
    ) && (n((c) => ({
      edges: UE(
        {
          ...e,
          id: `e-${e.source}-${e.sourceHandle}-${e.target}-${e.targetHandle}`
        },
        c.edges
      )
    })), t().execute());
  },
  addNode: (e, r) => {
    const a = qF();
    let o = { x: 425, y: 50 };
    if (!r) {
      const u = t().nodes;
      u.length > 0 && (o = { x: 425, y: Math.max(...u.map((h) => h.position.y)) + 200 });
    }
    const c = {
      id: a,
      type: e,
      position: r ?? o,
      data: {
        params: Nw(e),
        enabled: !0
      }
    };
    return n((u) => ({
      nodes: [...u.nodes, c]
    })), a;
  },
  removeNode: (e) => {
    n((r) => ({
      nodes: r.nodes.filter((a) => a.id !== e),
      edges: r.edges.filter((a) => a.source !== e && a.target !== e)
    })), t().execute();
  },
  updateNodeParams: (e, r) => {
    n((a) => ({
      nodes: a.nodes.map((o) => o.id !== e ? o : {
        ...o,
        data: {
          ...o.data,
          params: { ...o.data.params, ...r }
        }
      })
    })), t().execute();
  },
  toggleNode: (e) => {
    n((r) => ({
      nodes: r.nodes.map((a) => a.id !== e ? a : {
        ...a,
        data: { ...a.data, enabled: !a.data.enabled }
      })
    })), t().execute();
  },
  execute: () => {
    const { nodes: e, edges: r, snapshot: a, atomLabels: o, structureFrames: c, structureMeta: u, fileFrames: d, fileMeta: h, fileVectors: p } = t(), g = dF(e, r, {
      snapshot: a,
      atomLabels: o,
      structureFrames: c,
      structureMeta: u,
      fileFrames: d,
      fileMeta: h,
      fileVectors: p
    });
    n({ viewportState: g });
  },
  serialize: () => {
    const { nodes: e, edges: r } = t();
    return pF(e, r);
  },
  deserialize: (e) => {
    const { nodes: r, edges: a } = mF(e);
    n({ nodes: r, edges: a }), t().execute();
  },
  pendingTemplateId: null,
  applyTemplate: (e) => {
    const r = Iw.find((u) => u.id === e);
    if (!r) return;
    const a = r.create(), { nodes: o, edges: c } = h0(a.nodes, a.edges);
    n({
      nodes: o,
      edges: c,
      viewportState: { ...fd },
      pendingTemplateId: e
    }), t().execute();
  },
  clearPendingTemplate: () => {
    n({ pendingTemplateId: null });
  },
  autoLayout: () => {
    const { nodes: e, edges: r } = t(), { nodes: a } = h0(e, r);
    n({ nodes: a });
  },
  reset: () => {
    const e = Fw();
    n({
      nodes: e.nodes,
      edges: e.edges,
      viewportState: { ...fd }
    });
  }
})), ZF = {
  position: "absolute",
  top: 12,
  right: 12,
  bottom: 60,
  zIndex: 10,
  background: "rgba(255, 255, 255, 0.92)",
  backdropFilter: "blur(16px)",
  WebkitBackdropFilter: "blur(16px)",
  borderRadius: 12,
  boxShadow: "0 1px 8px rgba(0,0,0,0.06)",
  border: "1px solid rgba(226,232,240,0.6)",
  display: "flex",
  flexDirection: "column",
  overflow: "hidden"
}, $F = {
  padding: "10px 14px",
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  borderBottom: "1px solid rgba(226,232,240,0.6)",
  flexShrink: 0
}, KF = {
  fontWeight: 600,
  color: "#1e293b",
  fontSize: 13,
  letterSpacing: "-0.02em"
}, QF = {
  background: "none",
  border: "none",
  cursor: "pointer",
  fontSize: 13,
  color: "#94a3b8",
  padding: "2px 4px"
}, JF = {
  background: "rgba(255, 255, 255, 0.88)",
  backdropFilter: "blur(16px)",
  WebkitBackdropFilter: "blur(16px)",
  border: "1px solid rgba(226,232,240,0.6)",
  borderRadius: 10,
  padding: "8px 12px",
  cursor: "pointer",
  boxShadow: "0 1px 8px rgba(0,0,0,0.06)",
  display: "flex",
  alignItems: "center",
  gap: 8,
  fontSize: 13,
  fontWeight: 600,
  color: "#1e293b",
  letterSpacing: "-0.02em"
};
function tH({
  title: n,
  collapsed: t,
  onToggleCollapse: e,
  width: r = 220,
  headerExtra: a,
  containerExtra: o,
  children: c
}) {
  return t ? /* @__PURE__ */ J.jsx("div", { style: { position: "absolute", top: 12, right: 12, zIndex: 10 }, children: /* @__PURE__ */ J.jsxs(
    "button",
    {
      onClick: e,
      style: JF,
      title: `Open ${n.toLowerCase()}`,
      children: [
        /* @__PURE__ */ J.jsx("span", { style: { fontSize: 11, color: "#94a3b8", fontWeight: 400 }, children: "◀" }),
        n
      ]
    }
  ) }) : /* @__PURE__ */ J.jsxs("div", { style: { ...ZF, width: r }, children: [
    o,
    /* @__PURE__ */ J.jsxs("div", { style: $F, children: [
      /* @__PURE__ */ J.jsx("span", { style: KF, children: n }),
      /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, position: "relative" }, children: [
        a,
        /* @__PURE__ */ J.jsx(
          "button",
          {
            onClick: e,
            style: QF,
            title: "Collapse panel",
            children: "▶"
          }
        )
      ] })
    ] }),
    c
  ] });
}
const Hw = {
  background: "rgba(255, 255, 255, 0.95)",
  backdropFilter: "blur(8px)",
  border: "1px solid #e2e8f0",
  borderRadius: 14,
  minWidth: 340,
  maxWidth: 420,
  fontSize: 20,
  boxShadow: "0 2px 6px rgba(0,0,0,0.08)"
}, eH = {
  ...Hw,
  opacity: 0.5
}, nH = {
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  padding: "10px 17px",
  borderBottom: "1px solid #e2e8f0",
  gap: 10
}, iH = {
  fontWeight: 600,
  fontSize: 19,
  color: "#1e293b",
  letterSpacing: "-0.02em",
  flex: 1
}, rH = {
  background: "none",
  border: "none",
  cursor: "pointer",
  fontSize: 19,
  color: "#94a3b8",
  padding: "3px 7px",
  lineHeight: 1
}, sH = {
  padding: "14px 17px"
}, I1 = {
  width: 14,
  height: 14,
  border: "3px solid white",
  boxShadow: "0 0 3px rgba(0,0,0,0.2)"
}, B1 = {
  position: "absolute",
  fontSize: 14,
  color: "#94a3b8",
  whiteSpace: "nowrap",
  pointerEvents: "none"
};
function F1(n, t) {
  return t ? "#cbd5e1" : Cw[n.dataType];
}
function H1(n, t) {
  return t === 1 ? "50%" : `${10 + 80 / (t - 1) * n}%`;
}
function xr({ id: n, nodeType: t, enabled: e, children: r, disabledPorts: a }) {
  const o = $e((p) => p.toggleNode), c = $e((p) => p.removeNode), u = kc[t], d = Dw[G5[t]], h = {
    ...e ? Hw : eH,
    borderLeft: `5px solid ${d}`
  };
  return /* @__PURE__ */ J.jsxs("div", { style: h, children: [
    u.inputs.map((p, m) => {
      const g = (a == null ? void 0 : a.has(p.name)) ?? !1;
      return /* @__PURE__ */ J.jsx(
        pl,
        {
          type: "target",
          position: re.Top,
          id: p.name,
          style: {
            ...I1,
            background: F1(p, g),
            left: H1(m, u.inputs.length)
          },
          children: /* @__PURE__ */ J.jsx(
            "span",
            {
              style: {
                ...B1,
                top: -22,
                left: "50%",
                transform: "translateX(-50%)",
                color: g ? "#cbd5e1" : "#94a3b8"
              },
              children: p.label
            }
          )
        },
        `in-${p.name}`
      );
    }),
    /* @__PURE__ */ J.jsxs("div", { style: nH, children: [
      /* @__PURE__ */ J.jsx("span", { style: iH, children: Rw[t] }),
      /* @__PURE__ */ J.jsx(
        "div",
        {
          onClick: () => o(n),
          style: {
            width: 48,
            height: 24,
            borderRadius: 12,
            background: e ? "#3b82f6" : "#cbd5e1",
            position: "relative",
            cursor: "pointer",
            transition: "background 0.15s",
            flexShrink: 0
          },
          title: e ? "Disable node" : "Enable node",
          children: /* @__PURE__ */ J.jsx(
            "div",
            {
              style: {
                width: 18,
                height: 18,
                borderRadius: "50%",
                background: "white",
                position: "absolute",
                top: 3,
                left: e ? 27 : 3,
                transition: "left 0.15s"
              }
            }
          )
        }
      ),
      t !== "viewport" && /* @__PURE__ */ J.jsx(
        "button",
        {
          onClick: () => c(n),
          style: rH,
          title: "Remove node",
          children: "×"
        }
      )
    ] }),
    /* @__PURE__ */ J.jsx("div", { style: sH, children: r }),
    u.outputs.map((p, m) => {
      const g = (a == null ? void 0 : a.has(p.name)) ?? !1;
      return /* @__PURE__ */ J.jsx(
        pl,
        {
          type: "source",
          position: re.Bottom,
          id: p.name,
          style: {
            ...I1,
            background: F1(p, g),
            left: H1(m, u.outputs.length)
          },
          children: /* @__PURE__ */ J.jsx(
            "span",
            {
              style: {
                ...B1,
                bottom: -22,
                left: "50%",
                transform: "translateX(-50%)",
                color: g ? "#cbd5e1" : "#94a3b8"
              },
              children: p.label
            }
          )
        },
        `out-${p.name}`
      );
    })
  ] });
}
const tv = {
  background: "none",
  border: "1px solid #e2e8f0",
  borderRadius: 8,
  padding: "3px 17px",
  cursor: "pointer",
  fontSize: 19,
  fontWeight: 500,
  color: "#64748b",
  transition: "all 0.15s"
}, ev = {
  fontSize: 22,
  fontWeight: 600,
  color: "#1e293b",
  wordBreak: "break-all"
};
function Vw({
  options: n,
  value: t,
  onChange: e,
  disabledOptions: r
}) {
  return /* @__PURE__ */ J.jsx(
    "div",
    {
      style: {
        display: "flex",
        borderRadius: 10,
        overflow: "hidden",
        border: "1px solid #e2e8f0",
        marginBottom: 10
      },
      children: n.map((a, o) => {
        const c = a.value === t, u = (r == null ? void 0 : r.has(a.value)) ?? !1;
        return /* @__PURE__ */ J.jsx(
          "button",
          {
            onClick: c || u ? void 0 : () => e(a.value),
            style: {
              flex: 1,
              background: c ? "rgba(59,130,246,0.08)" : "none",
              border: "none",
              borderRight: o < n.length - 1 ? "1px solid #e2e8f0" : "none",
              padding: "7px 0",
              cursor: c || u ? "default" : "pointer",
              fontSize: 19,
              fontWeight: 500,
              color: u ? "#cbd5e1" : c ? "#3b82f6" : "#94a3b8",
              transition: "all 0.15s"
            },
            disabled: u,
            children: a.label
          },
          a.value
        );
      })
    }
  );
}
const aH = ".pdb,.gro,.xyz,.mol,.sdf", V1 = [".pdb", ".gro", ".xyz", ".mol", ".sdf"];
function oH({ id: n, data: t }) {
  const e = $e((h) => h.updateNodeParams), r = t.params, a = ct.useRef(null), o = ct.useCallback(
    (h) => {
      const p = h.name.toLowerCase();
      V1.some((m) => p.endsWith(m)) && e(n, { fileName: h.name });
    },
    [n, e]
  ), c = ct.useCallback(
    (h) => {
      h.preventDefault(), h.stopPropagation();
      const m = Array.from(h.dataTransfer.files).find(
        (g) => V1.some((_) => g.name.toLowerCase().endsWith(_))
      );
      m && o(m);
    },
    [o]
  ), u = ct.useCallback((h) => {
    h.preventDefault(), h.stopPropagation();
  }, []), d = /* @__PURE__ */ new Set();
  return r.hasTrajectory || d.add("trajectory"), r.hasCell || d.add("cell"), /* @__PURE__ */ J.jsx(xr, { id: n, nodeType: "load_structure", enabled: t.enabled, disabledPorts: d, children: /* @__PURE__ */ J.jsxs("div", { onDrop: c, onDragOver: u, children: [
    r.fileName ? /* @__PURE__ */ J.jsx("div", { style: ev, children: r.fileName }) : /* @__PURE__ */ J.jsx("div", { style: { fontSize: 20, color: "#94a3b8", fontStyle: "italic" }, children: "No structure loaded" }),
    /* @__PURE__ */ J.jsx(
      "button",
      {
        onClick: () => {
          var h;
          return (h = a.current) == null ? void 0 : h.click();
        },
        style: { ...tv, marginTop: 6, width: "100%" },
        children: "Load structure..."
      }
    ),
    /* @__PURE__ */ J.jsx(
      "input",
      {
        ref: a,
        type: "file",
        accept: aH,
        onChange: (h) => {
          var m;
          const p = (m = h.target.files) == null ? void 0 : m[0];
          p && o(p), h.target.value = "";
        },
        style: { display: "none" }
      }
    )
  ] }) });
}
const lH = ".xtc", k1 = [".xtc"];
function cH({ id: n, data: t }) {
  const e = $e((d) => d.updateNodeParams), r = t.params, a = ct.useRef(null), o = ct.useCallback(
    (d) => {
      const h = d.name.toLowerCase();
      k1.some((p) => h.endsWith(p)) && e(n, { fileName: d.name });
    },
    [n, e]
  ), c = ct.useCallback(
    (d) => {
      d.preventDefault(), d.stopPropagation();
      const p = Array.from(d.dataTransfer.files).find(
        (m) => k1.some((g) => m.name.toLowerCase().endsWith(g))
      );
      p && o(p);
    },
    [o]
  ), u = ct.useCallback((d) => {
    d.preventDefault(), d.stopPropagation();
  }, []);
  return /* @__PURE__ */ J.jsx(xr, { id: n, nodeType: "load_trajectory", enabled: t.enabled, children: /* @__PURE__ */ J.jsxs("div", { onDrop: c, onDragOver: u, children: [
    r.fileName ? /* @__PURE__ */ J.jsx("div", { style: ev, children: r.fileName }) : /* @__PURE__ */ J.jsx("div", { style: { fontSize: 20, color: "#94a3b8", fontStyle: "italic" }, children: "No trajectory loaded" }),
    /* @__PURE__ */ J.jsx(
      "button",
      {
        onClick: () => {
          var d;
          return (d = a.current) == null ? void 0 : d.click();
        },
        style: { ...tv, marginTop: 6, width: "100%" },
        children: "Load trajectory..."
      }
    ),
    /* @__PURE__ */ J.jsx(
      "input",
      {
        ref: a,
        type: "file",
        accept: lH,
        onChange: (d) => {
          var p;
          const h = (p = d.target.files) == null ? void 0 : p[0];
          h && o(h), d.target.value = "";
        },
        style: { display: "none" }
      }
    )
  ] }) });
}
const uH = {
  fontSize: 17,
  fontWeight: 600,
  color: "#94a3b8",
  textTransform: "uppercase",
  letterSpacing: "0.06em",
  marginBottom: 7,
  marginTop: 0
};
function fH({ id: n, data: t }) {
  const e = $e((a) => a.updateNodeParams), r = t.params;
  return /* @__PURE__ */ J.jsxs(xr, { id: n, nodeType: "add_bond", enabled: t.enabled, children: [
    /* @__PURE__ */ J.jsx("div", { style: uH, children: "Source" }),
    /* @__PURE__ */ J.jsx(
      Vw,
      {
        options: [
          { value: "structure", label: "File" },
          { value: "distance", label: "VDW" }
        ],
        value: r.bondSource,
        onChange: (a) => e(n, { bondSource: a })
      }
    )
  ] });
}
const G1 = {
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  fontSize: 19,
  color: "#475569",
  padding: "3px 0"
}, X1 = {
  cursor: "pointer",
  accentColor: "#3b82f6"
};
function dH({ id: n, data: t }) {
  const e = $e((a) => a.updateNodeParams), r = t.params;
  return /* @__PURE__ */ J.jsx(xr, { id: n, nodeType: "viewport", enabled: t.enabled, children: /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 7 }, children: [
    /* @__PURE__ */ J.jsxs("label", { style: G1, children: [
      "Perspective",
      /* @__PURE__ */ J.jsx(
        "input",
        {
          type: "checkbox",
          checked: r.perspective,
          onChange: (a) => e(n, { perspective: a.target.checked }),
          style: X1
        }
      )
    ] }),
    /* @__PURE__ */ J.jsxs("label", { style: G1, children: [
      "Cell axes",
      /* @__PURE__ */ J.jsx(
        "input",
        {
          type: "checkbox",
          checked: r.cellAxesVisible,
          onChange: (a) => e(n, { cellAxesVisible: a.target.checked }),
          style: X1
        }
      )
    ] })
  ] }) });
}
const kw = {
  width: "100%",
  padding: "7px 10px",
  fontSize: 19,
  fontFamily: "monospace",
  border: "1px solid #e2e8f0",
  borderRadius: 7,
  outline: "none",
  background: "#f8fafc",
  color: "#1e293b",
  boxSizing: "border-box"
}, hH = {
  ...kw,
  borderColor: "#ef4444",
  background: "#fef2f2"
}, pH = {
  fontSize: 17,
  color: "#ef4444",
  marginTop: 7,
  lineHeight: 1.3
}, mH = {
  fontSize: 15,
  color: "#94a3b8",
  marginTop: 7,
  lineHeight: 1.3
};
function gH({ id: n, data: t }) {
  const e = $e((p) => p.updateNodeParams), r = t.params, [a, o] = ct.useState(r.query), [c, u] = ct.useState(null);
  ct.useEffect(() => {
    o(r.query);
  }, [r.query]);
  const d = ct.useCallback(() => {
    const p = J5(a);
    u(p.valid ? null : p.error ?? "Invalid query"), e(n, { query: a });
  }, [n, a, e]), h = ct.useCallback(
    (p) => {
      p.key === "Enter" && d();
    },
    [d]
  );
  return /* @__PURE__ */ J.jsxs(xr, { id: n, nodeType: "filter", enabled: t.enabled, children: [
    /* @__PURE__ */ J.jsx(
      "input",
      {
        value: a,
        onChange: (p) => o(p.target.value),
        onBlur: d,
        onKeyDown: h,
        placeholder: 'element == "C"',
        style: c ? hH : kw
      }
    ),
    c && /* @__PURE__ */ J.jsx("div", { style: pH, children: c }),
    !c && !a && /* @__PURE__ */ J.jsx("div", { style: mH, children: "element, index, x, y, z, resname, mass" })
  ] });
}
const j1 = {
  width: "100%",
  height: 7,
  cursor: "pointer",
  appearance: "none",
  WebkitAppearance: "none",
  borderRadius: 3,
  outline: "none"
}, W1 = {
  fontSize: 19,
  fontWeight: 500,
  color: "#3b82f6",
  minWidth: 50,
  textAlign: "right"
}, Y1 = {
  fontSize: 17,
  fontWeight: 500,
  color: "#64748b",
  marginBottom: 3
};
function vH({ id: n, data: t }) {
  const e = $e((a) => a.updateNodeParams), r = t.params;
  return /* @__PURE__ */ J.jsx(xr, { id: n, nodeType: "modify", enabled: t.enabled, children: /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 10 }, children: [
    /* @__PURE__ */ J.jsxs("div", { children: [
      /* @__PURE__ */ J.jsx("div", { style: Y1, children: "Scale" }),
      /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
        /* @__PURE__ */ J.jsx(
          "input",
          {
            className: "nodrag",
            type: "range",
            min: 0.1,
            max: 2,
            step: 0.01,
            value: r.scale,
            onChange: (a) => e(n, { scale: parseFloat(a.target.value) }),
            style: j1
          }
        ),
        /* @__PURE__ */ J.jsx("span", { style: W1, children: r.scale.toFixed(2) })
      ] })
    ] }),
    /* @__PURE__ */ J.jsxs("div", { children: [
      /* @__PURE__ */ J.jsx("div", { style: Y1, children: "Opacity" }),
      /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
        /* @__PURE__ */ J.jsx(
          "input",
          {
            className: "nodrag",
            type: "range",
            min: 0,
            max: 1,
            step: 0.01,
            value: r.opacity,
            onChange: (a) => e(n, { opacity: parseFloat(a.target.value) }),
            style: j1
          }
        ),
        /* @__PURE__ */ J.jsx("span", { style: W1, children: `${Math.round(r.opacity * 100)}%` })
      ] })
    ] })
  ] }) });
}
function _H({ id: n, data: t }) {
  const e = $e((a) => a.updateNodeParams), r = t.params;
  return /* @__PURE__ */ J.jsx(xr, { id: n, nodeType: "label_generator", enabled: t.enabled, children: /* @__PURE__ */ J.jsx(
    Vw,
    {
      options: [
        { value: "element", label: "Element" },
        { value: "resname", label: "Resname" },
        { value: "index", label: "Index" }
      ],
      value: r.source,
      onChange: (a) => e(n, { source: a })
    }
  ) });
}
const yH = [
  { z: 14, sym: "Si" },
  { z: 13, sym: "Al" },
  { z: 22, sym: "Ti" },
  { z: 26, sym: "Fe" },
  { z: 40, sym: "Zr" },
  { z: 25, sym: "Mn" },
  { z: 27, sym: "Co" },
  { z: 28, sym: "Ni" },
  { z: 24, sym: "Cr" },
  { z: 30, sym: "Zn" },
  { z: 12, sym: "Mg" },
  { z: 20, sym: "Ca" }
], xH = [
  { z: 8, sym: "O" },
  { z: 9, sym: "F" },
  { z: 17, sym: "Cl" },
  { z: 7, sym: "N" },
  { z: 16, sym: "S" }
], Vo = {
  fontSize: 17,
  fontWeight: 500,
  color: "#64748b",
  marginBottom: 3
}, SH = {
  display: "flex",
  flexWrap: "wrap",
  gap: 5,
  marginBottom: 10
}, Gw = {
  border: "1px solid #e2e8f0",
  borderRadius: 7,
  padding: "3px 10px",
  cursor: "pointer",
  fontSize: 17,
  fontWeight: 500,
  background: "none",
  color: "#94a3b8",
  transition: "all 0.15s",
  lineHeight: "27px"
}, bH = {
  ...Gw,
  background: "rgba(59, 130, 246, 0.08)",
  borderColor: "rgba(59, 130, 246, 0.25)",
  color: "#3b82f6"
}, ig = {
  width: "100%",
  height: 7,
  cursor: "pointer",
  appearance: "none",
  WebkitAppearance: "none",
  borderRadius: 3,
  outline: "none"
}, rg = {
  fontSize: 19,
  fontWeight: 500,
  color: "#3b82f6",
  minWidth: 50,
  textAlign: "right"
}, MH = {
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  fontSize: 19,
  color: "#475569",
  padding: "3px 0"
}, EH = {
  cursor: "pointer",
  accentColor: "#3b82f6"
};
function q1({
  elements: n,
  selected: t,
  onChange: e
}) {
  const r = new Set(t), a = ct.useCallback(
    (o) => {
      const c = new Set(r);
      c.has(o) ? c.delete(o) : c.add(o), e([...c]);
    },
    [r, e]
  );
  return /* @__PURE__ */ J.jsx("div", { style: SH, children: n.map(({ z: o, sym: c }) => /* @__PURE__ */ J.jsx(
    "button",
    {
      onClick: () => a(o),
      style: r.has(o) ? bH : Gw,
      children: c
    },
    o
  )) });
}
function wH({ id: n, data: t }) {
  const e = $e((a) => a.updateNodeParams), r = t.params;
  return /* @__PURE__ */ J.jsx(xr, { id: n, nodeType: "polyhedron_generator", enabled: t.enabled, children: /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
    /* @__PURE__ */ J.jsxs("div", { children: [
      /* @__PURE__ */ J.jsx("div", { style: Vo, children: "Center" }),
      /* @__PURE__ */ J.jsx(
        q1,
        {
          elements: yH,
          selected: r.centerElements,
          onChange: (a) => e(n, { centerElements: a })
        }
      )
    ] }),
    /* @__PURE__ */ J.jsxs("div", { children: [
      /* @__PURE__ */ J.jsx("div", { style: Vo, children: "Ligand" }),
      /* @__PURE__ */ J.jsx(
        q1,
        {
          elements: xH,
          selected: r.ligandElements,
          onChange: (a) => e(n, { ligandElements: a })
        }
      )
    ] }),
    /* @__PURE__ */ J.jsxs("div", { children: [
      /* @__PURE__ */ J.jsx("div", { style: Vo, children: "Max distance" }),
      /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
        /* @__PURE__ */ J.jsx(
          "input",
          {
            className: "nodrag",
            type: "range",
            min: 1,
            max: 5,
            step: 0.1,
            value: r.maxDistance,
            onChange: (a) => e(n, { maxDistance: parseFloat(a.target.value) }),
            style: ig
          }
        ),
        /* @__PURE__ */ J.jsx("span", { style: rg, children: r.maxDistance.toFixed(1) })
      ] })
    ] }),
    /* @__PURE__ */ J.jsxs("div", { children: [
      /* @__PURE__ */ J.jsx("div", { style: Vo, children: "Opacity" }),
      /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
        /* @__PURE__ */ J.jsx(
          "input",
          {
            className: "nodrag",
            type: "range",
            min: 0,
            max: 1,
            step: 0.05,
            value: r.opacity,
            onChange: (a) => e(n, { opacity: parseFloat(a.target.value) }),
            style: ig
          }
        ),
        /* @__PURE__ */ J.jsx("span", { style: rg, children: `${Math.round(r.opacity * 100)}%` })
      ] })
    ] }),
    /* @__PURE__ */ J.jsxs("label", { style: MH, children: [
      "Show edges",
      /* @__PURE__ */ J.jsx(
        "input",
        {
          type: "checkbox",
          checked: r.showEdges,
          onChange: (a) => e(n, { showEdges: a.target.checked }),
          style: EH
        }
      )
    ] }),
    r.showEdges && /* @__PURE__ */ J.jsxs(J.Fragment, { children: [
      /* @__PURE__ */ J.jsxs("div", { children: [
        /* @__PURE__ */ J.jsx("div", { style: Vo, children: "Edge color" }),
        /* @__PURE__ */ J.jsx(
          "input",
          {
            type: "color",
            value: r.edgeColor,
            onChange: (a) => e(n, { edgeColor: a.target.value }),
            style: { width: "100%", height: 28, cursor: "pointer", border: "1px solid #e2e8f0", borderRadius: 4 }
          }
        )
      ] }),
      /* @__PURE__ */ J.jsxs("div", { children: [
        /* @__PURE__ */ J.jsx("div", { style: Vo, children: "Edge width" }),
        /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
          /* @__PURE__ */ J.jsx(
            "input",
            {
              className: "nodrag",
              type: "range",
              min: 1,
              max: 10,
              step: 0.5,
              value: r.edgeWidth,
              onChange: (a) => e(n, { edgeWidth: parseFloat(a.target.value) }),
              style: ig
            }
          ),
          /* @__PURE__ */ J.jsx("span", { style: rg, children: r.edgeWidth.toFixed(1) })
        ] })
      ] })
    ] })
  ] }) });
}
const TH = ".vec", Z1 = [".vec"];
function AH({ id: n, data: t }) {
  const e = $e((d) => d.updateNodeParams), r = t.params, a = ct.useRef(null), o = ct.useCallback(
    (d) => {
      const h = d.name.toLowerCase();
      Z1.some((p) => h.endsWith(p)) && e(n, { fileName: d.name });
    },
    [n, e]
  ), c = ct.useCallback(
    (d) => {
      d.preventDefault(), d.stopPropagation();
      const p = Array.from(d.dataTransfer.files).find(
        (m) => Z1.some((g) => m.name.toLowerCase().endsWith(g))
      );
      p && o(p);
    },
    [o]
  ), u = ct.useCallback((d) => {
    d.preventDefault(), d.stopPropagation();
  }, []);
  return /* @__PURE__ */ J.jsx(xr, { id: n, nodeType: "load_vector", enabled: t.enabled, children: /* @__PURE__ */ J.jsxs("div", { onDrop: c, onDragOver: u, children: [
    r.fileName ? /* @__PURE__ */ J.jsx("div", { style: ev, children: r.fileName }) : /* @__PURE__ */ J.jsx("div", { style: { fontSize: 20, color: "#94a3b8", fontStyle: "italic" }, children: "No vector file loaded" }),
    /* @__PURE__ */ J.jsx(
      "button",
      {
        onClick: () => {
          var d;
          return (d = a.current) == null ? void 0 : d.click();
        },
        style: { ...tv, marginTop: 6, width: "100%" },
        children: "Load vectors..."
      }
    ),
    /* @__PURE__ */ J.jsx(
      "input",
      {
        ref: a,
        type: "file",
        accept: TH,
        onChange: (d) => {
          var p;
          const h = (p = d.target.files) == null ? void 0 : p[0];
          h && o(h), d.target.value = "";
        },
        style: { display: "none" }
      }
    )
  ] }) });
}
const CH = {
  fontSize: 17,
  fontWeight: 500,
  color: "#64748b",
  marginBottom: 3
}, RH = {
  width: "100%",
  height: 7,
  cursor: "pointer"
}, DH = {
  fontSize: 18,
  fontWeight: 500,
  color: "#3b82f6",
  minWidth: 40,
  textAlign: "right"
};
function NH({ id: n, data: t }) {
  const e = $e((a) => a.updateNodeParams), r = t.params;
  return /* @__PURE__ */ J.jsxs(xr, { id: n, nodeType: "vector_overlay", enabled: t.enabled, children: [
    /* @__PURE__ */ J.jsx("div", { style: CH, children: "Scale" }),
    /* @__PURE__ */ J.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
      /* @__PURE__ */ J.jsx(
        "input",
        {
          className: "nodrag",
          type: "range",
          min: 0.1,
          max: 5,
          step: 0.1,
          value: r.scale,
          onChange: (a) => e(n, { scale: parseFloat(a.target.value) }),
          style: RH
        }
      ),
      /* @__PURE__ */ J.jsx("span", { style: DH, children: r.scale.toFixed(1) })
    ] })
  ] });
}
const LH = {
  load_structure: oH,
  load_trajectory: cH,
  load_vector: AH,
  add_bond: fH,
  viewport: dH,
  filter: gH,
  modify: vH,
  label_generator: _H,
  polyhedron_generator: wH,
  vector_overlay: NH
}, UH = [
  { category: "data_load", label: "Data Load", types: ["load_structure", "load_trajectory", "load_vector"] },
  { category: "bond", label: "Bond", types: ["add_bond"] },
  { category: "filter", label: "Filter", types: ["filter"] },
  { category: "modify", label: "Modify", types: ["modify"] },
  { category: "overlay", label: "Overlay", types: ["label_generator", "polyhedron_generator", "vector_overlay"] }
], OH = 320, PH = 600, zH = 480, IH = {
  background: "rgba(59, 130, 246, 0.08)",
  border: "1px solid rgba(59, 130, 246, 0.25)",
  borderRadius: 6,
  padding: "4px 12px",
  cursor: "pointer",
  fontSize: 11,
  fontWeight: 600,
  color: "#3b82f6"
}, $1 = {
  position: "absolute",
  top: "100%",
  right: 0,
  marginTop: 4,
  background: "white",
  border: "1px solid #e2e8f0",
  borderRadius: 8,
  boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
  zIndex: 100,
  minWidth: 180,
  padding: "4px 0"
}, K1 = {
  display: "block",
  width: "100%",
  background: "none",
  border: "none",
  padding: "6px 14px 6px 20px",
  cursor: "pointer",
  fontSize: 12,
  color: "#334155",
  textAlign: "left"
}, BH = {
  fontSize: 10,
  fontWeight: 600,
  color: "#94a3b8",
  textTransform: "uppercase",
  letterSpacing: "0.06em",
  padding: "6px 14px 2px",
  display: "flex",
  alignItems: "center",
  gap: 6
}, FH = {
  background: "rgba(16, 185, 129, 0.08)",
  border: "1px solid rgba(16, 185, 129, 0.25)",
  borderRadius: 6,
  padding: "4px 12px",
  cursor: "pointer",
  fontSize: 11,
  fontWeight: 600,
  color: "#10b981"
}, HH = {
  background: "rgba(139, 92, 246, 0.08)",
  border: "1px solid rgba(139, 92, 246, 0.25)",
  borderRadius: 6,
  padding: "4px 12px",
  cursor: "pointer",
  fontSize: 11,
  fontWeight: 600,
  color: "#8b5cf6"
}, VH = {
  fontSize: 10,
  color: "#94a3b8",
  marginTop: 1
}, kH = {
  position: "absolute",
  left: 0,
  top: 0,
  bottom: 0,
  width: 5,
  cursor: "col-resize",
  zIndex: 20,
  background: "transparent"
};
function GH(n, t) {
  if (!n || !t) return "#94a3b8";
  const e = kc[n];
  if (!e) return "#94a3b8";
  const r = e.outputs.find((a) => a.name === t);
  return r ? Cw[r.dataType] : "#94a3b8";
}
function XH({
  collapsed: n,
  onToggleCollapse: t,
  onWidthChange: e
}) {
  const r = $e((C) => C.nodes), a = $e((C) => C.edges), o = $e((C) => C.onNodesChange), c = $e((C) => C.onEdgesChange), u = $e((C) => C.onConnect), d = $e((C) => C.addNode), h = $e((C) => C.applyTemplate), p = $e((C) => C.autoLayout), { fitView: m } = Vc(), { screenToFlowPosition: g } = Vc(), [_, b] = ct.useState(!1), [E, S] = ct.useState(!1), [y, A] = ct.useState(zH), w = ct.useRef(null), M = ct.useRef(null), O = ct.useCallback((C) => {
    C.preventDefault(), w.current = { startX: C.clientX, startWidth: y };
    const X = (V) => {
      if (!w.current) return;
      const H = w.current.startWidth - (V.clientX - w.current.startX), j = Math.max(OH, Math.min(PH, H));
      A(j), e == null || e(j);
    }, D = () => {
      w.current = null, document.removeEventListener("mousemove", X), document.removeEventListener("mouseup", D);
    };
    document.addEventListener("mousemove", X), document.addEventListener("mouseup", D);
  }, [y, e]), L = ct.useCallback(
    (C) => {
      if (C.source === C.target) return !1;
      const X = r.find((V) => V.id === C.source), D = r.find((V) => V.id === C.target);
      return !(X != null && X.type) || !(D != null && D.type) ? !1 : Lw(
        X.type,
        C.sourceHandle ?? null,
        D.type,
        C.targetHandle ?? null
      );
    },
    [r]
  ), N = ct.useMemo(() => a.map((C) => {
    const X = r.find((V) => V.id === C.source), D = GH(X == null ? void 0 : X.type, C.sourceHandle ?? null);
    return {
      ...C,
      animated: !0,
      style: {
        stroke: D,
        strokeWidth: 2
      }
    };
  }), [a, r]), z = ct.useCallback(
    (C) => {
      const X = M.current;
      if (X) {
        const D = X.getBoundingClientRect(), V = g({
          x: D.left + D.width / 2,
          y: D.top + D.height / 2
        });
        d(C, V);
      } else
        d(C);
      b(!1);
    },
    [d, g]
  ), R = ct.useCallback(
    (C) => {
      h(C), S(!1);
    },
    [h]
  ), T = ct.useCallback(() => {
    p(), window.requestAnimationFrame(() => {
      m({ padding: 0.1, maxZoom: 1.95, duration: 300 });
    });
  }, [p, m]), U = ct.useMemo(() => LH, []), B = /* @__PURE__ */ J.jsxs(J.Fragment, { children: [
    /* @__PURE__ */ J.jsx("button", { onClick: T, style: FH, children: "Auto Layout" }),
    /* @__PURE__ */ J.jsx(
      "button",
      {
        onClick: () => {
          S(!E), b(!1);
        },
        style: HH,
        children: "Templates"
      }
    ),
    E && /* @__PURE__ */ J.jsx("div", { style: { ...$1, right: "auto", left: 0 }, children: Iw.map((C) => /* @__PURE__ */ J.jsxs(
      "button",
      {
        onClick: () => R(C.id),
        style: { ...K1, padding: "8px 14px" },
        onMouseEnter: (X) => {
          X.target.style.background = "rgba(139,92,246,0.06)";
        },
        onMouseLeave: (X) => {
          X.target.style.background = "none";
        },
        children: [
          /* @__PURE__ */ J.jsx("div", { style: { fontWeight: 500 }, children: C.label }),
          /* @__PURE__ */ J.jsx("div", { style: VH, children: C.description })
        ]
      },
      C.id
    )) }),
    /* @__PURE__ */ J.jsx(
      "button",
      {
        onClick: () => {
          b(!_), S(!1);
        },
        style: IH,
        children: "+ Add Node"
      }
    ),
    _ && /* @__PURE__ */ J.jsx("div", { style: $1, children: UH.map((C) => /* @__PURE__ */ J.jsxs("div", { children: [
      /* @__PURE__ */ J.jsxs("div", { style: BH, children: [
        /* @__PURE__ */ J.jsx(
          "span",
          {
            style: {
              width: 6,
              height: 6,
              borderRadius: "50%",
              background: Dw[C.category],
              display: "inline-block",
              flexShrink: 0
            }
          }
        ),
        C.label
      ] }),
      C.types.map((X) => /* @__PURE__ */ J.jsx(
        "button",
        {
          onClick: () => z(X),
          style: K1,
          onMouseEnter: (D) => {
            D.target.style.background = "rgba(59,130,246,0.06)";
          },
          onMouseLeave: (D) => {
            D.target.style.background = "none";
          },
          children: Rw[X]
        },
        X
      ))
    ] }, C.category)) })
  ] }), I = /* @__PURE__ */ J.jsx(
    "div",
    {
      style: kH,
      onMouseDown: O,
      onMouseEnter: (C) => {
        C.currentTarget.style.background = "rgba(59,130,246,0.15)";
      },
      onMouseLeave: (C) => {
        C.currentTarget.style.background = "transparent";
      }
    }
  );
  return /* @__PURE__ */ J.jsx(
    tH,
    {
      title: "Pipeline",
      collapsed: n,
      onToggleCollapse: t,
      width: y,
      headerExtra: B,
      containerExtra: I,
      children: /* @__PURE__ */ J.jsx("div", { ref: M, style: { flex: 1, position: "relative" }, children: /* @__PURE__ */ J.jsxs(
        u5,
        {
          nodes: r,
          edges: N,
          onNodesChange: o,
          onEdgesChange: c,
          onConnect: u,
          isValidConnection: L,
          nodeTypes: U,
          fitView: !0,
          fitViewOptions: { padding: 0.1, maxZoom: 1.95 },
          minZoom: 0.3,
          maxZoom: 2,
          defaultEdgeOptions: {
            type: "bezier",
            animated: !0,
            style: { stroke: "#94a3b8", strokeWidth: 3 }
          },
          proOptions: { hideAttribution: !0 },
          children: [
            /* @__PURE__ */ J.jsx(m5, { variant: ts.Dots, gap: 16, size: 1, color: "#e2e8f0" }),
            /* @__PURE__ */ J.jsx(
              P5,
              {
                style: {
                  background: "rgba(255,255,255,0.8)",
                  border: "1px solid #e2e8f0",
                  borderRadius: 6,
                  width: 100,
                  height: 70
                },
                nodeColor: "#3b82f6",
                maskColor: "rgba(59,130,246,0.05)"
              }
            ),
            /* @__PURE__ */ J.jsx(
              b5,
              {
                showInteractive: !1,
                style: {
                  border: "1px solid #e2e8f0",
                  borderRadius: 6,
                  boxShadow: "none"
                }
              }
            )
          ]
        }
      ) })
    }
  );
}
function jH({
  collapsed: n,
  onToggleCollapse: t,
  onWidthChange: e
}) {
  return /* @__PURE__ */ J.jsx(Ew, { children: /* @__PURE__ */ J.jsx(
    XH,
    {
      collapsed: n,
      onToggleCollapse: t,
      onWidthChange: e
    }
  ) });
}
function Xw({
  currentFrame: n,
  totalFrames: t,
  playing: e,
  fps: r,
  onSeek: a,
  onPlayPause: o,
  onFpsChange: c
}) {
  return t <= 1 ? null : /* @__PURE__ */ J.jsxs(
    "div",
    {
      style: {
        position: "absolute",
        bottom: 0,
        left: 0,
        right: 0,
        padding: "10px 20px 14px",
        background: "rgba(255, 255, 255, 0.88)",
        backdropFilter: "blur(16px)",
        WebkitBackdropFilter: "blur(16px)",
        borderTop: "1px solid rgba(226,232,240,0.6)",
        boxShadow: "0 -1px 8px rgba(0,0,0,0.04)",
        display: "flex",
        alignItems: "center",
        gap: 12,
        zIndex: 10,
        fontSize: 13,
        color: "#64748b"
      },
      children: [
        /* @__PURE__ */ J.jsx(
          "button",
          {
            onClick: o,
            style: {
              background: "none",
              border: "1px solid #e2e8f0",
              borderRadius: 8,
              width: 32,
              height: 32,
              cursor: "pointer",
              display: "flex",
              alignItems: "center",
              justifyContent: "center",
              fontSize: 14,
              fontWeight: 500,
              color: "#64748b",
              flexShrink: 0,
              transition: "all 0.15s"
            },
            title: e ? "Pause" : "Play",
            children: e ? "⏸" : "▶"
          }
        ),
        /* @__PURE__ */ J.jsxs(
          "span",
          {
            style: {
              minWidth: 80,
              textAlign: "center",
              fontVariantNumeric: "tabular-nums",
              fontWeight: 500,
              color: "#64748b",
              flexShrink: 0
            },
            children: [
              n + 1,
              " / ",
              t
            ]
          }
        ),
        /* @__PURE__ */ J.jsx(
          "input",
          {
            type: "range",
            min: 0,
            max: t - 1,
            value: n,
            onChange: (u) => a(parseInt(u.target.value, 10)),
            style: {
              flex: 1,
              height: 4,
              cursor: "pointer",
              accentColor: "#3b82f6"
            }
          }
        ),
        /* @__PURE__ */ J.jsxs(
          "select",
          {
            value: r,
            onChange: (u) => c(parseInt(u.target.value, 10)),
            style: {
              background: "rgba(255,255,255,0.8)",
              border: "1px solid #e2e8f0",
              borderRadius: 6,
              padding: "2px 6px",
              fontSize: 12,
              fontWeight: 500,
              color: "#64748b",
              cursor: "pointer",
              flexShrink: 0
            },
            children: [
              /* @__PURE__ */ J.jsx("option", { value: 10, children: "10 fps" }),
              /* @__PURE__ */ J.jsx("option", { value: 20, children: "20 fps" }),
              /* @__PURE__ */ J.jsx("option", { value: 30, children: "30 fps" }),
              /* @__PURE__ */ J.jsx("option", { value: 60, children: "60 fps" })
            ]
          }
        )
      ]
    }
  );
}
function WH(n, t) {
  if (!n.fileVectors || n.fileVectors.length === 0) return null;
  if (n.fileVectors.length === 1) return n.fileVectors[0].vectors;
  const e = n.fileVectors.find((r) => r.frame === t);
  return (e == null ? void 0 : e.vectors) ?? null;
}
function sg(n, t, e) {
  const r = t.particles.length > 0, a = ((e == null ? void 0 : e.particles.length) ?? 0) > 0;
  (!e || r !== a) && n.setAtomsVisible(r), YH(n, t.particles, (e == null ? void 0 : e.particles) ?? null), qH(n, t.bonds, (e == null ? void 0 : e.bonds) ?? null);
  const o = t.cells.length > 0, c = ((e == null ? void 0 : e.cells.length) ?? 0) > 0, u = o && t.cells.some((g) => g.visible), d = c && ((e == null ? void 0 : e.cells.some((g) => g.visible)) ?? !1);
  (!e || u !== d) && n.setCellVisible(u);
  const h = o && t.cells.some((g) => g.axesVisible);
  (!e || h !== (e.cellAxesVisible ?? !0)) && n.setCellAxesVisible(h), (!e || t.perspective !== e.perspective) && n.setPerspective(t.perspective), (!e || t.cellAxesVisible !== e.cellAxesVisible) && n.setCellAxesVisible(t.cellAxesVisible), ZH(n, t.labels, (e == null ? void 0 : e.labels) ?? null), $H(n, t.meshes, (e == null ? void 0 : e.meshes) ?? null), KH(n, t.vectors, (e == null ? void 0 : e.vectors) ?? null);
  const p = t.bonds.length > 0, m = ((e == null ? void 0 : e.bonds.length) ?? 0) > 0;
  (!e || p !== m) && n.setBondsVisible(p);
}
function YH(n, t, e) {
  if (t.length === 0) {
    e && e.length > 0 && (n.clearAtomOverrides(), n.setAtomScale(1), n.setAtomOpacity(1));
    return;
  }
  let r = null, a = null;
  for (const o of t) {
    if (o.scaleOverrides)
      if (!r)
        r = new Float32Array(o.scaleOverrides);
      else
        for (let c = 0; c < r.length; c++)
          o.scaleOverrides[c] !== 1 && (r[c] = o.scaleOverrides[c]);
    if (o.opacityOverrides)
      if (!a)
        a = new Float32Array(o.opacityOverrides);
      else
        for (let c = 0; c < a.length; c++)
          o.opacityOverrides[c] !== 1 && (a[c] = o.opacityOverrides[c]);
  }
  r ? (n.setAtomScale(1), n.setAtomScaleOverrides(r)) : (n.clearAtomOverrides(), n.setAtomScale(1)), a ? (n.setAtomOpacity(1), n.setAtomOpacityOverrides(a)) : n.setAtomOpacity(1);
}
function qH(n, t, e) {
  if (t.length === 0) return;
  const r = t[0], a = e == null ? void 0 : e[0];
  (!a || r.bondIndices !== a.bondIndices) && n.updateBondsExt(
    r.bondIndices,
    r.bondOrders,
    r.positions,
    r.elements,
    r.nAtoms
  ), (!a || r.scale !== a.scale) && n.setBondScale(r.scale), (!a || r.opacity !== a.opacity) && n.setBondOpacity(r.opacity);
}
function ZH(n, t, e) {
  t.length > 0 ? n.setLabels(t[0].labels) : e && e.length > 0 && n.setLabels(null);
}
function $H(n, t, e) {
  t.length > 0 ? n.loadPolyhedra(t[0]) : e && e.length > 0 && n.clearPolyhedra();
}
function KH(n, t, e) {
  if (t.length > 0) {
    const r = t[0], a = WH({ fileVectors: r.frames }, 0);
    n.setVectors(a), n.setVectorScale(r.scale);
  } else e && e.length > 0 && n.setVectors(null);
}
function QH(n) {
  return n.pipeline ? /* @__PURE__ */ J.jsx(JH, { ...n }) : /* @__PURE__ */ J.jsx(t8, { ...n });
}
function JH({
  snapshot: n,
  frame: t,
  currentFrame: e,
  totalFrames: r,
  onSeek: a,
  pipelineJson: o,
  onPipelineChange: c
}) {
  const u = ct.useRef(null), d = ct.useRef(null), [h, p] = ct.useState(!1), [m, g] = ct.useState(30), _ = typeof window < "u" && window.innerWidth < 768, [b, E] = ct.useState(_), S = ct.useRef(_), y = ct.useRef(480), A = ct.useRef(null);
  ct.useEffect(() => {
    S.current = b;
  }, [b]);
  const w = $e((I) => I.viewportState), M = $e((I) => I.setSnapshot);
  ct.useEffect(() => {
    M(n);
    const I = u.current;
    if (I) {
      const C = $e.getState().viewportState;
      sg(I, C, null), A.current = C;
    }
  }, [n, M]), ct.useEffect(() => {
    const I = u.current;
    I && (sg(I, w, A.current), A.current = w);
  }, [w]), ct.useEffect(() => {
    const C = $e.getState().nodes.find((j) => j.type === "add_bond");
    if (!C) return;
    const X = C.data.params;
    if (X.type !== "add_bond" || X.bondSource !== "distance" || !n || !t) return;
    const D = u.current;
    if (!D) return;
    const V = Uw(
      t.positions,
      n.elements,
      n.nAtoms,
      0.6,
      n.box
    ), H = d0(
      V,
      null,
      t.positions,
      n.elements,
      n.nAtoms,
      n.box
    );
    D.updateBondsExt(
      H.bondIndices,
      H.bondOrders,
      H.positions,
      H.elements,
      H.nAtoms
    );
  }, [t, n]);
  const O = ct.useRef("");
  ct.useEffect(() => {
    if (!(!o || o === O.current)) {
      O.current = o;
      try {
        const I = JSON.parse(o);
        $e.getState().deserialize(I);
      } catch {
      }
    }
  }, [o]);
  const L = ct.useRef(null);
  ct.useEffect(() => {
    c && (L.current && clearTimeout(L.current), L.current = setTimeout(() => {
      const I = $e.getState().serialize(), C = JSON.stringify(I);
      C !== O.current && (O.current = C, c(C));
    }, 500));
  }, [w, c]);
  const N = ct.useCallback((I) => {
    u.current = I, I.setViewInsets(
      0,
      S.current ? 0 : y.current + 12
    ), sg(I, $e.getState().viewportState, null), A.current = $e.getState().viewportState;
  }, []), z = ct.useCallback(() => {
    E((I) => !I);
  }, []), R = ct.useCallback((I) => {
    var C;
    y.current = I, S.current || (C = u.current) == null || C.setViewInsets(0, I + 12);
  }, []);
  ct.useEffect(() => {
    var I;
    (I = u.current) == null || I.setViewInsets(
      0,
      b ? 0 : y.current + 12
    );
  }, [b]);
  const T = ct.useCallback(() => {
    p((I) => I ? (d.current && (clearInterval(d.current), d.current = null), !1) : (d.current = setInterval(() => {
      a(-1);
    }, 1e3 / m), !0));
  }, [m, a]), U = ct.useCallback(
    (I) => {
      g(I), d.current && (clearInterval(d.current), d.current = setInterval(() => {
        a(-1);
      }, 1e3 / I));
    },
    [a]
  ), B = ct.useCallback(
    (I) => {
      h && (p(!1), d.current && (clearInterval(d.current), d.current = null)), a(I);
    },
    [a, h]
  );
  return /* @__PURE__ */ J.jsxs(
    "div",
    {
      style: {
        width: "100%",
        height: "100%",
        position: "relative",
        overflow: "hidden"
      },
      children: [
        /* @__PURE__ */ J.jsx(
          FM,
          {
            snapshot: n,
            frame: t,
            onRendererReady: N,
            onHover: () => {
            },
            onAtomRightClick: () => {
            },
            onFrameUpdated: () => {
            }
          }
        ),
        /* @__PURE__ */ J.jsx(
          jH,
          {
            collapsed: b,
            onToggleCollapse: z,
            onWidthChange: R
          }
        ),
        r > 1 && /* @__PURE__ */ J.jsx(
          Xw,
          {
            currentFrame: e,
            totalFrames: r,
            playing: h,
            fps: m,
            onSeek: B,
            onPlayPause: T,
            onFpsChange: U
          }
        )
      ]
    }
  );
}
function t8({
  snapshot: n,
  frame: t,
  currentFrame: e,
  totalFrames: r,
  onSeek: a
}) {
  const o = ct.useRef(null), c = ct.useRef(null), [u, d] = ct.useState(!1), [h, p] = ct.useState(30), m = ct.useCallback((E) => {
    o.current = E;
  }, []), g = ct.useCallback(() => {
    d((E) => E ? (c.current && (clearInterval(c.current), c.current = null), !1) : (c.current = setInterval(() => {
      a(-1);
    }, 1e3 / h), !0));
  }, [h, a]), _ = ct.useCallback(
    (E) => {
      p(E), c.current && (clearInterval(c.current), c.current = setInterval(() => {
        a(-1);
      }, 1e3 / E));
    },
    [a]
  ), b = ct.useCallback(
    (E) => {
      u && (d(!1), c.current && (clearInterval(c.current), c.current = null)), a(E);
    },
    [a, u]
  );
  return /* @__PURE__ */ J.jsxs(
    "div",
    {
      style: {
        width: "100%",
        height: "100%",
        position: "relative",
        overflow: "hidden"
      },
      children: [
        /* @__PURE__ */ J.jsx(
          FM,
          {
            snapshot: n,
            frame: t,
            onRendererReady: m,
            onHover: () => {
            },
            onAtomRightClick: () => {
            },
            onFrameUpdated: () => {
            }
          }
        ),
        r > 1 && /* @__PURE__ */ J.jsx(
          Xw,
          {
            currentFrame: e,
            totalFrames: r,
            playing: u,
            fps: h,
            onSeek: b,
            onPlayPause: g,
            onFpsChange: _
          }
        )
      ]
    }
  );
}
const Q1 = 1313293645, e8 = 0, n8 = 1, i8 = 1, r8 = 2;
function J1(n) {
  const t = new DataView(n), e = t.getUint32(0, !0);
  if (e !== Q1)
    throw new Error(
      `Invalid magic: 0x${e.toString(16)}, expected 0x${Q1.toString(16)}`
    );
  return {
    msgType: t.getUint8(4),
    flags: t.getUint8(5)
  };
}
function s8(n) {
  const t = new DataView(n), e = t.getUint8(5);
  let r = 8;
  const a = t.getUint32(r, !0);
  r += 4;
  const o = t.getUint32(r, !0);
  r += 4;
  const c = new Float32Array(n, r, a * 3);
  r += a * 3 * 4;
  const u = new Uint8Array(n, r, a);
  r += a, r += (4 - r % 4) % 4;
  const d = new Uint32Array(n, r, o * 2);
  r += o * 2 * 4;
  let h = null;
  e & i8 && (h = new Uint8Array(n, r, o), r += o, r += (4 - r % 4) % 4);
  let p = null;
  return e & r8 && (p = new Float32Array(n, r, 9), r += 36), { nAtoms: a, nBonds: o, nFileBonds: o, positions: c, elements: u, bonds: d, bondOrders: h, box: p };
}
function a8(n) {
  const t = new DataView(n);
  let e = 8;
  const r = t.getUint32(e, !0);
  e += 4;
  const a = t.getUint32(e, !0);
  e += 4;
  const o = new Float32Array(n, e, a * 3);
  return { frameId: r, nAtoms: a, positions: o };
}
function o8({ model: n, el: t }) {
  const e = document.createElement("div");
  e.style.width = "100%", e.style.height = "500px", e.style.position = "relative", e.style.background = "#ffffff", e.style.borderRadius = "8px", e.style.overflow = "hidden", t.appendChild(e);
  let r = null, a = null, o = null, c = !1;
  function u() {
    const E = n.get("_snapshot_data");
    if (!E || E.byteLength === 0) return null;
    const S = new ArrayBuffer(E.byteLength);
    new Uint8Array(S).set(
      new Uint8Array(E.buffer, E.byteOffset, E.byteLength)
    );
    const { msgType: y } = J1(S);
    return y === e8 ? s8(S) : null;
  }
  function d() {
    const E = n.get("_frame_data");
    if (!E || E.byteLength === 0) return null;
    const S = new ArrayBuffer(E.byteLength);
    new Uint8Array(S).set(
      new Uint8Array(E.buffer, E.byteOffset, E.byteLength)
    );
    const { msgType: y } = J1(S);
    return y === n8 ? a8(S) : null;
  }
  function h(E) {
    const S = n.get("total_frames") || 0;
    if (E === -1) {
      const A = ((n.get("frame_index") || 0) + 1) % S;
      n.set("frame_index", A);
    } else
      n.set("frame_index", E);
    n.save_changes();
  }
  function p(E) {
    const S = E ? JSON.stringify(E) : "";
    n.set("_measurement_json", S), n.save_changes();
  }
  function m(E) {
    n.set("_pipeline_json", E), n.save_changes();
  }
  function g() {
    if (!r || c) return;
    const E = n.get("frame_index") || 0, S = n.get("total_frames") || 0, y = n.get("selected_atoms") || [], A = n.get("pipeline") || !1, w = n.get("_pipeline_json") || "";
    r.render(
      ct.createElement(QH, {
        snapshot: a,
        frame: o,
        currentFrame: E,
        totalFrames: S,
        onSeek: h,
        selectedAtoms: y,
        onMeasurementChange: p,
        pipeline: A,
        pipelineJson: w,
        onPipelineChange: m
      })
    );
  }
  function _() {
    return r || c ? !!r : e.clientWidth === 0 || e.clientHeight === 0 ? !1 : (r = r2.createRoot(e), a = u(), o = d(), g(), !0);
  }
  const b = new ResizeObserver(() => {
    !r && !c && _();
  });
  return b.observe(e), _(), n.on("change:_snapshot_data", () => {
    a = u(), r ? g() : _();
  }), n.on("change:_frame_data", () => {
    o = d(), g();
  }), n.on("change:frame_index", () => {
    g();
  }), n.on("change:total_frames", () => {
    g();
  }), n.on("change:selected_atoms", () => {
    g();
  }), n.on("change:pipeline", () => {
    g();
  }), n.on("change:_pipeline_json", () => {
    g();
  }), () => {
    c = !0, b.disconnect(), r == null || r.unmount(), r = null;
  };
}
const f8 = { render: o8 };
export {
  f8 as default
};
