var lw = Object.defineProperty;
var cw = (n, t, e) => t in n ? lw(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
var Ct = (n, t, e) => cw(n, typeof t != "symbol" ? t + "" : t, e);
function hM(n) {
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
}
var Up = { exports: {} }, he = {};
/**
 * @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 rx;
function uw() {
  if (rx) return he;
  rx = 1;
  var n = Symbol.for("react.transitional.element"), t = Symbol.for("react.portal"), e = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), r = Symbol.for("react.profiler"), l = Symbol.for("react.consumer"), c = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), h = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), p = Symbol.for("react.activity"), _ = Symbol.iterator;
  function x(I) {
    return I === null || typeof I != "object" ? null : (I = _ && I[_] || I["@@iterator"], typeof I == "function" ? I : null);
  }
  var b = {
    isMounted: function() {
      return !1;
    },
    enqueueForceUpdate: function() {
    },
    enqueueReplaceState: function() {
    },
    enqueueSetState: function() {
    }
  }, M = Object.assign, S = {};
  function y(I, q, lt) {
    this.props = I, this.context = q, this.refs = S, this.updater = lt || b;
  }
  y.prototype.isReactComponent = {}, y.prototype.setState = function(I, q) {
    if (typeof I != "object" && typeof I != "function" && I != 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, I, q, "setState");
  }, y.prototype.forceUpdate = function(I) {
    this.updater.enqueueForceUpdate(this, I, "forceUpdate");
  };
  function C() {
  }
  C.prototype = y.prototype;
  function T(I, q, lt) {
    this.props = I, this.context = q, this.refs = S, this.updater = lt || b;
  }
  var E = T.prototype = new C();
  E.constructor = T, M(E, y.prototype), E.isPureReactComponent = !0;
  var O = Array.isArray;
  function N() {
  }
  var D = { H: null, A: null, T: null, S: null }, z = Object.prototype.hasOwnProperty;
  function A(I, q, lt) {
    var $ = lt.ref;
    return {
      $$typeof: n,
      type: I,
      key: q,
      ref: $ !== void 0 ? $ : null,
      props: lt
    };
  }
  function R(I, q) {
    return A(I.type, q, I.props);
  }
  function L(I) {
    return typeof I == "object" && I !== null && I.$$typeof === n;
  }
  function H(I) {
    var q = { "=": "=0", ":": "=2" };
    return "$" + I.replace(/[=:]/g, function(lt) {
      return q[lt];
    });
  }
  var k = /\/+/g;
  function P(I, q) {
    return typeof I == "object" && I !== null && I.key != null ? H("" + I.key) : q.toString(36);
  }
  function Y(I) {
    switch (I.status) {
      case "fulfilled":
        return I.value;
      case "rejected":
        throw I.reason;
      default:
        switch (typeof I.status == "string" ? I.then(N, N) : (I.status = "pending", I.then(
          function(q) {
            I.status === "pending" && (I.status = "fulfilled", I.value = q);
          },
          function(q) {
            I.status === "pending" && (I.status = "rejected", I.reason = q);
          }
        )), I.status) {
          case "fulfilled":
            return I.value;
          case "rejected":
            throw I.reason;
        }
    }
    throw I;
  }
  function U(I, q, lt, $, ot) {
    var gt = typeof I;
    (gt === "undefined" || gt === "boolean") && (I = null);
    var ht = !1;
    if (I === null) ht = !0;
    else
      switch (gt) {
        case "bigint":
        case "string":
        case "number":
          ht = !0;
          break;
        case "object":
          switch (I.$$typeof) {
            case n:
            case t:
              ht = !0;
              break;
            case m:
              return ht = I._init, U(
                ht(I._payload),
                q,
                lt,
                $,
                ot
              );
          }
      }
    if (ht)
      return ot = ot(I), ht = $ === "" ? "." + P(I, 0) : $, O(ot) ? (lt = "", ht != null && (lt = ht.replace(k, "$&/") + "/"), U(ot, q, lt, "", function(Lt) {
        return Lt;
      })) : ot != null && (L(ot) && (ot = R(
        ot,
        lt + (ot.key == null || I && I.key === ot.key ? "" : ("" + ot.key).replace(
          k,
          "$&/"
        ) + "/") + ht
      )), q.push(ot)), 1;
    ht = 0;
    var _t = $ === "" ? "." : $ + ":";
    if (O(I))
      for (var Et = 0; Et < I.length; Et++)
        $ = I[Et], gt = _t + P($, Et), ht += U(
          $,
          q,
          lt,
          gt,
          ot
        );
    else if (Et = x(I), typeof Et == "function")
      for (I = Et.call(I), Et = 0; !($ = I.next()).done; )
        $ = $.value, gt = _t + P($, Et++), ht += U(
          $,
          q,
          lt,
          gt,
          ot
        );
    else if (gt === "object") {
      if (typeof I.then == "function")
        return U(
          Y(I),
          q,
          lt,
          $,
          ot
        );
      throw q = String(I), Error(
        "Objects are not valid as a React child (found: " + (q === "[object Object]" ? "object with keys {" + Object.keys(I).join(", ") + "}" : q) + "). If you meant to render a collection of children, use an array instead."
      );
    }
    return ht;
  }
  function X(I, q, lt) {
    if (I == null) return I;
    var $ = [], ot = 0;
    return U(I, $, "", "", function(gt) {
      return q.call(lt, gt, ot++);
    }), $;
  }
  function V(I) {
    if (I._status === -1) {
      var q = I._result;
      q = q(), q.then(
        function(lt) {
          (I._status === 0 || I._status === -1) && (I._status = 1, I._result = lt);
        },
        function(lt) {
          (I._status === 0 || I._status === -1) && (I._status = 2, I._result = lt);
        }
      ), I._status === -1 && (I._status = 0, I._result = q);
    }
    if (I._status === 1) return I._result.default;
    throw I._result;
  }
  var W = typeof reportError == "function" ? reportError : function(I) {
    if (typeof window == "object" && typeof window.ErrorEvent == "function") {
      var q = 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(q)) return;
    } else if (typeof process == "object" && typeof process.emit == "function") {
      process.emit("uncaughtException", I);
      return;
    }
    console.error(I);
  }, J = {
    map: X,
    forEach: function(I, q, lt) {
      X(
        I,
        function() {
          q.apply(this, arguments);
        },
        lt
      );
    },
    count: function(I) {
      var q = 0;
      return X(I, function() {
        q++;
      }), q;
    },
    toArray: function(I) {
      return X(I, function(q) {
        return q;
      }) || [];
    },
    only: function(I) {
      if (!L(I))
        throw Error(
          "React.Children.only expected to receive a single React element child."
        );
      return I;
    }
  };
  return he.Activity = p, he.Children = J, he.Component = y, he.Fragment = e, he.Profiler = r, he.PureComponent = T, he.StrictMode = s, he.Suspense = d, he.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = D, he.__COMPILER_RUNTIME = {
    __proto__: null,
    c: function(I) {
      return D.H.useMemoCache(I);
    }
  }, he.cache = function(I) {
    return function() {
      return I.apply(null, arguments);
    };
  }, he.cacheSignal = function() {
    return null;
  }, he.cloneElement = function(I, q, lt) {
    if (I == null)
      throw Error(
        "The argument must be a React element, but you passed " + I + "."
      );
    var $ = M({}, I.props), ot = I.key;
    if (q != null)
      for (gt in q.key !== void 0 && (ot = "" + q.key), q)
        !z.call(q, gt) || gt === "key" || gt === "__self" || gt === "__source" || gt === "ref" && q.ref === void 0 || ($[gt] = q[gt]);
    var gt = arguments.length - 2;
    if (gt === 1) $.children = lt;
    else if (1 < gt) {
      for (var ht = Array(gt), _t = 0; _t < gt; _t++)
        ht[_t] = arguments[_t + 2];
      $.children = ht;
    }
    return A(I.type, ot, $);
  }, he.createContext = function(I) {
    return I = {
      $$typeof: c,
      _currentValue: I,
      _currentValue2: I,
      _threadCount: 0,
      Provider: null,
      Consumer: null
    }, I.Provider = I, I.Consumer = {
      $$typeof: l,
      _context: I
    }, I;
  }, he.createElement = function(I, q, lt) {
    var $, ot = {}, gt = null;
    if (q != null)
      for ($ in q.key !== void 0 && (gt = "" + q.key), q)
        z.call(q, $) && $ !== "key" && $ !== "__self" && $ !== "__source" && (ot[$] = q[$]);
    var ht = arguments.length - 2;
    if (ht === 1) ot.children = lt;
    else if (1 < ht) {
      for (var _t = Array(ht), Et = 0; Et < ht; Et++)
        _t[Et] = arguments[Et + 2];
      ot.children = _t;
    }
    if (I && I.defaultProps)
      for ($ in ht = I.defaultProps, ht)
        ot[$] === void 0 && (ot[$] = ht[$]);
    return A(I, gt, ot);
  }, he.createRef = function() {
    return { current: null };
  }, he.forwardRef = function(I) {
    return { $$typeof: f, render: I };
  }, he.isValidElement = L, he.lazy = function(I) {
    return {
      $$typeof: m,
      _payload: { _status: -1, _result: I },
      _init: V
    };
  }, he.memo = function(I, q) {
    return {
      $$typeof: h,
      type: I,
      compare: q === void 0 ? null : q
    };
  }, he.startTransition = function(I) {
    var q = D.T, lt = {};
    D.T = lt;
    try {
      var $ = I(), ot = D.S;
      ot !== null && ot(lt, $), typeof $ == "object" && $ !== null && typeof $.then == "function" && $.then(N, W);
    } catch (gt) {
      W(gt);
    } finally {
      q !== null && lt.types !== null && (q.types = lt.types), D.T = q;
    }
  }, he.unstable_useCacheRefresh = function() {
    return D.H.useCacheRefresh();
  }, he.use = function(I) {
    return D.H.use(I);
  }, he.useActionState = function(I, q, lt) {
    return D.H.useActionState(I, q, lt);
  }, he.useCallback = function(I, q) {
    return D.H.useCallback(I, q);
  }, he.useContext = function(I) {
    return D.H.useContext(I);
  }, he.useDebugValue = function() {
  }, he.useDeferredValue = function(I, q) {
    return D.H.useDeferredValue(I, q);
  }, he.useEffect = function(I, q) {
    return D.H.useEffect(I, q);
  }, he.useEffectEvent = function(I) {
    return D.H.useEffectEvent(I);
  }, he.useId = function() {
    return D.H.useId();
  }, he.useImperativeHandle = function(I, q, lt) {
    return D.H.useImperativeHandle(I, q, lt);
  }, he.useInsertionEffect = function(I, q) {
    return D.H.useInsertionEffect(I, q);
  }, he.useLayoutEffect = function(I, q) {
    return D.H.useLayoutEffect(I, q);
  }, he.useMemo = function(I, q) {
    return D.H.useMemo(I, q);
  }, he.useOptimistic = function(I, q) {
    return D.H.useOptimistic(I, q);
  }, he.useReducer = function(I, q, lt) {
    return D.H.useReducer(I, q, lt);
  }, he.useRef = function(I) {
    return D.H.useRef(I);
  }, he.useState = function(I) {
    return D.H.useState(I);
  }, he.useSyncExternalStore = function(I, q, lt) {
    return D.H.useSyncExternalStore(
      I,
      q,
      lt
    );
  }, he.useTransition = function() {
    return D.H.useTransition();
  }, he.version = "19.2.4", he;
}
var ox;
function wc() {
  return ox || (ox = 1, Up.exports = uw()), Up.exports;
}
var st = wc();
const lc = /* @__PURE__ */ hM(st);
var Op = { exports: {} }, Yl = {}, Pp = { exports: {} }, zp = {};
/**
 * @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 lx;
function fw() {
  return lx || (lx = 1, (function(n) {
    function t(U, X) {
      var V = U.length;
      U.push(X);
      t: for (; 0 < V; ) {
        var W = V - 1 >>> 1, J = U[W];
        if (0 < r(J, X))
          U[W] = X, U[V] = J, V = W;
        else break t;
      }
    }
    function e(U) {
      return U.length === 0 ? null : U[0];
    }
    function s(U) {
      if (U.length === 0) return null;
      var X = U[0], V = U.pop();
      if (V !== X) {
        U[0] = V;
        t: for (var W = 0, J = U.length, I = J >>> 1; W < I; ) {
          var q = 2 * (W + 1) - 1, lt = U[q], $ = q + 1, ot = U[$];
          if (0 > r(lt, V))
            $ < J && 0 > r(ot, lt) ? (U[W] = ot, U[$] = V, W = $) : (U[W] = lt, U[q] = V, W = q);
          else if ($ < J && 0 > r(ot, V))
            U[W] = ot, U[$] = V, W = $;
          else break t;
        }
      }
      return X;
    }
    function r(U, X) {
      var V = U.sortIndex - X.sortIndex;
      return V !== 0 ? V : U.id - X.id;
    }
    if (n.unstable_now = void 0, typeof performance == "object" && typeof performance.now == "function") {
      var l = performance;
      n.unstable_now = function() {
        return l.now();
      };
    } else {
      var c = Date, f = c.now();
      n.unstable_now = function() {
        return c.now() - f;
      };
    }
    var d = [], h = [], m = 1, p = null, _ = 3, x = !1, b = !1, M = !1, S = !1, y = typeof setTimeout == "function" ? setTimeout : null, C = typeof clearTimeout == "function" ? clearTimeout : null, T = typeof setImmediate < "u" ? setImmediate : null;
    function E(U) {
      for (var X = e(h); X !== null; ) {
        if (X.callback === null) s(h);
        else if (X.startTime <= U)
          s(h), X.sortIndex = X.expirationTime, t(d, X);
        else break;
        X = e(h);
      }
    }
    function O(U) {
      if (M = !1, E(U), !b)
        if (e(d) !== null)
          b = !0, N || (N = !0, H());
        else {
          var X = e(h);
          X !== null && Y(O, X.startTime - U);
        }
    }
    var N = !1, D = -1, z = 5, A = -1;
    function R() {
      return S ? !0 : !(n.unstable_now() - A < z);
    }
    function L() {
      if (S = !1, N) {
        var U = n.unstable_now();
        A = U;
        var X = !0;
        try {
          t: {
            b = !1, M && (M = !1, C(D), D = -1), x = !0;
            var V = _;
            try {
              e: {
                for (E(U), p = e(d); p !== null && !(p.expirationTime > U && R()); ) {
                  var W = p.callback;
                  if (typeof W == "function") {
                    p.callback = null, _ = p.priorityLevel;
                    var J = W(
                      p.expirationTime <= U
                    );
                    if (U = n.unstable_now(), typeof J == "function") {
                      p.callback = J, E(U), X = !0;
                      break e;
                    }
                    p === e(d) && s(d), E(U);
                  } else s(d);
                  p = e(d);
                }
                if (p !== null) X = !0;
                else {
                  var I = e(h);
                  I !== null && Y(
                    O,
                    I.startTime - U
                  ), X = !1;
                }
              }
              break t;
            } finally {
              p = null, _ = V, x = !1;
            }
            X = void 0;
          }
        } finally {
          X ? H() : N = !1;
        }
      }
    }
    var H;
    if (typeof T == "function")
      H = function() {
        T(L);
      };
    else if (typeof MessageChannel < "u") {
      var k = new MessageChannel(), P = k.port2;
      k.port1.onmessage = L, H = function() {
        P.postMessage(null);
      };
    } else
      H = function() {
        y(L, 0);
      };
    function Y(U, X) {
      D = y(function() {
        U(n.unstable_now());
      }, X);
    }
    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(U) {
      U.callback = null;
    }, n.unstable_forceFrameRate = function(U) {
      0 > U || 125 < U ? console.error(
        "forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"
      ) : z = 0 < U ? Math.floor(1e3 / U) : 5;
    }, n.unstable_getCurrentPriorityLevel = function() {
      return _;
    }, n.unstable_next = function(U) {
      switch (_) {
        case 1:
        case 2:
        case 3:
          var X = 3;
          break;
        default:
          X = _;
      }
      var V = _;
      _ = X;
      try {
        return U();
      } finally {
        _ = V;
      }
    }, n.unstable_requestPaint = function() {
      S = !0;
    }, n.unstable_runWithPriority = function(U, X) {
      switch (U) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
          break;
        default:
          U = 3;
      }
      var V = _;
      _ = U;
      try {
        return X();
      } finally {
        _ = V;
      }
    }, n.unstable_scheduleCallback = function(U, X, V) {
      var W = n.unstable_now();
      switch (typeof V == "object" && V !== null ? (V = V.delay, V = typeof V == "number" && 0 < V ? W + V : W) : V = W, U) {
        case 1:
          var J = -1;
          break;
        case 2:
          J = 250;
          break;
        case 5:
          J = 1073741823;
          break;
        case 4:
          J = 1e4;
          break;
        default:
          J = 5e3;
      }
      return J = V + J, U = {
        id: m++,
        callback: X,
        priorityLevel: U,
        startTime: V,
        expirationTime: J,
        sortIndex: -1
      }, V > W ? (U.sortIndex = V, t(h, U), e(d) === null && U === e(h) && (M ? (C(D), D = -1) : M = !0, Y(O, V - W))) : (U.sortIndex = J, t(d, U), b || x || (b = !0, N || (N = !0, H()))), U;
    }, n.unstable_shouldYield = R, n.unstable_wrapCallback = function(U) {
      var X = _;
      return function() {
        var V = _;
        _ = X;
        try {
          return U.apply(this, arguments);
        } finally {
          _ = V;
        }
      };
    };
  })(zp)), zp;
}
var cx;
function dw() {
  return cx || (cx = 1, Pp.exports = fw()), Pp.exports;
}
var Ip = { exports: {} }, Xn = {};
/**
 * @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 ux;
function hw() {
  if (ux) return Xn;
  ux = 1;
  var n = wc();
  function t(d) {
    var h = "https://react.dev/errors/" + d;
    if (1 < arguments.length) {
      h += "?args[]=" + encodeURIComponent(arguments[1]);
      for (var m = 2; m < arguments.length; m++)
        h += "&args[]=" + encodeURIComponent(arguments[m]);
    }
    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 s = {
    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
  }, r = Symbol.for("react.portal");
  function l(d, h, m) {
    var p = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
    return {
      $$typeof: r,
      key: p == null ? null : "" + p,
      children: d,
      containerInfo: h,
      implementation: m
    };
  }
  var c = n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
  function f(d, h) {
    if (d === "font") return "";
    if (typeof h == "string")
      return h === "use-credentials" ? h : "";
  }
  return Xn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = s, Xn.createPortal = function(d, h) {
    var m = 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 l(d, h, null, m);
  }, Xn.flushSync = function(d) {
    var h = c.T, m = s.p;
    try {
      if (c.T = null, s.p = 2, d) return d();
    } finally {
      c.T = h, s.p = m, s.d.f();
    }
  }, Xn.preconnect = function(d, h) {
    typeof d == "string" && (h ? (h = h.crossOrigin, h = typeof h == "string" ? h === "use-credentials" ? h : "" : void 0) : h = null, s.d.C(d, h));
  }, Xn.prefetchDNS = function(d) {
    typeof d == "string" && s.d.D(d);
  }, Xn.preinit = function(d, h) {
    if (typeof d == "string" && h && typeof h.as == "string") {
      var m = h.as, p = f(m, h.crossOrigin), _ = typeof h.integrity == "string" ? h.integrity : void 0, x = typeof h.fetchPriority == "string" ? h.fetchPriority : void 0;
      m === "style" ? s.d.S(
        d,
        typeof h.precedence == "string" ? h.precedence : void 0,
        {
          crossOrigin: p,
          integrity: _,
          fetchPriority: x
        }
      ) : m === "script" && s.d.X(d, {
        crossOrigin: p,
        integrity: _,
        fetchPriority: x,
        nonce: typeof h.nonce == "string" ? h.nonce : void 0
      });
    }
  }, Xn.preinitModule = function(d, h) {
    if (typeof d == "string")
      if (typeof h == "object" && h !== null) {
        if (h.as == null || h.as === "script") {
          var m = f(
            h.as,
            h.crossOrigin
          );
          s.d.M(d, {
            crossOrigin: m,
            integrity: typeof h.integrity == "string" ? h.integrity : void 0,
            nonce: typeof h.nonce == "string" ? h.nonce : void 0
          });
        }
      } else h == null && s.d.M(d);
  }, Xn.preload = function(d, h) {
    if (typeof d == "string" && typeof h == "object" && h !== null && typeof h.as == "string") {
      var m = h.as, p = f(m, h.crossOrigin);
      s.d.L(d, m, {
        crossOrigin: p,
        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
      });
    }
  }, Xn.preloadModule = function(d, h) {
    if (typeof d == "string")
      if (h) {
        var m = f(h.as, h.crossOrigin);
        s.d.m(d, {
          as: typeof h.as == "string" && h.as !== "script" ? h.as : void 0,
          crossOrigin: m,
          integrity: typeof h.integrity == "string" ? h.integrity : void 0
        });
      } else s.d.m(d);
  }, Xn.requestFormReset = function(d) {
    s.d.r(d);
  }, Xn.unstable_batchedUpdates = function(d, h) {
    return d(h);
  }, Xn.useFormState = function(d, h, m) {
    return c.H.useFormState(d, h, m);
  }, Xn.useFormStatus = function() {
    return c.H.useHostTransitionStatus();
  }, Xn.version = "19.2.4", Xn;
}
var fx;
function pM() {
  if (fx) return Ip.exports;
  fx = 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(), Ip.exports = hw(), Ip.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 dx;
function pw() {
  if (dx) return Yl;
  dx = 1;
  var n = dw(), t = wc(), e = pM();
  function s(i) {
    var a = "https://react.dev/errors/" + i;
    if (1 < arguments.length) {
      a += "?args[]=" + encodeURIComponent(arguments[1]);
      for (var o = 2; o < arguments.length; o++)
        a += "&args[]=" + encodeURIComponent(arguments[o]);
    }
    return "Minified React error #" + i + "; visit " + a + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  function r(i) {
    return !(!i || i.nodeType !== 1 && i.nodeType !== 9 && i.nodeType !== 11);
  }
  function l(i) {
    var a = i, o = i;
    if (i.alternate) for (; a.return; ) a = a.return;
    else {
      i = a;
      do
        a = i, (a.flags & 4098) !== 0 && (o = a.return), i = a.return;
      while (i);
    }
    return a.tag === 3 ? o : null;
  }
  function c(i) {
    if (i.tag === 13) {
      var a = i.memoizedState;
      if (a === null && (i = i.alternate, i !== null && (a = i.memoizedState)), a !== null) return a.dehydrated;
    }
    return null;
  }
  function f(i) {
    if (i.tag === 31) {
      var a = i.memoizedState;
      if (a === null && (i = i.alternate, i !== null && (a = i.memoizedState)), a !== null) return a.dehydrated;
    }
    return null;
  }
  function d(i) {
    if (l(i) !== i)
      throw Error(s(188));
  }
  function h(i) {
    var a = i.alternate;
    if (!a) {
      if (a = l(i), a === null) throw Error(s(188));
      return a !== i ? null : i;
    }
    for (var o = i, u = a; ; ) {
      var g = o.return;
      if (g === null) break;
      var v = g.alternate;
      if (v === null) {
        if (u = g.return, u !== null) {
          o = u;
          continue;
        }
        break;
      }
      if (g.child === v.child) {
        for (v = g.child; v; ) {
          if (v === o) return d(g), i;
          if (v === u) return d(g), a;
          v = v.sibling;
        }
        throw Error(s(188));
      }
      if (o.return !== u.return) o = g, u = v;
      else {
        for (var w = !1, F = g.child; F; ) {
          if (F === o) {
            w = !0, o = g, u = v;
            break;
          }
          if (F === u) {
            w = !0, u = g, o = v;
            break;
          }
          F = F.sibling;
        }
        if (!w) {
          for (F = v.child; F; ) {
            if (F === o) {
              w = !0, o = v, u = g;
              break;
            }
            if (F === u) {
              w = !0, u = v, o = g;
              break;
            }
            F = F.sibling;
          }
          if (!w) throw Error(s(189));
        }
      }
      if (o.alternate !== u) throw Error(s(190));
    }
    if (o.tag !== 3) throw Error(s(188));
    return o.stateNode.current === o ? i : a;
  }
  function m(i) {
    var a = i.tag;
    if (a === 5 || a === 26 || a === 27 || a === 6) return i;
    for (i = i.child; i !== null; ) {
      if (a = m(i), a !== null) return a;
      i = i.sibling;
    }
    return null;
  }
  var p = Object.assign, _ = Symbol.for("react.element"), x = Symbol.for("react.transitional.element"), b = Symbol.for("react.portal"), M = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), C = Symbol.for("react.consumer"), T = Symbol.for("react.context"), E = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), D = Symbol.for("react.memo"), z = Symbol.for("react.lazy"), A = Symbol.for("react.activity"), R = Symbol.for("react.memo_cache_sentinel"), L = Symbol.iterator;
  function H(i) {
    return i === null || typeof i != "object" ? null : (i = L && i[L] || i["@@iterator"], typeof i == "function" ? i : null);
  }
  var k = Symbol.for("react.client.reference");
  function P(i) {
    if (i == null) return null;
    if (typeof i == "function")
      return i.$$typeof === k ? null : i.displayName || i.name || null;
    if (typeof i == "string") return i;
    switch (i) {
      case M:
        return "Fragment";
      case y:
        return "Profiler";
      case S:
        return "StrictMode";
      case O:
        return "Suspense";
      case N:
        return "SuspenseList";
      case A:
        return "Activity";
    }
    if (typeof i == "object")
      switch (i.$$typeof) {
        case b:
          return "Portal";
        case T:
          return i.displayName || "Context";
        case C:
          return (i._context.displayName || "Context") + ".Consumer";
        case E:
          var a = i.render;
          return i = i.displayName, i || (i = a.displayName || a.name || "", i = i !== "" ? "ForwardRef(" + i + ")" : "ForwardRef"), i;
        case D:
          return a = i.displayName || null, a !== null ? a : P(i.type) || "Memo";
        case z:
          a = i._payload, i = i._init;
          try {
            return P(i(a));
          } catch {
          }
      }
    return null;
  }
  var Y = Array.isArray, U = t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, X = e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, V = {
    pending: !1,
    data: null,
    method: null,
    action: null
  }, W = [], J = -1;
  function I(i) {
    return { current: i };
  }
  function q(i) {
    0 > J || (i.current = W[J], W[J] = null, J--);
  }
  function lt(i, a) {
    J++, W[J] = i.current, i.current = a;
  }
  var $ = I(null), ot = I(null), gt = I(null), ht = I(null);
  function _t(i, a) {
    switch (lt(gt, a), lt(ot, i), lt($, null), a.nodeType) {
      case 9:
      case 11:
        i = (i = a.documentElement) && (i = i.namespaceURI) ? Ry(i) : 0;
        break;
      default:
        if (i = a.tagName, a = a.namespaceURI)
          a = Ry(a), i = Dy(a, i);
        else
          switch (i) {
            case "svg":
              i = 1;
              break;
            case "math":
              i = 2;
              break;
            default:
              i = 0;
          }
    }
    q($), lt($, i);
  }
  function Et() {
    q($), q(ot), q(gt);
  }
  function Lt(i) {
    i.memoizedState !== null && lt(ht, i);
    var a = $.current, o = Dy(a, i.type);
    a !== o && (lt(ot, i), lt($, o));
  }
  function Gt(i) {
    ot.current === i && (q($), q(ot)), ht.current === i && (q(ht), Gl._currentValue = V);
  }
  var Nt, Bt;
  function K(i) {
    if (Nt === void 0)
      try {
        throw Error();
      } catch (o) {
        var a = o.stack.trim().match(/\n( *(at )?)/);
        Nt = a && a[1] || "", Bt = -1 < o.stack.indexOf(`
    at`) ? " (<anonymous>)" : -1 < o.stack.indexOf("@") ? "@unknown:0:0" : "";
      }
    return `
` + Nt + i + Bt;
  }
  var pe = !1;
  function Xt(i, a) {
    if (!i || pe) return "";
    pe = !0;
    var o = Error.prepareStackTrace;
    Error.prepareStackTrace = void 0;
    try {
      var u = {
        DetermineComponentFrameRoot: function() {
          try {
            if (a) {
              var Tt = function() {
                throw Error();
              };
              if (Object.defineProperty(Tt.prototype, "props", {
                set: function() {
                  throw Error();
                }
              }), typeof Reflect == "object" && Reflect.construct) {
                try {
                  Reflect.construct(Tt, []);
                } catch (vt) {
                  var pt = vt;
                }
                Reflect.construct(i, [], Tt);
              } else {
                try {
                  Tt.call();
                } catch (vt) {
                  pt = vt;
                }
                i.call(Tt.prototype);
              }
            } else {
              try {
                throw Error();
              } catch (vt) {
                pt = vt;
              }
              (Tt = i()) && typeof Tt.catch == "function" && Tt.catch(function() {
              });
            }
          } catch (vt) {
            if (vt && pt && typeof vt.stack == "string")
              return [vt.stack, pt.stack];
          }
          return [null, null];
        }
      };
      u.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
      var g = Object.getOwnPropertyDescriptor(
        u.DetermineComponentFrameRoot,
        "name"
      );
      g && g.configurable && Object.defineProperty(
        u.DetermineComponentFrameRoot,
        "name",
        { value: "DetermineComponentFrameRoot" }
      );
      var v = u.DetermineComponentFrameRoot(), w = v[0], F = v[1];
      if (w && F) {
        var Q = w.split(`
`), ut = F.split(`
`);
        for (g = u = 0; u < Q.length && !Q[u].includes("DetermineComponentFrameRoot"); )
          u++;
        for (; g < ut.length && !ut[g].includes(
          "DetermineComponentFrameRoot"
        ); )
          g++;
        if (u === Q.length || g === ut.length)
          for (u = Q.length - 1, g = ut.length - 1; 1 <= u && 0 <= g && Q[u] !== ut[g]; )
            g--;
        for (; 1 <= u && 0 <= g; u--, g--)
          if (Q[u] !== ut[g]) {
            if (u !== 1 || g !== 1)
              do
                if (u--, g--, 0 > g || Q[u] !== ut[g]) {
                  var xt = `
` + Q[u].replace(" at new ", " at ");
                  return i.displayName && xt.includes("<anonymous>") && (xt = xt.replace("<anonymous>", i.displayName)), xt;
                }
              while (1 <= u && 0 <= g);
            break;
          }
      }
    } finally {
      pe = !1, Error.prepareStackTrace = o;
    }
    return (o = i ? i.displayName || i.name : "") ? K(o) : "";
  }
  function se(i, a) {
    switch (i.tag) {
      case 26:
      case 27:
      case 5:
        return K(i.type);
      case 16:
        return K("Lazy");
      case 13:
        return i.child !== a && a !== null ? K("Suspense Fallback") : K("Suspense");
      case 19:
        return K("SuspenseList");
      case 0:
      case 15:
        return Xt(i.type, !1);
      case 11:
        return Xt(i.type.render, !1);
      case 1:
        return Xt(i.type, !0);
      case 31:
        return K("Activity");
      default:
        return "";
    }
  }
  function qt(i) {
    try {
      var a = "", o = null;
      do
        a += se(i, o), o = i, i = i.return;
      while (i);
      return a;
    } catch (u) {
      return `
Error generating stack: ` + u.message + `
` + u.stack;
    }
  }
  var xe = Object.prototype.hasOwnProperty, jt = n.unstable_scheduleCallback, j = n.unstable_cancelCallback, B = n.unstable_shouldYield, ft = n.unstable_requestPaint, St = n.unstable_now, wt = n.unstable_getCurrentPriorityLevel, bt = n.unstable_ImmediatePriority, Zt = n.unstable_UserBlockingPriority, Ut = n.unstable_NormalPriority, Wt = n.unstable_LowPriority, ve = n.unstable_IdlePriority, Dt = n.log, Yt = n.unstable_setDisableYieldValue, Jt = null, $t = null;
  function Vt(i) {
    if (typeof Dt == "function" && Yt(i), $t && typeof $t.setStrictMode == "function")
      try {
        $t.setStrictMode(Jt, i);
      } catch {
      }
  }
  var re = Math.clz32 ? Math.clz32 : nt, de = Math.log, Fe = Math.LN2;
  function nt(i) {
    return i >>>= 0, i === 0 ? 32 : 31 - (de(i) / Fe | 0) | 0;
  }
  var Ot = 256, yt = 262144, At = 4194304;
  function Pt(i) {
    var a = i & 42;
    if (a !== 0) return a;
    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 zt(i, a, o) {
    var u = i.pendingLanes;
    if (u === 0) return 0;
    var g = 0, v = i.suspendedLanes, w = i.pingedLanes;
    i = i.warmLanes;
    var F = u & 134217727;
    return F !== 0 ? (u = F & ~v, u !== 0 ? g = Pt(u) : (w &= F, w !== 0 ? g = Pt(w) : o || (o = F & ~i, o !== 0 && (g = Pt(o))))) : (F = u & ~v, F !== 0 ? g = Pt(F) : w !== 0 ? g = Pt(w) : o || (o = u & ~i, o !== 0 && (g = Pt(o)))), g === 0 ? 0 : a !== 0 && a !== g && (a & v) === 0 && (v = g & -g, o = a & -a, v >= o || v === 32 && (o & 4194048) !== 0) ? a : g;
  }
  function ce(i, a) {
    return (i.pendingLanes & ~(i.suspendedLanes & ~i.pingedLanes) & a) === 0;
  }
  function $e(i, a) {
    switch (i) {
      case 1:
      case 2:
      case 4:
      case 8:
      case 64:
        return a + 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 a + 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 fn() {
    var i = At;
    return At <<= 1, (At & 62914560) === 0 && (At = 4194304), i;
  }
  function De(i) {
    for (var a = [], o = 0; 31 > o; o++) a.push(i);
    return a;
  }
  function Mn(i, a) {
    i.pendingLanes |= a, a !== 268435456 && (i.suspendedLanes = 0, i.pingedLanes = 0, i.warmLanes = 0);
  }
  function ci(i, a, o, u, g, v) {
    var w = i.pendingLanes;
    i.pendingLanes = o, i.suspendedLanes = 0, i.pingedLanes = 0, i.warmLanes = 0, i.expiredLanes &= o, i.entangledLanes &= o, i.errorRecoveryDisabledLanes &= o, i.shellSuspendCounter = 0;
    var F = i.entanglements, Q = i.expirationTimes, ut = i.hiddenUpdates;
    for (o = w & ~o; 0 < o; ) {
      var xt = 31 - re(o), Tt = 1 << xt;
      F[xt] = 0, Q[xt] = -1;
      var pt = ut[xt];
      if (pt !== null)
        for (ut[xt] = null, xt = 0; xt < pt.length; xt++) {
          var vt = pt[xt];
          vt !== null && (vt.lane &= -536870913);
        }
      o &= ~Tt;
    }
    u !== 0 && Oa(i, u, 0), v !== 0 && g === 0 && i.tag !== 0 && (i.suspendedLanes |= v & ~(w & ~a));
  }
  function Oa(i, a, o) {
    i.pendingLanes |= a, i.suspendedLanes &= ~a;
    var u = 31 - re(a);
    i.entangledLanes |= a, i.entanglements[u] = i.entanglements[u] | 1073741824 | o & 261930;
  }
  function Pa(i, a) {
    var o = i.entangledLanes |= a;
    for (i = i.entanglements; o; ) {
      var u = 31 - re(o), g = 1 << u;
      g & a | i[u] & a && (i[u] |= a), o &= ~g;
    }
  }
  function Ei(i, a) {
    var o = a & -a;
    return o = (o & 42) !== 0 ? 1 : ls(o), (o & (i.suspendedLanes | a)) !== 0 ? 0 : o;
  }
  function ls(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 Xs(i) {
    return i &= -i, 2 < i ? 8 < i ? (i & 134217727) !== 0 ? 32 : 268435456 : 8 : 2;
  }
  function za() {
    var i = X.p;
    return i !== 0 ? i : (i = window.event, i === void 0 ? 32 : Jy(i.type));
  }
  function cs(i, a) {
    var o = X.p;
    try {
      return X.p = i, a();
    } finally {
      X.p = o;
    }
  }
  var ui = Math.random().toString(36).slice(2), nn = "__reactFiber$" + ui, En = "__reactProps$" + ui, Ti = "__reactContainer$" + ui, Ws = "__reactEvents$" + ui, Ar = "__reactListeners$" + ui, sl = "__reactHandles$" + ui, wr = "__reactResources$" + ui, us = "__reactMarker$" + ui;
  function Ia(i) {
    delete i[nn], delete i[En], delete i[Ws], delete i[Ar], delete i[sl];
  }
  function G(i) {
    var a = i[nn];
    if (a) return a;
    for (var o = i.parentNode; o; ) {
      if (a = o[Ti] || o[nn]) {
        if (o = a.alternate, a.child !== null || o !== null && o.child !== null)
          for (i = Iy(i); i !== null; ) {
            if (o = i[nn]) return o;
            i = Iy(i);
          }
        return a;
      }
      i = o, o = i.parentNode;
    }
    return null;
  }
  function it(i) {
    if (i = i[nn] || i[Ti]) {
      var a = i.tag;
      if (a === 5 || a === 6 || a === 13 || a === 31 || a === 26 || a === 27 || a === 3)
        return i;
    }
    return null;
  }
  function dt(i) {
    var a = i.tag;
    if (a === 5 || a === 26 || a === 27 || a === 6) return i.stateNode;
    throw Error(s(33));
  }
  function mt(i) {
    var a = i[wr];
    return a || (a = i[wr] = { hoistableStyles: /* @__PURE__ */ new Map(), hoistableScripts: /* @__PURE__ */ new Map() }), a;
  }
  function et(i) {
    i[us] = !0;
  }
  var Rt = /* @__PURE__ */ new Set(), It = {};
  function Ft(i, a) {
    kt(i, a), kt(i + "Capture", a);
  }
  function kt(i, a) {
    for (It[i] = a, i = 0; i < a.length; i++)
      Rt.add(a[i]);
  }
  var ue = 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]*$"
  ), oe = {}, te = {};
  function be(i) {
    return xe.call(te, i) ? !0 : xe.call(oe, i) ? !1 : ue.test(i) ? te[i] = !0 : (oe[i] = !0, !1);
  }
  function Me(i, a, o) {
    if (be(a))
      if (o === null) i.removeAttribute(a);
      else {
        switch (typeof o) {
          case "undefined":
          case "function":
          case "symbol":
            i.removeAttribute(a);
            return;
          case "boolean":
            var u = a.toLowerCase().slice(0, 5);
            if (u !== "data-" && u !== "aria-") {
              i.removeAttribute(a);
              return;
            }
        }
        i.setAttribute(a, "" + o);
      }
  }
  function Ze(i, a, o) {
    if (o === null) i.removeAttribute(a);
    else {
      switch (typeof o) {
        case "undefined":
        case "function":
        case "symbol":
        case "boolean":
          i.removeAttribute(a);
          return;
      }
      i.setAttribute(a, "" + o);
    }
  }
  function Le(i, a, o, u) {
    if (u === null) i.removeAttribute(o);
    else {
      switch (typeof u) {
        case "undefined":
        case "function":
        case "symbol":
        case "boolean":
          i.removeAttribute(o);
          return;
      }
      i.setAttributeNS(a, o, "" + u);
    }
  }
  function fe(i) {
    switch (typeof i) {
      case "bigint":
      case "boolean":
      case "number":
      case "string":
      case "undefined":
        return i;
      case "object":
        return i;
      default:
        return "";
    }
  }
  function ee(i) {
    var a = i.type;
    return (i = i.nodeName) && i.toLowerCase() === "input" && (a === "checkbox" || a === "radio");
  }
  function dn(i, a, o) {
    var u = Object.getOwnPropertyDescriptor(
      i.constructor.prototype,
      a
    );
    if (!i.hasOwnProperty(a) && typeof u < "u" && typeof u.get == "function" && typeof u.set == "function") {
      var g = u.get, v = u.set;
      return Object.defineProperty(i, a, {
        configurable: !0,
        get: function() {
          return g.call(this);
        },
        set: function(w) {
          o = "" + w, v.call(this, w);
        }
      }), Object.defineProperty(i, a, {
        enumerable: u.enumerable
      }), {
        getValue: function() {
          return o;
        },
        setValue: function(w) {
          o = "" + w;
        },
        stopTracking: function() {
          i._valueTracker = null, delete i[a];
        }
      };
    }
  }
  function Se(i) {
    if (!i._valueTracker) {
      var a = ee(i) ? "checked" : "value";
      i._valueTracker = dn(
        i,
        a,
        "" + i[a]
      );
    }
  }
  function kn(i) {
    if (!i) return !1;
    var a = i._valueTracker;
    if (!a) return !0;
    var o = a.getValue(), u = "";
    return i && (u = ee(i) ? i.checked ? "true" : "false" : i.value), i = u, i !== o ? (a.setValue(i), !0) : !1;
  }
  function Qn(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 On = /[\n"\\]/g;
  function mn(i) {
    return i.replace(
      On,
      function(a) {
        return "\\" + a.charCodeAt(0).toString(16) + " ";
      }
    );
  }
  function Oe(i, a, o, u, g, v, w, F) {
    i.name = "", w != null && typeof w != "function" && typeof w != "symbol" && typeof w != "boolean" ? i.type = w : i.removeAttribute("type"), a != null ? w === "number" ? (a === 0 && i.value === "" || i.value != a) && (i.value = "" + fe(a)) : i.value !== "" + fe(a) && (i.value = "" + fe(a)) : w !== "submit" && w !== "reset" || i.removeAttribute("value"), a != null ? Dn(i, w, fe(a)) : o != null ? Dn(i, w, fe(o)) : u != null && i.removeAttribute("value"), g == null && v != null && (i.defaultChecked = !!v), g != null && (i.checked = g && typeof g != "function" && typeof g != "symbol"), F != null && typeof F != "function" && typeof F != "symbol" && typeof F != "boolean" ? i.name = "" + fe(F) : i.removeAttribute("name");
  }
  function Pn(i, a, o, u, g, v, w, F) {
    if (v != null && typeof v != "function" && typeof v != "symbol" && typeof v != "boolean" && (i.type = v), a != null || o != null) {
      if (!(v !== "submit" && v !== "reset" || a != null)) {
        Se(i);
        return;
      }
      o = o != null ? "" + fe(o) : "", a = a != null ? "" + fe(a) : o, F || a === i.value || (i.value = a), i.defaultValue = a;
    }
    u = u ?? g, u = typeof u != "function" && typeof u != "symbol" && !!u, i.checked = F ? i.checked : !!u, i.defaultChecked = !!u, w != null && typeof w != "function" && typeof w != "symbol" && typeof w != "boolean" && (i.name = w), Se(i);
  }
  function Dn(i, a, o) {
    a === "number" && Qn(i.ownerDocument) === i || i.defaultValue === "" + o || (i.defaultValue = "" + o);
  }
  function Qe(i, a, o, u) {
    if (i = i.options, a) {
      a = {};
      for (var g = 0; g < o.length; g++)
        a["$" + o[g]] = !0;
      for (o = 0; o < i.length; o++)
        g = a.hasOwnProperty("$" + i[o].value), i[o].selected !== g && (i[o].selected = g), g && u && (i[o].defaultSelected = !0);
    } else {
      for (o = "" + fe(o), a = null, g = 0; g < i.length; g++) {
        if (i[g].value === o) {
          i[g].selected = !0, u && (i[g].defaultSelected = !0);
          return;
        }
        a !== null || i[g].disabled || (a = i[g]);
      }
      a !== null && (a.selected = !0);
    }
  }
  function zn(i, a, o) {
    if (a != null && (a = "" + fe(a), a !== i.value && (i.value = a), o == null)) {
      i.defaultValue !== a && (i.defaultValue = a);
      return;
    }
    i.defaultValue = o != null ? "" + fe(o) : "";
  }
  function Cr(i, a, o, u) {
    if (a == null) {
      if (u != null) {
        if (o != null) throw Error(s(92));
        if (Y(u)) {
          if (1 < u.length) throw Error(s(93));
          u = u[0];
        }
        o = u;
      }
      o == null && (o = ""), a = o;
    }
    o = fe(a), i.defaultValue = o, u = i.textContent, u === o && u !== "" && u !== null && (i.value = u), Se(i);
  }
  function Jn(i, a) {
    if (a) {
      var o = i.firstChild;
      if (o && o === i.lastChild && o.nodeType === 3) {
        o.nodeValue = a;
        return;
      }
    }
    i.textContent = a;
  }
  var iT = 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 A0(i, a, o) {
    var u = a.indexOf("--") === 0;
    o == null || typeof o == "boolean" || o === "" ? u ? i.setProperty(a, "") : a === "float" ? i.cssFloat = "" : i[a] = "" : u ? i.setProperty(a, o) : typeof o != "number" || o === 0 || iT.has(a) ? a === "float" ? i.cssFloat = o : i[a] = ("" + o).trim() : i[a] = o + "px";
  }
  function w0(i, a, o) {
    if (a != null && typeof a != "object")
      throw Error(s(62));
    if (i = i.style, o != null) {
      for (var u in o)
        !o.hasOwnProperty(u) || a != null && a.hasOwnProperty(u) || (u.indexOf("--") === 0 ? i.setProperty(u, "") : u === "float" ? i.cssFloat = "" : i[u] = "");
      for (var g in a)
        u = a[g], a.hasOwnProperty(g) && o[g] !== u && A0(i, g, u);
    } else
      for (var v in a)
        a.hasOwnProperty(v) && A0(i, v, a[v]);
  }
  function Rd(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 sT = /* @__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"]
  ]), aT = /^[\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 Bc(i) {
    return aT.test("" + i) ? "javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')" : i;
  }
  function fs() {
  }
  var Dd = null;
  function Nd(i) {
    return i = i.target || i.srcElement || window, i.correspondingUseElement && (i = i.correspondingUseElement), i.nodeType === 3 ? i.parentNode : i;
  }
  var Rr = null, Dr = null;
  function C0(i) {
    var a = it(i);
    if (a && (i = a.stateNode)) {
      var o = i[En] || null;
      t: switch (i = a.stateNode, a.type) {
        case "input":
          if (Oe(
            i,
            o.value,
            o.defaultValue,
            o.defaultValue,
            o.checked,
            o.defaultChecked,
            o.type,
            o.name
          ), a = o.name, o.type === "radio" && a != null) {
            for (o = i; o.parentNode; ) o = o.parentNode;
            for (o = o.querySelectorAll(
              'input[name="' + mn(
                "" + a
              ) + '"][type="radio"]'
            ), a = 0; a < o.length; a++) {
              var u = o[a];
              if (u !== i && u.form === i.form) {
                var g = u[En] || null;
                if (!g) throw Error(s(90));
                Oe(
                  u,
                  g.value,
                  g.defaultValue,
                  g.defaultValue,
                  g.checked,
                  g.defaultChecked,
                  g.type,
                  g.name
                );
              }
            }
            for (a = 0; a < o.length; a++)
              u = o[a], u.form === i.form && kn(u);
          }
          break t;
        case "textarea":
          zn(i, o.value, o.defaultValue);
          break t;
        case "select":
          a = o.value, a != null && Qe(i, !!o.multiple, a, !1);
      }
    }
  }
  var Ld = !1;
  function R0(i, a, o) {
    if (Ld) return i(a, o);
    Ld = !0;
    try {
      var u = i(a);
      return u;
    } finally {
      if (Ld = !1, (Rr !== null || Dr !== null) && (Tu(), Rr && (a = Rr, i = Dr, Dr = Rr = null, C0(a), i)))
        for (a = 0; a < i.length; a++) C0(i[a]);
    }
  }
  function al(i, a) {
    var o = i.stateNode;
    if (o === null) return null;
    var u = o[En] || null;
    if (u === null) return null;
    o = u[a];
    t: switch (a) {
      case "onClick":
      case "onClickCapture":
      case "onDoubleClick":
      case "onDoubleClickCapture":
      case "onMouseDown":
      case "onMouseDownCapture":
      case "onMouseMove":
      case "onMouseMoveCapture":
      case "onMouseUp":
      case "onMouseUpCapture":
      case "onMouseEnter":
        (u = !u.disabled) || (i = i.type, u = !(i === "button" || i === "input" || i === "select" || i === "textarea")), i = !u;
        break t;
      default:
        i = !1;
    }
    if (i) return null;
    if (o && typeof o != "function")
      throw Error(
        s(231, a, typeof o)
      );
    return o;
  }
  var ds = !(typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u"), Ud = !1;
  if (ds)
    try {
      var rl = {};
      Object.defineProperty(rl, "passive", {
        get: function() {
          Ud = !0;
        }
      }), window.addEventListener("test", rl, rl), window.removeEventListener("test", rl, rl);
    } catch {
      Ud = !1;
    }
  var Ys = null, Od = null, Fc = null;
  function D0() {
    if (Fc) return Fc;
    var i, a = Od, o = a.length, u, g = "value" in Ys ? Ys.value : Ys.textContent, v = g.length;
    for (i = 0; i < o && a[i] === g[i]; i++) ;
    var w = o - i;
    for (u = 1; u <= w && a[o - u] === g[v - u]; u++) ;
    return Fc = g.slice(i, 1 < u ? 1 - u : void 0);
  }
  function Hc(i) {
    var a = i.keyCode;
    return "charCode" in i ? (i = i.charCode, i === 0 && a === 13 && (i = 13)) : i = a, i === 10 && (i = 13), 32 <= i || i === 13 ? i : 0;
  }
  function Vc() {
    return !0;
  }
  function N0() {
    return !1;
  }
  function ti(i) {
    function a(o, u, g, v, w) {
      this._reactName = o, this._targetInst = g, this.type = u, this.nativeEvent = v, this.target = w, this.currentTarget = null;
      for (var F in i)
        i.hasOwnProperty(F) && (o = i[F], this[F] = o ? o(v) : v[F]);
      return this.isDefaultPrevented = (v.defaultPrevented != null ? v.defaultPrevented : v.returnValue === !1) ? Vc : N0, this.isPropagationStopped = N0, this;
    }
    return p(a.prototype, {
      preventDefault: function() {
        this.defaultPrevented = !0;
        var o = this.nativeEvent;
        o && (o.preventDefault ? o.preventDefault() : typeof o.returnValue != "unknown" && (o.returnValue = !1), this.isDefaultPrevented = Vc);
      },
      stopPropagation: function() {
        var o = this.nativeEvent;
        o && (o.stopPropagation ? o.stopPropagation() : typeof o.cancelBubble != "unknown" && (o.cancelBubble = !0), this.isPropagationStopped = Vc);
      },
      persist: function() {
      },
      isPersistent: Vc
    }), a;
  }
  var Ba = {
    eventPhase: 0,
    bubbles: 0,
    cancelable: 0,
    timeStamp: function(i) {
      return i.timeStamp || Date.now();
    },
    defaultPrevented: 0,
    isTrusted: 0
  }, Gc = ti(Ba), ol = p({}, Ba, { view: 0, detail: 0 }), rT = ti(ol), Pd, zd, ll, kc = p({}, ol, {
    screenX: 0,
    screenY: 0,
    clientX: 0,
    clientY: 0,
    pageX: 0,
    pageY: 0,
    ctrlKey: 0,
    shiftKey: 0,
    altKey: 0,
    metaKey: 0,
    getModifierState: Bd,
    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 !== ll && (ll && i.type === "mousemove" ? (Pd = i.screenX - ll.screenX, zd = i.screenY - ll.screenY) : zd = Pd = 0, ll = i), Pd);
    },
    movementY: function(i) {
      return "movementY" in i ? i.movementY : zd;
    }
  }), L0 = ti(kc), oT = p({}, kc, { dataTransfer: 0 }), lT = ti(oT), cT = p({}, ol, { relatedTarget: 0 }), Id = ti(cT), uT = p({}, Ba, {
    animationName: 0,
    elapsedTime: 0,
    pseudoElement: 0
  }), fT = ti(uT), dT = p({}, Ba, {
    clipboardData: function(i) {
      return "clipboardData" in i ? i.clipboardData : window.clipboardData;
    }
  }), hT = ti(dT), pT = p({}, Ba, { data: 0 }), U0 = ti(pT), mT = {
    Esc: "Escape",
    Spacebar: " ",
    Left: "ArrowLeft",
    Up: "ArrowUp",
    Right: "ArrowRight",
    Down: "ArrowDown",
    Del: "Delete",
    Win: "OS",
    Menu: "ContextMenu",
    Apps: "ContextMenu",
    Scroll: "ScrollLock",
    MozPrintableKey: "Unidentified"
  }, gT = {
    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"
  }, _T = {
    Alt: "altKey",
    Control: "ctrlKey",
    Meta: "metaKey",
    Shift: "shiftKey"
  };
  function vT(i) {
    var a = this.nativeEvent;
    return a.getModifierState ? a.getModifierState(i) : (i = _T[i]) ? !!a[i] : !1;
  }
  function Bd() {
    return vT;
  }
  var yT = p({}, ol, {
    key: function(i) {
      if (i.key) {
        var a = mT[i.key] || i.key;
        if (a !== "Unidentified") return a;
      }
      return i.type === "keypress" ? (i = Hc(i), i === 13 ? "Enter" : String.fromCharCode(i)) : i.type === "keydown" || i.type === "keyup" ? gT[i.keyCode] || "Unidentified" : "";
    },
    code: 0,
    location: 0,
    ctrlKey: 0,
    shiftKey: 0,
    altKey: 0,
    metaKey: 0,
    repeat: 0,
    locale: 0,
    getModifierState: Bd,
    charCode: function(i) {
      return i.type === "keypress" ? Hc(i) : 0;
    },
    keyCode: function(i) {
      return i.type === "keydown" || i.type === "keyup" ? i.keyCode : 0;
    },
    which: function(i) {
      return i.type === "keypress" ? Hc(i) : i.type === "keydown" || i.type === "keyup" ? i.keyCode : 0;
    }
  }), xT = ti(yT), ST = p({}, kc, {
    pointerId: 0,
    width: 0,
    height: 0,
    pressure: 0,
    tangentialPressure: 0,
    tiltX: 0,
    tiltY: 0,
    twist: 0,
    pointerType: 0,
    isPrimary: 0
  }), O0 = ti(ST), bT = p({}, ol, {
    touches: 0,
    targetTouches: 0,
    changedTouches: 0,
    altKey: 0,
    metaKey: 0,
    ctrlKey: 0,
    shiftKey: 0,
    getModifierState: Bd
  }), MT = ti(bT), ET = p({}, Ba, {
    propertyName: 0,
    elapsedTime: 0,
    pseudoElement: 0
  }), TT = ti(ET), AT = p({}, kc, {
    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
  }), wT = ti(AT), CT = p({}, Ba, {
    newState: 0,
    oldState: 0
  }), RT = ti(CT), DT = [9, 13, 27, 32], Fd = ds && "CompositionEvent" in window, cl = null;
  ds && "documentMode" in document && (cl = document.documentMode);
  var NT = ds && "TextEvent" in window && !cl, P0 = ds && (!Fd || cl && 8 < cl && 11 >= cl), z0 = " ", I0 = !1;
  function B0(i, a) {
    switch (i) {
      case "keyup":
        return DT.indexOf(a.keyCode) !== -1;
      case "keydown":
        return a.keyCode !== 229;
      case "keypress":
      case "mousedown":
      case "focusout":
        return !0;
      default:
        return !1;
    }
  }
  function F0(i) {
    return i = i.detail, typeof i == "object" && "data" in i ? i.data : null;
  }
  var Nr = !1;
  function LT(i, a) {
    switch (i) {
      case "compositionend":
        return F0(a);
      case "keypress":
        return a.which !== 32 ? null : (I0 = !0, z0);
      case "textInput":
        return i = a.data, i === z0 && I0 ? null : i;
      default:
        return null;
    }
  }
  function UT(i, a) {
    if (Nr)
      return i === "compositionend" || !Fd && B0(i, a) ? (i = D0(), Fc = Od = Ys = null, Nr = !1, i) : null;
    switch (i) {
      case "paste":
        return null;
      case "keypress":
        if (!(a.ctrlKey || a.altKey || a.metaKey) || a.ctrlKey && a.altKey) {
          if (a.char && 1 < a.char.length)
            return a.char;
          if (a.which) return String.fromCharCode(a.which);
        }
        return null;
      case "compositionend":
        return P0 && a.locale !== "ko" ? null : a.data;
      default:
        return null;
    }
  }
  var OT = {
    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 H0(i) {
    var a = i && i.nodeName && i.nodeName.toLowerCase();
    return a === "input" ? !!OT[i.type] : a === "textarea";
  }
  function V0(i, a, o, u) {
    Rr ? Dr ? Dr.push(u) : Dr = [u] : Rr = u, a = Lu(a, "onChange"), 0 < a.length && (o = new Gc(
      "onChange",
      "change",
      null,
      o,
      u
    ), i.push({ event: o, listeners: a }));
  }
  var ul = null, fl = null;
  function PT(i) {
    My(i, 0);
  }
  function Xc(i) {
    var a = dt(i);
    if (kn(a)) return i;
  }
  function G0(i, a) {
    if (i === "change") return a;
  }
  var k0 = !1;
  if (ds) {
    var Hd;
    if (ds) {
      var Vd = "oninput" in document;
      if (!Vd) {
        var X0 = document.createElement("div");
        X0.setAttribute("oninput", "return;"), Vd = typeof X0.oninput == "function";
      }
      Hd = Vd;
    } else Hd = !1;
    k0 = Hd && (!document.documentMode || 9 < document.documentMode);
  }
  function W0() {
    ul && (ul.detachEvent("onpropertychange", Y0), fl = ul = null);
  }
  function Y0(i) {
    if (i.propertyName === "value" && Xc(fl)) {
      var a = [];
      V0(
        a,
        fl,
        i,
        Nd(i)
      ), R0(PT, a);
    }
  }
  function zT(i, a, o) {
    i === "focusin" ? (W0(), ul = a, fl = o, ul.attachEvent("onpropertychange", Y0)) : i === "focusout" && W0();
  }
  function IT(i) {
    if (i === "selectionchange" || i === "keyup" || i === "keydown")
      return Xc(fl);
  }
  function BT(i, a) {
    if (i === "click") return Xc(a);
  }
  function FT(i, a) {
    if (i === "input" || i === "change")
      return Xc(a);
  }
  function HT(i, a) {
    return i === a && (i !== 0 || 1 / i === 1 / a) || i !== i && a !== a;
  }
  var fi = typeof Object.is == "function" ? Object.is : HT;
  function dl(i, a) {
    if (fi(i, a)) return !0;
    if (typeof i != "object" || i === null || typeof a != "object" || a === null)
      return !1;
    var o = Object.keys(i), u = Object.keys(a);
    if (o.length !== u.length) return !1;
    for (u = 0; u < o.length; u++) {
      var g = o[u];
      if (!xe.call(a, g) || !fi(i[g], a[g]))
        return !1;
    }
    return !0;
  }
  function j0(i) {
    for (; i && i.firstChild; ) i = i.firstChild;
    return i;
  }
  function q0(i, a) {
    var o = j0(i);
    i = 0;
    for (var u; o; ) {
      if (o.nodeType === 3) {
        if (u = i + o.textContent.length, i <= a && u >= a)
          return { node: o, offset: a - i };
        i = u;
      }
      t: {
        for (; o; ) {
          if (o.nextSibling) {
            o = o.nextSibling;
            break t;
          }
          o = o.parentNode;
        }
        o = void 0;
      }
      o = j0(o);
    }
  }
  function Z0(i, a) {
    return i && a ? i === a ? !0 : i && i.nodeType === 3 ? !1 : a && a.nodeType === 3 ? Z0(i, a.parentNode) : "contains" in i ? i.contains(a) : i.compareDocumentPosition ? !!(i.compareDocumentPosition(a) & 16) : !1 : !1;
  }
  function K0(i) {
    i = i != null && i.ownerDocument != null && i.ownerDocument.defaultView != null ? i.ownerDocument.defaultView : window;
    for (var a = Qn(i.document); a instanceof i.HTMLIFrameElement; ) {
      try {
        var o = typeof a.contentWindow.location.href == "string";
      } catch {
        o = !1;
      }
      if (o) i = a.contentWindow;
      else break;
      a = Qn(i.document);
    }
    return a;
  }
  function Gd(i) {
    var a = i && i.nodeName && i.nodeName.toLowerCase();
    return a && (a === "input" && (i.type === "text" || i.type === "search" || i.type === "tel" || i.type === "url" || i.type === "password") || a === "textarea" || i.contentEditable === "true");
  }
  var VT = ds && "documentMode" in document && 11 >= document.documentMode, Lr = null, kd = null, hl = null, Xd = !1;
  function $0(i, a, o) {
    var u = o.window === o ? o.document : o.nodeType === 9 ? o : o.ownerDocument;
    Xd || Lr == null || Lr !== Qn(u) || (u = Lr, "selectionStart" in u && Gd(u) ? u = { start: u.selectionStart, end: u.selectionEnd } : (u = (u.ownerDocument && u.ownerDocument.defaultView || window).getSelection(), u = {
      anchorNode: u.anchorNode,
      anchorOffset: u.anchorOffset,
      focusNode: u.focusNode,
      focusOffset: u.focusOffset
    }), hl && dl(hl, u) || (hl = u, u = Lu(kd, "onSelect"), 0 < u.length && (a = new Gc(
      "onSelect",
      "select",
      null,
      a,
      o
    ), i.push({ event: a, listeners: u }), a.target = Lr)));
  }
  function Fa(i, a) {
    var o = {};
    return o[i.toLowerCase()] = a.toLowerCase(), o["Webkit" + i] = "webkit" + a, o["Moz" + i] = "moz" + a, o;
  }
  var Ur = {
    animationend: Fa("Animation", "AnimationEnd"),
    animationiteration: Fa("Animation", "AnimationIteration"),
    animationstart: Fa("Animation", "AnimationStart"),
    transitionrun: Fa("Transition", "TransitionRun"),
    transitionstart: Fa("Transition", "TransitionStart"),
    transitioncancel: Fa("Transition", "TransitionCancel"),
    transitionend: Fa("Transition", "TransitionEnd")
  }, Wd = {}, Q0 = {};
  ds && (Q0 = document.createElement("div").style, "AnimationEvent" in window || (delete Ur.animationend.animation, delete Ur.animationiteration.animation, delete Ur.animationstart.animation), "TransitionEvent" in window || delete Ur.transitionend.transition);
  function Ha(i) {
    if (Wd[i]) return Wd[i];
    if (!Ur[i]) return i;
    var a = Ur[i], o;
    for (o in a)
      if (a.hasOwnProperty(o) && o in Q0)
        return Wd[i] = a[o];
    return i;
  }
  var J0 = Ha("animationend"), t_ = Ha("animationiteration"), e_ = Ha("animationstart"), GT = Ha("transitionrun"), kT = Ha("transitionstart"), XT = Ha("transitioncancel"), n_ = Ha("transitionend"), i_ = /* @__PURE__ */ new Map(), Yd = "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(
    " "
  );
  Yd.push("scrollEnd");
  function Bi(i, a) {
    i_.set(i, a), Ft(a, [i]);
  }
  var Wc = typeof reportError == "function" ? reportError : function(i) {
    if (typeof window == "object" && typeof window.ErrorEvent == "function") {
      var a = 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(a)) return;
    } else if (typeof process == "object" && typeof process.emit == "function") {
      process.emit("uncaughtException", i);
      return;
    }
    console.error(i);
  }, Ai = [], Or = 0, jd = 0;
  function Yc() {
    for (var i = Or, a = jd = Or = 0; a < i; ) {
      var o = Ai[a];
      Ai[a++] = null;
      var u = Ai[a];
      Ai[a++] = null;
      var g = Ai[a];
      Ai[a++] = null;
      var v = Ai[a];
      if (Ai[a++] = null, u !== null && g !== null) {
        var w = u.pending;
        w === null ? g.next = g : (g.next = w.next, w.next = g), u.pending = g;
      }
      v !== 0 && s_(o, g, v);
    }
  }
  function jc(i, a, o, u) {
    Ai[Or++] = i, Ai[Or++] = a, Ai[Or++] = o, Ai[Or++] = u, jd |= u, i.lanes |= u, i = i.alternate, i !== null && (i.lanes |= u);
  }
  function qd(i, a, o, u) {
    return jc(i, a, o, u), qc(i);
  }
  function Va(i, a) {
    return jc(i, null, null, a), qc(i);
  }
  function s_(i, a, o) {
    i.lanes |= o;
    var u = i.alternate;
    u !== null && (u.lanes |= o);
    for (var g = !1, v = i.return; v !== null; )
      v.childLanes |= o, u = v.alternate, u !== null && (u.childLanes |= o), v.tag === 22 && (i = v.stateNode, i === null || i._visibility & 1 || (g = !0)), i = v, v = v.return;
    return i.tag === 3 ? (v = i.stateNode, g && a !== null && (g = 31 - re(o), i = v.hiddenUpdates, u = i[g], u === null ? i[g] = [a] : u.push(a), a.lane = o | 536870912), v) : null;
  }
  function qc(i) {
    if (50 < Pl)
      throw Pl = 0, ip = null, Error(s(185));
    for (var a = i.return; a !== null; )
      i = a, a = i.return;
    return i.tag === 3 ? i.stateNode : null;
  }
  var Pr = {};
  function WT(i, a, o, u) {
    this.tag = i, this.key = o, this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null, this.index = 0, this.refCleanup = this.ref = null, this.pendingProps = a, this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null, this.mode = u, this.subtreeFlags = this.flags = 0, this.deletions = null, this.childLanes = this.lanes = 0, this.alternate = null;
  }
  function di(i, a, o, u) {
    return new WT(i, a, o, u);
  }
  function Zd(i) {
    return i = i.prototype, !(!i || !i.isReactComponent);
  }
  function hs(i, a) {
    var o = i.alternate;
    return o === null ? (o = di(
      i.tag,
      a,
      i.key,
      i.mode
    ), o.elementType = i.elementType, o.type = i.type, o.stateNode = i.stateNode, o.alternate = i, i.alternate = o) : (o.pendingProps = a, o.type = i.type, o.flags = 0, o.subtreeFlags = 0, o.deletions = null), o.flags = i.flags & 65011712, o.childLanes = i.childLanes, o.lanes = i.lanes, o.child = i.child, o.memoizedProps = i.memoizedProps, o.memoizedState = i.memoizedState, o.updateQueue = i.updateQueue, a = i.dependencies, o.dependencies = a === null ? null : { lanes: a.lanes, firstContext: a.firstContext }, o.sibling = i.sibling, o.index = i.index, o.ref = i.ref, o.refCleanup = i.refCleanup, o;
  }
  function a_(i, a) {
    i.flags &= 65011714;
    var o = i.alternate;
    return o === null ? (i.childLanes = 0, i.lanes = a, i.child = null, i.subtreeFlags = 0, i.memoizedProps = null, i.memoizedState = null, i.updateQueue = null, i.dependencies = null, i.stateNode = null) : (i.childLanes = o.childLanes, i.lanes = o.lanes, i.child = o.child, i.subtreeFlags = 0, i.deletions = null, i.memoizedProps = o.memoizedProps, i.memoizedState = o.memoizedState, i.updateQueue = o.updateQueue, i.type = o.type, a = o.dependencies, i.dependencies = a === null ? null : {
      lanes: a.lanes,
      firstContext: a.firstContext
    }), i;
  }
  function Zc(i, a, o, u, g, v) {
    var w = 0;
    if (u = i, typeof i == "function") Zd(i) && (w = 1);
    else if (typeof i == "string")
      w = KA(
        i,
        o,
        $.current
      ) ? 26 : i === "html" || i === "head" || i === "body" ? 27 : 5;
    else
      t: switch (i) {
        case A:
          return i = di(31, o, a, g), i.elementType = A, i.lanes = v, i;
        case M:
          return Ga(o.children, g, v, a);
        case S:
          w = 8, g |= 24;
          break;
        case y:
          return i = di(12, o, a, g | 2), i.elementType = y, i.lanes = v, i;
        case O:
          return i = di(13, o, a, g), i.elementType = O, i.lanes = v, i;
        case N:
          return i = di(19, o, a, g), i.elementType = N, i.lanes = v, i;
        default:
          if (typeof i == "object" && i !== null)
            switch (i.$$typeof) {
              case T:
                w = 10;
                break t;
              case C:
                w = 9;
                break t;
              case E:
                w = 11;
                break t;
              case D:
                w = 14;
                break t;
              case z:
                w = 16, u = null;
                break t;
            }
          w = 29, o = Error(
            s(130, i === null ? "null" : typeof i, "")
          ), u = null;
      }
    return a = di(w, o, a, g), a.elementType = i, a.type = u, a.lanes = v, a;
  }
  function Ga(i, a, o, u) {
    return i = di(7, i, u, a), i.lanes = o, i;
  }
  function Kd(i, a, o) {
    return i = di(6, i, null, a), i.lanes = o, i;
  }
  function r_(i) {
    var a = di(18, null, null, 0);
    return a.stateNode = i, a;
  }
  function $d(i, a, o) {
    return a = di(
      4,
      i.children !== null ? i.children : [],
      i.key,
      a
    ), a.lanes = o, a.stateNode = {
      containerInfo: i.containerInfo,
      pendingChildren: null,
      implementation: i.implementation
    }, a;
  }
  var o_ = /* @__PURE__ */ new WeakMap();
  function wi(i, a) {
    if (typeof i == "object" && i !== null) {
      var o = o_.get(i);
      return o !== void 0 ? o : (a = {
        value: i,
        source: a,
        stack: qt(a)
      }, o_.set(i, a), a);
    }
    return {
      value: i,
      source: a,
      stack: qt(a)
    };
  }
  var zr = [], Ir = 0, Kc = null, pl = 0, Ci = [], Ri = 0, js = null, Zi = 1, Ki = "";
  function ps(i, a) {
    zr[Ir++] = pl, zr[Ir++] = Kc, Kc = i, pl = a;
  }
  function l_(i, a, o) {
    Ci[Ri++] = Zi, Ci[Ri++] = Ki, Ci[Ri++] = js, js = i;
    var u = Zi;
    i = Ki;
    var g = 32 - re(u) - 1;
    u &= ~(1 << g), o += 1;
    var v = 32 - re(a) + g;
    if (30 < v) {
      var w = g - g % 5;
      v = (u & (1 << w) - 1).toString(32), u >>= w, g -= w, Zi = 1 << 32 - re(a) + g | o << g | u, Ki = v + i;
    } else
      Zi = 1 << v | o << g | u, Ki = i;
  }
  function Qd(i) {
    i.return !== null && (ps(i, 1), l_(i, 1, 0));
  }
  function Jd(i) {
    for (; i === Kc; )
      Kc = zr[--Ir], zr[Ir] = null, pl = zr[--Ir], zr[Ir] = null;
    for (; i === js; )
      js = Ci[--Ri], Ci[Ri] = null, Ki = Ci[--Ri], Ci[Ri] = null, Zi = Ci[--Ri], Ci[Ri] = null;
  }
  function c_(i, a) {
    Ci[Ri++] = Zi, Ci[Ri++] = Ki, Ci[Ri++] = js, Zi = a.id, Ki = a.overflow, js = i;
  }
  var In = null, Je = null, Ne = !1, qs = null, Di = !1, th = Error(s(519));
  function Zs(i) {
    var a = Error(
      s(
        418,
        1 < arguments.length && arguments[1] !== void 0 && arguments[1] ? "text" : "HTML",
        ""
      )
    );
    throw ml(wi(a, i)), th;
  }
  function u_(i) {
    var a = i.stateNode, o = i.type, u = i.memoizedProps;
    switch (a[nn] = i, a[En] = u, o) {
      case "dialog":
        Te("cancel", a), Te("close", a);
        break;
      case "iframe":
      case "object":
      case "embed":
        Te("load", a);
        break;
      case "video":
      case "audio":
        for (o = 0; o < Il.length; o++)
          Te(Il[o], a);
        break;
      case "source":
        Te("error", a);
        break;
      case "img":
      case "image":
      case "link":
        Te("error", a), Te("load", a);
        break;
      case "details":
        Te("toggle", a);
        break;
      case "input":
        Te("invalid", a), Pn(
          a,
          u.value,
          u.defaultValue,
          u.checked,
          u.defaultChecked,
          u.type,
          u.name,
          !0
        );
        break;
      case "select":
        Te("invalid", a);
        break;
      case "textarea":
        Te("invalid", a), Cr(a, u.value, u.defaultValue, u.children);
    }
    o = u.children, typeof o != "string" && typeof o != "number" && typeof o != "bigint" || a.textContent === "" + o || u.suppressHydrationWarning === !0 || wy(a.textContent, o) ? (u.popover != null && (Te("beforetoggle", a), Te("toggle", a)), u.onScroll != null && Te("scroll", a), u.onScrollEnd != null && Te("scrollend", a), u.onClick != null && (a.onclick = fs), a = !0) : a = !1, a || Zs(i, !0);
  }
  function f_(i) {
    for (In = i.return; In; )
      switch (In.tag) {
        case 5:
        case 31:
        case 13:
          Di = !1;
          return;
        case 27:
        case 3:
          Di = !0;
          return;
        default:
          In = In.return;
      }
  }
  function Br(i) {
    if (i !== In) return !1;
    if (!Ne) return f_(i), Ne = !0, !1;
    var a = i.tag, o;
    if ((o = a !== 3 && a !== 27) && ((o = a === 5) && (o = i.type, o = !(o !== "form" && o !== "button") || vp(i.type, i.memoizedProps)), o = !o), o && Je && Zs(i), f_(i), a === 13) {
      if (i = i.memoizedState, i = i !== null ? i.dehydrated : null, !i) throw Error(s(317));
      Je = zy(i);
    } else if (a === 31) {
      if (i = i.memoizedState, i = i !== null ? i.dehydrated : null, !i) throw Error(s(317));
      Je = zy(i);
    } else
      a === 27 ? (a = Je, ca(i.type) ? (i = Mp, Mp = null, Je = i) : Je = a) : Je = In ? Li(i.stateNode.nextSibling) : null;
    return !0;
  }
  function ka() {
    Je = In = null, Ne = !1;
  }
  function eh() {
    var i = qs;
    return i !== null && (si === null ? si = i : si.push.apply(
      si,
      i
    ), qs = null), i;
  }
  function ml(i) {
    qs === null ? qs = [i] : qs.push(i);
  }
  var nh = I(null), Xa = null, ms = null;
  function Ks(i, a, o) {
    lt(nh, a._currentValue), a._currentValue = o;
  }
  function gs(i) {
    i._currentValue = nh.current, q(nh);
  }
  function ih(i, a, o) {
    for (; i !== null; ) {
      var u = i.alternate;
      if ((i.childLanes & a) !== a ? (i.childLanes |= a, u !== null && (u.childLanes |= a)) : u !== null && (u.childLanes & a) !== a && (u.childLanes |= a), i === o) break;
      i = i.return;
    }
  }
  function sh(i, a, o, u) {
    var g = i.child;
    for (g !== null && (g.return = i); g !== null; ) {
      var v = g.dependencies;
      if (v !== null) {
        var w = g.child;
        v = v.firstContext;
        t: for (; v !== null; ) {
          var F = v;
          v = g;
          for (var Q = 0; Q < a.length; Q++)
            if (F.context === a[Q]) {
              v.lanes |= o, F = v.alternate, F !== null && (F.lanes |= o), ih(
                v.return,
                o,
                i
              ), u || (w = null);
              break t;
            }
          v = F.next;
        }
      } else if (g.tag === 18) {
        if (w = g.return, w === null) throw Error(s(341));
        w.lanes |= o, v = w.alternate, v !== null && (v.lanes |= o), ih(w, o, i), w = null;
      } else w = g.child;
      if (w !== null) w.return = g;
      else
        for (w = g; w !== null; ) {
          if (w === i) {
            w = null;
            break;
          }
          if (g = w.sibling, g !== null) {
            g.return = w.return, w = g;
            break;
          }
          w = w.return;
        }
      g = w;
    }
  }
  function Fr(i, a, o, u) {
    i = null;
    for (var g = a, v = !1; g !== null; ) {
      if (!v) {
        if ((g.flags & 524288) !== 0) v = !0;
        else if ((g.flags & 262144) !== 0) break;
      }
      if (g.tag === 10) {
        var w = g.alternate;
        if (w === null) throw Error(s(387));
        if (w = w.memoizedProps, w !== null) {
          var F = g.type;
          fi(g.pendingProps.value, w.value) || (i !== null ? i.push(F) : i = [F]);
        }
      } else if (g === ht.current) {
        if (w = g.alternate, w === null) throw Error(s(387));
        w.memoizedState.memoizedState !== g.memoizedState.memoizedState && (i !== null ? i.push(Gl) : i = [Gl]);
      }
      g = g.return;
    }
    i !== null && sh(
      a,
      i,
      o,
      u
    ), a.flags |= 262144;
  }
  function $c(i) {
    for (i = i.firstContext; i !== null; ) {
      if (!fi(
        i.context._currentValue,
        i.memoizedValue
      ))
        return !0;
      i = i.next;
    }
    return !1;
  }
  function Wa(i) {
    Xa = i, ms = null, i = i.dependencies, i !== null && (i.firstContext = null);
  }
  function Bn(i) {
    return d_(Xa, i);
  }
  function Qc(i, a) {
    return Xa === null && Wa(i), d_(i, a);
  }
  function d_(i, a) {
    var o = a._currentValue;
    if (a = { context: a, memoizedValue: o, next: null }, ms === null) {
      if (i === null) throw Error(s(308));
      ms = a, i.dependencies = { lanes: 0, firstContext: a }, i.flags |= 524288;
    } else ms = ms.next = a;
    return o;
  }
  var YT = typeof AbortController < "u" ? AbortController : function() {
    var i = [], a = this.signal = {
      aborted: !1,
      addEventListener: function(o, u) {
        i.push(u);
      }
    };
    this.abort = function() {
      a.aborted = !0, i.forEach(function(o) {
        return o();
      });
    };
  }, jT = n.unstable_scheduleCallback, qT = n.unstable_NormalPriority, gn = {
    $$typeof: T,
    Consumer: null,
    Provider: null,
    _currentValue: null,
    _currentValue2: null,
    _threadCount: 0
  };
  function ah() {
    return {
      controller: new YT(),
      data: /* @__PURE__ */ new Map(),
      refCount: 0
    };
  }
  function gl(i) {
    i.refCount--, i.refCount === 0 && jT(qT, function() {
      i.controller.abort();
    });
  }
  var _l = null, rh = 0, Hr = 0, Vr = null;
  function ZT(i, a) {
    if (_l === null) {
      var o = _l = [];
      rh = 0, Hr = cp(), Vr = {
        status: "pending",
        value: void 0,
        then: function(u) {
          o.push(u);
        }
      };
    }
    return rh++, a.then(h_, h_), a;
  }
  function h_() {
    if (--rh === 0 && _l !== null) {
      Vr !== null && (Vr.status = "fulfilled");
      var i = _l;
      _l = null, Hr = 0, Vr = null;
      for (var a = 0; a < i.length; a++) (0, i[a])();
    }
  }
  function KT(i, a) {
    var o = [], u = {
      status: "pending",
      value: null,
      reason: null,
      then: function(g) {
        o.push(g);
      }
    };
    return i.then(
      function() {
        u.status = "fulfilled", u.value = a;
        for (var g = 0; g < o.length; g++) (0, o[g])(a);
      },
      function(g) {
        for (u.status = "rejected", u.reason = g, g = 0; g < o.length; g++)
          (0, o[g])(void 0);
      }
    ), u;
  }
  var p_ = U.S;
  U.S = function(i, a) {
    $v = St(), typeof a == "object" && a !== null && typeof a.then == "function" && ZT(i, a), p_ !== null && p_(i, a);
  };
  var Ya = I(null);
  function oh() {
    var i = Ya.current;
    return i !== null ? i : Ke.pooledCache;
  }
  function Jc(i, a) {
    a === null ? lt(Ya, Ya.current) : lt(Ya, a.pool);
  }
  function m_() {
    var i = oh();
    return i === null ? null : { parent: gn._currentValue, pool: i };
  }
  var Gr = Error(s(460)), lh = Error(s(474)), tu = Error(s(542)), eu = { then: function() {
  } };
  function g_(i) {
    return i = i.status, i === "fulfilled" || i === "rejected";
  }
  function __(i, a, o) {
    switch (o = i[o], o === void 0 ? i.push(a) : o !== a && (a.then(fs, fs), a = o), a.status) {
      case "fulfilled":
        return a.value;
      case "rejected":
        throw i = a.reason, y_(i), i;
      default:
        if (typeof a.status == "string") a.then(fs, fs);
        else {
          if (i = Ke, i !== null && 100 < i.shellSuspendCounter)
            throw Error(s(482));
          i = a, i.status = "pending", i.then(
            function(u) {
              if (a.status === "pending") {
                var g = a;
                g.status = "fulfilled", g.value = u;
              }
            },
            function(u) {
              if (a.status === "pending") {
                var g = a;
                g.status = "rejected", g.reason = u;
              }
            }
          );
        }
        switch (a.status) {
          case "fulfilled":
            return a.value;
          case "rejected":
            throw i = a.reason, y_(i), i;
        }
        throw qa = a, Gr;
    }
  }
  function ja(i) {
    try {
      var a = i._init;
      return a(i._payload);
    } catch (o) {
      throw o !== null && typeof o == "object" && typeof o.then == "function" ? (qa = o, Gr) : o;
    }
  }
  var qa = null;
  function v_() {
    if (qa === null) throw Error(s(459));
    var i = qa;
    return qa = null, i;
  }
  function y_(i) {
    if (i === Gr || i === tu)
      throw Error(s(483));
  }
  var kr = null, vl = 0;
  function nu(i) {
    var a = vl;
    return vl += 1, kr === null && (kr = []), __(kr, i, a);
  }
  function yl(i, a) {
    a = a.props.ref, i.ref = a !== void 0 ? a : null;
  }
  function iu(i, a) {
    throw a.$$typeof === _ ? Error(s(525)) : (i = Object.prototype.toString.call(a), Error(
      s(
        31,
        i === "[object Object]" ? "object with keys {" + Object.keys(a).join(", ") + "}" : i
      )
    ));
  }
  function x_(i) {
    function a(rt, tt) {
      if (i) {
        var ct = rt.deletions;
        ct === null ? (rt.deletions = [tt], rt.flags |= 16) : ct.push(tt);
      }
    }
    function o(rt, tt) {
      if (!i) return null;
      for (; tt !== null; )
        a(rt, tt), tt = tt.sibling;
      return null;
    }
    function u(rt) {
      for (var tt = /* @__PURE__ */ new Map(); rt !== null; )
        rt.key !== null ? tt.set(rt.key, rt) : tt.set(rt.index, rt), rt = rt.sibling;
      return tt;
    }
    function g(rt, tt) {
      return rt = hs(rt, tt), rt.index = 0, rt.sibling = null, rt;
    }
    function v(rt, tt, ct) {
      return rt.index = ct, i ? (ct = rt.alternate, ct !== null ? (ct = ct.index, ct < tt ? (rt.flags |= 67108866, tt) : ct) : (rt.flags |= 67108866, tt)) : (rt.flags |= 1048576, tt);
    }
    function w(rt) {
      return i && rt.alternate === null && (rt.flags |= 67108866), rt;
    }
    function F(rt, tt, ct, Mt) {
      return tt === null || tt.tag !== 6 ? (tt = Kd(ct, rt.mode, Mt), tt.return = rt, tt) : (tt = g(tt, ct), tt.return = rt, tt);
    }
    function Q(rt, tt, ct, Mt) {
      var ie = ct.type;
      return ie === M ? xt(
        rt,
        tt,
        ct.props.children,
        Mt,
        ct.key
      ) : tt !== null && (tt.elementType === ie || typeof ie == "object" && ie !== null && ie.$$typeof === z && ja(ie) === tt.type) ? (tt = g(tt, ct.props), yl(tt, ct), tt.return = rt, tt) : (tt = Zc(
        ct.type,
        ct.key,
        ct.props,
        null,
        rt.mode,
        Mt
      ), yl(tt, ct), tt.return = rt, tt);
    }
    function ut(rt, tt, ct, Mt) {
      return tt === null || tt.tag !== 4 || tt.stateNode.containerInfo !== ct.containerInfo || tt.stateNode.implementation !== ct.implementation ? (tt = $d(ct, rt.mode, Mt), tt.return = rt, tt) : (tt = g(tt, ct.children || []), tt.return = rt, tt);
    }
    function xt(rt, tt, ct, Mt, ie) {
      return tt === null || tt.tag !== 7 ? (tt = Ga(
        ct,
        rt.mode,
        Mt,
        ie
      ), tt.return = rt, tt) : (tt = g(tt, ct), tt.return = rt, tt);
    }
    function Tt(rt, tt, ct) {
      if (typeof tt == "string" && tt !== "" || typeof tt == "number" || typeof tt == "bigint")
        return tt = Kd(
          "" + tt,
          rt.mode,
          ct
        ), tt.return = rt, tt;
      if (typeof tt == "object" && tt !== null) {
        switch (tt.$$typeof) {
          case x:
            return ct = Zc(
              tt.type,
              tt.key,
              tt.props,
              null,
              rt.mode,
              ct
            ), yl(ct, tt), ct.return = rt, ct;
          case b:
            return tt = $d(
              tt,
              rt.mode,
              ct
            ), tt.return = rt, tt;
          case z:
            return tt = ja(tt), Tt(rt, tt, ct);
        }
        if (Y(tt) || H(tt))
          return tt = Ga(
            tt,
            rt.mode,
            ct,
            null
          ), tt.return = rt, tt;
        if (typeof tt.then == "function")
          return Tt(rt, nu(tt), ct);
        if (tt.$$typeof === T)
          return Tt(
            rt,
            Qc(rt, tt),
            ct
          );
        iu(rt, tt);
      }
      return null;
    }
    function pt(rt, tt, ct, Mt) {
      var ie = tt !== null ? tt.key : null;
      if (typeof ct == "string" && ct !== "" || typeof ct == "number" || typeof ct == "bigint")
        return ie !== null ? null : F(rt, tt, "" + ct, Mt);
      if (typeof ct == "object" && ct !== null) {
        switch (ct.$$typeof) {
          case x:
            return ct.key === ie ? Q(rt, tt, ct, Mt) : null;
          case b:
            return ct.key === ie ? ut(rt, tt, ct, Mt) : null;
          case z:
            return ct = ja(ct), pt(rt, tt, ct, Mt);
        }
        if (Y(ct) || H(ct))
          return ie !== null ? null : xt(rt, tt, ct, Mt, null);
        if (typeof ct.then == "function")
          return pt(
            rt,
            tt,
            nu(ct),
            Mt
          );
        if (ct.$$typeof === T)
          return pt(
            rt,
            tt,
            Qc(rt, ct),
            Mt
          );
        iu(rt, ct);
      }
      return null;
    }
    function vt(rt, tt, ct, Mt, ie) {
      if (typeof Mt == "string" && Mt !== "" || typeof Mt == "number" || typeof Mt == "bigint")
        return rt = rt.get(ct) || null, F(tt, rt, "" + Mt, ie);
      if (typeof Mt == "object" && Mt !== null) {
        switch (Mt.$$typeof) {
          case x:
            return rt = rt.get(
              Mt.key === null ? ct : Mt.key
            ) || null, Q(tt, rt, Mt, ie);
          case b:
            return rt = rt.get(
              Mt.key === null ? ct : Mt.key
            ) || null, ut(tt, rt, Mt, ie);
          case z:
            return Mt = ja(Mt), vt(
              rt,
              tt,
              ct,
              Mt,
              ie
            );
        }
        if (Y(Mt) || H(Mt))
          return rt = rt.get(ct) || null, xt(tt, rt, Mt, ie, null);
        if (typeof Mt.then == "function")
          return vt(
            rt,
            tt,
            ct,
            nu(Mt),
            ie
          );
        if (Mt.$$typeof === T)
          return vt(
            rt,
            tt,
            ct,
            Qc(tt, Mt),
            ie
          );
        iu(tt, Mt);
      }
      return null;
    }
    function Kt(rt, tt, ct, Mt) {
      for (var ie = null, Pe = null, Qt = tt, ge = tt = 0, Re = null; Qt !== null && ge < ct.length; ge++) {
        Qt.index > ge ? (Re = Qt, Qt = null) : Re = Qt.sibling;
        var ze = pt(
          rt,
          Qt,
          ct[ge],
          Mt
        );
        if (ze === null) {
          Qt === null && (Qt = Re);
          break;
        }
        i && Qt && ze.alternate === null && a(rt, Qt), tt = v(ze, tt, ge), Pe === null ? ie = ze : Pe.sibling = ze, Pe = ze, Qt = Re;
      }
      if (ge === ct.length)
        return o(rt, Qt), Ne && ps(rt, ge), ie;
      if (Qt === null) {
        for (; ge < ct.length; ge++)
          Qt = Tt(rt, ct[ge], Mt), Qt !== null && (tt = v(
            Qt,
            tt,
            ge
          ), Pe === null ? ie = Qt : Pe.sibling = Qt, Pe = Qt);
        return Ne && ps(rt, ge), ie;
      }
      for (Qt = u(Qt); ge < ct.length; ge++)
        Re = vt(
          Qt,
          rt,
          ge,
          ct[ge],
          Mt
        ), Re !== null && (i && Re.alternate !== null && Qt.delete(
          Re.key === null ? ge : Re.key
        ), tt = v(
          Re,
          tt,
          ge
        ), Pe === null ? ie = Re : Pe.sibling = Re, Pe = Re);
      return i && Qt.forEach(function(pa) {
        return a(rt, pa);
      }), Ne && ps(rt, ge), ie;
    }
    function ae(rt, tt, ct, Mt) {
      if (ct == null) throw Error(s(151));
      for (var ie = null, Pe = null, Qt = tt, ge = tt = 0, Re = null, ze = ct.next(); Qt !== null && !ze.done; ge++, ze = ct.next()) {
        Qt.index > ge ? (Re = Qt, Qt = null) : Re = Qt.sibling;
        var pa = pt(rt, Qt, ze.value, Mt);
        if (pa === null) {
          Qt === null && (Qt = Re);
          break;
        }
        i && Qt && pa.alternate === null && a(rt, Qt), tt = v(pa, tt, ge), Pe === null ? ie = pa : Pe.sibling = pa, Pe = pa, Qt = Re;
      }
      if (ze.done)
        return o(rt, Qt), Ne && ps(rt, ge), ie;
      if (Qt === null) {
        for (; !ze.done; ge++, ze = ct.next())
          ze = Tt(rt, ze.value, Mt), ze !== null && (tt = v(ze, tt, ge), Pe === null ? ie = ze : Pe.sibling = ze, Pe = ze);
        return Ne && ps(rt, ge), ie;
      }
      for (Qt = u(Qt); !ze.done; ge++, ze = ct.next())
        ze = vt(Qt, rt, ge, ze.value, Mt), ze !== null && (i && ze.alternate !== null && Qt.delete(ze.key === null ? ge : ze.key), tt = v(ze, tt, ge), Pe === null ? ie = ze : Pe.sibling = ze, Pe = ze);
      return i && Qt.forEach(function(ow) {
        return a(rt, ow);
      }), Ne && ps(rt, ge), ie;
    }
    function Xe(rt, tt, ct, Mt) {
      if (typeof ct == "object" && ct !== null && ct.type === M && ct.key === null && (ct = ct.props.children), typeof ct == "object" && ct !== null) {
        switch (ct.$$typeof) {
          case x:
            t: {
              for (var ie = ct.key; tt !== null; ) {
                if (tt.key === ie) {
                  if (ie = ct.type, ie === M) {
                    if (tt.tag === 7) {
                      o(
                        rt,
                        tt.sibling
                      ), Mt = g(
                        tt,
                        ct.props.children
                      ), Mt.return = rt, rt = Mt;
                      break t;
                    }
                  } else if (tt.elementType === ie || typeof ie == "object" && ie !== null && ie.$$typeof === z && ja(ie) === tt.type) {
                    o(
                      rt,
                      tt.sibling
                    ), Mt = g(tt, ct.props), yl(Mt, ct), Mt.return = rt, rt = Mt;
                    break t;
                  }
                  o(rt, tt);
                  break;
                } else a(rt, tt);
                tt = tt.sibling;
              }
              ct.type === M ? (Mt = Ga(
                ct.props.children,
                rt.mode,
                Mt,
                ct.key
              ), Mt.return = rt, rt = Mt) : (Mt = Zc(
                ct.type,
                ct.key,
                ct.props,
                null,
                rt.mode,
                Mt
              ), yl(Mt, ct), Mt.return = rt, rt = Mt);
            }
            return w(rt);
          case b:
            t: {
              for (ie = ct.key; tt !== null; ) {
                if (tt.key === ie)
                  if (tt.tag === 4 && tt.stateNode.containerInfo === ct.containerInfo && tt.stateNode.implementation === ct.implementation) {
                    o(
                      rt,
                      tt.sibling
                    ), Mt = g(tt, ct.children || []), Mt.return = rt, rt = Mt;
                    break t;
                  } else {
                    o(rt, tt);
                    break;
                  }
                else a(rt, tt);
                tt = tt.sibling;
              }
              Mt = $d(ct, rt.mode, Mt), Mt.return = rt, rt = Mt;
            }
            return w(rt);
          case z:
            return ct = ja(ct), Xe(
              rt,
              tt,
              ct,
              Mt
            );
        }
        if (Y(ct))
          return Kt(
            rt,
            tt,
            ct,
            Mt
          );
        if (H(ct)) {
          if (ie = H(ct), typeof ie != "function") throw Error(s(150));
          return ct = ie.call(ct), ae(
            rt,
            tt,
            ct,
            Mt
          );
        }
        if (typeof ct.then == "function")
          return Xe(
            rt,
            tt,
            nu(ct),
            Mt
          );
        if (ct.$$typeof === T)
          return Xe(
            rt,
            tt,
            Qc(rt, ct),
            Mt
          );
        iu(rt, ct);
      }
      return typeof ct == "string" && ct !== "" || typeof ct == "number" || typeof ct == "bigint" ? (ct = "" + ct, tt !== null && tt.tag === 6 ? (o(rt, tt.sibling), Mt = g(tt, ct), Mt.return = rt, rt = Mt) : (o(rt, tt), Mt = Kd(ct, rt.mode, Mt), Mt.return = rt, rt = Mt), w(rt)) : o(rt, tt);
    }
    return function(rt, tt, ct, Mt) {
      try {
        vl = 0;
        var ie = Xe(
          rt,
          tt,
          ct,
          Mt
        );
        return kr = null, ie;
      } catch (Qt) {
        if (Qt === Gr || Qt === tu) throw Qt;
        var Pe = di(29, Qt, null, rt.mode);
        return Pe.lanes = Mt, Pe.return = rt, Pe;
      } finally {
      }
    };
  }
  var Za = x_(!0), S_ = x_(!1), $s = !1;
  function ch(i) {
    i.updateQueue = {
      baseState: i.memoizedState,
      firstBaseUpdate: null,
      lastBaseUpdate: null,
      shared: { pending: null, lanes: 0, hiddenCallbacks: null },
      callbacks: null
    };
  }
  function uh(i, a) {
    i = i.updateQueue, a.updateQueue === i && (a.updateQueue = {
      baseState: i.baseState,
      firstBaseUpdate: i.firstBaseUpdate,
      lastBaseUpdate: i.lastBaseUpdate,
      shared: i.shared,
      callbacks: null
    });
  }
  function Qs(i) {
    return { lane: i, tag: 0, payload: null, callback: null, next: null };
  }
  function Js(i, a, o) {
    var u = i.updateQueue;
    if (u === null) return null;
    if (u = u.shared, (Be & 2) !== 0) {
      var g = u.pending;
      return g === null ? a.next = a : (a.next = g.next, g.next = a), u.pending = a, a = qc(i), s_(i, null, o), a;
    }
    return jc(i, u, a, o), qc(i);
  }
  function xl(i, a, o) {
    if (a = a.updateQueue, a !== null && (a = a.shared, (o & 4194048) !== 0)) {
      var u = a.lanes;
      u &= i.pendingLanes, o |= u, a.lanes = o, Pa(i, o);
    }
  }
  function fh(i, a) {
    var o = i.updateQueue, u = i.alternate;
    if (u !== null && (u = u.updateQueue, o === u)) {
      var g = null, v = null;
      if (o = o.firstBaseUpdate, o !== null) {
        do {
          var w = {
            lane: o.lane,
            tag: o.tag,
            payload: o.payload,
            callback: null,
            next: null
          };
          v === null ? g = v = w : v = v.next = w, o = o.next;
        } while (o !== null);
        v === null ? g = v = a : v = v.next = a;
      } else g = v = a;
      o = {
        baseState: u.baseState,
        firstBaseUpdate: g,
        lastBaseUpdate: v,
        shared: u.shared,
        callbacks: u.callbacks
      }, i.updateQueue = o;
      return;
    }
    i = o.lastBaseUpdate, i === null ? o.firstBaseUpdate = a : i.next = a, o.lastBaseUpdate = a;
  }
  var dh = !1;
  function Sl() {
    if (dh) {
      var i = Vr;
      if (i !== null) throw i;
    }
  }
  function bl(i, a, o, u) {
    dh = !1;
    var g = i.updateQueue;
    $s = !1;
    var v = g.firstBaseUpdate, w = g.lastBaseUpdate, F = g.shared.pending;
    if (F !== null) {
      g.shared.pending = null;
      var Q = F, ut = Q.next;
      Q.next = null, w === null ? v = ut : w.next = ut, w = Q;
      var xt = i.alternate;
      xt !== null && (xt = xt.updateQueue, F = xt.lastBaseUpdate, F !== w && (F === null ? xt.firstBaseUpdate = ut : F.next = ut, xt.lastBaseUpdate = Q));
    }
    if (v !== null) {
      var Tt = g.baseState;
      w = 0, xt = ut = Q = null, F = v;
      do {
        var pt = F.lane & -536870913, vt = pt !== F.lane;
        if (vt ? (Ce & pt) === pt : (u & pt) === pt) {
          pt !== 0 && pt === Hr && (dh = !0), xt !== null && (xt = xt.next = {
            lane: 0,
            tag: F.tag,
            payload: F.payload,
            callback: null,
            next: null
          });
          t: {
            var Kt = i, ae = F;
            pt = a;
            var Xe = o;
            switch (ae.tag) {
              case 1:
                if (Kt = ae.payload, typeof Kt == "function") {
                  Tt = Kt.call(Xe, Tt, pt);
                  break t;
                }
                Tt = Kt;
                break t;
              case 3:
                Kt.flags = Kt.flags & -65537 | 128;
              case 0:
                if (Kt = ae.payload, pt = typeof Kt == "function" ? Kt.call(Xe, Tt, pt) : Kt, pt == null) break t;
                Tt = p({}, Tt, pt);
                break t;
              case 2:
                $s = !0;
            }
          }
          pt = F.callback, pt !== null && (i.flags |= 64, vt && (i.flags |= 8192), vt = g.callbacks, vt === null ? g.callbacks = [pt] : vt.push(pt));
        } else
          vt = {
            lane: pt,
            tag: F.tag,
            payload: F.payload,
            callback: F.callback,
            next: null
          }, xt === null ? (ut = xt = vt, Q = Tt) : xt = xt.next = vt, w |= pt;
        if (F = F.next, F === null) {
          if (F = g.shared.pending, F === null)
            break;
          vt = F, F = vt.next, vt.next = null, g.lastBaseUpdate = vt, g.shared.pending = null;
        }
      } while (!0);
      xt === null && (Q = Tt), g.baseState = Q, g.firstBaseUpdate = ut, g.lastBaseUpdate = xt, v === null && (g.shared.lanes = 0), sa |= w, i.lanes = w, i.memoizedState = Tt;
    }
  }
  function b_(i, a) {
    if (typeof i != "function")
      throw Error(s(191, i));
    i.call(a);
  }
  function M_(i, a) {
    var o = i.callbacks;
    if (o !== null)
      for (i.callbacks = null, i = 0; i < o.length; i++)
        b_(o[i], a);
  }
  var Xr = I(null), su = I(0);
  function E_(i, a) {
    i = Ts, lt(su, i), lt(Xr, a), Ts = i | a.baseLanes;
  }
  function hh() {
    lt(su, Ts), lt(Xr, Xr.current);
  }
  function ph() {
    Ts = su.current, q(Xr), q(su);
  }
  var hi = I(null), Ni = null;
  function ta(i) {
    var a = i.alternate;
    lt(hn, hn.current & 1), lt(hi, i), Ni === null && (a === null || Xr.current !== null || a.memoizedState !== null) && (Ni = i);
  }
  function mh(i) {
    lt(hn, hn.current), lt(hi, i), Ni === null && (Ni = i);
  }
  function T_(i) {
    i.tag === 22 ? (lt(hn, hn.current), lt(hi, i), Ni === null && (Ni = i)) : ea();
  }
  function ea() {
    lt(hn, hn.current), lt(hi, hi.current);
  }
  function pi(i) {
    q(hi), Ni === i && (Ni = null), q(hn);
  }
  var hn = I(0);
  function au(i) {
    for (var a = i; a !== null; ) {
      if (a.tag === 13) {
        var o = a.memoizedState;
        if (o !== null && (o = o.dehydrated, o === null || Sp(o) || bp(o)))
          return a;
      } else if (a.tag === 19 && (a.memoizedProps.revealOrder === "forwards" || a.memoizedProps.revealOrder === "backwards" || a.memoizedProps.revealOrder === "unstable_legacy-backwards" || a.memoizedProps.revealOrder === "together")) {
        if ((a.flags & 128) !== 0) return a;
      } else if (a.child !== null) {
        a.child.return = a, a = a.child;
        continue;
      }
      if (a === i) break;
      for (; a.sibling === null; ) {
        if (a.return === null || a.return === i) return null;
        a = a.return;
      }
      a.sibling.return = a.return, a = a.sibling;
    }
    return null;
  }
  var _s = 0, me = null, Ge = null, _n = null, ru = !1, Wr = !1, Ka = !1, ou = 0, Ml = 0, Yr = null, $T = 0;
  function cn() {
    throw Error(s(321));
  }
  function gh(i, a) {
    if (a === null) return !1;
    for (var o = 0; o < a.length && o < i.length; o++)
      if (!fi(i[o], a[o])) return !1;
    return !0;
  }
  function _h(i, a, o, u, g, v) {
    return _s = v, me = a, a.memoizedState = null, a.updateQueue = null, a.lanes = 0, U.H = i === null || i.memoizedState === null ? lv : Lh, Ka = !1, v = o(u, g), Ka = !1, Wr && (v = w_(
      a,
      o,
      u,
      g
    )), A_(i), v;
  }
  function A_(i) {
    U.H = Al;
    var a = Ge !== null && Ge.next !== null;
    if (_s = 0, _n = Ge = me = null, ru = !1, Ml = 0, Yr = null, a) throw Error(s(300));
    i === null || vn || (i = i.dependencies, i !== null && $c(i) && (vn = !0));
  }
  function w_(i, a, o, u) {
    me = i;
    var g = 0;
    do {
      if (Wr && (Yr = null), Ml = 0, Wr = !1, 25 <= g) throw Error(s(301));
      if (g += 1, _n = Ge = null, i.updateQueue != null) {
        var v = i.updateQueue;
        v.lastEffect = null, v.events = null, v.stores = null, v.memoCache != null && (v.memoCache.index = 0);
      }
      U.H = cv, v = a(o, u);
    } while (Wr);
    return v;
  }
  function QT() {
    var i = U.H, a = i.useState()[0];
    return a = typeof a.then == "function" ? El(a) : a, i = i.useState()[0], (Ge !== null ? Ge.memoizedState : null) !== i && (me.flags |= 1024), a;
  }
  function vh() {
    var i = ou !== 0;
    return ou = 0, i;
  }
  function yh(i, a, o) {
    a.updateQueue = i.updateQueue, a.flags &= -2053, i.lanes &= ~o;
  }
  function xh(i) {
    if (ru) {
      for (i = i.memoizedState; i !== null; ) {
        var a = i.queue;
        a !== null && (a.pending = null), i = i.next;
      }
      ru = !1;
    }
    _s = 0, _n = Ge = me = null, Wr = !1, Ml = ou = 0, Yr = null;
  }
  function Zn() {
    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 pn() {
    if (Ge === null) {
      var i = me.alternate;
      i = i !== null ? i.memoizedState : null;
    } else i = Ge.next;
    var a = _n === null ? me.memoizedState : _n.next;
    if (a !== null)
      _n = a, Ge = i;
    else {
      if (i === null)
        throw me.alternate === null ? Error(s(467)) : Error(s(310));
      Ge = i, i = {
        memoizedState: Ge.memoizedState,
        baseState: Ge.baseState,
        baseQueue: Ge.baseQueue,
        queue: Ge.queue,
        next: null
      }, _n === null ? me.memoizedState = _n = i : _n = _n.next = i;
    }
    return _n;
  }
  function lu() {
    return { lastEffect: null, events: null, stores: null, memoCache: null };
  }
  function El(i) {
    var a = Ml;
    return Ml += 1, Yr === null && (Yr = []), i = __(Yr, i, a), a = me, (_n === null ? a.memoizedState : _n.next) === null && (a = a.alternate, U.H = a === null || a.memoizedState === null ? lv : Lh), i;
  }
  function cu(i) {
    if (i !== null && typeof i == "object") {
      if (typeof i.then == "function") return El(i);
      if (i.$$typeof === T) return Bn(i);
    }
    throw Error(s(438, String(i)));
  }
  function Sh(i) {
    var a = null, o = me.updateQueue;
    if (o !== null && (a = o.memoCache), a == null) {
      var u = me.alternate;
      u !== null && (u = u.updateQueue, u !== null && (u = u.memoCache, u != null && (a = {
        data: u.data.map(function(g) {
          return g.slice();
        }),
        index: 0
      })));
    }
    if (a == null && (a = { data: [], index: 0 }), o === null && (o = lu(), me.updateQueue = o), o.memoCache = a, o = a.data[a.index], o === void 0)
      for (o = a.data[a.index] = Array(i), u = 0; u < i; u++)
        o[u] = R;
    return a.index++, o;
  }
  function vs(i, a) {
    return typeof a == "function" ? a(i) : a;
  }
  function uu(i) {
    var a = pn();
    return bh(a, Ge, i);
  }
  function bh(i, a, o) {
    var u = i.queue;
    if (u === null) throw Error(s(311));
    u.lastRenderedReducer = o;
    var g = i.baseQueue, v = u.pending;
    if (v !== null) {
      if (g !== null) {
        var w = g.next;
        g.next = v.next, v.next = w;
      }
      a.baseQueue = g = v, u.pending = null;
    }
    if (v = i.baseState, g === null) i.memoizedState = v;
    else {
      a = g.next;
      var F = w = null, Q = null, ut = a, xt = !1;
      do {
        var Tt = ut.lane & -536870913;
        if (Tt !== ut.lane ? (Ce & Tt) === Tt : (_s & Tt) === Tt) {
          var pt = ut.revertLane;
          if (pt === 0)
            Q !== null && (Q = Q.next = {
              lane: 0,
              revertLane: 0,
              gesture: null,
              action: ut.action,
              hasEagerState: ut.hasEagerState,
              eagerState: ut.eagerState,
              next: null
            }), Tt === Hr && (xt = !0);
          else if ((_s & pt) === pt) {
            ut = ut.next, pt === Hr && (xt = !0);
            continue;
          } else
            Tt = {
              lane: 0,
              revertLane: ut.revertLane,
              gesture: null,
              action: ut.action,
              hasEagerState: ut.hasEagerState,
              eagerState: ut.eagerState,
              next: null
            }, Q === null ? (F = Q = Tt, w = v) : Q = Q.next = Tt, me.lanes |= pt, sa |= pt;
          Tt = ut.action, Ka && o(v, Tt), v = ut.hasEagerState ? ut.eagerState : o(v, Tt);
        } else
          pt = {
            lane: Tt,
            revertLane: ut.revertLane,
            gesture: ut.gesture,
            action: ut.action,
            hasEagerState: ut.hasEagerState,
            eagerState: ut.eagerState,
            next: null
          }, Q === null ? (F = Q = pt, w = v) : Q = Q.next = pt, me.lanes |= Tt, sa |= Tt;
        ut = ut.next;
      } while (ut !== null && ut !== a);
      if (Q === null ? w = v : Q.next = F, !fi(v, i.memoizedState) && (vn = !0, xt && (o = Vr, o !== null)))
        throw o;
      i.memoizedState = v, i.baseState = w, i.baseQueue = Q, u.lastRenderedState = v;
    }
    return g === null && (u.lanes = 0), [i.memoizedState, u.dispatch];
  }
  function Mh(i) {
    var a = pn(), o = a.queue;
    if (o === null) throw Error(s(311));
    o.lastRenderedReducer = i;
    var u = o.dispatch, g = o.pending, v = a.memoizedState;
    if (g !== null) {
      o.pending = null;
      var w = g = g.next;
      do
        v = i(v, w.action), w = w.next;
      while (w !== g);
      fi(v, a.memoizedState) || (vn = !0), a.memoizedState = v, a.baseQueue === null && (a.baseState = v), o.lastRenderedState = v;
    }
    return [v, u];
  }
  function C_(i, a, o) {
    var u = me, g = pn(), v = Ne;
    if (v) {
      if (o === void 0) throw Error(s(407));
      o = o();
    } else o = a();
    var w = !fi(
      (Ge || g).memoizedState,
      o
    );
    if (w && (g.memoizedState = o, vn = !0), g = g.queue, Ah(N_.bind(null, u, g, i), [
      i
    ]), g.getSnapshot !== a || w || _n !== null && _n.memoizedState.tag & 1) {
      if (u.flags |= 2048, jr(
        9,
        { destroy: void 0 },
        D_.bind(
          null,
          u,
          g,
          o,
          a
        ),
        null
      ), Ke === null) throw Error(s(349));
      v || (_s & 127) !== 0 || R_(u, a, o);
    }
    return o;
  }
  function R_(i, a, o) {
    i.flags |= 16384, i = { getSnapshot: a, value: o }, a = me.updateQueue, a === null ? (a = lu(), me.updateQueue = a, a.stores = [i]) : (o = a.stores, o === null ? a.stores = [i] : o.push(i));
  }
  function D_(i, a, o, u) {
    a.value = o, a.getSnapshot = u, L_(a) && U_(i);
  }
  function N_(i, a, o) {
    return o(function() {
      L_(a) && U_(i);
    });
  }
  function L_(i) {
    var a = i.getSnapshot;
    i = i.value;
    try {
      var o = a();
      return !fi(i, o);
    } catch {
      return !0;
    }
  }
  function U_(i) {
    var a = Va(i, 2);
    a !== null && ai(a, i, 2);
  }
  function Eh(i) {
    var a = Zn();
    if (typeof i == "function") {
      var o = i;
      if (i = o(), Ka) {
        Vt(!0);
        try {
          o();
        } finally {
          Vt(!1);
        }
      }
    }
    return a.memoizedState = a.baseState = i, a.queue = {
      pending: null,
      lanes: 0,
      dispatch: null,
      lastRenderedReducer: vs,
      lastRenderedState: i
    }, a;
  }
  function O_(i, a, o, u) {
    return i.baseState = o, bh(
      i,
      Ge,
      typeof u == "function" ? u : vs
    );
  }
  function JT(i, a, o, u, g) {
    if (hu(i)) throw Error(s(485));
    if (i = a.action, i !== null) {
      var v = {
        payload: g,
        action: i,
        next: null,
        isTransition: !0,
        status: "pending",
        value: null,
        reason: null,
        listeners: [],
        then: function(w) {
          v.listeners.push(w);
        }
      };
      U.T !== null ? o(!0) : v.isTransition = !1, u(v), o = a.pending, o === null ? (v.next = a.pending = v, P_(a, v)) : (v.next = o.next, a.pending = o.next = v);
    }
  }
  function P_(i, a) {
    var o = a.action, u = a.payload, g = i.state;
    if (a.isTransition) {
      var v = U.T, w = {};
      U.T = w;
      try {
        var F = o(g, u), Q = U.S;
        Q !== null && Q(w, F), z_(i, a, F);
      } catch (ut) {
        Th(i, a, ut);
      } finally {
        v !== null && w.types !== null && (v.types = w.types), U.T = v;
      }
    } else
      try {
        v = o(g, u), z_(i, a, v);
      } catch (ut) {
        Th(i, a, ut);
      }
  }
  function z_(i, a, o) {
    o !== null && typeof o == "object" && typeof o.then == "function" ? o.then(
      function(u) {
        I_(i, a, u);
      },
      function(u) {
        return Th(i, a, u);
      }
    ) : I_(i, a, o);
  }
  function I_(i, a, o) {
    a.status = "fulfilled", a.value = o, B_(a), i.state = o, a = i.pending, a !== null && (o = a.next, o === a ? i.pending = null : (o = o.next, a.next = o, P_(i, o)));
  }
  function Th(i, a, o) {
    var u = i.pending;
    if (i.pending = null, u !== null) {
      u = u.next;
      do
        a.status = "rejected", a.reason = o, B_(a), a = a.next;
      while (a !== u);
    }
    i.action = null;
  }
  function B_(i) {
    i = i.listeners;
    for (var a = 0; a < i.length; a++) (0, i[a])();
  }
  function F_(i, a) {
    return a;
  }
  function H_(i, a) {
    if (Ne) {
      var o = Ke.formState;
      if (o !== null) {
        t: {
          var u = me;
          if (Ne) {
            if (Je) {
              e: {
                for (var g = Je, v = Di; g.nodeType !== 8; ) {
                  if (!v) {
                    g = null;
                    break e;
                  }
                  if (g = Li(
                    g.nextSibling
                  ), g === null) {
                    g = null;
                    break e;
                  }
                }
                v = g.data, g = v === "F!" || v === "F" ? g : null;
              }
              if (g) {
                Je = Li(
                  g.nextSibling
                ), u = g.data === "F!";
                break t;
              }
            }
            Zs(u);
          }
          u = !1;
        }
        u && (a = o[0]);
      }
    }
    return o = Zn(), o.memoizedState = o.baseState = a, u = {
      pending: null,
      lanes: 0,
      dispatch: null,
      lastRenderedReducer: F_,
      lastRenderedState: a
    }, o.queue = u, o = av.bind(
      null,
      me,
      u
    ), u.dispatch = o, u = Eh(!1), v = Nh.bind(
      null,
      me,
      !1,
      u.queue
    ), u = Zn(), g = {
      state: a,
      dispatch: null,
      action: i,
      pending: null
    }, u.queue = g, o = JT.bind(
      null,
      me,
      g,
      v,
      o
    ), g.dispatch = o, u.memoizedState = i, [a, o, !1];
  }
  function V_(i) {
    var a = pn();
    return G_(a, Ge, i);
  }
  function G_(i, a, o) {
    if (a = bh(
      i,
      a,
      F_
    )[0], i = uu(vs)[0], typeof a == "object" && a !== null && typeof a.then == "function")
      try {
        var u = El(a);
      } catch (w) {
        throw w === Gr ? tu : w;
      }
    else u = a;
    a = pn();
    var g = a.queue, v = g.dispatch;
    return o !== a.memoizedState && (me.flags |= 2048, jr(
      9,
      { destroy: void 0 },
      tA.bind(null, g, o),
      null
    )), [u, v, i];
  }
  function tA(i, a) {
    i.action = a;
  }
  function k_(i) {
    var a = pn(), o = Ge;
    if (o !== null)
      return G_(a, o, i);
    pn(), a = a.memoizedState, o = pn();
    var u = o.queue.dispatch;
    return o.memoizedState = i, [a, u, !1];
  }
  function jr(i, a, o, u) {
    return i = { tag: i, create: o, deps: u, inst: a, next: null }, a = me.updateQueue, a === null && (a = lu(), me.updateQueue = a), o = a.lastEffect, o === null ? a.lastEffect = i.next = i : (u = o.next, o.next = i, i.next = u, a.lastEffect = i), i;
  }
  function X_() {
    return pn().memoizedState;
  }
  function fu(i, a, o, u) {
    var g = Zn();
    me.flags |= i, g.memoizedState = jr(
      1 | a,
      { destroy: void 0 },
      o,
      u === void 0 ? null : u
    );
  }
  function du(i, a, o, u) {
    var g = pn();
    u = u === void 0 ? null : u;
    var v = g.memoizedState.inst;
    Ge !== null && u !== null && gh(u, Ge.memoizedState.deps) ? g.memoizedState = jr(a, v, o, u) : (me.flags |= i, g.memoizedState = jr(
      1 | a,
      v,
      o,
      u
    ));
  }
  function W_(i, a) {
    fu(8390656, 8, i, a);
  }
  function Ah(i, a) {
    du(2048, 8, i, a);
  }
  function eA(i) {
    me.flags |= 4;
    var a = me.updateQueue;
    if (a === null)
      a = lu(), me.updateQueue = a, a.events = [i];
    else {
      var o = a.events;
      o === null ? a.events = [i] : o.push(i);
    }
  }
  function Y_(i) {
    var a = pn().memoizedState;
    return eA({ ref: a, nextImpl: i }), function() {
      if ((Be & 2) !== 0) throw Error(s(440));
      return a.impl.apply(void 0, arguments);
    };
  }
  function j_(i, a) {
    return du(4, 2, i, a);
  }
  function q_(i, a) {
    return du(4, 4, i, a);
  }
  function Z_(i, a) {
    if (typeof a == "function") {
      i = i();
      var o = a(i);
      return function() {
        typeof o == "function" ? o() : a(null);
      };
    }
    if (a != null)
      return i = i(), a.current = i, function() {
        a.current = null;
      };
  }
  function K_(i, a, o) {
    o = o != null ? o.concat([i]) : null, du(4, 4, Z_.bind(null, a, i), o);
  }
  function wh() {
  }
  function $_(i, a) {
    var o = pn();
    a = a === void 0 ? null : a;
    var u = o.memoizedState;
    return a !== null && gh(a, u[1]) ? u[0] : (o.memoizedState = [i, a], i);
  }
  function Q_(i, a) {
    var o = pn();
    a = a === void 0 ? null : a;
    var u = o.memoizedState;
    if (a !== null && gh(a, u[1]))
      return u[0];
    if (u = i(), Ka) {
      Vt(!0);
      try {
        i();
      } finally {
        Vt(!1);
      }
    }
    return o.memoizedState = [u, a], u;
  }
  function Ch(i, a, o) {
    return o === void 0 || (_s & 1073741824) !== 0 && (Ce & 261930) === 0 ? i.memoizedState = a : (i.memoizedState = o, i = Jv(), me.lanes |= i, sa |= i, o);
  }
  function J_(i, a, o, u) {
    return fi(o, a) ? o : Xr.current !== null ? (i = Ch(i, o, u), fi(i, a) || (vn = !0), i) : (_s & 42) === 0 || (_s & 1073741824) !== 0 && (Ce & 261930) === 0 ? (vn = !0, i.memoizedState = o) : (i = Jv(), me.lanes |= i, sa |= i, a);
  }
  function tv(i, a, o, u, g) {
    var v = X.p;
    X.p = v !== 0 && 8 > v ? v : 8;
    var w = U.T, F = {};
    U.T = F, Nh(i, !1, a, o);
    try {
      var Q = g(), ut = U.S;
      if (ut !== null && ut(F, Q), Q !== null && typeof Q == "object" && typeof Q.then == "function") {
        var xt = KT(
          Q,
          u
        );
        Tl(
          i,
          a,
          xt,
          _i(i)
        );
      } else
        Tl(
          i,
          a,
          u,
          _i(i)
        );
    } catch (Tt) {
      Tl(
        i,
        a,
        { then: function() {
        }, status: "rejected", reason: Tt },
        _i()
      );
    } finally {
      X.p = v, w !== null && F.types !== null && (w.types = F.types), U.T = w;
    }
  }
  function nA() {
  }
  function Rh(i, a, o, u) {
    if (i.tag !== 5) throw Error(s(476));
    var g = ev(i).queue;
    tv(
      i,
      g,
      a,
      V,
      o === null ? nA : function() {
        return nv(i), o(u);
      }
    );
  }
  function ev(i) {
    var a = i.memoizedState;
    if (a !== null) return a;
    a = {
      memoizedState: V,
      baseState: V,
      baseQueue: null,
      queue: {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: vs,
        lastRenderedState: V
      },
      next: null
    };
    var o = {};
    return a.next = {
      memoizedState: o,
      baseState: o,
      baseQueue: null,
      queue: {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: vs,
        lastRenderedState: o
      },
      next: null
    }, i.memoizedState = a, i = i.alternate, i !== null && (i.memoizedState = a), a;
  }
  function nv(i) {
    var a = ev(i);
    a.next === null && (a = i.alternate.memoizedState), Tl(
      i,
      a.next.queue,
      {},
      _i()
    );
  }
  function Dh() {
    return Bn(Gl);
  }
  function iv() {
    return pn().memoizedState;
  }
  function sv() {
    return pn().memoizedState;
  }
  function iA(i) {
    for (var a = i.return; a !== null; ) {
      switch (a.tag) {
        case 24:
        case 3:
          var o = _i();
          i = Qs(o);
          var u = Js(a, i, o);
          u !== null && (ai(u, a, o), xl(u, a, o)), a = { cache: ah() }, i.payload = a;
          return;
      }
      a = a.return;
    }
  }
  function sA(i, a, o) {
    var u = _i();
    o = {
      lane: u,
      revertLane: 0,
      gesture: null,
      action: o,
      hasEagerState: !1,
      eagerState: null,
      next: null
    }, hu(i) ? rv(a, o) : (o = qd(i, a, o, u), o !== null && (ai(o, i, u), ov(o, a, u)));
  }
  function av(i, a, o) {
    var u = _i();
    Tl(i, a, o, u);
  }
  function Tl(i, a, o, u) {
    var g = {
      lane: u,
      revertLane: 0,
      gesture: null,
      action: o,
      hasEagerState: !1,
      eagerState: null,
      next: null
    };
    if (hu(i)) rv(a, g);
    else {
      var v = i.alternate;
      if (i.lanes === 0 && (v === null || v.lanes === 0) && (v = a.lastRenderedReducer, v !== null))
        try {
          var w = a.lastRenderedState, F = v(w, o);
          if (g.hasEagerState = !0, g.eagerState = F, fi(F, w))
            return jc(i, a, g, 0), Ke === null && Yc(), !1;
        } catch {
        } finally {
        }
      if (o = qd(i, a, g, u), o !== null)
        return ai(o, i, u), ov(o, a, u), !0;
    }
    return !1;
  }
  function Nh(i, a, o, u) {
    if (u = {
      lane: 2,
      revertLane: cp(),
      gesture: null,
      action: u,
      hasEagerState: !1,
      eagerState: null,
      next: null
    }, hu(i)) {
      if (a) throw Error(s(479));
    } else
      a = qd(
        i,
        o,
        u,
        2
      ), a !== null && ai(a, i, 2);
  }
  function hu(i) {
    var a = i.alternate;
    return i === me || a !== null && a === me;
  }
  function rv(i, a) {
    Wr = ru = !0;
    var o = i.pending;
    o === null ? a.next = a : (a.next = o.next, o.next = a), i.pending = a;
  }
  function ov(i, a, o) {
    if ((o & 4194048) !== 0) {
      var u = a.lanes;
      u &= i.pendingLanes, o |= u, a.lanes = o, Pa(i, o);
    }
  }
  var Al = {
    readContext: Bn,
    use: cu,
    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
  };
  Al.useEffectEvent = cn;
  var lv = {
    readContext: Bn,
    use: cu,
    useCallback: function(i, a) {
      return Zn().memoizedState = [
        i,
        a === void 0 ? null : a
      ], i;
    },
    useContext: Bn,
    useEffect: W_,
    useImperativeHandle: function(i, a, o) {
      o = o != null ? o.concat([i]) : null, fu(
        4194308,
        4,
        Z_.bind(null, a, i),
        o
      );
    },
    useLayoutEffect: function(i, a) {
      return fu(4194308, 4, i, a);
    },
    useInsertionEffect: function(i, a) {
      fu(4, 2, i, a);
    },
    useMemo: function(i, a) {
      var o = Zn();
      a = a === void 0 ? null : a;
      var u = i();
      if (Ka) {
        Vt(!0);
        try {
          i();
        } finally {
          Vt(!1);
        }
      }
      return o.memoizedState = [u, a], u;
    },
    useReducer: function(i, a, o) {
      var u = Zn();
      if (o !== void 0) {
        var g = o(a);
        if (Ka) {
          Vt(!0);
          try {
            o(a);
          } finally {
            Vt(!1);
          }
        }
      } else g = a;
      return u.memoizedState = u.baseState = g, i = {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: i,
        lastRenderedState: g
      }, u.queue = i, i = i.dispatch = sA.bind(
        null,
        me,
        i
      ), [u.memoizedState, i];
    },
    useRef: function(i) {
      var a = Zn();
      return i = { current: i }, a.memoizedState = i;
    },
    useState: function(i) {
      i = Eh(i);
      var a = i.queue, o = av.bind(null, me, a);
      return a.dispatch = o, [i.memoizedState, o];
    },
    useDebugValue: wh,
    useDeferredValue: function(i, a) {
      var o = Zn();
      return Ch(o, i, a);
    },
    useTransition: function() {
      var i = Eh(!1);
      return i = tv.bind(
        null,
        me,
        i.queue,
        !0,
        !1
      ), Zn().memoizedState = i, [!1, i];
    },
    useSyncExternalStore: function(i, a, o) {
      var u = me, g = Zn();
      if (Ne) {
        if (o === void 0)
          throw Error(s(407));
        o = o();
      } else {
        if (o = a(), Ke === null)
          throw Error(s(349));
        (Ce & 127) !== 0 || R_(u, a, o);
      }
      g.memoizedState = o;
      var v = { value: o, getSnapshot: a };
      return g.queue = v, W_(N_.bind(null, u, v, i), [
        i
      ]), u.flags |= 2048, jr(
        9,
        { destroy: void 0 },
        D_.bind(
          null,
          u,
          v,
          o,
          a
        ),
        null
      ), o;
    },
    useId: function() {
      var i = Zn(), a = Ke.identifierPrefix;
      if (Ne) {
        var o = Ki, u = Zi;
        o = (u & ~(1 << 32 - re(u) - 1)).toString(32) + o, a = "_" + a + "R_" + o, o = ou++, 0 < o && (a += "H" + o.toString(32)), a += "_";
      } else
        o = $T++, a = "_" + a + "r_" + o.toString(32) + "_";
      return i.memoizedState = a;
    },
    useHostTransitionStatus: Dh,
    useFormState: H_,
    useActionState: H_,
    useOptimistic: function(i) {
      var a = Zn();
      a.memoizedState = a.baseState = i;
      var o = {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: null,
        lastRenderedState: null
      };
      return a.queue = o, a = Nh.bind(
        null,
        me,
        !0,
        o
      ), o.dispatch = a, [i, a];
    },
    useMemoCache: Sh,
    useCacheRefresh: function() {
      return Zn().memoizedState = iA.bind(
        null,
        me
      );
    },
    useEffectEvent: function(i) {
      var a = Zn(), o = { impl: i };
      return a.memoizedState = o, function() {
        if ((Be & 2) !== 0)
          throw Error(s(440));
        return o.impl.apply(void 0, arguments);
      };
    }
  }, Lh = {
    readContext: Bn,
    use: cu,
    useCallback: $_,
    useContext: Bn,
    useEffect: Ah,
    useImperativeHandle: K_,
    useInsertionEffect: j_,
    useLayoutEffect: q_,
    useMemo: Q_,
    useReducer: uu,
    useRef: X_,
    useState: function() {
      return uu(vs);
    },
    useDebugValue: wh,
    useDeferredValue: function(i, a) {
      var o = pn();
      return J_(
        o,
        Ge.memoizedState,
        i,
        a
      );
    },
    useTransition: function() {
      var i = uu(vs)[0], a = pn().memoizedState;
      return [
        typeof i == "boolean" ? i : El(i),
        a
      ];
    },
    useSyncExternalStore: C_,
    useId: iv,
    useHostTransitionStatus: Dh,
    useFormState: V_,
    useActionState: V_,
    useOptimistic: function(i, a) {
      var o = pn();
      return O_(o, Ge, i, a);
    },
    useMemoCache: Sh,
    useCacheRefresh: sv
  };
  Lh.useEffectEvent = Y_;
  var cv = {
    readContext: Bn,
    use: cu,
    useCallback: $_,
    useContext: Bn,
    useEffect: Ah,
    useImperativeHandle: K_,
    useInsertionEffect: j_,
    useLayoutEffect: q_,
    useMemo: Q_,
    useReducer: Mh,
    useRef: X_,
    useState: function() {
      return Mh(vs);
    },
    useDebugValue: wh,
    useDeferredValue: function(i, a) {
      var o = pn();
      return Ge === null ? Ch(o, i, a) : J_(
        o,
        Ge.memoizedState,
        i,
        a
      );
    },
    useTransition: function() {
      var i = Mh(vs)[0], a = pn().memoizedState;
      return [
        typeof i == "boolean" ? i : El(i),
        a
      ];
    },
    useSyncExternalStore: C_,
    useId: iv,
    useHostTransitionStatus: Dh,
    useFormState: k_,
    useActionState: k_,
    useOptimistic: function(i, a) {
      var o = pn();
      return Ge !== null ? O_(o, Ge, i, a) : (o.baseState = i, [i, o.queue.dispatch]);
    },
    useMemoCache: Sh,
    useCacheRefresh: sv
  };
  cv.useEffectEvent = Y_;
  function Uh(i, a, o, u) {
    a = i.memoizedState, o = o(u, a), o = o == null ? a : p({}, a, o), i.memoizedState = o, i.lanes === 0 && (i.updateQueue.baseState = o);
  }
  var Oh = {
    enqueueSetState: function(i, a, o) {
      i = i._reactInternals;
      var u = _i(), g = Qs(u);
      g.payload = a, o != null && (g.callback = o), a = Js(i, g, u), a !== null && (ai(a, i, u), xl(a, i, u));
    },
    enqueueReplaceState: function(i, a, o) {
      i = i._reactInternals;
      var u = _i(), g = Qs(u);
      g.tag = 1, g.payload = a, o != null && (g.callback = o), a = Js(i, g, u), a !== null && (ai(a, i, u), xl(a, i, u));
    },
    enqueueForceUpdate: function(i, a) {
      i = i._reactInternals;
      var o = _i(), u = Qs(o);
      u.tag = 2, a != null && (u.callback = a), a = Js(i, u, o), a !== null && (ai(a, i, o), xl(a, i, o));
    }
  };
  function uv(i, a, o, u, g, v, w) {
    return i = i.stateNode, typeof i.shouldComponentUpdate == "function" ? i.shouldComponentUpdate(u, v, w) : a.prototype && a.prototype.isPureReactComponent ? !dl(o, u) || !dl(g, v) : !0;
  }
  function fv(i, a, o, u) {
    i = a.state, typeof a.componentWillReceiveProps == "function" && a.componentWillReceiveProps(o, u), typeof a.UNSAFE_componentWillReceiveProps == "function" && a.UNSAFE_componentWillReceiveProps(o, u), a.state !== i && Oh.enqueueReplaceState(a, a.state, null);
  }
  function $a(i, a) {
    var o = a;
    if ("ref" in a) {
      o = {};
      for (var u in a)
        u !== "ref" && (o[u] = a[u]);
    }
    if (i = i.defaultProps) {
      o === a && (o = p({}, o));
      for (var g in i)
        o[g] === void 0 && (o[g] = i[g]);
    }
    return o;
  }
  function dv(i) {
    Wc(i);
  }
  function hv(i) {
    console.error(i);
  }
  function pv(i) {
    Wc(i);
  }
  function pu(i, a) {
    try {
      var o = i.onUncaughtError;
      o(a.value, { componentStack: a.stack });
    } catch (u) {
      setTimeout(function() {
        throw u;
      });
    }
  }
  function mv(i, a, o) {
    try {
      var u = i.onCaughtError;
      u(o.value, {
        componentStack: o.stack,
        errorBoundary: a.tag === 1 ? a.stateNode : null
      });
    } catch (g) {
      setTimeout(function() {
        throw g;
      });
    }
  }
  function Ph(i, a, o) {
    return o = Qs(o), o.tag = 3, o.payload = { element: null }, o.callback = function() {
      pu(i, a);
    }, o;
  }
  function gv(i) {
    return i = Qs(i), i.tag = 3, i;
  }
  function _v(i, a, o, u) {
    var g = o.type.getDerivedStateFromError;
    if (typeof g == "function") {
      var v = u.value;
      i.payload = function() {
        return g(v);
      }, i.callback = function() {
        mv(a, o, u);
      };
    }
    var w = o.stateNode;
    w !== null && typeof w.componentDidCatch == "function" && (i.callback = function() {
      mv(a, o, u), typeof g != "function" && (aa === null ? aa = /* @__PURE__ */ new Set([this]) : aa.add(this));
      var F = u.stack;
      this.componentDidCatch(u.value, {
        componentStack: F !== null ? F : ""
      });
    });
  }
  function aA(i, a, o, u, g) {
    if (o.flags |= 32768, u !== null && typeof u == "object" && typeof u.then == "function") {
      if (a = o.alternate, a !== null && Fr(
        a,
        o,
        g,
        !0
      ), o = hi.current, o !== null) {
        switch (o.tag) {
          case 31:
          case 13:
            return Ni === null ? Au() : o.alternate === null && un === 0 && (un = 3), o.flags &= -257, o.flags |= 65536, o.lanes = g, u === eu ? o.flags |= 16384 : (a = o.updateQueue, a === null ? o.updateQueue = /* @__PURE__ */ new Set([u]) : a.add(u), rp(i, u, g)), !1;
          case 22:
            return o.flags |= 65536, u === eu ? o.flags |= 16384 : (a = o.updateQueue, a === null ? (a = {
              transitions: null,
              markerInstances: null,
              retryQueue: /* @__PURE__ */ new Set([u])
            }, o.updateQueue = a) : (o = a.retryQueue, o === null ? a.retryQueue = /* @__PURE__ */ new Set([u]) : o.add(u)), rp(i, u, g)), !1;
        }
        throw Error(s(435, o.tag));
      }
      return rp(i, u, g), Au(), !1;
    }
    if (Ne)
      return a = hi.current, a !== null ? ((a.flags & 65536) === 0 && (a.flags |= 256), a.flags |= 65536, a.lanes = g, u !== th && (i = Error(s(422), { cause: u }), ml(wi(i, o)))) : (u !== th && (a = Error(s(423), {
        cause: u
      }), ml(
        wi(a, o)
      )), i = i.current.alternate, i.flags |= 65536, g &= -g, i.lanes |= g, u = wi(u, o), g = Ph(
        i.stateNode,
        u,
        g
      ), fh(i, g), un !== 4 && (un = 2)), !1;
    var v = Error(s(520), { cause: u });
    if (v = wi(v, o), Ol === null ? Ol = [v] : Ol.push(v), un !== 4 && (un = 2), a === null) return !0;
    u = wi(u, o), o = a;
    do {
      switch (o.tag) {
        case 3:
          return o.flags |= 65536, i = g & -g, o.lanes |= i, i = Ph(o.stateNode, u, i), fh(o, i), !1;
        case 1:
          if (a = o.type, v = o.stateNode, (o.flags & 128) === 0 && (typeof a.getDerivedStateFromError == "function" || v !== null && typeof v.componentDidCatch == "function" && (aa === null || !aa.has(v))))
            return o.flags |= 65536, g &= -g, o.lanes |= g, g = gv(g), _v(
              g,
              i,
              o,
              u
            ), fh(o, g), !1;
      }
      o = o.return;
    } while (o !== null);
    return !1;
  }
  var zh = Error(s(461)), vn = !1;
  function Fn(i, a, o, u) {
    a.child = i === null ? S_(a, null, o, u) : Za(
      a,
      i.child,
      o,
      u
    );
  }
  function vv(i, a, o, u, g) {
    o = o.render;
    var v = a.ref;
    if ("ref" in u) {
      var w = {};
      for (var F in u)
        F !== "ref" && (w[F] = u[F]);
    } else w = u;
    return Wa(a), u = _h(
      i,
      a,
      o,
      w,
      v,
      g
    ), F = vh(), i !== null && !vn ? (yh(i, a, g), ys(i, a, g)) : (Ne && F && Qd(a), a.flags |= 1, Fn(i, a, u, g), a.child);
  }
  function yv(i, a, o, u, g) {
    if (i === null) {
      var v = o.type;
      return typeof v == "function" && !Zd(v) && v.defaultProps === void 0 && o.compare === null ? (a.tag = 15, a.type = v, xv(
        i,
        a,
        v,
        u,
        g
      )) : (i = Zc(
        o.type,
        null,
        u,
        a,
        a.mode,
        g
      ), i.ref = a.ref, i.return = a, a.child = i);
    }
    if (v = i.child, !Xh(i, g)) {
      var w = v.memoizedProps;
      if (o = o.compare, o = o !== null ? o : dl, o(w, u) && i.ref === a.ref)
        return ys(i, a, g);
    }
    return a.flags |= 1, i = hs(v, u), i.ref = a.ref, i.return = a, a.child = i;
  }
  function xv(i, a, o, u, g) {
    if (i !== null) {
      var v = i.memoizedProps;
      if (dl(v, u) && i.ref === a.ref)
        if (vn = !1, a.pendingProps = u = v, Xh(i, g))
          (i.flags & 131072) !== 0 && (vn = !0);
        else
          return a.lanes = i.lanes, ys(i, a, g);
    }
    return Ih(
      i,
      a,
      o,
      u,
      g
    );
  }
  function Sv(i, a, o, u) {
    var g = u.children, v = i !== null ? i.memoizedState : null;
    if (i === null && a.stateNode === null && (a.stateNode = {
      _visibility: 1,
      _pendingMarkers: null,
      _retryCache: null,
      _transitions: null
    }), u.mode === "hidden") {
      if ((a.flags & 128) !== 0) {
        if (v = v !== null ? v.baseLanes | o : o, i !== null) {
          for (u = a.child = i.child, g = 0; u !== null; )
            g = g | u.lanes | u.childLanes, u = u.sibling;
          u = g & ~v;
        } else u = 0, a.child = null;
        return bv(
          i,
          a,
          v,
          o,
          u
        );
      }
      if ((o & 536870912) !== 0)
        a.memoizedState = { baseLanes: 0, cachePool: null }, i !== null && Jc(
          a,
          v !== null ? v.cachePool : null
        ), v !== null ? E_(a, v) : hh(), T_(a);
      else
        return u = a.lanes = 536870912, bv(
          i,
          a,
          v !== null ? v.baseLanes | o : o,
          o,
          u
        );
    } else
      v !== null ? (Jc(a, v.cachePool), E_(a, v), ea(), a.memoizedState = null) : (i !== null && Jc(a, null), hh(), ea());
    return Fn(i, a, g, o), a.child;
  }
  function wl(i, a) {
    return i !== null && i.tag === 22 || a.stateNode !== null || (a.stateNode = {
      _visibility: 1,
      _pendingMarkers: null,
      _retryCache: null,
      _transitions: null
    }), a.sibling;
  }
  function bv(i, a, o, u, g) {
    var v = oh();
    return v = v === null ? null : { parent: gn._currentValue, pool: v }, a.memoizedState = {
      baseLanes: o,
      cachePool: v
    }, i !== null && Jc(a, null), hh(), T_(a), i !== null && Fr(i, a, u, !0), a.childLanes = g, null;
  }
  function mu(i, a) {
    return a = _u(
      { mode: a.mode, children: a.children },
      i.mode
    ), a.ref = i.ref, i.child = a, a.return = i, a;
  }
  function Mv(i, a, o) {
    return Za(a, i.child, null, o), i = mu(a, a.pendingProps), i.flags |= 2, pi(a), a.memoizedState = null, i;
  }
  function rA(i, a, o) {
    var u = a.pendingProps, g = (a.flags & 128) !== 0;
    if (a.flags &= -129, i === null) {
      if (Ne) {
        if (u.mode === "hidden")
          return i = mu(a, u), a.lanes = 536870912, wl(null, i);
        if (mh(a), (i = Je) ? (i = Py(
          i,
          Di
        ), i = i !== null && i.data === "&" ? i : null, i !== null && (a.memoizedState = {
          dehydrated: i,
          treeContext: js !== null ? { id: Zi, overflow: Ki } : null,
          retryLane: 536870912,
          hydrationErrors: null
        }, o = r_(i), o.return = a, a.child = o, In = a, Je = null)) : i = null, i === null) throw Zs(a);
        return a.lanes = 536870912, null;
      }
      return mu(a, u);
    }
    var v = i.memoizedState;
    if (v !== null) {
      var w = v.dehydrated;
      if (mh(a), g)
        if (a.flags & 256)
          a.flags &= -257, a = Mv(
            i,
            a,
            o
          );
        else if (a.memoizedState !== null)
          a.child = i.child, a.flags |= 128, a = null;
        else throw Error(s(558));
      else if (vn || Fr(i, a, o, !1), g = (o & i.childLanes) !== 0, vn || g) {
        if (u = Ke, u !== null && (w = Ei(u, o), w !== 0 && w !== v.retryLane))
          throw v.retryLane = w, Va(i, w), ai(u, i, w), zh;
        Au(), a = Mv(
          i,
          a,
          o
        );
      } else
        i = v.treeContext, Je = Li(w.nextSibling), In = a, Ne = !0, qs = null, Di = !1, i !== null && c_(a, i), a = mu(a, u), a.flags |= 4096;
      return a;
    }
    return i = hs(i.child, {
      mode: u.mode,
      children: u.children
    }), i.ref = a.ref, a.child = i, i.return = a, i;
  }
  function gu(i, a) {
    var o = a.ref;
    if (o === null)
      i !== null && i.ref !== null && (a.flags |= 4194816);
    else {
      if (typeof o != "function" && typeof o != "object")
        throw Error(s(284));
      (i === null || i.ref !== o) && (a.flags |= 4194816);
    }
  }
  function Ih(i, a, o, u, g) {
    return Wa(a), o = _h(
      i,
      a,
      o,
      u,
      void 0,
      g
    ), u = vh(), i !== null && !vn ? (yh(i, a, g), ys(i, a, g)) : (Ne && u && Qd(a), a.flags |= 1, Fn(i, a, o, g), a.child);
  }
  function Ev(i, a, o, u, g, v) {
    return Wa(a), a.updateQueue = null, o = w_(
      a,
      u,
      o,
      g
    ), A_(i), u = vh(), i !== null && !vn ? (yh(i, a, v), ys(i, a, v)) : (Ne && u && Qd(a), a.flags |= 1, Fn(i, a, o, v), a.child);
  }
  function Tv(i, a, o, u, g) {
    if (Wa(a), a.stateNode === null) {
      var v = Pr, w = o.contextType;
      typeof w == "object" && w !== null && (v = Bn(w)), v = new o(u, v), a.memoizedState = v.state !== null && v.state !== void 0 ? v.state : null, v.updater = Oh, a.stateNode = v, v._reactInternals = a, v = a.stateNode, v.props = u, v.state = a.memoizedState, v.refs = {}, ch(a), w = o.contextType, v.context = typeof w == "object" && w !== null ? Bn(w) : Pr, v.state = a.memoizedState, w = o.getDerivedStateFromProps, typeof w == "function" && (Uh(
        a,
        o,
        w,
        u
      ), v.state = a.memoizedState), typeof o.getDerivedStateFromProps == "function" || typeof v.getSnapshotBeforeUpdate == "function" || typeof v.UNSAFE_componentWillMount != "function" && typeof v.componentWillMount != "function" || (w = v.state, typeof v.componentWillMount == "function" && v.componentWillMount(), typeof v.UNSAFE_componentWillMount == "function" && v.UNSAFE_componentWillMount(), w !== v.state && Oh.enqueueReplaceState(v, v.state, null), bl(a, u, v, g), Sl(), v.state = a.memoizedState), typeof v.componentDidMount == "function" && (a.flags |= 4194308), u = !0;
    } else if (i === null) {
      v = a.stateNode;
      var F = a.memoizedProps, Q = $a(o, F);
      v.props = Q;
      var ut = v.context, xt = o.contextType;
      w = Pr, typeof xt == "object" && xt !== null && (w = Bn(xt));
      var Tt = o.getDerivedStateFromProps;
      xt = typeof Tt == "function" || typeof v.getSnapshotBeforeUpdate == "function", F = a.pendingProps !== F, xt || typeof v.UNSAFE_componentWillReceiveProps != "function" && typeof v.componentWillReceiveProps != "function" || (F || ut !== w) && fv(
        a,
        v,
        u,
        w
      ), $s = !1;
      var pt = a.memoizedState;
      v.state = pt, bl(a, u, v, g), Sl(), ut = a.memoizedState, F || pt !== ut || $s ? (typeof Tt == "function" && (Uh(
        a,
        o,
        Tt,
        u
      ), ut = a.memoizedState), (Q = $s || uv(
        a,
        o,
        Q,
        u,
        pt,
        ut,
        w
      )) ? (xt || typeof v.UNSAFE_componentWillMount != "function" && typeof v.componentWillMount != "function" || (typeof v.componentWillMount == "function" && v.componentWillMount(), typeof v.UNSAFE_componentWillMount == "function" && v.UNSAFE_componentWillMount()), typeof v.componentDidMount == "function" && (a.flags |= 4194308)) : (typeof v.componentDidMount == "function" && (a.flags |= 4194308), a.memoizedProps = u, a.memoizedState = ut), v.props = u, v.state = ut, v.context = w, u = Q) : (typeof v.componentDidMount == "function" && (a.flags |= 4194308), u = !1);
    } else {
      v = a.stateNode, uh(i, a), w = a.memoizedProps, xt = $a(o, w), v.props = xt, Tt = a.pendingProps, pt = v.context, ut = o.contextType, Q = Pr, typeof ut == "object" && ut !== null && (Q = Bn(ut)), F = o.getDerivedStateFromProps, (ut = typeof F == "function" || typeof v.getSnapshotBeforeUpdate == "function") || typeof v.UNSAFE_componentWillReceiveProps != "function" && typeof v.componentWillReceiveProps != "function" || (w !== Tt || pt !== Q) && fv(
        a,
        v,
        u,
        Q
      ), $s = !1, pt = a.memoizedState, v.state = pt, bl(a, u, v, g), Sl();
      var vt = a.memoizedState;
      w !== Tt || pt !== vt || $s || i !== null && i.dependencies !== null && $c(i.dependencies) ? (typeof F == "function" && (Uh(
        a,
        o,
        F,
        u
      ), vt = a.memoizedState), (xt = $s || uv(
        a,
        o,
        xt,
        u,
        pt,
        vt,
        Q
      ) || i !== null && i.dependencies !== null && $c(i.dependencies)) ? (ut || typeof v.UNSAFE_componentWillUpdate != "function" && typeof v.componentWillUpdate != "function" || (typeof v.componentWillUpdate == "function" && v.componentWillUpdate(u, vt, Q), typeof v.UNSAFE_componentWillUpdate == "function" && v.UNSAFE_componentWillUpdate(
        u,
        vt,
        Q
      )), typeof v.componentDidUpdate == "function" && (a.flags |= 4), typeof v.getSnapshotBeforeUpdate == "function" && (a.flags |= 1024)) : (typeof v.componentDidUpdate != "function" || w === i.memoizedProps && pt === i.memoizedState || (a.flags |= 4), typeof v.getSnapshotBeforeUpdate != "function" || w === i.memoizedProps && pt === i.memoizedState || (a.flags |= 1024), a.memoizedProps = u, a.memoizedState = vt), v.props = u, v.state = vt, v.context = Q, u = xt) : (typeof v.componentDidUpdate != "function" || w === i.memoizedProps && pt === i.memoizedState || (a.flags |= 4), typeof v.getSnapshotBeforeUpdate != "function" || w === i.memoizedProps && pt === i.memoizedState || (a.flags |= 1024), u = !1);
    }
    return v = u, gu(i, a), u = (a.flags & 128) !== 0, v || u ? (v = a.stateNode, o = u && typeof o.getDerivedStateFromError != "function" ? null : v.render(), a.flags |= 1, i !== null && u ? (a.child = Za(
      a,
      i.child,
      null,
      g
    ), a.child = Za(
      a,
      null,
      o,
      g
    )) : Fn(i, a, o, g), a.memoizedState = v.state, i = a.child) : i = ys(
      i,
      a,
      g
    ), i;
  }
  function Av(i, a, o, u) {
    return ka(), a.flags |= 256, Fn(i, a, o, u), a.child;
  }
  var Bh = {
    dehydrated: null,
    treeContext: null,
    retryLane: 0,
    hydrationErrors: null
  };
  function Fh(i) {
    return { baseLanes: i, cachePool: m_() };
  }
  function Hh(i, a, o) {
    return i = i !== null ? i.childLanes & ~o : 0, a && (i |= gi), i;
  }
  function wv(i, a, o) {
    var u = a.pendingProps, g = !1, v = (a.flags & 128) !== 0, w;
    if ((w = v) || (w = i !== null && i.memoizedState === null ? !1 : (hn.current & 2) !== 0), w && (g = !0, a.flags &= -129), w = (a.flags & 32) !== 0, a.flags &= -33, i === null) {
      if (Ne) {
        if (g ? ta(a) : ea(), (i = Je) ? (i = Py(
          i,
          Di
        ), i = i !== null && i.data !== "&" ? i : null, i !== null && (a.memoizedState = {
          dehydrated: i,
          treeContext: js !== null ? { id: Zi, overflow: Ki } : null,
          retryLane: 536870912,
          hydrationErrors: null
        }, o = r_(i), o.return = a, a.child = o, In = a, Je = null)) : i = null, i === null) throw Zs(a);
        return bp(i) ? a.lanes = 32 : a.lanes = 536870912, null;
      }
      var F = u.children;
      return u = u.fallback, g ? (ea(), g = a.mode, F = _u(
        { mode: "hidden", children: F },
        g
      ), u = Ga(
        u,
        g,
        o,
        null
      ), F.return = a, u.return = a, F.sibling = u, a.child = F, u = a.child, u.memoizedState = Fh(o), u.childLanes = Hh(
        i,
        w,
        o
      ), a.memoizedState = Bh, wl(null, u)) : (ta(a), Vh(a, F));
    }
    var Q = i.memoizedState;
    if (Q !== null && (F = Q.dehydrated, F !== null)) {
      if (v)
        a.flags & 256 ? (ta(a), a.flags &= -257, a = Gh(
          i,
          a,
          o
        )) : a.memoizedState !== null ? (ea(), a.child = i.child, a.flags |= 128, a = null) : (ea(), F = u.fallback, g = a.mode, u = _u(
          { mode: "visible", children: u.children },
          g
        ), F = Ga(
          F,
          g,
          o,
          null
        ), F.flags |= 2, u.return = a, F.return = a, u.sibling = F, a.child = u, Za(
          a,
          i.child,
          null,
          o
        ), u = a.child, u.memoizedState = Fh(o), u.childLanes = Hh(
          i,
          w,
          o
        ), a.memoizedState = Bh, a = wl(null, u));
      else if (ta(a), bp(F)) {
        if (w = F.nextSibling && F.nextSibling.dataset, w) var ut = w.dgst;
        w = ut, u = Error(s(419)), u.stack = "", u.digest = w, ml({ value: u, source: null, stack: null }), a = Gh(
          i,
          a,
          o
        );
      } else if (vn || Fr(i, a, o, !1), w = (o & i.childLanes) !== 0, vn || w) {
        if (w = Ke, w !== null && (u = Ei(w, o), u !== 0 && u !== Q.retryLane))
          throw Q.retryLane = u, Va(i, u), ai(w, i, u), zh;
        Sp(F) || Au(), a = Gh(
          i,
          a,
          o
        );
      } else
        Sp(F) ? (a.flags |= 192, a.child = i.child, a = null) : (i = Q.treeContext, Je = Li(
          F.nextSibling
        ), In = a, Ne = !0, qs = null, Di = !1, i !== null && c_(a, i), a = Vh(
          a,
          u.children
        ), a.flags |= 4096);
      return a;
    }
    return g ? (ea(), F = u.fallback, g = a.mode, Q = i.child, ut = Q.sibling, u = hs(Q, {
      mode: "hidden",
      children: u.children
    }), u.subtreeFlags = Q.subtreeFlags & 65011712, ut !== null ? F = hs(
      ut,
      F
    ) : (F = Ga(
      F,
      g,
      o,
      null
    ), F.flags |= 2), F.return = a, u.return = a, u.sibling = F, a.child = u, wl(null, u), u = a.child, F = i.child.memoizedState, F === null ? F = Fh(o) : (g = F.cachePool, g !== null ? (Q = gn._currentValue, g = g.parent !== Q ? { parent: Q, pool: Q } : g) : g = m_(), F = {
      baseLanes: F.baseLanes | o,
      cachePool: g
    }), u.memoizedState = F, u.childLanes = Hh(
      i,
      w,
      o
    ), a.memoizedState = Bh, wl(i.child, u)) : (ta(a), o = i.child, i = o.sibling, o = hs(o, {
      mode: "visible",
      children: u.children
    }), o.return = a, o.sibling = null, i !== null && (w = a.deletions, w === null ? (a.deletions = [i], a.flags |= 16) : w.push(i)), a.child = o, a.memoizedState = null, o);
  }
  function Vh(i, a) {
    return a = _u(
      { mode: "visible", children: a },
      i.mode
    ), a.return = i, i.child = a;
  }
  function _u(i, a) {
    return i = di(22, i, null, a), i.lanes = 0, i;
  }
  function Gh(i, a, o) {
    return Za(a, i.child, null, o), i = Vh(
      a,
      a.pendingProps.children
    ), i.flags |= 2, a.memoizedState = null, i;
  }
  function Cv(i, a, o) {
    i.lanes |= a;
    var u = i.alternate;
    u !== null && (u.lanes |= a), ih(i.return, a, o);
  }
  function kh(i, a, o, u, g, v) {
    var w = i.memoizedState;
    w === null ? i.memoizedState = {
      isBackwards: a,
      rendering: null,
      renderingStartTime: 0,
      last: u,
      tail: o,
      tailMode: g,
      treeForkCount: v
    } : (w.isBackwards = a, w.rendering = null, w.renderingStartTime = 0, w.last = u, w.tail = o, w.tailMode = g, w.treeForkCount = v);
  }
  function Rv(i, a, o) {
    var u = a.pendingProps, g = u.revealOrder, v = u.tail;
    u = u.children;
    var w = hn.current, F = (w & 2) !== 0;
    if (F ? (w = w & 1 | 2, a.flags |= 128) : w &= 1, lt(hn, w), Fn(i, a, u, o), u = Ne ? pl : 0, !F && i !== null && (i.flags & 128) !== 0)
      t: for (i = a.child; i !== null; ) {
        if (i.tag === 13)
          i.memoizedState !== null && Cv(i, o, a);
        else if (i.tag === 19)
          Cv(i, o, a);
        else if (i.child !== null) {
          i.child.return = i, i = i.child;
          continue;
        }
        if (i === a) break t;
        for (; i.sibling === null; ) {
          if (i.return === null || i.return === a)
            break t;
          i = i.return;
        }
        i.sibling.return = i.return, i = i.sibling;
      }
    switch (g) {
      case "forwards":
        for (o = a.child, g = null; o !== null; )
          i = o.alternate, i !== null && au(i) === null && (g = o), o = o.sibling;
        o = g, o === null ? (g = a.child, a.child = null) : (g = o.sibling, o.sibling = null), kh(
          a,
          !1,
          g,
          o,
          v,
          u
        );
        break;
      case "backwards":
      case "unstable_legacy-backwards":
        for (o = null, g = a.child, a.child = null; g !== null; ) {
          if (i = g.alternate, i !== null && au(i) === null) {
            a.child = g;
            break;
          }
          i = g.sibling, g.sibling = o, o = g, g = i;
        }
        kh(
          a,
          !0,
          o,
          null,
          v,
          u
        );
        break;
      case "together":
        kh(
          a,
          !1,
          null,
          null,
          void 0,
          u
        );
        break;
      default:
        a.memoizedState = null;
    }
    return a.child;
  }
  function ys(i, a, o) {
    if (i !== null && (a.dependencies = i.dependencies), sa |= a.lanes, (o & a.childLanes) === 0)
      if (i !== null) {
        if (Fr(
          i,
          a,
          o,
          !1
        ), (o & a.childLanes) === 0)
          return null;
      } else return null;
    if (i !== null && a.child !== i.child)
      throw Error(s(153));
    if (a.child !== null) {
      for (i = a.child, o = hs(i, i.pendingProps), a.child = o, o.return = a; i.sibling !== null; )
        i = i.sibling, o = o.sibling = hs(i, i.pendingProps), o.return = a;
      o.sibling = null;
    }
    return a.child;
  }
  function Xh(i, a) {
    return (i.lanes & a) !== 0 ? !0 : (i = i.dependencies, !!(i !== null && $c(i)));
  }
  function oA(i, a, o) {
    switch (a.tag) {
      case 3:
        _t(a, a.stateNode.containerInfo), Ks(a, gn, i.memoizedState.cache), ka();
        break;
      case 27:
      case 5:
        Lt(a);
        break;
      case 4:
        _t(a, a.stateNode.containerInfo);
        break;
      case 10:
        Ks(
          a,
          a.type,
          a.memoizedProps.value
        );
        break;
      case 31:
        if (a.memoizedState !== null)
          return a.flags |= 128, mh(a), null;
        break;
      case 13:
        var u = a.memoizedState;
        if (u !== null)
          return u.dehydrated !== null ? (ta(a), a.flags |= 128, null) : (o & a.child.childLanes) !== 0 ? wv(i, a, o) : (ta(a), i = ys(
            i,
            a,
            o
          ), i !== null ? i.sibling : null);
        ta(a);
        break;
      case 19:
        var g = (i.flags & 128) !== 0;
        if (u = (o & a.childLanes) !== 0, u || (Fr(
          i,
          a,
          o,
          !1
        ), u = (o & a.childLanes) !== 0), g) {
          if (u)
            return Rv(
              i,
              a,
              o
            );
          a.flags |= 128;
        }
        if (g = a.memoizedState, g !== null && (g.rendering = null, g.tail = null, g.lastEffect = null), lt(hn, hn.current), u) break;
        return null;
      case 22:
        return a.lanes = 0, Sv(
          i,
          a,
          o,
          a.pendingProps
        );
      case 24:
        Ks(a, gn, i.memoizedState.cache);
    }
    return ys(i, a, o);
  }
  function Dv(i, a, o) {
    if (i !== null)
      if (i.memoizedProps !== a.pendingProps)
        vn = !0;
      else {
        if (!Xh(i, o) && (a.flags & 128) === 0)
          return vn = !1, oA(
            i,
            a,
            o
          );
        vn = (i.flags & 131072) !== 0;
      }
    else
      vn = !1, Ne && (a.flags & 1048576) !== 0 && l_(a, pl, a.index);
    switch (a.lanes = 0, a.tag) {
      case 16:
        t: {
          var u = a.pendingProps;
          if (i = ja(a.elementType), a.type = i, typeof i == "function")
            Zd(i) ? (u = $a(i, u), a.tag = 1, a = Tv(
              null,
              a,
              i,
              u,
              o
            )) : (a.tag = 0, a = Ih(
              null,
              a,
              i,
              u,
              o
            ));
          else {
            if (i != null) {
              var g = i.$$typeof;
              if (g === E) {
                a.tag = 11, a = vv(
                  null,
                  a,
                  i,
                  u,
                  o
                );
                break t;
              } else if (g === D) {
                a.tag = 14, a = yv(
                  null,
                  a,
                  i,
                  u,
                  o
                );
                break t;
              }
            }
            throw a = P(i) || i, Error(s(306, a, ""));
          }
        }
        return a;
      case 0:
        return Ih(
          i,
          a,
          a.type,
          a.pendingProps,
          o
        );
      case 1:
        return u = a.type, g = $a(
          u,
          a.pendingProps
        ), Tv(
          i,
          a,
          u,
          g,
          o
        );
      case 3:
        t: {
          if (_t(
            a,
            a.stateNode.containerInfo
          ), i === null) throw Error(s(387));
          u = a.pendingProps;
          var v = a.memoizedState;
          g = v.element, uh(i, a), bl(a, u, null, o);
          var w = a.memoizedState;
          if (u = w.cache, Ks(a, gn, u), u !== v.cache && sh(
            a,
            [gn],
            o,
            !0
          ), Sl(), u = w.element, v.isDehydrated)
            if (v = {
              element: u,
              isDehydrated: !1,
              cache: w.cache
            }, a.updateQueue.baseState = v, a.memoizedState = v, a.flags & 256) {
              a = Av(
                i,
                a,
                u,
                o
              );
              break t;
            } else if (u !== g) {
              g = wi(
                Error(s(424)),
                a
              ), ml(g), a = Av(
                i,
                a,
                u,
                o
              );
              break t;
            } else {
              switch (i = a.stateNode.containerInfo, i.nodeType) {
                case 9:
                  i = i.body;
                  break;
                default:
                  i = i.nodeName === "HTML" ? i.ownerDocument.body : i;
              }
              for (Je = Li(i.firstChild), In = a, Ne = !0, qs = null, Di = !0, o = S_(
                a,
                null,
                u,
                o
              ), a.child = o; o; )
                o.flags = o.flags & -3 | 4096, o = o.sibling;
            }
          else {
            if (ka(), u === g) {
              a = ys(
                i,
                a,
                o
              );
              break t;
            }
            Fn(i, a, u, o);
          }
          a = a.child;
        }
        return a;
      case 26:
        return gu(i, a), i === null ? (o = Vy(
          a.type,
          null,
          a.pendingProps,
          null
        )) ? a.memoizedState = o : Ne || (o = a.type, i = a.pendingProps, u = Uu(
          gt.current
        ).createElement(o), u[nn] = a, u[En] = i, Hn(u, o, i), et(u), a.stateNode = u) : a.memoizedState = Vy(
          a.type,
          i.memoizedProps,
          a.pendingProps,
          i.memoizedState
        ), null;
      case 27:
        return Lt(a), i === null && Ne && (u = a.stateNode = By(
          a.type,
          a.pendingProps,
          gt.current
        ), In = a, Di = !0, g = Je, ca(a.type) ? (Mp = g, Je = Li(u.firstChild)) : Je = g), Fn(
          i,
          a,
          a.pendingProps.children,
          o
        ), gu(i, a), i === null && (a.flags |= 4194304), a.child;
      case 5:
        return i === null && Ne && ((g = u = Je) && (u = IA(
          u,
          a.type,
          a.pendingProps,
          Di
        ), u !== null ? (a.stateNode = u, In = a, Je = Li(u.firstChild), Di = !1, g = !0) : g = !1), g || Zs(a)), Lt(a), g = a.type, v = a.pendingProps, w = i !== null ? i.memoizedProps : null, u = v.children, vp(g, v) ? u = null : w !== null && vp(g, w) && (a.flags |= 32), a.memoizedState !== null && (g = _h(
          i,
          a,
          QT,
          null,
          null,
          o
        ), Gl._currentValue = g), gu(i, a), Fn(i, a, u, o), a.child;
      case 6:
        return i === null && Ne && ((i = o = Je) && (o = BA(
          o,
          a.pendingProps,
          Di
        ), o !== null ? (a.stateNode = o, In = a, Je = null, i = !0) : i = !1), i || Zs(a)), null;
      case 13:
        return wv(i, a, o);
      case 4:
        return _t(
          a,
          a.stateNode.containerInfo
        ), u = a.pendingProps, i === null ? a.child = Za(
          a,
          null,
          u,
          o
        ) : Fn(i, a, u, o), a.child;
      case 11:
        return vv(
          i,
          a,
          a.type,
          a.pendingProps,
          o
        );
      case 7:
        return Fn(
          i,
          a,
          a.pendingProps,
          o
        ), a.child;
      case 8:
        return Fn(
          i,
          a,
          a.pendingProps.children,
          o
        ), a.child;
      case 12:
        return Fn(
          i,
          a,
          a.pendingProps.children,
          o
        ), a.child;
      case 10:
        return u = a.pendingProps, Ks(a, a.type, u.value), Fn(i, a, u.children, o), a.child;
      case 9:
        return g = a.type._context, u = a.pendingProps.children, Wa(a), g = Bn(g), u = u(g), a.flags |= 1, Fn(i, a, u, o), a.child;
      case 14:
        return yv(
          i,
          a,
          a.type,
          a.pendingProps,
          o
        );
      case 15:
        return xv(
          i,
          a,
          a.type,
          a.pendingProps,
          o
        );
      case 19:
        return Rv(i, a, o);
      case 31:
        return rA(i, a, o);
      case 22:
        return Sv(
          i,
          a,
          o,
          a.pendingProps
        );
      case 24:
        return Wa(a), u = Bn(gn), i === null ? (g = oh(), g === null && (g = Ke, v = ah(), g.pooledCache = v, v.refCount++, v !== null && (g.pooledCacheLanes |= o), g = v), a.memoizedState = { parent: u, cache: g }, ch(a), Ks(a, gn, g)) : ((i.lanes & o) !== 0 && (uh(i, a), bl(a, null, null, o), Sl()), g = i.memoizedState, v = a.memoizedState, g.parent !== u ? (g = { parent: u, cache: u }, a.memoizedState = g, a.lanes === 0 && (a.memoizedState = a.updateQueue.baseState = g), Ks(a, gn, u)) : (u = v.cache, Ks(a, gn, u), u !== g.cache && sh(
          a,
          [gn],
          o,
          !0
        ))), Fn(
          i,
          a,
          a.pendingProps.children,
          o
        ), a.child;
      case 29:
        throw a.pendingProps;
    }
    throw Error(s(156, a.tag));
  }
  function xs(i) {
    i.flags |= 4;
  }
  function Wh(i, a, o, u, g) {
    if ((a = (i.mode & 32) !== 0) && (a = !1), a) {
      if (i.flags |= 16777216, (g & 335544128) === g)
        if (i.stateNode.complete) i.flags |= 8192;
        else if (iy()) i.flags |= 8192;
        else
          throw qa = eu, lh;
    } else i.flags &= -16777217;
  }
  function Nv(i, a) {
    if (a.type !== "stylesheet" || (a.state.loading & 4) !== 0)
      i.flags &= -16777217;
    else if (i.flags |= 16777216, !Yy(a))
      if (iy()) i.flags |= 8192;
      else
        throw qa = eu, lh;
  }
  function vu(i, a) {
    a !== null && (i.flags |= 4), i.flags & 16384 && (a = i.tag !== 22 ? fn() : 536870912, i.lanes |= a, $r |= a);
  }
  function Cl(i, a) {
    if (!Ne)
      switch (i.tailMode) {
        case "hidden":
          a = i.tail;
          for (var o = null; a !== null; )
            a.alternate !== null && (o = a), a = a.sibling;
          o === null ? i.tail = null : o.sibling = null;
          break;
        case "collapsed":
          o = i.tail;
          for (var u = null; o !== null; )
            o.alternate !== null && (u = o), o = o.sibling;
          u === null ? a || i.tail === null ? i.tail = null : i.tail.sibling = null : u.sibling = null;
      }
  }
  function tn(i) {
    var a = i.alternate !== null && i.alternate.child === i.child, o = 0, u = 0;
    if (a)
      for (var g = i.child; g !== null; )
        o |= g.lanes | g.childLanes, u |= g.subtreeFlags & 65011712, u |= g.flags & 65011712, g.return = i, g = g.sibling;
    else
      for (g = i.child; g !== null; )
        o |= g.lanes | g.childLanes, u |= g.subtreeFlags, u |= g.flags, g.return = i, g = g.sibling;
    return i.subtreeFlags |= u, i.childLanes = o, a;
  }
  function lA(i, a, o) {
    var u = a.pendingProps;
    switch (Jd(a), a.tag) {
      case 16:
      case 15:
      case 0:
      case 11:
      case 7:
      case 8:
      case 12:
      case 9:
      case 14:
        return tn(a), null;
      case 1:
        return tn(a), null;
      case 3:
        return o = a.stateNode, u = null, i !== null && (u = i.memoizedState.cache), a.memoizedState.cache !== u && (a.flags |= 2048), gs(gn), Et(), o.pendingContext && (o.context = o.pendingContext, o.pendingContext = null), (i === null || i.child === null) && (Br(a) ? xs(a) : i === null || i.memoizedState.isDehydrated && (a.flags & 256) === 0 || (a.flags |= 1024, eh())), tn(a), null;
      case 26:
        var g = a.type, v = a.memoizedState;
        return i === null ? (xs(a), v !== null ? (tn(a), Nv(a, v)) : (tn(a), Wh(
          a,
          g,
          null,
          u,
          o
        ))) : v ? v !== i.memoizedState ? (xs(a), tn(a), Nv(a, v)) : (tn(a), a.flags &= -16777217) : (i = i.memoizedProps, i !== u && xs(a), tn(a), Wh(
          a,
          g,
          i,
          u,
          o
        )), null;
      case 27:
        if (Gt(a), o = gt.current, g = a.type, i !== null && a.stateNode != null)
          i.memoizedProps !== u && xs(a);
        else {
          if (!u) {
            if (a.stateNode === null)
              throw Error(s(166));
            return tn(a), null;
          }
          i = $.current, Br(a) ? u_(a) : (i = By(g, u, o), a.stateNode = i, xs(a));
        }
        return tn(a), null;
      case 5:
        if (Gt(a), g = a.type, i !== null && a.stateNode != null)
          i.memoizedProps !== u && xs(a);
        else {
          if (!u) {
            if (a.stateNode === null)
              throw Error(s(166));
            return tn(a), null;
          }
          if (v = $.current, Br(a))
            u_(a);
          else {
            var w = Uu(
              gt.current
            );
            switch (v) {
              case 1:
                v = w.createElementNS(
                  "http://www.w3.org/2000/svg",
                  g
                );
                break;
              case 2:
                v = w.createElementNS(
                  "http://www.w3.org/1998/Math/MathML",
                  g
                );
                break;
              default:
                switch (g) {
                  case "svg":
                    v = w.createElementNS(
                      "http://www.w3.org/2000/svg",
                      g
                    );
                    break;
                  case "math":
                    v = w.createElementNS(
                      "http://www.w3.org/1998/Math/MathML",
                      g
                    );
                    break;
                  case "script":
                    v = w.createElement("div"), v.innerHTML = "<script><\/script>", v = v.removeChild(
                      v.firstChild
                    );
                    break;
                  case "select":
                    v = typeof u.is == "string" ? w.createElement("select", {
                      is: u.is
                    }) : w.createElement("select"), u.multiple ? v.multiple = !0 : u.size && (v.size = u.size);
                    break;
                  default:
                    v = typeof u.is == "string" ? w.createElement(g, { is: u.is }) : w.createElement(g);
                }
            }
            v[nn] = a, v[En] = u;
            t: for (w = a.child; w !== null; ) {
              if (w.tag === 5 || w.tag === 6)
                v.appendChild(w.stateNode);
              else if (w.tag !== 4 && w.tag !== 27 && w.child !== null) {
                w.child.return = w, w = w.child;
                continue;
              }
              if (w === a) break t;
              for (; w.sibling === null; ) {
                if (w.return === null || w.return === a)
                  break t;
                w = w.return;
              }
              w.sibling.return = w.return, w = w.sibling;
            }
            a.stateNode = v;
            t: switch (Hn(v, g, u), g) {
              case "button":
              case "input":
              case "select":
              case "textarea":
                u = !!u.autoFocus;
                break t;
              case "img":
                u = !0;
                break t;
              default:
                u = !1;
            }
            u && xs(a);
          }
        }
        return tn(a), Wh(
          a,
          a.type,
          i === null ? null : i.memoizedProps,
          a.pendingProps,
          o
        ), null;
      case 6:
        if (i && a.stateNode != null)
          i.memoizedProps !== u && xs(a);
        else {
          if (typeof u != "string" && a.stateNode === null)
            throw Error(s(166));
          if (i = gt.current, Br(a)) {
            if (i = a.stateNode, o = a.memoizedProps, u = null, g = In, g !== null)
              switch (g.tag) {
                case 27:
                case 5:
                  u = g.memoizedProps;
              }
            i[nn] = a, i = !!(i.nodeValue === o || u !== null && u.suppressHydrationWarning === !0 || wy(i.nodeValue, o)), i || Zs(a, !0);
          } else
            i = Uu(i).createTextNode(
              u
            ), i[nn] = a, a.stateNode = i;
        }
        return tn(a), null;
      case 31:
        if (o = a.memoizedState, i === null || i.memoizedState !== null) {
          if (u = Br(a), o !== null) {
            if (i === null) {
              if (!u) throw Error(s(318));
              if (i = a.memoizedState, i = i !== null ? i.dehydrated : null, !i) throw Error(s(557));
              i[nn] = a;
            } else
              ka(), (a.flags & 128) === 0 && (a.memoizedState = null), a.flags |= 4;
            tn(a), i = !1;
          } else
            o = eh(), i !== null && i.memoizedState !== null && (i.memoizedState.hydrationErrors = o), i = !0;
          if (!i)
            return a.flags & 256 ? (pi(a), a) : (pi(a), null);
          if ((a.flags & 128) !== 0)
            throw Error(s(558));
        }
        return tn(a), null;
      case 13:
        if (u = a.memoizedState, i === null || i.memoizedState !== null && i.memoizedState.dehydrated !== null) {
          if (g = Br(a), u !== null && u.dehydrated !== null) {
            if (i === null) {
              if (!g) throw Error(s(318));
              if (g = a.memoizedState, g = g !== null ? g.dehydrated : null, !g) throw Error(s(317));
              g[nn] = a;
            } else
              ka(), (a.flags & 128) === 0 && (a.memoizedState = null), a.flags |= 4;
            tn(a), g = !1;
          } else
            g = eh(), i !== null && i.memoizedState !== null && (i.memoizedState.hydrationErrors = g), g = !0;
          if (!g)
            return a.flags & 256 ? (pi(a), a) : (pi(a), null);
        }
        return pi(a), (a.flags & 128) !== 0 ? (a.lanes = o, a) : (o = u !== null, i = i !== null && i.memoizedState !== null, o && (u = a.child, g = null, u.alternate !== null && u.alternate.memoizedState !== null && u.alternate.memoizedState.cachePool !== null && (g = u.alternate.memoizedState.cachePool.pool), v = null, u.memoizedState !== null && u.memoizedState.cachePool !== null && (v = u.memoizedState.cachePool.pool), v !== g && (u.flags |= 2048)), o !== i && o && (a.child.flags |= 8192), vu(a, a.updateQueue), tn(a), null);
      case 4:
        return Et(), i === null && hp(a.stateNode.containerInfo), tn(a), null;
      case 10:
        return gs(a.type), tn(a), null;
      case 19:
        if (q(hn), u = a.memoizedState, u === null) return tn(a), null;
        if (g = (a.flags & 128) !== 0, v = u.rendering, v === null)
          if (g) Cl(u, !1);
          else {
            if (un !== 0 || i !== null && (i.flags & 128) !== 0)
              for (i = a.child; i !== null; ) {
                if (v = au(i), v !== null) {
                  for (a.flags |= 128, Cl(u, !1), i = v.updateQueue, a.updateQueue = i, vu(a, i), a.subtreeFlags = 0, i = o, o = a.child; o !== null; )
                    a_(o, i), o = o.sibling;
                  return lt(
                    hn,
                    hn.current & 1 | 2
                  ), Ne && ps(a, u.treeForkCount), a.child;
                }
                i = i.sibling;
              }
            u.tail !== null && St() > Mu && (a.flags |= 128, g = !0, Cl(u, !1), a.lanes = 4194304);
          }
        else {
          if (!g)
            if (i = au(v), i !== null) {
              if (a.flags |= 128, g = !0, i = i.updateQueue, a.updateQueue = i, vu(a, i), Cl(u, !0), u.tail === null && u.tailMode === "hidden" && !v.alternate && !Ne)
                return tn(a), null;
            } else
              2 * St() - u.renderingStartTime > Mu && o !== 536870912 && (a.flags |= 128, g = !0, Cl(u, !1), a.lanes = 4194304);
          u.isBackwards ? (v.sibling = a.child, a.child = v) : (i = u.last, i !== null ? i.sibling = v : a.child = v, u.last = v);
        }
        return u.tail !== null ? (i = u.tail, u.rendering = i, u.tail = i.sibling, u.renderingStartTime = St(), i.sibling = null, o = hn.current, lt(
          hn,
          g ? o & 1 | 2 : o & 1
        ), Ne && ps(a, u.treeForkCount), i) : (tn(a), null);
      case 22:
      case 23:
        return pi(a), ph(), u = a.memoizedState !== null, i !== null ? i.memoizedState !== null !== u && (a.flags |= 8192) : u && (a.flags |= 8192), u ? (o & 536870912) !== 0 && (a.flags & 128) === 0 && (tn(a), a.subtreeFlags & 6 && (a.flags |= 8192)) : tn(a), o = a.updateQueue, o !== null && vu(a, o.retryQueue), o = null, i !== null && i.memoizedState !== null && i.memoizedState.cachePool !== null && (o = i.memoizedState.cachePool.pool), u = null, a.memoizedState !== null && a.memoizedState.cachePool !== null && (u = a.memoizedState.cachePool.pool), u !== o && (a.flags |= 2048), i !== null && q(Ya), null;
      case 24:
        return o = null, i !== null && (o = i.memoizedState.cache), a.memoizedState.cache !== o && (a.flags |= 2048), gs(gn), tn(a), null;
      case 25:
        return null;
      case 30:
        return null;
    }
    throw Error(s(156, a.tag));
  }
  function cA(i, a) {
    switch (Jd(a), a.tag) {
      case 1:
        return i = a.flags, i & 65536 ? (a.flags = i & -65537 | 128, a) : null;
      case 3:
        return gs(gn), Et(), i = a.flags, (i & 65536) !== 0 && (i & 128) === 0 ? (a.flags = i & -65537 | 128, a) : null;
      case 26:
      case 27:
      case 5:
        return Gt(a), null;
      case 31:
        if (a.memoizedState !== null) {
          if (pi(a), a.alternate === null)
            throw Error(s(340));
          ka();
        }
        return i = a.flags, i & 65536 ? (a.flags = i & -65537 | 128, a) : null;
      case 13:
        if (pi(a), i = a.memoizedState, i !== null && i.dehydrated !== null) {
          if (a.alternate === null)
            throw Error(s(340));
          ka();
        }
        return i = a.flags, i & 65536 ? (a.flags = i & -65537 | 128, a) : null;
      case 19:
        return q(hn), null;
      case 4:
        return Et(), null;
      case 10:
        return gs(a.type), null;
      case 22:
      case 23:
        return pi(a), ph(), i !== null && q(Ya), i = a.flags, i & 65536 ? (a.flags = i & -65537 | 128, a) : null;
      case 24:
        return gs(gn), null;
      case 25:
        return null;
      default:
        return null;
    }
  }
  function Lv(i, a) {
    switch (Jd(a), a.tag) {
      case 3:
        gs(gn), Et();
        break;
      case 26:
      case 27:
      case 5:
        Gt(a);
        break;
      case 4:
        Et();
        break;
      case 31:
        a.memoizedState !== null && pi(a);
        break;
      case 13:
        pi(a);
        break;
      case 19:
        q(hn);
        break;
      case 10:
        gs(a.type);
        break;
      case 22:
      case 23:
        pi(a), ph(), i !== null && q(Ya);
        break;
      case 24:
        gs(gn);
    }
  }
  function Rl(i, a) {
    try {
      var o = a.updateQueue, u = o !== null ? o.lastEffect : null;
      if (u !== null) {
        var g = u.next;
        o = g;
        do {
          if ((o.tag & i) === i) {
            u = void 0;
            var v = o.create, w = o.inst;
            u = v(), w.destroy = u;
          }
          o = o.next;
        } while (o !== g);
      }
    } catch (F) {
      Ve(a, a.return, F);
    }
  }
  function na(i, a, o) {
    try {
      var u = a.updateQueue, g = u !== null ? u.lastEffect : null;
      if (g !== null) {
        var v = g.next;
        u = v;
        do {
          if ((u.tag & i) === i) {
            var w = u.inst, F = w.destroy;
            if (F !== void 0) {
              w.destroy = void 0, g = a;
              var Q = o, ut = F;
              try {
                ut();
              } catch (xt) {
                Ve(
                  g,
                  Q,
                  xt
                );
              }
            }
          }
          u = u.next;
        } while (u !== v);
      }
    } catch (xt) {
      Ve(a, a.return, xt);
    }
  }
  function Uv(i) {
    var a = i.updateQueue;
    if (a !== null) {
      var o = i.stateNode;
      try {
        M_(a, o);
      } catch (u) {
        Ve(i, i.return, u);
      }
    }
  }
  function Ov(i, a, o) {
    o.props = $a(
      i.type,
      i.memoizedProps
    ), o.state = i.memoizedState;
    try {
      o.componentWillUnmount();
    } catch (u) {
      Ve(i, a, u);
    }
  }
  function Dl(i, a) {
    try {
      var o = i.ref;
      if (o !== null) {
        switch (i.tag) {
          case 26:
          case 27:
          case 5:
            var u = i.stateNode;
            break;
          case 30:
            u = i.stateNode;
            break;
          default:
            u = i.stateNode;
        }
        typeof o == "function" ? i.refCleanup = o(u) : o.current = u;
      }
    } catch (g) {
      Ve(i, a, g);
    }
  }
  function $i(i, a) {
    var o = i.ref, u = i.refCleanup;
    if (o !== null)
      if (typeof u == "function")
        try {
          u();
        } catch (g) {
          Ve(i, a, g);
        } finally {
          i.refCleanup = null, i = i.alternate, i != null && (i.refCleanup = null);
        }
      else if (typeof o == "function")
        try {
          o(null);
        } catch (g) {
          Ve(i, a, g);
        }
      else o.current = null;
  }
  function Pv(i) {
    var a = i.type, o = i.memoizedProps, u = i.stateNode;
    try {
      t: switch (a) {
        case "button":
        case "input":
        case "select":
        case "textarea":
          o.autoFocus && u.focus();
          break t;
        case "img":
          o.src ? u.src = o.src : o.srcSet && (u.srcset = o.srcSet);
      }
    } catch (g) {
      Ve(i, i.return, g);
    }
  }
  function Yh(i, a, o) {
    try {
      var u = i.stateNode;
      NA(u, i.type, o, a), u[En] = a;
    } catch (g) {
      Ve(i, i.return, g);
    }
  }
  function zv(i) {
    return i.tag === 5 || i.tag === 3 || i.tag === 26 || i.tag === 27 && ca(i.type) || i.tag === 4;
  }
  function jh(i) {
    t: for (; ; ) {
      for (; i.sibling === null; ) {
        if (i.return === null || zv(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 && ca(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 qh(i, a, o) {
    var u = i.tag;
    if (u === 5 || u === 6)
      i = i.stateNode, a ? (o.nodeType === 9 ? o.body : o.nodeName === "HTML" ? o.ownerDocument.body : o).insertBefore(i, a) : (a = o.nodeType === 9 ? o.body : o.nodeName === "HTML" ? o.ownerDocument.body : o, a.appendChild(i), o = o._reactRootContainer, o != null || a.onclick !== null || (a.onclick = fs));
    else if (u !== 4 && (u === 27 && ca(i.type) && (o = i.stateNode, a = null), i = i.child, i !== null))
      for (qh(i, a, o), i = i.sibling; i !== null; )
        qh(i, a, o), i = i.sibling;
  }
  function yu(i, a, o) {
    var u = i.tag;
    if (u === 5 || u === 6)
      i = i.stateNode, a ? o.insertBefore(i, a) : o.appendChild(i);
    else if (u !== 4 && (u === 27 && ca(i.type) && (o = i.stateNode), i = i.child, i !== null))
      for (yu(i, a, o), i = i.sibling; i !== null; )
        yu(i, a, o), i = i.sibling;
  }
  function Iv(i) {
    var a = i.stateNode, o = i.memoizedProps;
    try {
      for (var u = i.type, g = a.attributes; g.length; )
        a.removeAttributeNode(g[0]);
      Hn(a, u, o), a[nn] = i, a[En] = o;
    } catch (v) {
      Ve(i, i.return, v);
    }
  }
  var Ss = !1, yn = !1, Zh = !1, Bv = typeof WeakSet == "function" ? WeakSet : Set, Nn = null;
  function uA(i, a) {
    if (i = i.containerInfo, gp = Hu, i = K0(i), Gd(i)) {
      if ("selectionStart" in i)
        var o = {
          start: i.selectionStart,
          end: i.selectionEnd
        };
      else
        t: {
          o = (o = i.ownerDocument) && o.defaultView || window;
          var u = o.getSelection && o.getSelection();
          if (u && u.rangeCount !== 0) {
            o = u.anchorNode;
            var g = u.anchorOffset, v = u.focusNode;
            u = u.focusOffset;
            try {
              o.nodeType, v.nodeType;
            } catch {
              o = null;
              break t;
            }
            var w = 0, F = -1, Q = -1, ut = 0, xt = 0, Tt = i, pt = null;
            e: for (; ; ) {
              for (var vt; Tt !== o || g !== 0 && Tt.nodeType !== 3 || (F = w + g), Tt !== v || u !== 0 && Tt.nodeType !== 3 || (Q = w + u), Tt.nodeType === 3 && (w += Tt.nodeValue.length), (vt = Tt.firstChild) !== null; )
                pt = Tt, Tt = vt;
              for (; ; ) {
                if (Tt === i) break e;
                if (pt === o && ++ut === g && (F = w), pt === v && ++xt === u && (Q = w), (vt = Tt.nextSibling) !== null) break;
                Tt = pt, pt = Tt.parentNode;
              }
              Tt = vt;
            }
            o = F === -1 || Q === -1 ? null : { start: F, end: Q };
          } else o = null;
        }
      o = o || { start: 0, end: 0 };
    } else o = null;
    for (_p = { focusedElem: i, selectionRange: o }, Hu = !1, Nn = a; Nn !== null; )
      if (a = Nn, i = a.child, (a.subtreeFlags & 1028) !== 0 && i !== null)
        i.return = a, Nn = i;
      else
        for (; Nn !== null; ) {
          switch (a = Nn, v = a.alternate, i = a.flags, a.tag) {
            case 0:
              if ((i & 4) !== 0 && (i = a.updateQueue, i = i !== null ? i.events : null, i !== null))
                for (o = 0; o < i.length; o++)
                  g = i[o], g.ref.impl = g.nextImpl;
              break;
            case 11:
            case 15:
              break;
            case 1:
              if ((i & 1024) !== 0 && v !== null) {
                i = void 0, o = a, g = v.memoizedProps, v = v.memoizedState, u = o.stateNode;
                try {
                  var Kt = $a(
                    o.type,
                    g
                  );
                  i = u.getSnapshotBeforeUpdate(
                    Kt,
                    v
                  ), u.__reactInternalSnapshotBeforeUpdate = i;
                } catch (ae) {
                  Ve(
                    o,
                    o.return,
                    ae
                  );
                }
              }
              break;
            case 3:
              if ((i & 1024) !== 0) {
                if (i = a.stateNode.containerInfo, o = i.nodeType, o === 9)
                  xp(i);
                else if (o === 1)
                  switch (i.nodeName) {
                    case "HEAD":
                    case "HTML":
                    case "BODY":
                      xp(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(s(163));
          }
          if (i = a.sibling, i !== null) {
            i.return = a.return, Nn = i;
            break;
          }
          Nn = a.return;
        }
  }
  function Fv(i, a, o) {
    var u = o.flags;
    switch (o.tag) {
      case 0:
      case 11:
      case 15:
        Ms(i, o), u & 4 && Rl(5, o);
        break;
      case 1:
        if (Ms(i, o), u & 4)
          if (i = o.stateNode, a === null)
            try {
              i.componentDidMount();
            } catch (w) {
              Ve(o, o.return, w);
            }
          else {
            var g = $a(
              o.type,
              a.memoizedProps
            );
            a = a.memoizedState;
            try {
              i.componentDidUpdate(
                g,
                a,
                i.__reactInternalSnapshotBeforeUpdate
              );
            } catch (w) {
              Ve(
                o,
                o.return,
                w
              );
            }
          }
        u & 64 && Uv(o), u & 512 && Dl(o, o.return);
        break;
      case 3:
        if (Ms(i, o), u & 64 && (i = o.updateQueue, i !== null)) {
          if (a = null, o.child !== null)
            switch (o.child.tag) {
              case 27:
              case 5:
                a = o.child.stateNode;
                break;
              case 1:
                a = o.child.stateNode;
            }
          try {
            M_(i, a);
          } catch (w) {
            Ve(o, o.return, w);
          }
        }
        break;
      case 27:
        a === null && u & 4 && Iv(o);
      case 26:
      case 5:
        Ms(i, o), a === null && u & 4 && Pv(o), u & 512 && Dl(o, o.return);
        break;
      case 12:
        Ms(i, o);
        break;
      case 31:
        Ms(i, o), u & 4 && Gv(i, o);
        break;
      case 13:
        Ms(i, o), u & 4 && kv(i, o), u & 64 && (i = o.memoizedState, i !== null && (i = i.dehydrated, i !== null && (o = yA.bind(
          null,
          o
        ), FA(i, o))));
        break;
      case 22:
        if (u = o.memoizedState !== null || Ss, !u) {
          a = a !== null && a.memoizedState !== null || yn, g = Ss;
          var v = yn;
          Ss = u, (yn = a) && !v ? Es(
            i,
            o,
            (o.subtreeFlags & 8772) !== 0
          ) : Ms(i, o), Ss = g, yn = v;
        }
        break;
      case 30:
        break;
      default:
        Ms(i, o);
    }
  }
  function Hv(i) {
    var a = i.alternate;
    a !== null && (i.alternate = null, Hv(a)), i.child = null, i.deletions = null, i.sibling = null, i.tag === 5 && (a = i.stateNode, a !== null && Ia(a)), 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 sn = null, ei = !1;
  function bs(i, a, o) {
    for (o = o.child; o !== null; )
      Vv(i, a, o), o = o.sibling;
  }
  function Vv(i, a, o) {
    if ($t && typeof $t.onCommitFiberUnmount == "function")
      try {
        $t.onCommitFiberUnmount(Jt, o);
      } catch {
      }
    switch (o.tag) {
      case 26:
        yn || $i(o, a), bs(
          i,
          a,
          o
        ), o.memoizedState ? o.memoizedState.count-- : o.stateNode && (o = o.stateNode, o.parentNode.removeChild(o));
        break;
      case 27:
        yn || $i(o, a);
        var u = sn, g = ei;
        ca(o.type) && (sn = o.stateNode, ei = !1), bs(
          i,
          a,
          o
        ), Fl(o.stateNode), sn = u, ei = g;
        break;
      case 5:
        yn || $i(o, a);
      case 6:
        if (u = sn, g = ei, sn = null, bs(
          i,
          a,
          o
        ), sn = u, ei = g, sn !== null)
          if (ei)
            try {
              (sn.nodeType === 9 ? sn.body : sn.nodeName === "HTML" ? sn.ownerDocument.body : sn).removeChild(o.stateNode);
            } catch (v) {
              Ve(
                o,
                a,
                v
              );
            }
          else
            try {
              sn.removeChild(o.stateNode);
            } catch (v) {
              Ve(
                o,
                a,
                v
              );
            }
        break;
      case 18:
        sn !== null && (ei ? (i = sn, Uy(
          i.nodeType === 9 ? i.body : i.nodeName === "HTML" ? i.ownerDocument.body : i,
          o.stateNode
        ), ao(i)) : Uy(sn, o.stateNode));
        break;
      case 4:
        u = sn, g = ei, sn = o.stateNode.containerInfo, ei = !0, bs(
          i,
          a,
          o
        ), sn = u, ei = g;
        break;
      case 0:
      case 11:
      case 14:
      case 15:
        na(2, o, a), yn || na(4, o, a), bs(
          i,
          a,
          o
        );
        break;
      case 1:
        yn || ($i(o, a), u = o.stateNode, typeof u.componentWillUnmount == "function" && Ov(
          o,
          a,
          u
        )), bs(
          i,
          a,
          o
        );
        break;
      case 21:
        bs(
          i,
          a,
          o
        );
        break;
      case 22:
        yn = (u = yn) || o.memoizedState !== null, bs(
          i,
          a,
          o
        ), yn = u;
        break;
      default:
        bs(
          i,
          a,
          o
        );
    }
  }
  function Gv(i, a) {
    if (a.memoizedState === null && (i = a.alternate, i !== null && (i = i.memoizedState, i !== null))) {
      i = i.dehydrated;
      try {
        ao(i);
      } catch (o) {
        Ve(a, a.return, o);
      }
    }
  }
  function kv(i, a) {
    if (a.memoizedState === null && (i = a.alternate, i !== null && (i = i.memoizedState, i !== null && (i = i.dehydrated, i !== null))))
      try {
        ao(i);
      } catch (o) {
        Ve(a, a.return, o);
      }
  }
  function fA(i) {
    switch (i.tag) {
      case 31:
      case 13:
      case 19:
        var a = i.stateNode;
        return a === null && (a = i.stateNode = new Bv()), a;
      case 22:
        return i = i.stateNode, a = i._retryCache, a === null && (a = i._retryCache = new Bv()), a;
      default:
        throw Error(s(435, i.tag));
    }
  }
  function xu(i, a) {
    var o = fA(i);
    a.forEach(function(u) {
      if (!o.has(u)) {
        o.add(u);
        var g = xA.bind(null, i, u);
        u.then(g, g);
      }
    });
  }
  function ni(i, a) {
    var o = a.deletions;
    if (o !== null)
      for (var u = 0; u < o.length; u++) {
        var g = o[u], v = i, w = a, F = w;
        t: for (; F !== null; ) {
          switch (F.tag) {
            case 27:
              if (ca(F.type)) {
                sn = F.stateNode, ei = !1;
                break t;
              }
              break;
            case 5:
              sn = F.stateNode, ei = !1;
              break t;
            case 3:
            case 4:
              sn = F.stateNode.containerInfo, ei = !0;
              break t;
          }
          F = F.return;
        }
        if (sn === null) throw Error(s(160));
        Vv(v, w, g), sn = null, ei = !1, v = g.alternate, v !== null && (v.return = null), g.return = null;
      }
    if (a.subtreeFlags & 13886)
      for (a = a.child; a !== null; )
        Xv(a, i), a = a.sibling;
  }
  var Fi = null;
  function Xv(i, a) {
    var o = i.alternate, u = i.flags;
    switch (i.tag) {
      case 0:
      case 11:
      case 14:
      case 15:
        ni(a, i), ii(i), u & 4 && (na(3, i, i.return), Rl(3, i), na(5, i, i.return));
        break;
      case 1:
        ni(a, i), ii(i), u & 512 && (yn || o === null || $i(o, o.return)), u & 64 && Ss && (i = i.updateQueue, i !== null && (u = i.callbacks, u !== null && (o = i.shared.hiddenCallbacks, i.shared.hiddenCallbacks = o === null ? u : o.concat(u))));
        break;
      case 26:
        var g = Fi;
        if (ni(a, i), ii(i), u & 512 && (yn || o === null || $i(o, o.return)), u & 4) {
          var v = o !== null ? o.memoizedState : null;
          if (u = i.memoizedState, o === null)
            if (u === null)
              if (i.stateNode === null) {
                t: {
                  u = i.type, o = i.memoizedProps, g = g.ownerDocument || g;
                  e: switch (u) {
                    case "title":
                      v = g.getElementsByTagName("title")[0], (!v || v[us] || v[nn] || v.namespaceURI === "http://www.w3.org/2000/svg" || v.hasAttribute("itemprop")) && (v = g.createElement(u), g.head.insertBefore(
                        v,
                        g.querySelector("head > title")
                      )), Hn(v, u, o), v[nn] = i, et(v), u = v;
                      break t;
                    case "link":
                      var w = Xy(
                        "link",
                        "href",
                        g
                      ).get(u + (o.href || ""));
                      if (w) {
                        for (var F = 0; F < w.length; F++)
                          if (v = w[F], v.getAttribute("href") === (o.href == null || o.href === "" ? null : o.href) && v.getAttribute("rel") === (o.rel == null ? null : o.rel) && v.getAttribute("title") === (o.title == null ? null : o.title) && v.getAttribute("crossorigin") === (o.crossOrigin == null ? null : o.crossOrigin)) {
                            w.splice(F, 1);
                            break e;
                          }
                      }
                      v = g.createElement(u), Hn(v, u, o), g.head.appendChild(v);
                      break;
                    case "meta":
                      if (w = Xy(
                        "meta",
                        "content",
                        g
                      ).get(u + (o.content || ""))) {
                        for (F = 0; F < w.length; F++)
                          if (v = w[F], v.getAttribute("content") === (o.content == null ? null : "" + o.content) && v.getAttribute("name") === (o.name == null ? null : o.name) && v.getAttribute("property") === (o.property == null ? null : o.property) && v.getAttribute("http-equiv") === (o.httpEquiv == null ? null : o.httpEquiv) && v.getAttribute("charset") === (o.charSet == null ? null : o.charSet)) {
                            w.splice(F, 1);
                            break e;
                          }
                      }
                      v = g.createElement(u), Hn(v, u, o), g.head.appendChild(v);
                      break;
                    default:
                      throw Error(s(468, u));
                  }
                  v[nn] = i, et(v), u = v;
                }
                i.stateNode = u;
              } else
                Wy(
                  g,
                  i.type,
                  i.stateNode
                );
            else
              i.stateNode = ky(
                g,
                u,
                i.memoizedProps
              );
          else
            v !== u ? (v === null ? o.stateNode !== null && (o = o.stateNode, o.parentNode.removeChild(o)) : v.count--, u === null ? Wy(
              g,
              i.type,
              i.stateNode
            ) : ky(
              g,
              u,
              i.memoizedProps
            )) : u === null && i.stateNode !== null && Yh(
              i,
              i.memoizedProps,
              o.memoizedProps
            );
        }
        break;
      case 27:
        ni(a, i), ii(i), u & 512 && (yn || o === null || $i(o, o.return)), o !== null && u & 4 && Yh(
          i,
          i.memoizedProps,
          o.memoizedProps
        );
        break;
      case 5:
        if (ni(a, i), ii(i), u & 512 && (yn || o === null || $i(o, o.return)), i.flags & 32) {
          g = i.stateNode;
          try {
            Jn(g, "");
          } catch (Kt) {
            Ve(i, i.return, Kt);
          }
        }
        u & 4 && i.stateNode != null && (g = i.memoizedProps, Yh(
          i,
          g,
          o !== null ? o.memoizedProps : g
        )), u & 1024 && (Zh = !0);
        break;
      case 6:
        if (ni(a, i), ii(i), u & 4) {
          if (i.stateNode === null)
            throw Error(s(162));
          u = i.memoizedProps, o = i.stateNode;
          try {
            o.nodeValue = u;
          } catch (Kt) {
            Ve(i, i.return, Kt);
          }
        }
        break;
      case 3:
        if (zu = null, g = Fi, Fi = Ou(a.containerInfo), ni(a, i), Fi = g, ii(i), u & 4 && o !== null && o.memoizedState.isDehydrated)
          try {
            ao(a.containerInfo);
          } catch (Kt) {
            Ve(i, i.return, Kt);
          }
        Zh && (Zh = !1, Wv(i));
        break;
      case 4:
        u = Fi, Fi = Ou(
          i.stateNode.containerInfo
        ), ni(a, i), ii(i), Fi = u;
        break;
      case 12:
        ni(a, i), ii(i);
        break;
      case 31:
        ni(a, i), ii(i), u & 4 && (u = i.updateQueue, u !== null && (i.updateQueue = null, xu(i, u)));
        break;
      case 13:
        ni(a, i), ii(i), i.child.flags & 8192 && i.memoizedState !== null != (o !== null && o.memoizedState !== null) && (bu = St()), u & 4 && (u = i.updateQueue, u !== null && (i.updateQueue = null, xu(i, u)));
        break;
      case 22:
        g = i.memoizedState !== null;
        var Q = o !== null && o.memoizedState !== null, ut = Ss, xt = yn;
        if (Ss = ut || g, yn = xt || Q, ni(a, i), yn = xt, Ss = ut, ii(i), u & 8192)
          t: for (a = i.stateNode, a._visibility = g ? a._visibility & -2 : a._visibility | 1, g && (o === null || Q || Ss || yn || Qa(i)), o = null, a = i; ; ) {
            if (a.tag === 5 || a.tag === 26) {
              if (o === null) {
                Q = o = a;
                try {
                  if (v = Q.stateNode, g)
                    w = v.style, typeof w.setProperty == "function" ? w.setProperty("display", "none", "important") : w.display = "none";
                  else {
                    F = Q.stateNode;
                    var Tt = Q.memoizedProps.style, pt = Tt != null && Tt.hasOwnProperty("display") ? Tt.display : null;
                    F.style.display = pt == null || typeof pt == "boolean" ? "" : ("" + pt).trim();
                  }
                } catch (Kt) {
                  Ve(Q, Q.return, Kt);
                }
              }
            } else if (a.tag === 6) {
              if (o === null) {
                Q = a;
                try {
                  Q.stateNode.nodeValue = g ? "" : Q.memoizedProps;
                } catch (Kt) {
                  Ve(Q, Q.return, Kt);
                }
              }
            } else if (a.tag === 18) {
              if (o === null) {
                Q = a;
                try {
                  var vt = Q.stateNode;
                  g ? Oy(vt, !0) : Oy(Q.stateNode, !1);
                } catch (Kt) {
                  Ve(Q, Q.return, Kt);
                }
              }
            } else if ((a.tag !== 22 && a.tag !== 23 || a.memoizedState === null || a === i) && a.child !== null) {
              a.child.return = a, a = a.child;
              continue;
            }
            if (a === i) break t;
            for (; a.sibling === null; ) {
              if (a.return === null || a.return === i) break t;
              o === a && (o = null), a = a.return;
            }
            o === a && (o = null), a.sibling.return = a.return, a = a.sibling;
          }
        u & 4 && (u = i.updateQueue, u !== null && (o = u.retryQueue, o !== null && (u.retryQueue = null, xu(i, o))));
        break;
      case 19:
        ni(a, i), ii(i), u & 4 && (u = i.updateQueue, u !== null && (i.updateQueue = null, xu(i, u)));
        break;
      case 30:
        break;
      case 21:
        break;
      default:
        ni(a, i), ii(i);
    }
  }
  function ii(i) {
    var a = i.flags;
    if (a & 2) {
      try {
        for (var o, u = i.return; u !== null; ) {
          if (zv(u)) {
            o = u;
            break;
          }
          u = u.return;
        }
        if (o == null) throw Error(s(160));
        switch (o.tag) {
          case 27:
            var g = o.stateNode, v = jh(i);
            yu(i, v, g);
            break;
          case 5:
            var w = o.stateNode;
            o.flags & 32 && (Jn(w, ""), o.flags &= -33);
            var F = jh(i);
            yu(i, F, w);
            break;
          case 3:
          case 4:
            var Q = o.stateNode.containerInfo, ut = jh(i);
            qh(
              i,
              ut,
              Q
            );
            break;
          default:
            throw Error(s(161));
        }
      } catch (xt) {
        Ve(i, i.return, xt);
      }
      i.flags &= -3;
    }
    a & 4096 && (i.flags &= -4097);
  }
  function Wv(i) {
    if (i.subtreeFlags & 1024)
      for (i = i.child; i !== null; ) {
        var a = i;
        Wv(a), a.tag === 5 && a.flags & 1024 && a.stateNode.reset(), i = i.sibling;
      }
  }
  function Ms(i, a) {
    if (a.subtreeFlags & 8772)
      for (a = a.child; a !== null; )
        Fv(i, a.alternate, a), a = a.sibling;
  }
  function Qa(i) {
    for (i = i.child; i !== null; ) {
      var a = i;
      switch (a.tag) {
        case 0:
        case 11:
        case 14:
        case 15:
          na(4, a, a.return), Qa(a);
          break;
        case 1:
          $i(a, a.return);
          var o = a.stateNode;
          typeof o.componentWillUnmount == "function" && Ov(
            a,
            a.return,
            o
          ), Qa(a);
          break;
        case 27:
          Fl(a.stateNode);
        case 26:
        case 5:
          $i(a, a.return), Qa(a);
          break;
        case 22:
          a.memoizedState === null && Qa(a);
          break;
        case 30:
          Qa(a);
          break;
        default:
          Qa(a);
      }
      i = i.sibling;
    }
  }
  function Es(i, a, o) {
    for (o = o && (a.subtreeFlags & 8772) !== 0, a = a.child; a !== null; ) {
      var u = a.alternate, g = i, v = a, w = v.flags;
      switch (v.tag) {
        case 0:
        case 11:
        case 15:
          Es(
            g,
            v,
            o
          ), Rl(4, v);
          break;
        case 1:
          if (Es(
            g,
            v,
            o
          ), u = v, g = u.stateNode, typeof g.componentDidMount == "function")
            try {
              g.componentDidMount();
            } catch (ut) {
              Ve(u, u.return, ut);
            }
          if (u = v, g = u.updateQueue, g !== null) {
            var F = u.stateNode;
            try {
              var Q = g.shared.hiddenCallbacks;
              if (Q !== null)
                for (g.shared.hiddenCallbacks = null, g = 0; g < Q.length; g++)
                  b_(Q[g], F);
            } catch (ut) {
              Ve(u, u.return, ut);
            }
          }
          o && w & 64 && Uv(v), Dl(v, v.return);
          break;
        case 27:
          Iv(v);
        case 26:
        case 5:
          Es(
            g,
            v,
            o
          ), o && u === null && w & 4 && Pv(v), Dl(v, v.return);
          break;
        case 12:
          Es(
            g,
            v,
            o
          );
          break;
        case 31:
          Es(
            g,
            v,
            o
          ), o && w & 4 && Gv(g, v);
          break;
        case 13:
          Es(
            g,
            v,
            o
          ), o && w & 4 && kv(g, v);
          break;
        case 22:
          v.memoizedState === null && Es(
            g,
            v,
            o
          ), Dl(v, v.return);
          break;
        case 30:
          break;
        default:
          Es(
            g,
            v,
            o
          );
      }
      a = a.sibling;
    }
  }
  function Kh(i, a) {
    var o = null;
    i !== null && i.memoizedState !== null && i.memoizedState.cachePool !== null && (o = i.memoizedState.cachePool.pool), i = null, a.memoizedState !== null && a.memoizedState.cachePool !== null && (i = a.memoizedState.cachePool.pool), i !== o && (i != null && i.refCount++, o != null && gl(o));
  }
  function $h(i, a) {
    i = null, a.alternate !== null && (i = a.alternate.memoizedState.cache), a = a.memoizedState.cache, a !== i && (a.refCount++, i != null && gl(i));
  }
  function Hi(i, a, o, u) {
    if (a.subtreeFlags & 10256)
      for (a = a.child; a !== null; )
        Yv(
          i,
          a,
          o,
          u
        ), a = a.sibling;
  }
  function Yv(i, a, o, u) {
    var g = a.flags;
    switch (a.tag) {
      case 0:
      case 11:
      case 15:
        Hi(
          i,
          a,
          o,
          u
        ), g & 2048 && Rl(9, a);
        break;
      case 1:
        Hi(
          i,
          a,
          o,
          u
        );
        break;
      case 3:
        Hi(
          i,
          a,
          o,
          u
        ), g & 2048 && (i = null, a.alternate !== null && (i = a.alternate.memoizedState.cache), a = a.memoizedState.cache, a !== i && (a.refCount++, i != null && gl(i)));
        break;
      case 12:
        if (g & 2048) {
          Hi(
            i,
            a,
            o,
            u
          ), i = a.stateNode;
          try {
            var v = a.memoizedProps, w = v.id, F = v.onPostCommit;
            typeof F == "function" && F(
              w,
              a.alternate === null ? "mount" : "update",
              i.passiveEffectDuration,
              -0
            );
          } catch (Q) {
            Ve(a, a.return, Q);
          }
        } else
          Hi(
            i,
            a,
            o,
            u
          );
        break;
      case 31:
        Hi(
          i,
          a,
          o,
          u
        );
        break;
      case 13:
        Hi(
          i,
          a,
          o,
          u
        );
        break;
      case 23:
        break;
      case 22:
        v = a.stateNode, w = a.alternate, a.memoizedState !== null ? v._visibility & 2 ? Hi(
          i,
          a,
          o,
          u
        ) : Nl(i, a) : v._visibility & 2 ? Hi(
          i,
          a,
          o,
          u
        ) : (v._visibility |= 2, qr(
          i,
          a,
          o,
          u,
          (a.subtreeFlags & 10256) !== 0 || !1
        )), g & 2048 && Kh(w, a);
        break;
      case 24:
        Hi(
          i,
          a,
          o,
          u
        ), g & 2048 && $h(a.alternate, a);
        break;
      default:
        Hi(
          i,
          a,
          o,
          u
        );
    }
  }
  function qr(i, a, o, u, g) {
    for (g = g && ((a.subtreeFlags & 10256) !== 0 || !1), a = a.child; a !== null; ) {
      var v = i, w = a, F = o, Q = u, ut = w.flags;
      switch (w.tag) {
        case 0:
        case 11:
        case 15:
          qr(
            v,
            w,
            F,
            Q,
            g
          ), Rl(8, w);
          break;
        case 23:
          break;
        case 22:
          var xt = w.stateNode;
          w.memoizedState !== null ? xt._visibility & 2 ? qr(
            v,
            w,
            F,
            Q,
            g
          ) : Nl(
            v,
            w
          ) : (xt._visibility |= 2, qr(
            v,
            w,
            F,
            Q,
            g
          )), g && ut & 2048 && Kh(
            w.alternate,
            w
          );
          break;
        case 24:
          qr(
            v,
            w,
            F,
            Q,
            g
          ), g && ut & 2048 && $h(w.alternate, w);
          break;
        default:
          qr(
            v,
            w,
            F,
            Q,
            g
          );
      }
      a = a.sibling;
    }
  }
  function Nl(i, a) {
    if (a.subtreeFlags & 10256)
      for (a = a.child; a !== null; ) {
        var o = i, u = a, g = u.flags;
        switch (u.tag) {
          case 22:
            Nl(o, u), g & 2048 && Kh(
              u.alternate,
              u
            );
            break;
          case 24:
            Nl(o, u), g & 2048 && $h(u.alternate, u);
            break;
          default:
            Nl(o, u);
        }
        a = a.sibling;
      }
  }
  var Ll = 8192;
  function Zr(i, a, o) {
    if (i.subtreeFlags & Ll)
      for (i = i.child; i !== null; )
        jv(
          i,
          a,
          o
        ), i = i.sibling;
  }
  function jv(i, a, o) {
    switch (i.tag) {
      case 26:
        Zr(
          i,
          a,
          o
        ), i.flags & Ll && i.memoizedState !== null && $A(
          o,
          Fi,
          i.memoizedState,
          i.memoizedProps
        );
        break;
      case 5:
        Zr(
          i,
          a,
          o
        );
        break;
      case 3:
      case 4:
        var u = Fi;
        Fi = Ou(i.stateNode.containerInfo), Zr(
          i,
          a,
          o
        ), Fi = u;
        break;
      case 22:
        i.memoizedState === null && (u = i.alternate, u !== null && u.memoizedState !== null ? (u = Ll, Ll = 16777216, Zr(
          i,
          a,
          o
        ), Ll = u) : Zr(
          i,
          a,
          o
        ));
        break;
      default:
        Zr(
          i,
          a,
          o
        );
    }
  }
  function qv(i) {
    var a = i.alternate;
    if (a !== null && (i = a.child, i !== null)) {
      a.child = null;
      do
        a = i.sibling, i.sibling = null, i = a;
      while (i !== null);
    }
  }
  function Ul(i) {
    var a = i.deletions;
    if ((i.flags & 16) !== 0) {
      if (a !== null)
        for (var o = 0; o < a.length; o++) {
          var u = a[o];
          Nn = u, Kv(
            u,
            i
          );
        }
      qv(i);
    }
    if (i.subtreeFlags & 10256)
      for (i = i.child; i !== null; )
        Zv(i), i = i.sibling;
  }
  function Zv(i) {
    switch (i.tag) {
      case 0:
      case 11:
      case 15:
        Ul(i), i.flags & 2048 && na(9, i, i.return);
        break;
      case 3:
        Ul(i);
        break;
      case 12:
        Ul(i);
        break;
      case 22:
        var a = i.stateNode;
        i.memoizedState !== null && a._visibility & 2 && (i.return === null || i.return.tag !== 13) ? (a._visibility &= -3, Su(i)) : Ul(i);
        break;
      default:
        Ul(i);
    }
  }
  function Su(i) {
    var a = i.deletions;
    if ((i.flags & 16) !== 0) {
      if (a !== null)
        for (var o = 0; o < a.length; o++) {
          var u = a[o];
          Nn = u, Kv(
            u,
            i
          );
        }
      qv(i);
    }
    for (i = i.child; i !== null; ) {
      switch (a = i, a.tag) {
        case 0:
        case 11:
        case 15:
          na(8, a, a.return), Su(a);
          break;
        case 22:
          o = a.stateNode, o._visibility & 2 && (o._visibility &= -3, Su(a));
          break;
        default:
          Su(a);
      }
      i = i.sibling;
    }
  }
  function Kv(i, a) {
    for (; Nn !== null; ) {
      var o = Nn;
      switch (o.tag) {
        case 0:
        case 11:
        case 15:
          na(8, o, a);
          break;
        case 23:
        case 22:
          if (o.memoizedState !== null && o.memoizedState.cachePool !== null) {
            var u = o.memoizedState.cachePool.pool;
            u != null && u.refCount++;
          }
          break;
        case 24:
          gl(o.memoizedState.cache);
      }
      if (u = o.child, u !== null) u.return = o, Nn = u;
      else
        t: for (o = i; Nn !== null; ) {
          u = Nn;
          var g = u.sibling, v = u.return;
          if (Hv(u), u === o) {
            Nn = null;
            break t;
          }
          if (g !== null) {
            g.return = v, Nn = g;
            break t;
          }
          Nn = v;
        }
    }
  }
  var dA = {
    getCacheForType: function(i) {
      var a = Bn(gn), o = a.data.get(i);
      return o === void 0 && (o = i(), a.data.set(i, o)), o;
    },
    cacheSignal: function() {
      return Bn(gn).controller.signal;
    }
  }, hA = typeof WeakMap == "function" ? WeakMap : Map, Be = 0, Ke = null, Ee = null, Ce = 0, He = 0, mi = null, ia = !1, Kr = !1, Qh = !1, Ts = 0, un = 0, sa = 0, Ja = 0, Jh = 0, gi = 0, $r = 0, Ol = null, si = null, tp = !1, bu = 0, $v = 0, Mu = 1 / 0, Eu = null, aa = null, Tn = 0, ra = null, Qr = null, As = 0, ep = 0, np = null, Qv = null, Pl = 0, ip = null;
  function _i() {
    return (Be & 2) !== 0 && Ce !== 0 ? Ce & -Ce : U.T !== null ? cp() : za();
  }
  function Jv() {
    if (gi === 0)
      if ((Ce & 536870912) === 0 || Ne) {
        var i = yt;
        yt <<= 1, (yt & 3932160) === 0 && (yt = 262144), gi = i;
      } else gi = 536870912;
    return i = hi.current, i !== null && (i.flags |= 32), gi;
  }
  function ai(i, a, o) {
    (i === Ke && (He === 2 || He === 9) || i.cancelPendingCommit !== null) && (Jr(i, 0), oa(
      i,
      Ce,
      gi,
      !1
    )), Mn(i, o), ((Be & 2) === 0 || i !== Ke) && (i === Ke && ((Be & 2) === 0 && (Ja |= o), un === 4 && oa(
      i,
      Ce,
      gi,
      !1
    )), Qi(i));
  }
  function ty(i, a, o) {
    if ((Be & 6) !== 0) throw Error(s(327));
    var u = !o && (a & 127) === 0 && (a & i.expiredLanes) === 0 || ce(i, a), g = u ? gA(i, a) : ap(i, a, !0), v = u;
    do {
      if (g === 0) {
        Kr && !u && oa(i, a, 0, !1);
        break;
      } else {
        if (o = i.current.alternate, v && !pA(o)) {
          g = ap(i, a, !1), v = !1;
          continue;
        }
        if (g === 2) {
          if (v = a, i.errorRecoveryDisabledLanes & v)
            var w = 0;
          else
            w = i.pendingLanes & -536870913, w = w !== 0 ? w : w & 536870912 ? 536870912 : 0;
          if (w !== 0) {
            a = w;
            t: {
              var F = i;
              g = Ol;
              var Q = F.current.memoizedState.isDehydrated;
              if (Q && (Jr(F, w).flags |= 256), w = ap(
                F,
                w,
                !1
              ), w !== 2) {
                if (Qh && !Q) {
                  F.errorRecoveryDisabledLanes |= v, Ja |= v, g = 4;
                  break t;
                }
                v = si, si = g, v !== null && (si === null ? si = v : si.push.apply(
                  si,
                  v
                ));
              }
              g = w;
            }
            if (v = !1, g !== 2) continue;
          }
        }
        if (g === 1) {
          Jr(i, 0), oa(i, a, 0, !0);
          break;
        }
        t: {
          switch (u = i, v = g, v) {
            case 0:
            case 1:
              throw Error(s(345));
            case 4:
              if ((a & 4194048) !== a) break;
            case 6:
              oa(
                u,
                a,
                gi,
                !ia
              );
              break t;
            case 2:
              si = null;
              break;
            case 3:
            case 5:
              break;
            default:
              throw Error(s(329));
          }
          if ((a & 62914560) === a && (g = bu + 300 - St(), 10 < g)) {
            if (oa(
              u,
              a,
              gi,
              !ia
            ), zt(u, 0, !0) !== 0) break t;
            As = a, u.timeoutHandle = Ny(
              ey.bind(
                null,
                u,
                o,
                si,
                Eu,
                tp,
                a,
                gi,
                Ja,
                $r,
                ia,
                v,
                "Throttled",
                -0,
                0
              ),
              g
            );
            break t;
          }
          ey(
            u,
            o,
            si,
            Eu,
            tp,
            a,
            gi,
            Ja,
            $r,
            ia,
            v,
            null,
            -0,
            0
          );
        }
      }
      break;
    } while (!0);
    Qi(i);
  }
  function ey(i, a, o, u, g, v, w, F, Q, ut, xt, Tt, pt, vt) {
    if (i.timeoutHandle = -1, Tt = a.subtreeFlags, Tt & 8192 || (Tt & 16785408) === 16785408) {
      Tt = {
        stylesheets: null,
        count: 0,
        imgCount: 0,
        imgBytes: 0,
        suspenseyImages: [],
        waitingForImages: !0,
        waitingForViewTransition: !1,
        unsuspend: fs
      }, jv(
        a,
        v,
        Tt
      );
      var Kt = (v & 62914560) === v ? bu - St() : (v & 4194048) === v ? $v - St() : 0;
      if (Kt = QA(
        Tt,
        Kt
      ), Kt !== null) {
        As = v, i.cancelPendingCommit = Kt(
          cy.bind(
            null,
            i,
            a,
            v,
            o,
            u,
            g,
            w,
            F,
            Q,
            xt,
            Tt,
            null,
            pt,
            vt
          )
        ), oa(i, v, w, !ut);
        return;
      }
    }
    cy(
      i,
      a,
      v,
      o,
      u,
      g,
      w,
      F,
      Q
    );
  }
  function pA(i) {
    for (var a = i; ; ) {
      var o = a.tag;
      if ((o === 0 || o === 11 || o === 15) && a.flags & 16384 && (o = a.updateQueue, o !== null && (o = o.stores, o !== null)))
        for (var u = 0; u < o.length; u++) {
          var g = o[u], v = g.getSnapshot;
          g = g.value;
          try {
            if (!fi(v(), g)) return !1;
          } catch {
            return !1;
          }
        }
      if (o = a.child, a.subtreeFlags & 16384 && o !== null)
        o.return = a, a = o;
      else {
        if (a === i) break;
        for (; a.sibling === null; ) {
          if (a.return === null || a.return === i) return !0;
          a = a.return;
        }
        a.sibling.return = a.return, a = a.sibling;
      }
    }
    return !0;
  }
  function oa(i, a, o, u) {
    a &= ~Jh, a &= ~Ja, i.suspendedLanes |= a, i.pingedLanes &= ~a, u && (i.warmLanes |= a), u = i.expirationTimes;
    for (var g = a; 0 < g; ) {
      var v = 31 - re(g), w = 1 << v;
      u[v] = -1, g &= ~w;
    }
    o !== 0 && Oa(i, o, a);
  }
  function Tu() {
    return (Be & 6) === 0 ? (zl(0), !1) : !0;
  }
  function sp() {
    if (Ee !== null) {
      if (He === 0)
        var i = Ee.return;
      else
        i = Ee, ms = Xa = null, xh(i), kr = null, vl = 0, i = Ee;
      for (; i !== null; )
        Lv(i.alternate, i), i = i.return;
      Ee = null;
    }
  }
  function Jr(i, a) {
    var o = i.timeoutHandle;
    o !== -1 && (i.timeoutHandle = -1, OA(o)), o = i.cancelPendingCommit, o !== null && (i.cancelPendingCommit = null, o()), As = 0, sp(), Ke = i, Ee = o = hs(i.current, null), Ce = a, He = 0, mi = null, ia = !1, Kr = ce(i, a), Qh = !1, $r = gi = Jh = Ja = sa = un = 0, si = Ol = null, tp = !1, (a & 8) !== 0 && (a |= a & 32);
    var u = i.entangledLanes;
    if (u !== 0)
      for (i = i.entanglements, u &= a; 0 < u; ) {
        var g = 31 - re(u), v = 1 << g;
        a |= i[g], u &= ~v;
      }
    return Ts = a, Yc(), o;
  }
  function ny(i, a) {
    me = null, U.H = Al, a === Gr || a === tu ? (a = v_(), He = 3) : a === lh ? (a = v_(), He = 4) : He = a === zh ? 8 : a !== null && typeof a == "object" && typeof a.then == "function" ? 6 : 1, mi = a, Ee === null && (un = 1, pu(
      i,
      wi(a, i.current)
    ));
  }
  function iy() {
    var i = hi.current;
    return i === null ? !0 : (Ce & 4194048) === Ce ? Ni === null : (Ce & 62914560) === Ce || (Ce & 536870912) !== 0 ? i === Ni : !1;
  }
  function sy() {
    var i = U.H;
    return U.H = Al, i === null ? Al : i;
  }
  function ay() {
    var i = U.A;
    return U.A = dA, i;
  }
  function Au() {
    un = 4, ia || (Ce & 4194048) !== Ce && hi.current !== null || (Kr = !0), (sa & 134217727) === 0 && (Ja & 134217727) === 0 || Ke === null || oa(
      Ke,
      Ce,
      gi,
      !1
    );
  }
  function ap(i, a, o) {
    var u = Be;
    Be |= 2;
    var g = sy(), v = ay();
    (Ke !== i || Ce !== a) && (Eu = null, Jr(i, a)), a = !1;
    var w = un;
    t: do
      try {
        if (He !== 0 && Ee !== null) {
          var F = Ee, Q = mi;
          switch (He) {
            case 8:
              sp(), w = 6;
              break t;
            case 3:
            case 2:
            case 9:
            case 6:
              hi.current === null && (a = !0);
              var ut = He;
              if (He = 0, mi = null, to(i, F, Q, ut), o && Kr) {
                w = 0;
                break t;
              }
              break;
            default:
              ut = He, He = 0, mi = null, to(i, F, Q, ut);
          }
        }
        mA(), w = un;
        break;
      } catch (xt) {
        ny(i, xt);
      }
    while (!0);
    return a && i.shellSuspendCounter++, ms = Xa = null, Be = u, U.H = g, U.A = v, Ee === null && (Ke = null, Ce = 0, Yc()), w;
  }
  function mA() {
    for (; Ee !== null; ) ry(Ee);
  }
  function gA(i, a) {
    var o = Be;
    Be |= 2;
    var u = sy(), g = ay();
    Ke !== i || Ce !== a ? (Eu = null, Mu = St() + 500, Jr(i, a)) : Kr = ce(
      i,
      a
    );
    t: do
      try {
        if (He !== 0 && Ee !== null) {
          a = Ee;
          var v = mi;
          e: switch (He) {
            case 1:
              He = 0, mi = null, to(i, a, v, 1);
              break;
            case 2:
            case 9:
              if (g_(v)) {
                He = 0, mi = null, oy(a);
                break;
              }
              a = function() {
                He !== 2 && He !== 9 || Ke !== i || (He = 7), Qi(i);
              }, v.then(a, a);
              break t;
            case 3:
              He = 7;
              break t;
            case 4:
              He = 5;
              break t;
            case 7:
              g_(v) ? (He = 0, mi = null, oy(a)) : (He = 0, mi = null, to(i, a, v, 7));
              break;
            case 5:
              var w = null;
              switch (Ee.tag) {
                case 26:
                  w = Ee.memoizedState;
                case 5:
                case 27:
                  var F = Ee;
                  if (w ? Yy(w) : F.stateNode.complete) {
                    He = 0, mi = null;
                    var Q = F.sibling;
                    if (Q !== null) Ee = Q;
                    else {
                      var ut = F.return;
                      ut !== null ? (Ee = ut, wu(ut)) : Ee = null;
                    }
                    break e;
                  }
              }
              He = 0, mi = null, to(i, a, v, 5);
              break;
            case 6:
              He = 0, mi = null, to(i, a, v, 6);
              break;
            case 8:
              sp(), un = 6;
              break t;
            default:
              throw Error(s(462));
          }
        }
        _A();
        break;
      } catch (xt) {
        ny(i, xt);
      }
    while (!0);
    return ms = Xa = null, U.H = u, U.A = g, Be = o, Ee !== null ? 0 : (Ke = null, Ce = 0, Yc(), un);
  }
  function _A() {
    for (; Ee !== null && !B(); )
      ry(Ee);
  }
  function ry(i) {
    var a = Dv(i.alternate, i, Ts);
    i.memoizedProps = i.pendingProps, a === null ? wu(i) : Ee = a;
  }
  function oy(i) {
    var a = i, o = a.alternate;
    switch (a.tag) {
      case 15:
      case 0:
        a = Ev(
          o,
          a,
          a.pendingProps,
          a.type,
          void 0,
          Ce
        );
        break;
      case 11:
        a = Ev(
          o,
          a,
          a.pendingProps,
          a.type.render,
          a.ref,
          Ce
        );
        break;
      case 5:
        xh(a);
      default:
        Lv(o, a), a = Ee = a_(a, Ts), a = Dv(o, a, Ts);
    }
    i.memoizedProps = i.pendingProps, a === null ? wu(i) : Ee = a;
  }
  function to(i, a, o, u) {
    ms = Xa = null, xh(a), kr = null, vl = 0;
    var g = a.return;
    try {
      if (aA(
        i,
        g,
        a,
        o,
        Ce
      )) {
        un = 1, pu(
          i,
          wi(o, i.current)
        ), Ee = null;
        return;
      }
    } catch (v) {
      if (g !== null) throw Ee = g, v;
      un = 1, pu(
        i,
        wi(o, i.current)
      ), Ee = null;
      return;
    }
    a.flags & 32768 ? (Ne || u === 1 ? i = !0 : Kr || (Ce & 536870912) !== 0 ? i = !1 : (ia = i = !0, (u === 2 || u === 9 || u === 3 || u === 6) && (u = hi.current, u !== null && u.tag === 13 && (u.flags |= 16384))), ly(a, i)) : wu(a);
  }
  function wu(i) {
    var a = i;
    do {
      if ((a.flags & 32768) !== 0) {
        ly(
          a,
          ia
        );
        return;
      }
      i = a.return;
      var o = lA(
        a.alternate,
        a,
        Ts
      );
      if (o !== null) {
        Ee = o;
        return;
      }
      if (a = a.sibling, a !== null) {
        Ee = a;
        return;
      }
      Ee = a = i;
    } while (a !== null);
    un === 0 && (un = 5);
  }
  function ly(i, a) {
    do {
      var o = cA(i.alternate, i);
      if (o !== null) {
        o.flags &= 32767, Ee = o;
        return;
      }
      if (o = i.return, o !== null && (o.flags |= 32768, o.subtreeFlags = 0, o.deletions = null), !a && (i = i.sibling, i !== null)) {
        Ee = i;
        return;
      }
      Ee = i = o;
    } while (i !== null);
    un = 6, Ee = null;
  }
  function cy(i, a, o, u, g, v, w, F, Q) {
    i.cancelPendingCommit = null;
    do
      Cu();
    while (Tn !== 0);
    if ((Be & 6) !== 0) throw Error(s(327));
    if (a !== null) {
      if (a === i.current) throw Error(s(177));
      if (v = a.lanes | a.childLanes, v |= jd, ci(
        i,
        o,
        v,
        w,
        F,
        Q
      ), i === Ke && (Ee = Ke = null, Ce = 0), Qr = a, ra = i, As = o, ep = v, np = g, Qv = u, (a.subtreeFlags & 10256) !== 0 || (a.flags & 10256) !== 0 ? (i.callbackNode = null, i.callbackPriority = 0, SA(Ut, function() {
        return py(), null;
      })) : (i.callbackNode = null, i.callbackPriority = 0), u = (a.flags & 13878) !== 0, (a.subtreeFlags & 13878) !== 0 || u) {
        u = U.T, U.T = null, g = X.p, X.p = 2, w = Be, Be |= 4;
        try {
          uA(i, a, o);
        } finally {
          Be = w, X.p = g, U.T = u;
        }
      }
      Tn = 1, uy(), fy(), dy();
    }
  }
  function uy() {
    if (Tn === 1) {
      Tn = 0;
      var i = ra, a = Qr, o = (a.flags & 13878) !== 0;
      if ((a.subtreeFlags & 13878) !== 0 || o) {
        o = U.T, U.T = null;
        var u = X.p;
        X.p = 2;
        var g = Be;
        Be |= 4;
        try {
          Xv(a, i);
          var v = _p, w = K0(i.containerInfo), F = v.focusedElem, Q = v.selectionRange;
          if (w !== F && F && F.ownerDocument && Z0(
            F.ownerDocument.documentElement,
            F
          )) {
            if (Q !== null && Gd(F)) {
              var ut = Q.start, xt = Q.end;
              if (xt === void 0 && (xt = ut), "selectionStart" in F)
                F.selectionStart = ut, F.selectionEnd = Math.min(
                  xt,
                  F.value.length
                );
              else {
                var Tt = F.ownerDocument || document, pt = Tt && Tt.defaultView || window;
                if (pt.getSelection) {
                  var vt = pt.getSelection(), Kt = F.textContent.length, ae = Math.min(Q.start, Kt), Xe = Q.end === void 0 ? ae : Math.min(Q.end, Kt);
                  !vt.extend && ae > Xe && (w = Xe, Xe = ae, ae = w);
                  var rt = q0(
                    F,
                    ae
                  ), tt = q0(
                    F,
                    Xe
                  );
                  if (rt && tt && (vt.rangeCount !== 1 || vt.anchorNode !== rt.node || vt.anchorOffset !== rt.offset || vt.focusNode !== tt.node || vt.focusOffset !== tt.offset)) {
                    var ct = Tt.createRange();
                    ct.setStart(rt.node, rt.offset), vt.removeAllRanges(), ae > Xe ? (vt.addRange(ct), vt.extend(tt.node, tt.offset)) : (ct.setEnd(tt.node, tt.offset), vt.addRange(ct));
                  }
                }
              }
            }
            for (Tt = [], vt = F; vt = vt.parentNode; )
              vt.nodeType === 1 && Tt.push({
                element: vt,
                left: vt.scrollLeft,
                top: vt.scrollTop
              });
            for (typeof F.focus == "function" && F.focus(), F = 0; F < Tt.length; F++) {
              var Mt = Tt[F];
              Mt.element.scrollLeft = Mt.left, Mt.element.scrollTop = Mt.top;
            }
          }
          Hu = !!gp, _p = gp = null;
        } finally {
          Be = g, X.p = u, U.T = o;
        }
      }
      i.current = a, Tn = 2;
    }
  }
  function fy() {
    if (Tn === 2) {
      Tn = 0;
      var i = ra, a = Qr, o = (a.flags & 8772) !== 0;
      if ((a.subtreeFlags & 8772) !== 0 || o) {
        o = U.T, U.T = null;
        var u = X.p;
        X.p = 2;
        var g = Be;
        Be |= 4;
        try {
          Fv(i, a.alternate, a);
        } finally {
          Be = g, X.p = u, U.T = o;
        }
      }
      Tn = 3;
    }
  }
  function dy() {
    if (Tn === 4 || Tn === 3) {
      Tn = 0, ft();
      var i = ra, a = Qr, o = As, u = Qv;
      (a.subtreeFlags & 10256) !== 0 || (a.flags & 10256) !== 0 ? Tn = 5 : (Tn = 0, Qr = ra = null, hy(i, i.pendingLanes));
      var g = i.pendingLanes;
      if (g === 0 && (aa = null), Xs(o), a = a.stateNode, $t && typeof $t.onCommitFiberRoot == "function")
        try {
          $t.onCommitFiberRoot(
            Jt,
            a,
            void 0,
            (a.current.flags & 128) === 128
          );
        } catch {
        }
      if (u !== null) {
        a = U.T, g = X.p, X.p = 2, U.T = null;
        try {
          for (var v = i.onRecoverableError, w = 0; w < u.length; w++) {
            var F = u[w];
            v(F.value, {
              componentStack: F.stack
            });
          }
        } finally {
          U.T = a, X.p = g;
        }
      }
      (As & 3) !== 0 && Cu(), Qi(i), g = i.pendingLanes, (o & 261930) !== 0 && (g & 42) !== 0 ? i === ip ? Pl++ : (Pl = 0, ip = i) : Pl = 0, zl(0);
    }
  }
  function hy(i, a) {
    (i.pooledCacheLanes &= a) === 0 && (a = i.pooledCache, a != null && (i.pooledCache = null, gl(a)));
  }
  function Cu() {
    return uy(), fy(), dy(), py();
  }
  function py() {
    if (Tn !== 5) return !1;
    var i = ra, a = ep;
    ep = 0;
    var o = Xs(As), u = U.T, g = X.p;
    try {
      X.p = 32 > o ? 32 : o, U.T = null, o = np, np = null;
      var v = ra, w = As;
      if (Tn = 0, Qr = ra = null, As = 0, (Be & 6) !== 0) throw Error(s(331));
      var F = Be;
      if (Be |= 4, Zv(v.current), Yv(
        v,
        v.current,
        w,
        o
      ), Be = F, zl(0, !1), $t && typeof $t.onPostCommitFiberRoot == "function")
        try {
          $t.onPostCommitFiberRoot(Jt, v);
        } catch {
        }
      return !0;
    } finally {
      X.p = g, U.T = u, hy(i, a);
    }
  }
  function my(i, a, o) {
    a = wi(o, a), a = Ph(i.stateNode, a, 2), i = Js(i, a, 2), i !== null && (Mn(i, 2), Qi(i));
  }
  function Ve(i, a, o) {
    if (i.tag === 3)
      my(i, i, o);
    else
      for (; a !== null; ) {
        if (a.tag === 3) {
          my(
            a,
            i,
            o
          );
          break;
        } else if (a.tag === 1) {
          var u = a.stateNode;
          if (typeof a.type.getDerivedStateFromError == "function" || typeof u.componentDidCatch == "function" && (aa === null || !aa.has(u))) {
            i = wi(o, i), o = gv(2), u = Js(a, o, 2), u !== null && (_v(
              o,
              u,
              a,
              i
            ), Mn(u, 2), Qi(u));
            break;
          }
        }
        a = a.return;
      }
  }
  function rp(i, a, o) {
    var u = i.pingCache;
    if (u === null) {
      u = i.pingCache = new hA();
      var g = /* @__PURE__ */ new Set();
      u.set(a, g);
    } else
      g = u.get(a), g === void 0 && (g = /* @__PURE__ */ new Set(), u.set(a, g));
    g.has(o) || (Qh = !0, g.add(o), i = vA.bind(null, i, a, o), a.then(i, i));
  }
  function vA(i, a, o) {
    var u = i.pingCache;
    u !== null && u.delete(a), i.pingedLanes |= i.suspendedLanes & o, i.warmLanes &= ~o, Ke === i && (Ce & o) === o && (un === 4 || un === 3 && (Ce & 62914560) === Ce && 300 > St() - bu ? (Be & 2) === 0 && Jr(i, 0) : Jh |= o, $r === Ce && ($r = 0)), Qi(i);
  }
  function gy(i, a) {
    a === 0 && (a = fn()), i = Va(i, a), i !== null && (Mn(i, a), Qi(i));
  }
  function yA(i) {
    var a = i.memoizedState, o = 0;
    a !== null && (o = a.retryLane), gy(i, o);
  }
  function xA(i, a) {
    var o = 0;
    switch (i.tag) {
      case 31:
      case 13:
        var u = i.stateNode, g = i.memoizedState;
        g !== null && (o = g.retryLane);
        break;
      case 19:
        u = i.stateNode;
        break;
      case 22:
        u = i.stateNode._retryCache;
        break;
      default:
        throw Error(s(314));
    }
    u !== null && u.delete(a), gy(i, o);
  }
  function SA(i, a) {
    return jt(i, a);
  }
  var Ru = null, eo = null, op = !1, Du = !1, lp = !1, la = 0;
  function Qi(i) {
    i !== eo && i.next === null && (eo === null ? Ru = eo = i : eo = eo.next = i), Du = !0, op || (op = !0, MA());
  }
  function zl(i, a) {
    if (!lp && Du) {
      lp = !0;
      do
        for (var o = !1, u = Ru; u !== null; ) {
          if (i !== 0) {
            var g = u.pendingLanes;
            if (g === 0) var v = 0;
            else {
              var w = u.suspendedLanes, F = u.pingedLanes;
              v = (1 << 31 - re(42 | i) + 1) - 1, v &= g & ~(w & ~F), v = v & 201326741 ? v & 201326741 | 1 : v ? v | 2 : 0;
            }
            v !== 0 && (o = !0, xy(u, v));
          } else
            v = Ce, v = zt(
              u,
              u === Ke ? v : 0,
              u.cancelPendingCommit !== null || u.timeoutHandle !== -1
            ), (v & 3) === 0 || ce(u, v) || (o = !0, xy(u, v));
          u = u.next;
        }
      while (o);
      lp = !1;
    }
  }
  function bA() {
    _y();
  }
  function _y() {
    Du = op = !1;
    var i = 0;
    la !== 0 && UA() && (i = la);
    for (var a = St(), o = null, u = Ru; u !== null; ) {
      var g = u.next, v = vy(u, a);
      v === 0 ? (u.next = null, o === null ? Ru = g : o.next = g, g === null && (eo = o)) : (o = u, (i !== 0 || (v & 3) !== 0) && (Du = !0)), u = g;
    }
    Tn !== 0 && Tn !== 5 || zl(i), la !== 0 && (la = 0);
  }
  function vy(i, a) {
    for (var o = i.suspendedLanes, u = i.pingedLanes, g = i.expirationTimes, v = i.pendingLanes & -62914561; 0 < v; ) {
      var w = 31 - re(v), F = 1 << w, Q = g[w];
      Q === -1 ? ((F & o) === 0 || (F & u) !== 0) && (g[w] = $e(F, a)) : Q <= a && (i.expiredLanes |= F), v &= ~F;
    }
    if (a = Ke, o = Ce, o = zt(
      i,
      i === a ? o : 0,
      i.cancelPendingCommit !== null || i.timeoutHandle !== -1
    ), u = i.callbackNode, o === 0 || i === a && (He === 2 || He === 9) || i.cancelPendingCommit !== null)
      return u !== null && u !== null && j(u), i.callbackNode = null, i.callbackPriority = 0;
    if ((o & 3) === 0 || ce(i, o)) {
      if (a = o & -o, a === i.callbackPriority) return a;
      switch (u !== null && j(u), Xs(o)) {
        case 2:
        case 8:
          o = Zt;
          break;
        case 32:
          o = Ut;
          break;
        case 268435456:
          o = ve;
          break;
        default:
          o = Ut;
      }
      return u = yy.bind(null, i), o = jt(o, u), i.callbackPriority = a, i.callbackNode = o, a;
    }
    return u !== null && u !== null && j(u), i.callbackPriority = 2, i.callbackNode = null, 2;
  }
  function yy(i, a) {
    if (Tn !== 0 && Tn !== 5)
      return i.callbackNode = null, i.callbackPriority = 0, null;
    var o = i.callbackNode;
    if (Cu() && i.callbackNode !== o)
      return null;
    var u = Ce;
    return u = zt(
      i,
      i === Ke ? u : 0,
      i.cancelPendingCommit !== null || i.timeoutHandle !== -1
    ), u === 0 ? null : (ty(i, u, a), vy(i, St()), i.callbackNode != null && i.callbackNode === o ? yy.bind(null, i) : null);
  }
  function xy(i, a) {
    if (Cu()) return null;
    ty(i, a, !0);
  }
  function MA() {
    PA(function() {
      (Be & 6) !== 0 ? jt(
        bt,
        bA
      ) : _y();
    });
  }
  function cp() {
    if (la === 0) {
      var i = Hr;
      i === 0 && (i = Ot, Ot <<= 1, (Ot & 261888) === 0 && (Ot = 256)), la = i;
    }
    return la;
  }
  function Sy(i) {
    return i == null || typeof i == "symbol" || typeof i == "boolean" ? null : typeof i == "function" ? i : Bc("" + i);
  }
  function by(i, a) {
    var o = a.ownerDocument.createElement("input");
    return o.name = a.name, o.value = a.value, i.id && o.setAttribute("form", i.id), a.parentNode.insertBefore(o, a), i = new FormData(i), o.parentNode.removeChild(o), i;
  }
  function EA(i, a, o, u, g) {
    if (a === "submit" && o && o.stateNode === g) {
      var v = Sy(
        (g[En] || null).action
      ), w = u.submitter;
      w && (a = (a = w[En] || null) ? Sy(a.formAction) : w.getAttribute("formAction"), a !== null && (v = a, w = null));
      var F = new Gc(
        "action",
        "action",
        null,
        u,
        g
      );
      i.push({
        event: F,
        listeners: [
          {
            instance: null,
            listener: function() {
              if (u.defaultPrevented) {
                if (la !== 0) {
                  var Q = w ? by(g, w) : new FormData(g);
                  Rh(
                    o,
                    {
                      pending: !0,
                      data: Q,
                      method: g.method,
                      action: v
                    },
                    null,
                    Q
                  );
                }
              } else
                typeof v == "function" && (F.preventDefault(), Q = w ? by(g, w) : new FormData(g), Rh(
                  o,
                  {
                    pending: !0,
                    data: Q,
                    method: g.method,
                    action: v
                  },
                  v,
                  Q
                ));
            },
            currentTarget: g
          }
        ]
      });
    }
  }
  for (var up = 0; up < Yd.length; up++) {
    var fp = Yd[up], TA = fp.toLowerCase(), AA = fp[0].toUpperCase() + fp.slice(1);
    Bi(
      TA,
      "on" + AA
    );
  }
  Bi(J0, "onAnimationEnd"), Bi(t_, "onAnimationIteration"), Bi(e_, "onAnimationStart"), Bi("dblclick", "onDoubleClick"), Bi("focusin", "onFocus"), Bi("focusout", "onBlur"), Bi(GT, "onTransitionRun"), Bi(kT, "onTransitionStart"), Bi(XT, "onTransitionCancel"), Bi(n_, "onTransitionEnd"), kt("onMouseEnter", ["mouseout", "mouseover"]), kt("onMouseLeave", ["mouseout", "mouseover"]), kt("onPointerEnter", ["pointerout", "pointerover"]), kt("onPointerLeave", ["pointerout", "pointerover"]), Ft(
    "onChange",
    "change click focusin focusout input keydown keyup selectionchange".split(" ")
  ), Ft(
    "onSelect",
    "focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(
      " "
    )
  ), Ft("onBeforeInput", [
    "compositionend",
    "keypress",
    "textInput",
    "paste"
  ]), Ft(
    "onCompositionEnd",
    "compositionend focusout keydown keypress keyup mousedown".split(" ")
  ), Ft(
    "onCompositionStart",
    "compositionstart focusout keydown keypress keyup mousedown".split(" ")
  ), Ft(
    "onCompositionUpdate",
    "compositionupdate focusout keydown keypress keyup mousedown".split(" ")
  );
  var Il = "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(
    " "
  ), wA = new Set(
    "beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Il)
  );
  function My(i, a) {
    a = (a & 4) !== 0;
    for (var o = 0; o < i.length; o++) {
      var u = i[o], g = u.event;
      u = u.listeners;
      t: {
        var v = void 0;
        if (a)
          for (var w = u.length - 1; 0 <= w; w--) {
            var F = u[w], Q = F.instance, ut = F.currentTarget;
            if (F = F.listener, Q !== v && g.isPropagationStopped())
              break t;
            v = F, g.currentTarget = ut;
            try {
              v(g);
            } catch (xt) {
              Wc(xt);
            }
            g.currentTarget = null, v = Q;
          }
        else
          for (w = 0; w < u.length; w++) {
            if (F = u[w], Q = F.instance, ut = F.currentTarget, F = F.listener, Q !== v && g.isPropagationStopped())
              break t;
            v = F, g.currentTarget = ut;
            try {
              v(g);
            } catch (xt) {
              Wc(xt);
            }
            g.currentTarget = null, v = Q;
          }
      }
    }
  }
  function Te(i, a) {
    var o = a[Ws];
    o === void 0 && (o = a[Ws] = /* @__PURE__ */ new Set());
    var u = i + "__bubble";
    o.has(u) || (Ey(a, i, 2, !1), o.add(u));
  }
  function dp(i, a, o) {
    var u = 0;
    a && (u |= 4), Ey(
      o,
      i,
      u,
      a
    );
  }
  var Nu = "_reactListening" + Math.random().toString(36).slice(2);
  function hp(i) {
    if (!i[Nu]) {
      i[Nu] = !0, Rt.forEach(function(o) {
        o !== "selectionchange" && (wA.has(o) || dp(o, !1, i), dp(o, !0, i));
      });
      var a = i.nodeType === 9 ? i : i.ownerDocument;
      a === null || a[Nu] || (a[Nu] = !0, dp("selectionchange", !1, a));
    }
  }
  function Ey(i, a, o, u) {
    switch (Jy(a)) {
      case 2:
        var g = ew;
        break;
      case 8:
        g = nw;
        break;
      default:
        g = Cp;
    }
    o = g.bind(
      null,
      a,
      o,
      i
    ), g = void 0, !Ud || a !== "touchstart" && a !== "touchmove" && a !== "wheel" || (g = !0), u ? g !== void 0 ? i.addEventListener(a, o, {
      capture: !0,
      passive: g
    }) : i.addEventListener(a, o, !0) : g !== void 0 ? i.addEventListener(a, o, {
      passive: g
    }) : i.addEventListener(a, o, !1);
  }
  function pp(i, a, o, u, g) {
    var v = u;
    if ((a & 1) === 0 && (a & 2) === 0 && u !== null)
      t: for (; ; ) {
        if (u === null) return;
        var w = u.tag;
        if (w === 3 || w === 4) {
          var F = u.stateNode.containerInfo;
          if (F === g) break;
          if (w === 4)
            for (w = u.return; w !== null; ) {
              var Q = w.tag;
              if ((Q === 3 || Q === 4) && w.stateNode.containerInfo === g)
                return;
              w = w.return;
            }
          for (; F !== null; ) {
            if (w = G(F), w === null) return;
            if (Q = w.tag, Q === 5 || Q === 6 || Q === 26 || Q === 27) {
              u = v = w;
              continue t;
            }
            F = F.parentNode;
          }
        }
        u = u.return;
      }
    R0(function() {
      var ut = v, xt = Nd(o), Tt = [];
      t: {
        var pt = i_.get(i);
        if (pt !== void 0) {
          var vt = Gc, Kt = i;
          switch (i) {
            case "keypress":
              if (Hc(o) === 0) break t;
            case "keydown":
            case "keyup":
              vt = xT;
              break;
            case "focusin":
              Kt = "focus", vt = Id;
              break;
            case "focusout":
              Kt = "blur", vt = Id;
              break;
            case "beforeblur":
            case "afterblur":
              vt = Id;
              break;
            case "click":
              if (o.button === 2) break t;
            case "auxclick":
            case "dblclick":
            case "mousedown":
            case "mousemove":
            case "mouseup":
            case "mouseout":
            case "mouseover":
            case "contextmenu":
              vt = L0;
              break;
            case "drag":
            case "dragend":
            case "dragenter":
            case "dragexit":
            case "dragleave":
            case "dragover":
            case "dragstart":
            case "drop":
              vt = lT;
              break;
            case "touchcancel":
            case "touchend":
            case "touchmove":
            case "touchstart":
              vt = MT;
              break;
            case J0:
            case t_:
            case e_:
              vt = fT;
              break;
            case n_:
              vt = TT;
              break;
            case "scroll":
            case "scrollend":
              vt = rT;
              break;
            case "wheel":
              vt = wT;
              break;
            case "copy":
            case "cut":
            case "paste":
              vt = hT;
              break;
            case "gotpointercapture":
            case "lostpointercapture":
            case "pointercancel":
            case "pointerdown":
            case "pointermove":
            case "pointerout":
            case "pointerover":
            case "pointerup":
              vt = O0;
              break;
            case "toggle":
            case "beforetoggle":
              vt = RT;
          }
          var ae = (a & 4) !== 0, Xe = !ae && (i === "scroll" || i === "scrollend"), rt = ae ? pt !== null ? pt + "Capture" : null : pt;
          ae = [];
          for (var tt = ut, ct; tt !== null; ) {
            var Mt = tt;
            if (ct = Mt.stateNode, Mt = Mt.tag, Mt !== 5 && Mt !== 26 && Mt !== 27 || ct === null || rt === null || (Mt = al(tt, rt), Mt != null && ae.push(
              Bl(tt, Mt, ct)
            )), Xe) break;
            tt = tt.return;
          }
          0 < ae.length && (pt = new vt(
            pt,
            Kt,
            null,
            o,
            xt
          ), Tt.push({ event: pt, listeners: ae }));
        }
      }
      if ((a & 7) === 0) {
        t: {
          if (pt = i === "mouseover" || i === "pointerover", vt = i === "mouseout" || i === "pointerout", pt && o !== Dd && (Kt = o.relatedTarget || o.fromElement) && (G(Kt) || Kt[Ti]))
            break t;
          if ((vt || pt) && (pt = xt.window === xt ? xt : (pt = xt.ownerDocument) ? pt.defaultView || pt.parentWindow : window, vt ? (Kt = o.relatedTarget || o.toElement, vt = ut, Kt = Kt ? G(Kt) : null, Kt !== null && (Xe = l(Kt), ae = Kt.tag, Kt !== Xe || ae !== 5 && ae !== 27 && ae !== 6) && (Kt = null)) : (vt = null, Kt = ut), vt !== Kt)) {
            if (ae = L0, Mt = "onMouseLeave", rt = "onMouseEnter", tt = "mouse", (i === "pointerout" || i === "pointerover") && (ae = O0, Mt = "onPointerLeave", rt = "onPointerEnter", tt = "pointer"), Xe = vt == null ? pt : dt(vt), ct = Kt == null ? pt : dt(Kt), pt = new ae(
              Mt,
              tt + "leave",
              vt,
              o,
              xt
            ), pt.target = Xe, pt.relatedTarget = ct, Mt = null, G(xt) === ut && (ae = new ae(
              rt,
              tt + "enter",
              Kt,
              o,
              xt
            ), ae.target = ct, ae.relatedTarget = Xe, Mt = ae), Xe = Mt, vt && Kt)
              e: {
                for (ae = CA, rt = vt, tt = Kt, ct = 0, Mt = rt; Mt; Mt = ae(Mt))
                  ct++;
                Mt = 0;
                for (var ie = tt; ie; ie = ae(ie))
                  Mt++;
                for (; 0 < ct - Mt; )
                  rt = ae(rt), ct--;
                for (; 0 < Mt - ct; )
                  tt = ae(tt), Mt--;
                for (; ct--; ) {
                  if (rt === tt || tt !== null && rt === tt.alternate) {
                    ae = rt;
                    break e;
                  }
                  rt = ae(rt), tt = ae(tt);
                }
                ae = null;
              }
            else ae = null;
            vt !== null && Ty(
              Tt,
              pt,
              vt,
              ae,
              !1
            ), Kt !== null && Xe !== null && Ty(
              Tt,
              Xe,
              Kt,
              ae,
              !0
            );
          }
        }
        t: {
          if (pt = ut ? dt(ut) : window, vt = pt.nodeName && pt.nodeName.toLowerCase(), vt === "select" || vt === "input" && pt.type === "file")
            var Pe = G0;
          else if (H0(pt))
            if (k0)
              Pe = FT;
            else {
              Pe = IT;
              var Qt = zT;
            }
          else
            vt = pt.nodeName, !vt || vt.toLowerCase() !== "input" || pt.type !== "checkbox" && pt.type !== "radio" ? ut && Rd(ut.elementType) && (Pe = G0) : Pe = BT;
          if (Pe && (Pe = Pe(i, ut))) {
            V0(
              Tt,
              Pe,
              o,
              xt
            );
            break t;
          }
          Qt && Qt(i, pt, ut), i === "focusout" && ut && pt.type === "number" && ut.memoizedProps.value != null && Dn(pt, "number", pt.value);
        }
        switch (Qt = ut ? dt(ut) : window, i) {
          case "focusin":
            (H0(Qt) || Qt.contentEditable === "true") && (Lr = Qt, kd = ut, hl = null);
            break;
          case "focusout":
            hl = kd = Lr = null;
            break;
          case "mousedown":
            Xd = !0;
            break;
          case "contextmenu":
          case "mouseup":
          case "dragend":
            Xd = !1, $0(Tt, o, xt);
            break;
          case "selectionchange":
            if (VT) break;
          case "keydown":
          case "keyup":
            $0(Tt, o, xt);
        }
        var ge;
        if (Fd)
          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
          Nr ? B0(i, o) && (Re = "onCompositionEnd") : i === "keydown" && o.keyCode === 229 && (Re = "onCompositionStart");
        Re && (P0 && o.locale !== "ko" && (Nr || Re !== "onCompositionStart" ? Re === "onCompositionEnd" && Nr && (ge = D0()) : (Ys = xt, Od = "value" in Ys ? Ys.value : Ys.textContent, Nr = !0)), Qt = Lu(ut, Re), 0 < Qt.length && (Re = new U0(
          Re,
          i,
          null,
          o,
          xt
        ), Tt.push({ event: Re, listeners: Qt }), ge ? Re.data = ge : (ge = F0(o), ge !== null && (Re.data = ge)))), (ge = NT ? LT(i, o) : UT(i, o)) && (Re = Lu(ut, "onBeforeInput"), 0 < Re.length && (Qt = new U0(
          "onBeforeInput",
          "beforeinput",
          null,
          o,
          xt
        ), Tt.push({
          event: Qt,
          listeners: Re
        }), Qt.data = ge)), EA(
          Tt,
          i,
          ut,
          o,
          xt
        );
      }
      My(Tt, a);
    });
  }
  function Bl(i, a, o) {
    return {
      instance: i,
      listener: a,
      currentTarget: o
    };
  }
  function Lu(i, a) {
    for (var o = a + "Capture", u = []; i !== null; ) {
      var g = i, v = g.stateNode;
      if (g = g.tag, g !== 5 && g !== 26 && g !== 27 || v === null || (g = al(i, o), g != null && u.unshift(
        Bl(i, g, v)
      ), g = al(i, a), g != null && u.push(
        Bl(i, g, v)
      )), i.tag === 3) return u;
      i = i.return;
    }
    return [];
  }
  function CA(i) {
    if (i === null) return null;
    do
      i = i.return;
    while (i && i.tag !== 5 && i.tag !== 27);
    return i || null;
  }
  function Ty(i, a, o, u, g) {
    for (var v = a._reactName, w = []; o !== null && o !== u; ) {
      var F = o, Q = F.alternate, ut = F.stateNode;
      if (F = F.tag, Q !== null && Q === u) break;
      F !== 5 && F !== 26 && F !== 27 || ut === null || (Q = ut, g ? (ut = al(o, v), ut != null && w.unshift(
        Bl(o, ut, Q)
      )) : g || (ut = al(o, v), ut != null && w.push(
        Bl(o, ut, Q)
      ))), o = o.return;
    }
    w.length !== 0 && i.push({ event: a, listeners: w });
  }
  var RA = /\r\n?/g, DA = /\u0000|\uFFFD/g;
  function Ay(i) {
    return (typeof i == "string" ? i : "" + i).replace(RA, `
`).replace(DA, "");
  }
  function wy(i, a) {
    return a = Ay(a), Ay(i) === a;
  }
  function ke(i, a, o, u, g, v) {
    switch (o) {
      case "children":
        typeof u == "string" ? a === "body" || a === "textarea" && u === "" || Jn(i, u) : (typeof u == "number" || typeof u == "bigint") && a !== "body" && Jn(i, "" + u);
        break;
      case "className":
        Ze(i, "class", u);
        break;
      case "tabIndex":
        Ze(i, "tabindex", u);
        break;
      case "dir":
      case "role":
      case "viewBox":
      case "width":
      case "height":
        Ze(i, o, u);
        break;
      case "style":
        w0(i, u, v);
        break;
      case "data":
        if (a !== "object") {
          Ze(i, "data", u);
          break;
        }
      case "src":
      case "href":
        if (u === "" && (a !== "a" || o !== "href")) {
          i.removeAttribute(o);
          break;
        }
        if (u == null || typeof u == "function" || typeof u == "symbol" || typeof u == "boolean") {
          i.removeAttribute(o);
          break;
        }
        u = Bc("" + u), i.setAttribute(o, u);
        break;
      case "action":
      case "formAction":
        if (typeof u == "function") {
          i.setAttribute(
            o,
            "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 v == "function" && (o === "formAction" ? (a !== "input" && ke(i, a, "name", g.name, g, null), ke(
            i,
            a,
            "formEncType",
            g.formEncType,
            g,
            null
          ), ke(
            i,
            a,
            "formMethod",
            g.formMethod,
            g,
            null
          ), ke(
            i,
            a,
            "formTarget",
            g.formTarget,
            g,
            null
          )) : (ke(i, a, "encType", g.encType, g, null), ke(i, a, "method", g.method, g, null), ke(i, a, "target", g.target, g, null)));
        if (u == null || typeof u == "symbol" || typeof u == "boolean") {
          i.removeAttribute(o);
          break;
        }
        u = Bc("" + u), i.setAttribute(o, u);
        break;
      case "onClick":
        u != null && (i.onclick = fs);
        break;
      case "onScroll":
        u != null && Te("scroll", i);
        break;
      case "onScrollEnd":
        u != null && Te("scrollend", i);
        break;
      case "dangerouslySetInnerHTML":
        if (u != null) {
          if (typeof u != "object" || !("__html" in u))
            throw Error(s(61));
          if (o = u.__html, o != null) {
            if (g.children != null) throw Error(s(60));
            i.innerHTML = o;
          }
        }
        break;
      case "multiple":
        i.multiple = u && typeof u != "function" && typeof u != "symbol";
        break;
      case "muted":
        i.muted = u && typeof u != "function" && typeof u != "symbol";
        break;
      case "suppressContentEditableWarning":
      case "suppressHydrationWarning":
      case "defaultValue":
      case "defaultChecked":
      case "innerHTML":
      case "ref":
        break;
      case "autoFocus":
        break;
      case "xlinkHref":
        if (u == null || typeof u == "function" || typeof u == "boolean" || typeof u == "symbol") {
          i.removeAttribute("xlink:href");
          break;
        }
        o = Bc("" + u), i.setAttributeNS(
          "http://www.w3.org/1999/xlink",
          "xlink:href",
          o
        );
        break;
      case "contentEditable":
      case "spellCheck":
      case "draggable":
      case "value":
      case "autoReverse":
      case "externalResourcesRequired":
      case "focusable":
      case "preserveAlpha":
        u != null && typeof u != "function" && typeof u != "symbol" ? i.setAttribute(o, "" + u) : i.removeAttribute(o);
        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":
        u && typeof u != "function" && typeof u != "symbol" ? i.setAttribute(o, "") : i.removeAttribute(o);
        break;
      case "capture":
      case "download":
        u === !0 ? i.setAttribute(o, "") : u !== !1 && u != null && typeof u != "function" && typeof u != "symbol" ? i.setAttribute(o, u) : i.removeAttribute(o);
        break;
      case "cols":
      case "rows":
      case "size":
      case "span":
        u != null && typeof u != "function" && typeof u != "symbol" && !isNaN(u) && 1 <= u ? i.setAttribute(o, u) : i.removeAttribute(o);
        break;
      case "rowSpan":
      case "start":
        u == null || typeof u == "function" || typeof u == "symbol" || isNaN(u) ? i.removeAttribute(o) : i.setAttribute(o, u);
        break;
      case "popover":
        Te("beforetoggle", i), Te("toggle", i), Me(i, "popover", u);
        break;
      case "xlinkActuate":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:actuate",
          u
        );
        break;
      case "xlinkArcrole":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:arcrole",
          u
        );
        break;
      case "xlinkRole":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:role",
          u
        );
        break;
      case "xlinkShow":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:show",
          u
        );
        break;
      case "xlinkTitle":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:title",
          u
        );
        break;
      case "xlinkType":
        Le(
          i,
          "http://www.w3.org/1999/xlink",
          "xlink:type",
          u
        );
        break;
      case "xmlBase":
        Le(
          i,
          "http://www.w3.org/XML/1998/namespace",
          "xml:base",
          u
        );
        break;
      case "xmlLang":
        Le(
          i,
          "http://www.w3.org/XML/1998/namespace",
          "xml:lang",
          u
        );
        break;
      case "xmlSpace":
        Le(
          i,
          "http://www.w3.org/XML/1998/namespace",
          "xml:space",
          u
        );
        break;
      case "is":
        Me(i, "is", u);
        break;
      case "innerText":
      case "textContent":
        break;
      default:
        (!(2 < o.length) || o[0] !== "o" && o[0] !== "O" || o[1] !== "n" && o[1] !== "N") && (o = sT.get(o) || o, Me(i, o, u));
    }
  }
  function mp(i, a, o, u, g, v) {
    switch (o) {
      case "style":
        w0(i, u, v);
        break;
      case "dangerouslySetInnerHTML":
        if (u != null) {
          if (typeof u != "object" || !("__html" in u))
            throw Error(s(61));
          if (o = u.__html, o != null) {
            if (g.children != null) throw Error(s(60));
            i.innerHTML = o;
          }
        }
        break;
      case "children":
        typeof u == "string" ? Jn(i, u) : (typeof u == "number" || typeof u == "bigint") && Jn(i, "" + u);
        break;
      case "onScroll":
        u != null && Te("scroll", i);
        break;
      case "onScrollEnd":
        u != null && Te("scrollend", i);
        break;
      case "onClick":
        u != null && (i.onclick = fs);
        break;
      case "suppressContentEditableWarning":
      case "suppressHydrationWarning":
      case "innerHTML":
      case "ref":
        break;
      case "innerText":
      case "textContent":
        break;
      default:
        if (!It.hasOwnProperty(o))
          t: {
            if (o[0] === "o" && o[1] === "n" && (g = o.endsWith("Capture"), a = o.slice(2, g ? o.length - 7 : void 0), v = i[En] || null, v = v != null ? v[o] : null, typeof v == "function" && i.removeEventListener(a, v, g), typeof u == "function")) {
              typeof v != "function" && v !== null && (o in i ? i[o] = null : i.hasAttribute(o) && i.removeAttribute(o)), i.addEventListener(a, u, g);
              break t;
            }
            o in i ? i[o] = u : u === !0 ? i.setAttribute(o, "") : Me(i, o, u);
          }
    }
  }
  function Hn(i, a, o) {
    switch (a) {
      case "div":
      case "span":
      case "svg":
      case "path":
      case "a":
      case "g":
      case "p":
      case "li":
        break;
      case "img":
        Te("error", i), Te("load", i);
        var u = !1, g = !1, v;
        for (v in o)
          if (o.hasOwnProperty(v)) {
            var w = o[v];
            if (w != null)
              switch (v) {
                case "src":
                  u = !0;
                  break;
                case "srcSet":
                  g = !0;
                  break;
                case "children":
                case "dangerouslySetInnerHTML":
                  throw Error(s(137, a));
                default:
                  ke(i, a, v, w, o, null);
              }
          }
        g && ke(i, a, "srcSet", o.srcSet, o, null), u && ke(i, a, "src", o.src, o, null);
        return;
      case "input":
        Te("invalid", i);
        var F = v = w = g = null, Q = null, ut = null;
        for (u in o)
          if (o.hasOwnProperty(u)) {
            var xt = o[u];
            if (xt != null)
              switch (u) {
                case "name":
                  g = xt;
                  break;
                case "type":
                  w = xt;
                  break;
                case "checked":
                  Q = xt;
                  break;
                case "defaultChecked":
                  ut = xt;
                  break;
                case "value":
                  v = xt;
                  break;
                case "defaultValue":
                  F = xt;
                  break;
                case "children":
                case "dangerouslySetInnerHTML":
                  if (xt != null)
                    throw Error(s(137, a));
                  break;
                default:
                  ke(i, a, u, xt, o, null);
              }
          }
        Pn(
          i,
          v,
          F,
          Q,
          ut,
          w,
          g,
          !1
        );
        return;
      case "select":
        Te("invalid", i), u = w = v = null;
        for (g in o)
          if (o.hasOwnProperty(g) && (F = o[g], F != null))
            switch (g) {
              case "value":
                v = F;
                break;
              case "defaultValue":
                w = F;
                break;
              case "multiple":
                u = F;
              default:
                ke(i, a, g, F, o, null);
            }
        a = v, o = w, i.multiple = !!u, a != null ? Qe(i, !!u, a, !1) : o != null && Qe(i, !!u, o, !0);
        return;
      case "textarea":
        Te("invalid", i), v = g = u = null;
        for (w in o)
          if (o.hasOwnProperty(w) && (F = o[w], F != null))
            switch (w) {
              case "value":
                u = F;
                break;
              case "defaultValue":
                g = F;
                break;
              case "children":
                v = F;
                break;
              case "dangerouslySetInnerHTML":
                if (F != null) throw Error(s(91));
                break;
              default:
                ke(i, a, w, F, o, null);
            }
        Cr(i, u, g, v);
        return;
      case "option":
        for (Q in o)
          if (o.hasOwnProperty(Q) && (u = o[Q], u != null))
            switch (Q) {
              case "selected":
                i.selected = u && typeof u != "function" && typeof u != "symbol";
                break;
              default:
                ke(i, a, Q, u, o, null);
            }
        return;
      case "dialog":
        Te("beforetoggle", i), Te("toggle", i), Te("cancel", i), Te("close", i);
        break;
      case "iframe":
      case "object":
        Te("load", i);
        break;
      case "video":
      case "audio":
        for (u = 0; u < Il.length; u++)
          Te(Il[u], i);
        break;
      case "image":
        Te("error", i), Te("load", i);
        break;
      case "details":
        Te("toggle", i);
        break;
      case "embed":
      case "source":
      case "link":
        Te("error", i), Te("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 (ut in o)
          if (o.hasOwnProperty(ut) && (u = o[ut], u != null))
            switch (ut) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(s(137, a));
              default:
                ke(i, a, ut, u, o, null);
            }
        return;
      default:
        if (Rd(a)) {
          for (xt in o)
            o.hasOwnProperty(xt) && (u = o[xt], u !== void 0 && mp(
              i,
              a,
              xt,
              u,
              o,
              void 0
            ));
          return;
        }
    }
    for (F in o)
      o.hasOwnProperty(F) && (u = o[F], u != null && ke(i, a, F, u, o, null));
  }
  function NA(i, a, o, u) {
    switch (a) {
      case "div":
      case "span":
      case "svg":
      case "path":
      case "a":
      case "g":
      case "p":
      case "li":
        break;
      case "input":
        var g = null, v = null, w = null, F = null, Q = null, ut = null, xt = null;
        for (vt in o) {
          var Tt = o[vt];
          if (o.hasOwnProperty(vt) && Tt != null)
            switch (vt) {
              case "checked":
                break;
              case "value":
                break;
              case "defaultValue":
                Q = Tt;
              default:
                u.hasOwnProperty(vt) || ke(i, a, vt, null, u, Tt);
            }
        }
        for (var pt in u) {
          var vt = u[pt];
          if (Tt = o[pt], u.hasOwnProperty(pt) && (vt != null || Tt != null))
            switch (pt) {
              case "type":
                v = vt;
                break;
              case "name":
                g = vt;
                break;
              case "checked":
                ut = vt;
                break;
              case "defaultChecked":
                xt = vt;
                break;
              case "value":
                w = vt;
                break;
              case "defaultValue":
                F = vt;
                break;
              case "children":
              case "dangerouslySetInnerHTML":
                if (vt != null)
                  throw Error(s(137, a));
                break;
              default:
                vt !== Tt && ke(
                  i,
                  a,
                  pt,
                  vt,
                  u,
                  Tt
                );
            }
        }
        Oe(
          i,
          w,
          F,
          Q,
          ut,
          xt,
          v,
          g
        );
        return;
      case "select":
        vt = w = F = pt = null;
        for (v in o)
          if (Q = o[v], o.hasOwnProperty(v) && Q != null)
            switch (v) {
              case "value":
                break;
              case "multiple":
                vt = Q;
              default:
                u.hasOwnProperty(v) || ke(
                  i,
                  a,
                  v,
                  null,
                  u,
                  Q
                );
            }
        for (g in u)
          if (v = u[g], Q = o[g], u.hasOwnProperty(g) && (v != null || Q != null))
            switch (g) {
              case "value":
                pt = v;
                break;
              case "defaultValue":
                F = v;
                break;
              case "multiple":
                w = v;
              default:
                v !== Q && ke(
                  i,
                  a,
                  g,
                  v,
                  u,
                  Q
                );
            }
        a = F, o = w, u = vt, pt != null ? Qe(i, !!o, pt, !1) : !!u != !!o && (a != null ? Qe(i, !!o, a, !0) : Qe(i, !!o, o ? [] : "", !1));
        return;
      case "textarea":
        vt = pt = null;
        for (F in o)
          if (g = o[F], o.hasOwnProperty(F) && g != null && !u.hasOwnProperty(F))
            switch (F) {
              case "value":
                break;
              case "children":
                break;
              default:
                ke(i, a, F, null, u, g);
            }
        for (w in u)
          if (g = u[w], v = o[w], u.hasOwnProperty(w) && (g != null || v != null))
            switch (w) {
              case "value":
                pt = g;
                break;
              case "defaultValue":
                vt = g;
                break;
              case "children":
                break;
              case "dangerouslySetInnerHTML":
                if (g != null) throw Error(s(91));
                break;
              default:
                g !== v && ke(i, a, w, g, u, v);
            }
        zn(i, pt, vt);
        return;
      case "option":
        for (var Kt in o)
          if (pt = o[Kt], o.hasOwnProperty(Kt) && pt != null && !u.hasOwnProperty(Kt))
            switch (Kt) {
              case "selected":
                i.selected = !1;
                break;
              default:
                ke(
                  i,
                  a,
                  Kt,
                  null,
                  u,
                  pt
                );
            }
        for (Q in u)
          if (pt = u[Q], vt = o[Q], u.hasOwnProperty(Q) && pt !== vt && (pt != null || vt != null))
            switch (Q) {
              case "selected":
                i.selected = pt && typeof pt != "function" && typeof pt != "symbol";
                break;
              default:
                ke(
                  i,
                  a,
                  Q,
                  pt,
                  u,
                  vt
                );
            }
        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 o)
          pt = o[ae], o.hasOwnProperty(ae) && pt != null && !u.hasOwnProperty(ae) && ke(i, a, ae, null, u, pt);
        for (ut in u)
          if (pt = u[ut], vt = o[ut], u.hasOwnProperty(ut) && pt !== vt && (pt != null || vt != null))
            switch (ut) {
              case "children":
              case "dangerouslySetInnerHTML":
                if (pt != null)
                  throw Error(s(137, a));
                break;
              default:
                ke(
                  i,
                  a,
                  ut,
                  pt,
                  u,
                  vt
                );
            }
        return;
      default:
        if (Rd(a)) {
          for (var Xe in o)
            pt = o[Xe], o.hasOwnProperty(Xe) && pt !== void 0 && !u.hasOwnProperty(Xe) && mp(
              i,
              a,
              Xe,
              void 0,
              u,
              pt
            );
          for (xt in u)
            pt = u[xt], vt = o[xt], !u.hasOwnProperty(xt) || pt === vt || pt === void 0 && vt === void 0 || mp(
              i,
              a,
              xt,
              pt,
              u,
              vt
            );
          return;
        }
    }
    for (var rt in o)
      pt = o[rt], o.hasOwnProperty(rt) && pt != null && !u.hasOwnProperty(rt) && ke(i, a, rt, null, u, pt);
    for (Tt in u)
      pt = u[Tt], vt = o[Tt], !u.hasOwnProperty(Tt) || pt === vt || pt == null && vt == null || ke(i, a, Tt, pt, u, vt);
  }
  function Cy(i) {
    switch (i) {
      case "css":
      case "script":
      case "font":
      case "img":
      case "image":
      case "input":
      case "link":
        return !0;
      default:
        return !1;
    }
  }
  function LA() {
    if (typeof performance.getEntriesByType == "function") {
      for (var i = 0, a = 0, o = performance.getEntriesByType("resource"), u = 0; u < o.length; u++) {
        var g = o[u], v = g.transferSize, w = g.initiatorType, F = g.duration;
        if (v && F && Cy(w)) {
          for (w = 0, F = g.responseEnd, u += 1; u < o.length; u++) {
            var Q = o[u], ut = Q.startTime;
            if (ut > F) break;
            var xt = Q.transferSize, Tt = Q.initiatorType;
            xt && Cy(Tt) && (Q = Q.responseEnd, w += xt * (Q < F ? 1 : (F - ut) / (Q - ut)));
          }
          if (--u, a += 8 * (v + w) / (g.duration / 1e3), i++, 10 < i) break;
        }
      }
      if (0 < i) return a / i / 1e6;
    }
    return navigator.connection && (i = navigator.connection.downlink, typeof i == "number") ? i : 5;
  }
  var gp = null, _p = null;
  function Uu(i) {
    return i.nodeType === 9 ? i : i.ownerDocument;
  }
  function Ry(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 Dy(i, a) {
    if (i === 0)
      switch (a) {
        case "svg":
          return 1;
        case "math":
          return 2;
        default:
          return 0;
      }
    return i === 1 && a === "foreignObject" ? 0 : i;
  }
  function vp(i, a) {
    return i === "textarea" || i === "noscript" || typeof a.children == "string" || typeof a.children == "number" || typeof a.children == "bigint" || typeof a.dangerouslySetInnerHTML == "object" && a.dangerouslySetInnerHTML !== null && a.dangerouslySetInnerHTML.__html != null;
  }
  var yp = null;
  function UA() {
    var i = window.event;
    return i && i.type === "popstate" ? i === yp ? !1 : (yp = i, !0) : (yp = null, !1);
  }
  var Ny = typeof setTimeout == "function" ? setTimeout : void 0, OA = typeof clearTimeout == "function" ? clearTimeout : void 0, Ly = typeof Promise == "function" ? Promise : void 0, PA = typeof queueMicrotask == "function" ? queueMicrotask : typeof Ly < "u" ? function(i) {
    return Ly.resolve(null).then(i).catch(zA);
  } : Ny;
  function zA(i) {
    setTimeout(function() {
      throw i;
    });
  }
  function ca(i) {
    return i === "head";
  }
  function Uy(i, a) {
    var o = a, u = 0;
    do {
      var g = o.nextSibling;
      if (i.removeChild(o), g && g.nodeType === 8)
        if (o = g.data, o === "/$" || o === "/&") {
          if (u === 0) {
            i.removeChild(g), ao(a);
            return;
          }
          u--;
        } else if (o === "$" || o === "$?" || o === "$~" || o === "$!" || o === "&")
          u++;
        else if (o === "html")
          Fl(i.ownerDocument.documentElement);
        else if (o === "head") {
          o = i.ownerDocument.head, Fl(o);
          for (var v = o.firstChild; v; ) {
            var w = v.nextSibling, F = v.nodeName;
            v[us] || F === "SCRIPT" || F === "STYLE" || F === "LINK" && v.rel.toLowerCase() === "stylesheet" || o.removeChild(v), v = w;
          }
        } else
          o === "body" && Fl(i.ownerDocument.body);
      o = g;
    } while (o);
    ao(a);
  }
  function Oy(i, a) {
    var o = i;
    i = 0;
    do {
      var u = o.nextSibling;
      if (o.nodeType === 1 ? a ? (o._stashedDisplay = o.style.display, o.style.display = "none") : (o.style.display = o._stashedDisplay || "", o.getAttribute("style") === "" && o.removeAttribute("style")) : o.nodeType === 3 && (a ? (o._stashedText = o.nodeValue, o.nodeValue = "") : o.nodeValue = o._stashedText || ""), u && u.nodeType === 8)
        if (o = u.data, o === "/$") {
          if (i === 0) break;
          i--;
        } else
          o !== "$" && o !== "$?" && o !== "$~" && o !== "$!" || i++;
      o = u;
    } while (o);
  }
  function xp(i) {
    var a = i.firstChild;
    for (a && a.nodeType === 10 && (a = a.nextSibling); a; ) {
      var o = a;
      switch (a = a.nextSibling, o.nodeName) {
        case "HTML":
        case "HEAD":
        case "BODY":
          xp(o), Ia(o);
          continue;
        case "SCRIPT":
        case "STYLE":
          continue;
        case "LINK":
          if (o.rel.toLowerCase() === "stylesheet") continue;
      }
      i.removeChild(o);
    }
  }
  function IA(i, a, o, u) {
    for (; i.nodeType === 1; ) {
      var g = o;
      if (i.nodeName.toLowerCase() !== a.toLowerCase()) {
        if (!u && (i.nodeName !== "INPUT" || i.type !== "hidden"))
          break;
      } else if (u) {
        if (!i[us])
          switch (a) {
            case "meta":
              if (!i.hasAttribute("itemprop")) break;
              return i;
            case "link":
              if (v = i.getAttribute("rel"), v === "stylesheet" && i.hasAttribute("data-precedence"))
                break;
              if (v !== g.rel || i.getAttribute("href") !== (g.href == null || g.href === "" ? null : g.href) || i.getAttribute("crossorigin") !== (g.crossOrigin == null ? null : g.crossOrigin) || i.getAttribute("title") !== (g.title == null ? null : g.title))
                break;
              return i;
            case "style":
              if (i.hasAttribute("data-precedence")) break;
              return i;
            case "script":
              if (v = i.getAttribute("src"), (v !== (g.src == null ? null : g.src) || i.getAttribute("type") !== (g.type == null ? null : g.type) || i.getAttribute("crossorigin") !== (g.crossOrigin == null ? null : g.crossOrigin)) && v && i.hasAttribute("async") && !i.hasAttribute("itemprop"))
                break;
              return i;
            default:
              return i;
          }
      } else if (a === "input" && i.type === "hidden") {
        var v = g.name == null ? null : "" + g.name;
        if (g.type === "hidden" && i.getAttribute("name") === v)
          return i;
      } else return i;
      if (i = Li(i.nextSibling), i === null) break;
    }
    return null;
  }
  function BA(i, a, o) {
    if (a === "") return null;
    for (; i.nodeType !== 3; )
      if ((i.nodeType !== 1 || i.nodeName !== "INPUT" || i.type !== "hidden") && !o || (i = Li(i.nextSibling), i === null)) return null;
    return i;
  }
  function Py(i, a) {
    for (; i.nodeType !== 8; )
      if ((i.nodeType !== 1 || i.nodeName !== "INPUT" || i.type !== "hidden") && !a || (i = Li(i.nextSibling), i === null)) return null;
    return i;
  }
  function Sp(i) {
    return i.data === "$?" || i.data === "$~";
  }
  function bp(i) {
    return i.data === "$!" || i.data === "$?" && i.ownerDocument.readyState !== "loading";
  }
  function FA(i, a) {
    var o = i.ownerDocument;
    if (i.data === "$~") i._reactRetry = a;
    else if (i.data !== "$?" || o.readyState !== "loading")
      a();
    else {
      var u = function() {
        a(), o.removeEventListener("DOMContentLoaded", u);
      };
      o.addEventListener("DOMContentLoaded", u), i._reactRetry = u;
    }
  }
  function Li(i) {
    for (; i != null; i = i.nextSibling) {
      var a = i.nodeType;
      if (a === 1 || a === 3) break;
      if (a === 8) {
        if (a = i.data, a === "$" || a === "$!" || a === "$?" || a === "$~" || a === "&" || a === "F!" || a === "F")
          break;
        if (a === "/$" || a === "/&") return null;
      }
    }
    return i;
  }
  var Mp = null;
  function zy(i) {
    i = i.nextSibling;
    for (var a = 0; i; ) {
      if (i.nodeType === 8) {
        var o = i.data;
        if (o === "/$" || o === "/&") {
          if (a === 0)
            return Li(i.nextSibling);
          a--;
        } else
          o !== "$" && o !== "$!" && o !== "$?" && o !== "$~" && o !== "&" || a++;
      }
      i = i.nextSibling;
    }
    return null;
  }
  function Iy(i) {
    i = i.previousSibling;
    for (var a = 0; i; ) {
      if (i.nodeType === 8) {
        var o = i.data;
        if (o === "$" || o === "$!" || o === "$?" || o === "$~" || o === "&") {
          if (a === 0) return i;
          a--;
        } else o !== "/$" && o !== "/&" || a++;
      }
      i = i.previousSibling;
    }
    return null;
  }
  function By(i, a, o) {
    switch (a = Uu(o), i) {
      case "html":
        if (i = a.documentElement, !i) throw Error(s(452));
        return i;
      case "head":
        if (i = a.head, !i) throw Error(s(453));
        return i;
      case "body":
        if (i = a.body, !i) throw Error(s(454));
        return i;
      default:
        throw Error(s(451));
    }
  }
  function Fl(i) {
    for (var a = i.attributes; a.length; )
      i.removeAttributeNode(a[0]);
    Ia(i);
  }
  var Ui = /* @__PURE__ */ new Map(), Fy = /* @__PURE__ */ new Set();
  function Ou(i) {
    return typeof i.getRootNode == "function" ? i.getRootNode() : i.nodeType === 9 ? i : i.ownerDocument;
  }
  var ws = X.d;
  X.d = {
    f: HA,
    r: VA,
    D: GA,
    C: kA,
    L: XA,
    m: WA,
    X: jA,
    S: YA,
    M: qA
  };
  function HA() {
    var i = ws.f(), a = Tu();
    return i || a;
  }
  function VA(i) {
    var a = it(i);
    a !== null && a.tag === 5 && a.type === "form" ? nv(a) : ws.r(i);
  }
  var no = typeof document > "u" ? null : document;
  function Hy(i, a, o) {
    var u = no;
    if (u && typeof a == "string" && a) {
      var g = mn(a);
      g = 'link[rel="' + i + '"][href="' + g + '"]', typeof o == "string" && (g += '[crossorigin="' + o + '"]'), Fy.has(g) || (Fy.add(g), i = { rel: i, crossOrigin: o, href: a }, u.querySelector(g) === null && (a = u.createElement("link"), Hn(a, "link", i), et(a), u.head.appendChild(a)));
    }
  }
  function GA(i) {
    ws.D(i), Hy("dns-prefetch", i, null);
  }
  function kA(i, a) {
    ws.C(i, a), Hy("preconnect", i, a);
  }
  function XA(i, a, o) {
    ws.L(i, a, o);
    var u = no;
    if (u && i && a) {
      var g = 'link[rel="preload"][as="' + mn(a) + '"]';
      a === "image" && o && o.imageSrcSet ? (g += '[imagesrcset="' + mn(
        o.imageSrcSet
      ) + '"]', typeof o.imageSizes == "string" && (g += '[imagesizes="' + mn(
        o.imageSizes
      ) + '"]')) : g += '[href="' + mn(i) + '"]';
      var v = g;
      switch (a) {
        case "style":
          v = io(i);
          break;
        case "script":
          v = so(i);
      }
      Ui.has(v) || (i = p(
        {
          rel: "preload",
          href: a === "image" && o && o.imageSrcSet ? void 0 : i,
          as: a
        },
        o
      ), Ui.set(v, i), u.querySelector(g) !== null || a === "style" && u.querySelector(Hl(v)) || a === "script" && u.querySelector(Vl(v)) || (a = u.createElement("link"), Hn(a, "link", i), et(a), u.head.appendChild(a)));
    }
  }
  function WA(i, a) {
    ws.m(i, a);
    var o = no;
    if (o && i) {
      var u = a && typeof a.as == "string" ? a.as : "script", g = 'link[rel="modulepreload"][as="' + mn(u) + '"][href="' + mn(i) + '"]', v = g;
      switch (u) {
        case "audioworklet":
        case "paintworklet":
        case "serviceworker":
        case "sharedworker":
        case "worker":
        case "script":
          v = so(i);
      }
      if (!Ui.has(v) && (i = p({ rel: "modulepreload", href: i }, a), Ui.set(v, i), o.querySelector(g) === null)) {
        switch (u) {
          case "audioworklet":
          case "paintworklet":
          case "serviceworker":
          case "sharedworker":
          case "worker":
          case "script":
            if (o.querySelector(Vl(v)))
              return;
        }
        u = o.createElement("link"), Hn(u, "link", i), et(u), o.head.appendChild(u);
      }
    }
  }
  function YA(i, a, o) {
    ws.S(i, a, o);
    var u = no;
    if (u && i) {
      var g = mt(u).hoistableStyles, v = io(i);
      a = a || "default";
      var w = g.get(v);
      if (!w) {
        var F = { loading: 0, preload: null };
        if (w = u.querySelector(
          Hl(v)
        ))
          F.loading = 5;
        else {
          i = p(
            { rel: "stylesheet", href: i, "data-precedence": a },
            o
          ), (o = Ui.get(v)) && Ep(i, o);
          var Q = w = u.createElement("link");
          et(Q), Hn(Q, "link", i), Q._p = new Promise(function(ut, xt) {
            Q.onload = ut, Q.onerror = xt;
          }), Q.addEventListener("load", function() {
            F.loading |= 1;
          }), Q.addEventListener("error", function() {
            F.loading |= 2;
          }), F.loading |= 4, Pu(w, a, u);
        }
        w = {
          type: "stylesheet",
          instance: w,
          count: 1,
          state: F
        }, g.set(v, w);
      }
    }
  }
  function jA(i, a) {
    ws.X(i, a);
    var o = no;
    if (o && i) {
      var u = mt(o).hoistableScripts, g = so(i), v = u.get(g);
      v || (v = o.querySelector(Vl(g)), v || (i = p({ src: i, async: !0 }, a), (a = Ui.get(g)) && Tp(i, a), v = o.createElement("script"), et(v), Hn(v, "link", i), o.head.appendChild(v)), v = {
        type: "script",
        instance: v,
        count: 1,
        state: null
      }, u.set(g, v));
    }
  }
  function qA(i, a) {
    ws.M(i, a);
    var o = no;
    if (o && i) {
      var u = mt(o).hoistableScripts, g = so(i), v = u.get(g);
      v || (v = o.querySelector(Vl(g)), v || (i = p({ src: i, async: !0, type: "module" }, a), (a = Ui.get(g)) && Tp(i, a), v = o.createElement("script"), et(v), Hn(v, "link", i), o.head.appendChild(v)), v = {
        type: "script",
        instance: v,
        count: 1,
        state: null
      }, u.set(g, v));
    }
  }
  function Vy(i, a, o, u) {
    var g = (g = gt.current) ? Ou(g) : null;
    if (!g) throw Error(s(446));
    switch (i) {
      case "meta":
      case "title":
        return null;
      case "style":
        return typeof o.precedence == "string" && typeof o.href == "string" ? (a = io(o.href), o = mt(
          g
        ).hoistableStyles, u = o.get(a), u || (u = {
          type: "style",
          instance: null,
          count: 0,
          state: null
        }, o.set(a, u)), u) : { type: "void", instance: null, count: 0, state: null };
      case "link":
        if (o.rel === "stylesheet" && typeof o.href == "string" && typeof o.precedence == "string") {
          i = io(o.href);
          var v = mt(
            g
          ).hoistableStyles, w = v.get(i);
          if (w || (g = g.ownerDocument || g, w = {
            type: "stylesheet",
            instance: null,
            count: 0,
            state: { loading: 0, preload: null }
          }, v.set(i, w), (v = g.querySelector(
            Hl(i)
          )) && !v._p && (w.instance = v, w.state.loading = 5), Ui.has(i) || (o = {
            rel: "preload",
            as: "style",
            href: o.href,
            crossOrigin: o.crossOrigin,
            integrity: o.integrity,
            media: o.media,
            hrefLang: o.hrefLang,
            referrerPolicy: o.referrerPolicy
          }, Ui.set(i, o), v || ZA(
            g,
            i,
            o,
            w.state
          ))), a && u === null)
            throw Error(s(528, ""));
          return w;
        }
        if (a && u !== null)
          throw Error(s(529, ""));
        return null;
      case "script":
        return a = o.async, o = o.src, typeof o == "string" && a && typeof a != "function" && typeof a != "symbol" ? (a = so(o), o = mt(
          g
        ).hoistableScripts, u = o.get(a), u || (u = {
          type: "script",
          instance: null,
          count: 0,
          state: null
        }, o.set(a, u)), u) : { type: "void", instance: null, count: 0, state: null };
      default:
        throw Error(s(444, i));
    }
  }
  function io(i) {
    return 'href="' + mn(i) + '"';
  }
  function Hl(i) {
    return 'link[rel="stylesheet"][' + i + "]";
  }
  function Gy(i) {
    return p({}, i, {
      "data-precedence": i.precedence,
      precedence: null
    });
  }
  function ZA(i, a, o, u) {
    i.querySelector('link[rel="preload"][as="style"][' + a + "]") ? u.loading = 1 : (a = i.createElement("link"), u.preload = a, a.addEventListener("load", function() {
      return u.loading |= 1;
    }), a.addEventListener("error", function() {
      return u.loading |= 2;
    }), Hn(a, "link", o), et(a), i.head.appendChild(a));
  }
  function so(i) {
    return '[src="' + mn(i) + '"]';
  }
  function Vl(i) {
    return "script[async]" + i;
  }
  function ky(i, a, o) {
    if (a.count++, a.instance === null)
      switch (a.type) {
        case "style":
          var u = i.querySelector(
            'style[data-href~="' + mn(o.href) + '"]'
          );
          if (u)
            return a.instance = u, et(u), u;
          var g = p({}, o, {
            "data-href": o.href,
            "data-precedence": o.precedence,
            href: null,
            precedence: null
          });
          return u = (i.ownerDocument || i).createElement(
            "style"
          ), et(u), Hn(u, "style", g), Pu(u, o.precedence, i), a.instance = u;
        case "stylesheet":
          g = io(o.href);
          var v = i.querySelector(
            Hl(g)
          );
          if (v)
            return a.state.loading |= 4, a.instance = v, et(v), v;
          u = Gy(o), (g = Ui.get(g)) && Ep(u, g), v = (i.ownerDocument || i).createElement("link"), et(v);
          var w = v;
          return w._p = new Promise(function(F, Q) {
            w.onload = F, w.onerror = Q;
          }), Hn(v, "link", u), a.state.loading |= 4, Pu(v, o.precedence, i), a.instance = v;
        case "script":
          return v = so(o.src), (g = i.querySelector(
            Vl(v)
          )) ? (a.instance = g, et(g), g) : (u = o, (g = Ui.get(v)) && (u = p({}, o), Tp(u, g)), i = i.ownerDocument || i, g = i.createElement("script"), et(g), Hn(g, "link", u), i.head.appendChild(g), a.instance = g);
        case "void":
          return null;
        default:
          throw Error(s(443, a.type));
      }
    else
      a.type === "stylesheet" && (a.state.loading & 4) === 0 && (u = a.instance, a.state.loading |= 4, Pu(u, o.precedence, i));
    return a.instance;
  }
  function Pu(i, a, o) {
    for (var u = o.querySelectorAll(
      'link[rel="stylesheet"][data-precedence],style[data-precedence]'
    ), g = u.length ? u[u.length - 1] : null, v = g, w = 0; w < u.length; w++) {
      var F = u[w];
      if (F.dataset.precedence === a) v = F;
      else if (v !== g) break;
    }
    v ? v.parentNode.insertBefore(i, v.nextSibling) : (a = o.nodeType === 9 ? o.head : o, a.insertBefore(i, a.firstChild));
  }
  function Ep(i, a) {
    i.crossOrigin == null && (i.crossOrigin = a.crossOrigin), i.referrerPolicy == null && (i.referrerPolicy = a.referrerPolicy), i.title == null && (i.title = a.title);
  }
  function Tp(i, a) {
    i.crossOrigin == null && (i.crossOrigin = a.crossOrigin), i.referrerPolicy == null && (i.referrerPolicy = a.referrerPolicy), i.integrity == null && (i.integrity = a.integrity);
  }
  var zu = null;
  function Xy(i, a, o) {
    if (zu === null) {
      var u = /* @__PURE__ */ new Map(), g = zu = /* @__PURE__ */ new Map();
      g.set(o, u);
    } else
      g = zu, u = g.get(o), u || (u = /* @__PURE__ */ new Map(), g.set(o, u));
    if (u.has(i)) return u;
    for (u.set(i, null), o = o.getElementsByTagName(i), g = 0; g < o.length; g++) {
      var v = o[g];
      if (!(v[us] || v[nn] || i === "link" && v.getAttribute("rel") === "stylesheet") && v.namespaceURI !== "http://www.w3.org/2000/svg") {
        var w = v.getAttribute(a) || "";
        w = i + w;
        var F = u.get(w);
        F ? F.push(v) : u.set(w, [v]);
      }
    }
    return u;
  }
  function Wy(i, a, o) {
    i = i.ownerDocument || i, i.head.insertBefore(
      o,
      a === "title" ? i.querySelector("head > title") : null
    );
  }
  function KA(i, a, o) {
    if (o === 1 || a.itemProp != null) return !1;
    switch (i) {
      case "meta":
      case "title":
        return !0;
      case "style":
        if (typeof a.precedence != "string" || typeof a.href != "string" || a.href === "")
          break;
        return !0;
      case "link":
        if (typeof a.rel != "string" || typeof a.href != "string" || a.href === "" || a.onLoad || a.onError)
          break;
        switch (a.rel) {
          case "stylesheet":
            return i = a.disabled, typeof a.precedence == "string" && i == null;
          default:
            return !0;
        }
      case "script":
        if (a.async && typeof a.async != "function" && typeof a.async != "symbol" && !a.onLoad && !a.onError && a.src && typeof a.src == "string")
          return !0;
    }
    return !1;
  }
  function Yy(i) {
    return !(i.type === "stylesheet" && (i.state.loading & 3) === 0);
  }
  function $A(i, a, o, u) {
    if (o.type === "stylesheet" && (typeof u.media != "string" || matchMedia(u.media).matches !== !1) && (o.state.loading & 4) === 0) {
      if (o.instance === null) {
        var g = io(u.href), v = a.querySelector(
          Hl(g)
        );
        if (v) {
          a = v._p, a !== null && typeof a == "object" && typeof a.then == "function" && (i.count++, i = Iu.bind(i), a.then(i, i)), o.state.loading |= 4, o.instance = v, et(v);
          return;
        }
        v = a.ownerDocument || a, u = Gy(u), (g = Ui.get(g)) && Ep(u, g), v = v.createElement("link"), et(v);
        var w = v;
        w._p = new Promise(function(F, Q) {
          w.onload = F, w.onerror = Q;
        }), Hn(v, "link", u), o.instance = v;
      }
      i.stylesheets === null && (i.stylesheets = /* @__PURE__ */ new Map()), i.stylesheets.set(o, a), (a = o.state.preload) && (o.state.loading & 3) === 0 && (i.count++, o = Iu.bind(i), a.addEventListener("load", o), a.addEventListener("error", o));
    }
  }
  var Ap = 0;
  function QA(i, a) {
    return i.stylesheets && i.count === 0 && Fu(i, i.stylesheets), 0 < i.count || 0 < i.imgCount ? function(o) {
      var u = setTimeout(function() {
        if (i.stylesheets && Fu(i, i.stylesheets), i.unsuspend) {
          var v = i.unsuspend;
          i.unsuspend = null, v();
        }
      }, 6e4 + a);
      0 < i.imgBytes && Ap === 0 && (Ap = 62500 * LA());
      var g = setTimeout(
        function() {
          if (i.waitingForImages = !1, i.count === 0 && (i.stylesheets && Fu(i, i.stylesheets), i.unsuspend)) {
            var v = i.unsuspend;
            i.unsuspend = null, v();
          }
        },
        (i.imgBytes > Ap ? 50 : 800) + a
      );
      return i.unsuspend = o, function() {
        i.unsuspend = null, clearTimeout(u), clearTimeout(g);
      };
    } : null;
  }
  function Iu() {
    if (this.count--, this.count === 0 && (this.imgCount === 0 || !this.waitingForImages)) {
      if (this.stylesheets) Fu(this, this.stylesheets);
      else if (this.unsuspend) {
        var i = this.unsuspend;
        this.unsuspend = null, i();
      }
    }
  }
  var Bu = null;
  function Fu(i, a) {
    i.stylesheets = null, i.unsuspend !== null && (i.count++, Bu = /* @__PURE__ */ new Map(), a.forEach(JA, i), Bu = null, Iu.call(i));
  }
  function JA(i, a) {
    if (!(a.state.loading & 4)) {
      var o = Bu.get(i);
      if (o) var u = o.get(null);
      else {
        o = /* @__PURE__ */ new Map(), Bu.set(i, o);
        for (var g = i.querySelectorAll(
          "link[data-precedence],style[data-precedence]"
        ), v = 0; v < g.length; v++) {
          var w = g[v];
          (w.nodeName === "LINK" || w.getAttribute("media") !== "not all") && (o.set(w.dataset.precedence, w), u = w);
        }
        u && o.set(null, u);
      }
      g = a.instance, w = g.getAttribute("data-precedence"), v = o.get(w) || u, v === u && o.set(null, g), o.set(w, g), this.count++, u = Iu.bind(this), g.addEventListener("load", u), g.addEventListener("error", u), v ? v.parentNode.insertBefore(g, v.nextSibling) : (i = i.nodeType === 9 ? i.head : i, i.insertBefore(g, i.firstChild)), a.state.loading |= 4;
    }
  }
  var Gl = {
    $$typeof: T,
    Provider: null,
    Consumer: null,
    _currentValue: V,
    _currentValue2: V,
    _threadCount: 0
  };
  function tw(i, a, o, u, g, v, w, F, Q) {
    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 = u, this.onUncaughtError = g, this.onCaughtError = v, this.onRecoverableError = w, this.pooledCache = null, this.pooledCacheLanes = 0, this.formState = Q, this.incompleteTransitions = /* @__PURE__ */ new Map();
  }
  function jy(i, a, o, u, g, v, w, F, Q, ut, xt, Tt) {
    return i = new tw(
      i,
      a,
      o,
      w,
      Q,
      ut,
      xt,
      Tt,
      F
    ), a = 1, v === !0 && (a |= 24), v = di(3, null, null, a), i.current = v, v.stateNode = i, a = ah(), a.refCount++, i.pooledCache = a, a.refCount++, v.memoizedState = {
      element: u,
      isDehydrated: o,
      cache: a
    }, ch(v), i;
  }
  function qy(i) {
    return i ? (i = Pr, i) : Pr;
  }
  function Zy(i, a, o, u, g, v) {
    g = qy(g), u.context === null ? u.context = g : u.pendingContext = g, u = Qs(a), u.payload = { element: o }, v = v === void 0 ? null : v, v !== null && (u.callback = v), o = Js(i, u, a), o !== null && (ai(o, i, a), xl(o, i, a));
  }
  function Ky(i, a) {
    if (i = i.memoizedState, i !== null && i.dehydrated !== null) {
      var o = i.retryLane;
      i.retryLane = o !== 0 && o < a ? o : a;
    }
  }
  function wp(i, a) {
    Ky(i, a), (i = i.alternate) && Ky(i, a);
  }
  function $y(i) {
    if (i.tag === 13 || i.tag === 31) {
      var a = Va(i, 67108864);
      a !== null && ai(a, i, 67108864), wp(i, 67108864);
    }
  }
  function Qy(i) {
    if (i.tag === 13 || i.tag === 31) {
      var a = _i();
      a = ls(a);
      var o = Va(i, a);
      o !== null && ai(o, i, a), wp(i, a);
    }
  }
  var Hu = !0;
  function ew(i, a, o, u) {
    var g = U.T;
    U.T = null;
    var v = X.p;
    try {
      X.p = 2, Cp(i, a, o, u);
    } finally {
      X.p = v, U.T = g;
    }
  }
  function nw(i, a, o, u) {
    var g = U.T;
    U.T = null;
    var v = X.p;
    try {
      X.p = 8, Cp(i, a, o, u);
    } finally {
      X.p = v, U.T = g;
    }
  }
  function Cp(i, a, o, u) {
    if (Hu) {
      var g = Rp(u);
      if (g === null)
        pp(
          i,
          a,
          u,
          Vu,
          o
        ), tx(i, u);
      else if (sw(
        g,
        i,
        a,
        o,
        u
      ))
        u.stopPropagation();
      else if (tx(i, u), a & 4 && -1 < iw.indexOf(i)) {
        for (; g !== null; ) {
          var v = it(g);
          if (v !== null)
            switch (v.tag) {
              case 3:
                if (v = v.stateNode, v.current.memoizedState.isDehydrated) {
                  var w = Pt(v.pendingLanes);
                  if (w !== 0) {
                    var F = v;
                    for (F.pendingLanes |= 2, F.entangledLanes |= 2; w; ) {
                      var Q = 1 << 31 - re(w);
                      F.entanglements[1] |= Q, w &= ~Q;
                    }
                    Qi(v), (Be & 6) === 0 && (Mu = St() + 500, zl(0));
                  }
                }
                break;
              case 31:
              case 13:
                F = Va(v, 2), F !== null && ai(F, v, 2), Tu(), wp(v, 2);
            }
          if (v = Rp(u), v === null && pp(
            i,
            a,
            u,
            Vu,
            o
          ), v === g) break;
          g = v;
        }
        g !== null && u.stopPropagation();
      } else
        pp(
          i,
          a,
          u,
          null,
          o
        );
    }
  }
  function Rp(i) {
    return i = Nd(i), Dp(i);
  }
  var Vu = null;
  function Dp(i) {
    if (Vu = null, i = G(i), i !== null) {
      var a = l(i);
      if (a === null) i = null;
      else {
        var o = a.tag;
        if (o === 13) {
          if (i = c(a), i !== null) return i;
          i = null;
        } else if (o === 31) {
          if (i = f(a), i !== null) return i;
          i = null;
        } else if (o === 3) {
          if (a.stateNode.current.memoizedState.isDehydrated)
            return a.tag === 3 ? a.stateNode.containerInfo : null;
          i = null;
        } else a !== i && (i = null);
      }
    }
    return Vu = i, null;
  }
  function Jy(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 (wt()) {
          case bt:
            return 2;
          case Zt:
            return 8;
          case Ut:
          case Wt:
            return 32;
          case ve:
            return 268435456;
          default:
            return 32;
        }
      default:
        return 32;
    }
  }
  var Np = !1, ua = null, fa = null, da = null, kl = /* @__PURE__ */ new Map(), Xl = /* @__PURE__ */ new Map(), ha = [], iw = "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 tx(i, a) {
    switch (i) {
      case "focusin":
      case "focusout":
        ua = null;
        break;
      case "dragenter":
      case "dragleave":
        fa = null;
        break;
      case "mouseover":
      case "mouseout":
        da = null;
        break;
      case "pointerover":
      case "pointerout":
        kl.delete(a.pointerId);
        break;
      case "gotpointercapture":
      case "lostpointercapture":
        Xl.delete(a.pointerId);
    }
  }
  function Wl(i, a, o, u, g, v) {
    return i === null || i.nativeEvent !== v ? (i = {
      blockedOn: a,
      domEventName: o,
      eventSystemFlags: u,
      nativeEvent: v,
      targetContainers: [g]
    }, a !== null && (a = it(a), a !== null && $y(a)), i) : (i.eventSystemFlags |= u, a = i.targetContainers, g !== null && a.indexOf(g) === -1 && a.push(g), i);
  }
  function sw(i, a, o, u, g) {
    switch (a) {
      case "focusin":
        return ua = Wl(
          ua,
          i,
          a,
          o,
          u,
          g
        ), !0;
      case "dragenter":
        return fa = Wl(
          fa,
          i,
          a,
          o,
          u,
          g
        ), !0;
      case "mouseover":
        return da = Wl(
          da,
          i,
          a,
          o,
          u,
          g
        ), !0;
      case "pointerover":
        var v = g.pointerId;
        return kl.set(
          v,
          Wl(
            kl.get(v) || null,
            i,
            a,
            o,
            u,
            g
          )
        ), !0;
      case "gotpointercapture":
        return v = g.pointerId, Xl.set(
          v,
          Wl(
            Xl.get(v) || null,
            i,
            a,
            o,
            u,
            g
          )
        ), !0;
    }
    return !1;
  }
  function ex(i) {
    var a = G(i.target);
    if (a !== null) {
      var o = l(a);
      if (o !== null) {
        if (a = o.tag, a === 13) {
          if (a = c(o), a !== null) {
            i.blockedOn = a, cs(i.priority, function() {
              Qy(o);
            });
            return;
          }
        } else if (a === 31) {
          if (a = f(o), a !== null) {
            i.blockedOn = a, cs(i.priority, function() {
              Qy(o);
            });
            return;
          }
        } else if (a === 3 && o.stateNode.current.memoizedState.isDehydrated) {
          i.blockedOn = o.tag === 3 ? o.stateNode.containerInfo : null;
          return;
        }
      }
    }
    i.blockedOn = null;
  }
  function Gu(i) {
    if (i.blockedOn !== null) return !1;
    for (var a = i.targetContainers; 0 < a.length; ) {
      var o = Rp(i.nativeEvent);
      if (o === null) {
        o = i.nativeEvent;
        var u = new o.constructor(
          o.type,
          o
        );
        Dd = u, o.target.dispatchEvent(u), Dd = null;
      } else
        return a = it(o), a !== null && $y(a), i.blockedOn = o, !1;
      a.shift();
    }
    return !0;
  }
  function nx(i, a, o) {
    Gu(i) && o.delete(a);
  }
  function aw() {
    Np = !1, ua !== null && Gu(ua) && (ua = null), fa !== null && Gu(fa) && (fa = null), da !== null && Gu(da) && (da = null), kl.forEach(nx), Xl.forEach(nx);
  }
  function ku(i, a) {
    i.blockedOn === a && (i.blockedOn = null, Np || (Np = !0, n.unstable_scheduleCallback(
      n.unstable_NormalPriority,
      aw
    )));
  }
  var Xu = null;
  function ix(i) {
    Xu !== i && (Xu = i, n.unstable_scheduleCallback(
      n.unstable_NormalPriority,
      function() {
        Xu === i && (Xu = null);
        for (var a = 0; a < i.length; a += 3) {
          var o = i[a], u = i[a + 1], g = i[a + 2];
          if (typeof u != "function") {
            if (Dp(u || o) === null)
              continue;
            break;
          }
          var v = it(o);
          v !== null && (i.splice(a, 3), a -= 3, Rh(
            v,
            {
              pending: !0,
              data: g,
              method: o.method,
              action: u
            },
            u,
            g
          ));
        }
      }
    ));
  }
  function ao(i) {
    function a(Q) {
      return ku(Q, i);
    }
    ua !== null && ku(ua, i), fa !== null && ku(fa, i), da !== null && ku(da, i), kl.forEach(a), Xl.forEach(a);
    for (var o = 0; o < ha.length; o++) {
      var u = ha[o];
      u.blockedOn === i && (u.blockedOn = null);
    }
    for (; 0 < ha.length && (o = ha[0], o.blockedOn === null); )
      ex(o), o.blockedOn === null && ha.shift();
    if (o = (i.ownerDocument || i).$$reactFormReplay, o != null)
      for (u = 0; u < o.length; u += 3) {
        var g = o[u], v = o[u + 1], w = g[En] || null;
        if (typeof v == "function")
          w || ix(o);
        else if (w) {
          var F = null;
          if (v && v.hasAttribute("formAction")) {
            if (g = v, w = v[En] || null)
              F = w.formAction;
            else if (Dp(g) !== null) continue;
          } else F = w.action;
          typeof F == "function" ? o[u + 1] = F : (o.splice(u, 3), u -= 3), ix(o);
        }
      }
  }
  function sx() {
    function i(v) {
      v.canIntercept && v.info === "react-transition" && v.intercept({
        handler: function() {
          return new Promise(function(w) {
            return g = w;
          });
        },
        focusReset: "manual",
        scroll: "manual"
      });
    }
    function a() {
      g !== null && (g(), g = null), u || setTimeout(o, 20);
    }
    function o() {
      if (!u && !navigation.transition) {
        var v = navigation.currentEntry;
        v && v.url != null && navigation.navigate(v.url, {
          state: v.getState(),
          info: "react-transition",
          history: "replace"
        });
      }
    }
    if (typeof navigation == "object") {
      var u = !1, g = null;
      return navigation.addEventListener("navigate", i), navigation.addEventListener("navigatesuccess", a), navigation.addEventListener("navigateerror", a), setTimeout(o, 100), function() {
        u = !0, navigation.removeEventListener("navigate", i), navigation.removeEventListener("navigatesuccess", a), navigation.removeEventListener("navigateerror", a), g !== null && (g(), g = null);
      };
    }
  }
  function Lp(i) {
    this._internalRoot = i;
  }
  Wu.prototype.render = Lp.prototype.render = function(i) {
    var a = this._internalRoot;
    if (a === null) throw Error(s(409));
    var o = a.current, u = _i();
    Zy(o, u, i, a, null, null);
  }, Wu.prototype.unmount = Lp.prototype.unmount = function() {
    var i = this._internalRoot;
    if (i !== null) {
      this._internalRoot = null;
      var a = i.containerInfo;
      Zy(i.current, 2, null, i, null, null), Tu(), a[Ti] = null;
    }
  };
  function Wu(i) {
    this._internalRoot = i;
  }
  Wu.prototype.unstable_scheduleHydration = function(i) {
    if (i) {
      var a = za();
      i = { blockedOn: null, target: i, priority: a };
      for (var o = 0; o < ha.length && a !== 0 && a < ha[o].priority; o++) ;
      ha.splice(o, 0, i), o === 0 && ex(i);
    }
  };
  var ax = t.version;
  if (ax !== "19.2.4")
    throw Error(
      s(
        527,
        ax,
        "19.2.4"
      )
    );
  X.findDOMNode = function(i) {
    var a = i._reactInternals;
    if (a === void 0)
      throw typeof i.render == "function" ? Error(s(188)) : (i = Object.keys(i).join(","), Error(s(268, i)));
    return i = h(a), i = i !== null ? m(i) : null, i = i === null ? null : i.stateNode, i;
  };
  var rw = {
    bundleType: 0,
    version: "19.2.4",
    rendererPackageName: "react-dom",
    currentDispatcherRef: U,
    reconcilerVersion: "19.2.4"
  };
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u") {
    var Yu = __REACT_DEVTOOLS_GLOBAL_HOOK__;
    if (!Yu.isDisabled && Yu.supportsFiber)
      try {
        Jt = Yu.inject(
          rw
        ), $t = Yu;
      } catch {
      }
  }
  return Yl.createRoot = function(i, a) {
    if (!r(i)) throw Error(s(299));
    var o = !1, u = "", g = dv, v = hv, w = pv;
    return a != null && (a.unstable_strictMode === !0 && (o = !0), a.identifierPrefix !== void 0 && (u = a.identifierPrefix), a.onUncaughtError !== void 0 && (g = a.onUncaughtError), a.onCaughtError !== void 0 && (v = a.onCaughtError), a.onRecoverableError !== void 0 && (w = a.onRecoverableError)), a = jy(
      i,
      1,
      !1,
      null,
      null,
      o,
      u,
      null,
      g,
      v,
      w,
      sx
    ), i[Ti] = a.current, hp(i), new Lp(a);
  }, Yl.hydrateRoot = function(i, a, o) {
    if (!r(i)) throw Error(s(299));
    var u = !1, g = "", v = dv, w = hv, F = pv, Q = null;
    return o != null && (o.unstable_strictMode === !0 && (u = !0), o.identifierPrefix !== void 0 && (g = o.identifierPrefix), o.onUncaughtError !== void 0 && (v = o.onUncaughtError), o.onCaughtError !== void 0 && (w = o.onCaughtError), o.onRecoverableError !== void 0 && (F = o.onRecoverableError), o.formState !== void 0 && (Q = o.formState)), a = jy(
      i,
      1,
      !0,
      a,
      o ?? null,
      u,
      g,
      Q,
      v,
      w,
      F,
      sx
    ), a.context = qy(null), o = a.current, u = _i(), u = ls(u), g = Qs(u), g.callback = null, Js(o, g, u), o = u, a.current.lanes = o, Mn(a, o), Qi(a), i[Ti] = a.current, hp(i), new Wu(a);
  }, Yl.version = "19.2.4", Yl;
}
var hx;
function mw() {
  if (hx) return Op.exports;
  hx = 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(), Op.exports = pw(), Op.exports;
}
var gw = mw(), Bp = { exports: {} }, jl = {};
/**
 * @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 px;
function _w() {
  if (px) return jl;
  px = 1;
  var n = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
  function e(s, r, l) {
    var c = null;
    if (l !== void 0 && (c = "" + l), r.key !== void 0 && (c = "" + r.key), "key" in r) {
      l = {};
      for (var f in r)
        f !== "key" && (l[f] = r[f]);
    } else l = r;
    return r = l.ref, {
      $$typeof: n,
      type: s,
      key: c,
      ref: r !== void 0 ? r : null,
      props: l
    };
  }
  return jl.Fragment = t, jl.jsx = e, jl.jsxs = e, jl;
}
var mx;
function vw() {
  return mx || (mx = 1, Bp.exports = _w()), Bp.exports;
}
var Z = vw();
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
const kg = "172", Po = { ROTATE: 0, DOLLY: 1, PAN: 2 }, No = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, yw = 0, gx = 1, xw = 2, mM = 1, Sw = 2, Os = 3, Na = 0, li = 1, es = 2, Ca = 0, zo = 1, _x = 2, vx = 3, yx = 4, bw = 5, cr = 100, Mw = 101, Ew = 102, Tw = 103, Aw = 104, ww = 200, Cw = 201, Rw = 202, Dw = 203, Im = 204, Bm = 205, Nw = 206, Lw = 207, Uw = 208, Ow = 209, Pw = 210, zw = 211, Iw = 212, Bw = 213, Fw = 214, Fm = 0, Hm = 1, Vm = 2, Vo = 3, Gm = 4, km = 5, Xm = 6, Wm = 7, Xg = 0, Hw = 1, Vw = 2, Ra = 0, Gw = 1, kw = 2, Xw = 3, Ww = 4, Yw = 5, jw = 6, qw = 7, gM = 300, Go = 301, ko = 302, Ym = 303, jm = 304, hd = 306, qm = 1e3, fr = 1001, Zm = 1002, Vn = 1003, Zw = 1004, ju = 1005, is = 1006, Fp = 1007, dr = 1008, Hs = 1009, _M = 1010, vM = 1011, pc = 1012, Wg = 1013, _r = 1014, Ii = 1015, Cc = 1016, Yg = 1017, jg = 1018, Xo = 1020, yM = 35902, xM = 1021, SM = 1022, bi = 1023, bM = 1024, MM = 1025, Io = 1026, Wo = 1027, qg = 1028, Zg = 1029, EM = 1030, Kg = 1031, $g = 1033, Pf = 33776, zf = 33777, If = 33778, Bf = 33779, Km = 35840, $m = 35841, Qm = 35842, Jm = 35843, tg = 36196, eg = 37492, ng = 37496, ig = 37808, sg = 37809, ag = 37810, rg = 37811, og = 37812, lg = 37813, cg = 37814, ug = 37815, fg = 37816, dg = 37817, hg = 37818, pg = 37819, mg = 37820, gg = 37821, Ff = 36492, _g = 36494, vg = 36495, TM = 36283, yg = 36284, xg = 36285, Sg = 36286, Kw = 3200, $w = 3201, AM = 0, Qw = 1, Ta = "", Pi = "srgb", Yo = "srgb-linear", Zf = "linear", We = "srgb", ro = 7680, xx = 519, Jw = 512, t2 = 513, e2 = 514, wM = 515, n2 = 516, i2 = 517, s2 = 518, a2 = 519, hr = 35044, oo = 35048, Kf = "300 es", Ps = 2e3, $f = 2001;
class Mr {
  addEventListener(t, e) {
    this._listeners === void 0 && (this._listeners = {});
    const s = this._listeners;
    s[t] === void 0 && (s[t] = []), s[t].indexOf(e) === -1 && s[t].push(e);
  }
  hasEventListener(t, e) {
    if (this._listeners === void 0) return !1;
    const s = this._listeners;
    return s[t] !== void 0 && s[t].indexOf(e) !== -1;
  }
  removeEventListener(t, e) {
    if (this._listeners === void 0) return;
    const r = this._listeners[t];
    if (r !== void 0) {
      const l = r.indexOf(e);
      l !== -1 && r.splice(l, 1);
    }
  }
  dispatchEvent(t) {
    if (this._listeners === void 0) return;
    const s = this._listeners[t.type];
    if (s !== void 0) {
      t.target = this;
      const r = s.slice(0);
      for (let l = 0, c = r.length; l < c; l++)
        r[l].call(this, t);
      t.target = null;
    }
  }
}
const Wn = ["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"], Hf = Math.PI / 180, bg = 180 / Math.PI;
function Da() {
  const n = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, s = Math.random() * 4294967295 | 0;
  return (Wn[n & 255] + Wn[n >> 8 & 255] + Wn[n >> 16 & 255] + Wn[n >> 24 & 255] + "-" + Wn[t & 255] + Wn[t >> 8 & 255] + "-" + Wn[t >> 16 & 15 | 64] + Wn[t >> 24 & 255] + "-" + Wn[e & 63 | 128] + Wn[e >> 8 & 255] + "-" + Wn[e >> 16 & 255] + Wn[e >> 24 & 255] + Wn[s & 255] + Wn[s >> 8 & 255] + Wn[s >> 16 & 255] + Wn[s >> 24 & 255]).toLowerCase();
}
function Ae(n, t, e) {
  return Math.max(t, Math.min(e, n));
}
function r2(n, t) {
  return (n % t + t) % t;
}
function Hp(n, t, e) {
  return (1 - e) * n + e * t;
}
function ns(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 Ye(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 o2 = {
  DEG2RAD: Hf
};
class le {
  constructor(t = 0, e = 0) {
    le.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, s = this.y, r = t.elements;
    return this.x = r[0] * e + r[3] * s + r[6], this.y = r[1] * e + r[4] * s + r[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 = Ae(this.x, t.x, e.x), this.y = Ae(this.y, t.y, e.y), this;
  }
  clampScalar(t, e) {
    return this.x = Ae(this.x, t, e), this.y = Ae(this.y, t, e), this;
  }
  clampLength(t, e) {
    const s = this.length();
    return this.divideScalar(s || 1).multiplyScalar(Ae(s, 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 s = this.dot(t) / e;
    return Math.acos(Ae(s, -1, 1));
  }
  distanceTo(t) {
    return Math.sqrt(this.distanceToSquared(t));
  }
  distanceToSquared(t) {
    const e = this.x - t.x, s = this.y - t.y;
    return e * e + s * s;
  }
  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, s) {
    return this.x = t.x + (e.x - t.x) * s, this.y = t.y + (e.y - t.y) * s, 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 s = Math.cos(e), r = Math.sin(e), l = this.x - t.x, c = this.y - t.y;
    return this.x = l * s - c * r + t.x, this.y = l * r + c * s + t.y, this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y;
  }
}
class _e {
  constructor(t, e, s, r, l, c, f, d, h) {
    _e.prototype.isMatrix3 = !0, this.elements = [
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ], t !== void 0 && this.set(t, e, s, r, l, c, f, d, h);
  }
  set(t, e, s, r, l, c, f, d, h) {
    const m = this.elements;
    return m[0] = t, m[1] = r, m[2] = f, m[3] = e, m[4] = l, m[5] = d, m[6] = s, m[7] = c, m[8] = h, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ), this;
  }
  copy(t) {
    const e = this.elements, s = t.elements;
    return e[0] = s[0], e[1] = s[1], e[2] = s[2], e[3] = s[3], e[4] = s[4], e[5] = s[5], e[6] = s[6], e[7] = s[7], e[8] = s[8], this;
  }
  extractBasis(t, e, s) {
    return t.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), s.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 s = t.elements, r = e.elements, l = this.elements, c = s[0], f = s[3], d = s[6], h = s[1], m = s[4], p = s[7], _ = s[2], x = s[5], b = s[8], M = r[0], S = r[3], y = r[6], C = r[1], T = r[4], E = r[7], O = r[2], N = r[5], D = r[8];
    return l[0] = c * M + f * C + d * O, l[3] = c * S + f * T + d * N, l[6] = c * y + f * E + d * D, l[1] = h * M + m * C + p * O, l[4] = h * S + m * T + p * N, l[7] = h * y + m * E + p * D, l[2] = _ * M + x * C + b * O, l[5] = _ * S + x * T + b * N, l[8] = _ * y + x * E + b * D, 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], s = t[1], r = t[2], l = t[3], c = t[4], f = t[5], d = t[6], h = t[7], m = t[8];
    return e * c * m - e * f * h - s * l * m + s * f * d + r * l * h - r * c * d;
  }
  invert() {
    const t = this.elements, e = t[0], s = t[1], r = t[2], l = t[3], c = t[4], f = t[5], d = t[6], h = t[7], m = t[8], p = m * c - f * h, _ = f * d - m * l, x = h * l - c * d, b = e * p + s * _ + r * x;
    if (b === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
    const M = 1 / b;
    return t[0] = p * M, t[1] = (r * h - m * s) * M, t[2] = (f * s - r * c) * M, t[3] = _ * M, t[4] = (m * e - r * d) * M, t[5] = (r * l - f * e) * M, t[6] = x * M, t[7] = (s * d - h * e) * M, t[8] = (c * e - s * l) * M, 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, s, r, l, c, f) {
    const d = Math.cos(l), h = Math.sin(l);
    return this.set(
      s * d,
      s * h,
      -s * (d * c + h * f) + c + t,
      -r * h,
      r * d,
      -r * (-h * c + d * f) + f + e,
      0,
      0,
      1
    ), this;
  }
  //
  scale(t, e) {
    return this.premultiply(Vp.makeScale(t, e)), this;
  }
  rotate(t) {
    return this.premultiply(Vp.makeRotation(-t)), this;
  }
  translate(t, e) {
    return this.premultiply(Vp.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), s = Math.sin(t);
    return this.set(
      e,
      -s,
      0,
      s,
      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, s = t.elements;
    for (let r = 0; r < 9; r++)
      if (e[r] !== s[r]) return !1;
    return !0;
  }
  fromArray(t, e = 0) {
    for (let s = 0; s < 9; s++)
      this.elements[s] = t[s + e];
    return this;
  }
  toArray(t = [], e = 0) {
    const s = this.elements;
    return t[e] = s[0], t[e + 1] = s[1], t[e + 2] = s[2], t[e + 3] = s[3], t[e + 4] = s[4], t[e + 5] = s[5], t[e + 6] = s[6], t[e + 7] = s[7], t[e + 8] = s[8], t;
  }
  clone() {
    return new this.constructor().fromArray(this.elements);
  }
}
const Vp = /* @__PURE__ */ new _e();
function CM(n) {
  for (let t = n.length - 1; t >= 0; --t)
    if (n[t] >= 65535) return !0;
  return !1;
}
function Qf(n) {
  return document.createElementNS("http://www.w3.org/1999/xhtml", n);
}
function l2() {
  const n = Qf("canvas");
  return n.style.display = "block", n;
}
const Sx = {};
function Ro(n) {
  n in Sx || (Sx[n] = !0, console.warn(n));
}
function c2(n, t, e) {
  return new Promise(function(s, r) {
    function l() {
      switch (n.clientWaitSync(t, n.SYNC_FLUSH_COMMANDS_BIT, 0)) {
        case n.WAIT_FAILED:
          r();
          break;
        case n.TIMEOUT_EXPIRED:
          setTimeout(l, e);
          break;
        default:
          s();
      }
    }
    setTimeout(l, e);
  });
}
function u2(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 f2(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 bx = /* @__PURE__ */ new _e().set(
  0.4123908,
  0.3575843,
  0.1804808,
  0.212639,
  0.7151687,
  0.0721923,
  0.0193308,
  0.1191948,
  0.9505322
), Mx = /* @__PURE__ */ new _e().set(
  3.2409699,
  -1.5373832,
  -0.4986108,
  -0.9692436,
  1.8759675,
  0.0415551,
  0.0556301,
  -0.203977,
  1.0569715
);
function d2() {
  const n = {
    enabled: !0,
    workingColorSpace: Yo,
    /**
     * 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(r, l, c) {
      return this.enabled === !1 || l === c || !l || !c || (this.spaces[l].transfer === We && (r.r = Bs(r.r), r.g = Bs(r.g), r.b = Bs(r.b)), this.spaces[l].primaries !== this.spaces[c].primaries && (r.applyMatrix3(this.spaces[l].toXYZ), r.applyMatrix3(this.spaces[c].fromXYZ)), this.spaces[c].transfer === We && (r.r = Bo(r.r), r.g = Bo(r.g), r.b = Bo(r.b))), r;
    },
    fromWorkingColorSpace: function(r, l) {
      return this.convert(r, this.workingColorSpace, l);
    },
    toWorkingColorSpace: function(r, l) {
      return this.convert(r, l, this.workingColorSpace);
    },
    getPrimaries: function(r) {
      return this.spaces[r].primaries;
    },
    getTransfer: function(r) {
      return r === Ta ? Zf : this.spaces[r].transfer;
    },
    getLuminanceCoefficients: function(r, l = this.workingColorSpace) {
      return r.fromArray(this.spaces[l].luminanceCoefficients);
    },
    define: function(r) {
      Object.assign(this.spaces, r);
    },
    // Internal APIs
    _getMatrix: function(r, l, c) {
      return r.copy(this.spaces[l].toXYZ).multiply(this.spaces[c].fromXYZ);
    },
    _getDrawingBufferColorSpace: function(r) {
      return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace;
    },
    _getUnpackColorSpace: function(r = this.workingColorSpace) {
      return this.spaces[r].workingColorSpaceConfig.unpackColorSpace;
    }
  }, t = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], e = [0.2126, 0.7152, 0.0722], s = [0.3127, 0.329];
  return n.define({
    [Yo]: {
      primaries: t,
      whitePoint: s,
      transfer: Zf,
      toXYZ: bx,
      fromXYZ: Mx,
      luminanceCoefficients: e,
      workingColorSpaceConfig: { unpackColorSpace: Pi },
      outputColorSpaceConfig: { drawingBufferColorSpace: Pi }
    },
    [Pi]: {
      primaries: t,
      whitePoint: s,
      transfer: We,
      toXYZ: bx,
      fromXYZ: Mx,
      luminanceCoefficients: e,
      outputColorSpaceConfig: { drawingBufferColorSpace: Pi }
    }
  }), n;
}
const Ie = /* @__PURE__ */ d2();
function Bs(n) {
  return n < 0.04045 ? n * 0.0773993808 : Math.pow(n * 0.9478672986 + 0.0521327014, 2.4);
}
function Bo(n) {
  return n < 31308e-7 ? n * 12.92 : 1.055 * Math.pow(n, 0.41666) - 0.055;
}
let lo;
class h2 {
  static getDataURL(t) {
    if (/^data:/i.test(t.src) || typeof HTMLCanvasElement > "u")
      return t.src;
    let e;
    if (t instanceof HTMLCanvasElement)
      e = t;
    else {
      lo === void 0 && (lo = Qf("canvas")), lo.width = t.width, lo.height = t.height;
      const s = lo.getContext("2d");
      t instanceof ImageData ? s.putImageData(t, 0, 0) : s.drawImage(t, 0, 0, t.width, t.height), e = lo;
    }
    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 = Qf("canvas");
      e.width = t.width, e.height = t.height;
      const s = e.getContext("2d");
      s.drawImage(t, 0, 0, t.width, t.height);
      const r = s.getImageData(0, 0, t.width, t.height), l = r.data;
      for (let c = 0; c < l.length; c++)
        l[c] = Bs(l[c] / 255) * 255;
      return s.putImageData(r, 0, 0), e;
    } else if (t.data) {
      const e = t.data.slice(0);
      for (let s = 0; s < e.length; s++)
        e instanceof Uint8Array || e instanceof Uint8ClampedArray ? e[s] = Math.floor(Bs(e[s] / 255) * 255) : e[s] = Bs(e[s]);
      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 p2 = 0;
class RM {
  constructor(t = null) {
    this.isSource = !0, Object.defineProperty(this, "id", { value: p2++ }), this.uuid = Da(), 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 s = {
      uuid: this.uuid,
      url: ""
    }, r = this.data;
    if (r !== null) {
      let l;
      if (Array.isArray(r)) {
        l = [];
        for (let c = 0, f = r.length; c < f; c++)
          r[c].isDataTexture ? l.push(Gp(r[c].image)) : l.push(Gp(r[c]));
      } else
        l = Gp(r);
      s.url = l;
    }
    return e || (t.images[this.uuid] = s), s;
  }
}
function Gp(n) {
  return typeof HTMLImageElement < "u" && n instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && n instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && n instanceof ImageBitmap ? h2.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 m2 = 0;
class jn extends Mr {
  constructor(t = jn.DEFAULT_IMAGE, e = jn.DEFAULT_MAPPING, s = fr, r = fr, l = is, c = dr, f = bi, d = Hs, h = jn.DEFAULT_ANISOTROPY, m = Ta) {
    super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: m2++ }), this.uuid = Da(), this.name = "", this.source = new RM(t), this.mipmaps = [], this.mapping = e, this.channel = 0, this.wrapS = s, this.wrapT = r, this.magFilter = l, this.minFilter = c, this.anisotropy = h, this.format = f, this.internalFormat = null, this.type = d, this.offset = new le(0, 0), this.repeat = new le(1, 1), this.center = new le(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new _e(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = m, 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 s = {
      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 && (s.userData = this.userData), e || (t.textures[this.uuid] = s), s;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  transformUv(t) {
    if (this.mapping !== gM) return t;
    if (t.applyMatrix3(this.matrix), t.x < 0 || t.x > 1)
      switch (this.wrapS) {
        case qm:
          t.x = t.x - Math.floor(t.x);
          break;
        case fr:
          t.x = t.x < 0 ? 0 : 1;
          break;
        case Zm:
          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 qm:
          t.y = t.y - Math.floor(t.y);
          break;
        case fr:
          t.y = t.y < 0 ? 0 : 1;
          break;
        case Zm:
          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 = gM;
jn.DEFAULT_ANISOTROPY = 1;
class on {
  constructor(t = 0, e = 0, s = 0, r = 1) {
    on.prototype.isVector4 = !0, this.x = t, this.y = e, this.z = s, this.w = r;
  }
  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, s, r) {
    return this.x = t, this.y = e, this.z = s, this.w = r, 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, s = this.y, r = this.z, l = this.w, c = t.elements;
    return this.x = c[0] * e + c[4] * s + c[8] * r + c[12] * l, this.y = c[1] * e + c[5] * s + c[9] * r + c[13] * l, this.z = c[2] * e + c[6] * s + c[10] * r + c[14] * l, this.w = c[3] * e + c[7] * s + c[11] * r + c[15] * l, 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, s, r, l;
    const d = t.elements, h = d[0], m = d[4], p = d[8], _ = d[1], x = d[5], b = d[9], M = d[2], S = d[6], y = d[10];
    if (Math.abs(m - _) < 0.01 && Math.abs(p - M) < 0.01 && Math.abs(b - S) < 0.01) {
      if (Math.abs(m + _) < 0.1 && Math.abs(p + M) < 0.1 && Math.abs(b + S) < 0.1 && Math.abs(h + x + y - 3) < 0.1)
        return this.set(1, 0, 0, 0), this;
      e = Math.PI;
      const T = (h + 1) / 2, E = (x + 1) / 2, O = (y + 1) / 2, N = (m + _) / 4, D = (p + M) / 4, z = (b + S) / 4;
      return T > E && T > O ? T < 0.01 ? (s = 0, r = 0.707106781, l = 0.707106781) : (s = Math.sqrt(T), r = N / s, l = D / s) : E > O ? E < 0.01 ? (s = 0.707106781, r = 0, l = 0.707106781) : (r = Math.sqrt(E), s = N / r, l = z / r) : O < 0.01 ? (s = 0.707106781, r = 0.707106781, l = 0) : (l = Math.sqrt(O), s = D / l, r = z / l), this.set(s, r, l, e), this;
    }
    let C = Math.sqrt((S - b) * (S - b) + (p - M) * (p - M) + (_ - m) * (_ - m));
    return Math.abs(C) < 1e-3 && (C = 1), this.x = (S - b) / C, this.y = (p - M) / C, this.z = (_ - m) / C, this.w = Math.acos((h + x + 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 = Ae(this.x, t.x, e.x), this.y = Ae(this.y, t.y, e.y), this.z = Ae(this.z, t.z, e.z), this.w = Ae(this.w, t.w, e.w), this;
  }
  clampScalar(t, e) {
    return this.x = Ae(this.x, t, e), this.y = Ae(this.y, t, e), this.z = Ae(this.z, t, e), this.w = Ae(this.w, t, e), this;
  }
  clampLength(t, e) {
    const s = this.length();
    return this.divideScalar(s || 1).multiplyScalar(Ae(s, 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, s) {
    return this.x = t.x + (e.x - t.x) * s, this.y = t.y + (e.y - t.y) * s, this.z = t.z + (e.z - t.z) * s, this.w = t.w + (e.w - t.w) * s, 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 g2 extends Mr {
  constructor(t = 1, e = 1, s = {}) {
    super(), this.isRenderTarget = !0, this.width = t, this.height = e, this.depth = 1, this.scissor = new on(0, 0, t, e), this.scissorTest = !1, this.viewport = new on(0, 0, t, e);
    const r = { width: t, height: e, depth: 1 };
    s = Object.assign({
      generateMipmaps: !1,
      internalFormat: null,
      minFilter: is,
      depthBuffer: !0,
      stencilBuffer: !1,
      resolveDepthBuffer: !0,
      resolveStencilBuffer: !0,
      depthTexture: null,
      samples: 0,
      count: 1
    }, s);
    const l = new jn(r, s.mapping, s.wrapS, s.wrapT, s.magFilter, s.minFilter, s.format, s.type, s.anisotropy, s.colorSpace);
    l.flipY = !1, l.generateMipmaps = s.generateMipmaps, l.internalFormat = s.internalFormat, this.textures = [];
    const c = s.count;
    for (let f = 0; f < c; f++)
      this.textures[f] = l.clone(), this.textures[f].isRenderTargetTexture = !0, this.textures[f].renderTarget = this;
    this.depthBuffer = s.depthBuffer, this.stencilBuffer = s.stencilBuffer, this.resolveDepthBuffer = s.resolveDepthBuffer, this.resolveStencilBuffer = s.resolveStencilBuffer, this._depthTexture = null, this.depthTexture = s.depthTexture, this.samples = s.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, s = 1) {
    if (this.width !== t || this.height !== e || this.depth !== s) {
      this.width = t, this.height = e, this.depth = s;
      for (let r = 0, l = this.textures.length; r < l; r++)
        this.textures[r].image.width = t, this.textures[r].image.height = e, this.textures[r].image.depth = s;
      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 s = 0, r = t.textures.length; s < r; s++)
      this.textures[s] = t.textures[s].clone(), this.textures[s].isRenderTargetTexture = !0, this.textures[s].renderTarget = this;
    const e = Object.assign({}, t.texture.image);
    return this.texture.source = new RM(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 vr extends g2 {
  constructor(t = 1, e = 1, s = {}) {
    super(t, e, s), this.isWebGLRenderTarget = !0;
  }
}
class DM extends jn {
  constructor(t = null, e = 1, s = 1, r = 1) {
    super(null), this.isDataArrayTexture = !0, this.image = { data: t, width: e, height: s, depth: r }, this.magFilter = Vn, this.minFilter = Vn, this.wrapR = fr, 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 _2 extends jn {
  constructor(t = null, e = 1, s = 1, r = 1) {
    super(null), this.isData3DTexture = !0, this.image = { data: t, width: e, height: s, depth: r }, this.magFilter = Vn, this.minFilter = Vn, this.wrapR = fr, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class La {
  constructor(t = 0, e = 0, s = 0, r = 1) {
    this.isQuaternion = !0, this._x = t, this._y = e, this._z = s, this._w = r;
  }
  static slerpFlat(t, e, s, r, l, c, f) {
    let d = s[r + 0], h = s[r + 1], m = s[r + 2], p = s[r + 3];
    const _ = l[c + 0], x = l[c + 1], b = l[c + 2], M = l[c + 3];
    if (f === 0) {
      t[e + 0] = d, t[e + 1] = h, t[e + 2] = m, t[e + 3] = p;
      return;
    }
    if (f === 1) {
      t[e + 0] = _, t[e + 1] = x, t[e + 2] = b, t[e + 3] = M;
      return;
    }
    if (p !== M || d !== _ || h !== x || m !== b) {
      let S = 1 - f;
      const y = d * _ + h * x + m * b + p * M, C = y >= 0 ? 1 : -1, T = 1 - y * y;
      if (T > Number.EPSILON) {
        const O = Math.sqrt(T), N = Math.atan2(O, y * C);
        S = Math.sin(S * N) / O, f = Math.sin(f * N) / O;
      }
      const E = f * C;
      if (d = d * S + _ * E, h = h * S + x * E, m = m * S + b * E, p = p * S + M * E, S === 1 - f) {
        const O = 1 / Math.sqrt(d * d + h * h + m * m + p * p);
        d *= O, h *= O, m *= O, p *= O;
      }
    }
    t[e] = d, t[e + 1] = h, t[e + 2] = m, t[e + 3] = p;
  }
  static multiplyQuaternionsFlat(t, e, s, r, l, c) {
    const f = s[r], d = s[r + 1], h = s[r + 2], m = s[r + 3], p = l[c], _ = l[c + 1], x = l[c + 2], b = l[c + 3];
    return t[e] = f * b + m * p + d * x - h * _, t[e + 1] = d * b + m * _ + h * p - f * x, t[e + 2] = h * b + m * x + f * _ - d * p, t[e + 3] = m * b - f * p - d * _ - h * x, 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, s, r) {
    return this._x = t, this._y = e, this._z = s, this._w = r, 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 s = t._x, r = t._y, l = t._z, c = t._order, f = Math.cos, d = Math.sin, h = f(s / 2), m = f(r / 2), p = f(l / 2), _ = d(s / 2), x = d(r / 2), b = d(l / 2);
    switch (c) {
      case "XYZ":
        this._x = _ * m * p + h * x * b, this._y = h * x * p - _ * m * b, this._z = h * m * b + _ * x * p, this._w = h * m * p - _ * x * b;
        break;
      case "YXZ":
        this._x = _ * m * p + h * x * b, this._y = h * x * p - _ * m * b, this._z = h * m * b - _ * x * p, this._w = h * m * p + _ * x * b;
        break;
      case "ZXY":
        this._x = _ * m * p - h * x * b, this._y = h * x * p + _ * m * b, this._z = h * m * b + _ * x * p, this._w = h * m * p - _ * x * b;
        break;
      case "ZYX":
        this._x = _ * m * p - h * x * b, this._y = h * x * p + _ * m * b, this._z = h * m * b - _ * x * p, this._w = h * m * p + _ * x * b;
        break;
      case "YZX":
        this._x = _ * m * p + h * x * b, this._y = h * x * p + _ * m * b, this._z = h * m * b - _ * x * p, this._w = h * m * p - _ * x * b;
        break;
      case "XZY":
        this._x = _ * m * p - h * x * b, this._y = h * x * p - _ * m * b, this._z = h * m * b + _ * x * p, this._w = h * m * p + _ * x * b;
        break;
      default:
        console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + c);
    }
    return e === !0 && this._onChangeCallback(), this;
  }
  setFromAxisAngle(t, e) {
    const s = e / 2, r = Math.sin(s);
    return this._x = t.x * r, this._y = t.y * r, this._z = t.z * r, this._w = Math.cos(s), this._onChangeCallback(), this;
  }
  setFromRotationMatrix(t) {
    const e = t.elements, s = e[0], r = e[4], l = e[8], c = e[1], f = e[5], d = e[9], h = e[2], m = e[6], p = e[10], _ = s + f + p;
    if (_ > 0) {
      const x = 0.5 / Math.sqrt(_ + 1);
      this._w = 0.25 / x, this._x = (m - d) * x, this._y = (l - h) * x, this._z = (c - r) * x;
    } else if (s > f && s > p) {
      const x = 2 * Math.sqrt(1 + s - f - p);
      this._w = (m - d) / x, this._x = 0.25 * x, this._y = (r + c) / x, this._z = (l + h) / x;
    } else if (f > p) {
      const x = 2 * Math.sqrt(1 + f - s - p);
      this._w = (l - h) / x, this._x = (r + c) / x, this._y = 0.25 * x, this._z = (d + m) / x;
    } else {
      const x = 2 * Math.sqrt(1 + p - s - f);
      this._w = (c - r) / x, this._x = (l + h) / x, this._y = (d + m) / x, this._z = 0.25 * x;
    }
    return this._onChangeCallback(), this;
  }
  setFromUnitVectors(t, e) {
    let s = t.dot(e) + 1;
    return s < Number.EPSILON ? (s = 0, Math.abs(t.x) > Math.abs(t.z) ? (this._x = -t.y, this._y = t.x, this._z = 0, this._w = s) : (this._x = 0, this._y = -t.z, this._z = t.y, this._w = s)) : (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 = s), this.normalize();
  }
  angleTo(t) {
    return 2 * Math.acos(Math.abs(Ae(this.dot(t), -1, 1)));
  }
  rotateTowards(t, e) {
    const s = this.angleTo(t);
    if (s === 0) return this;
    const r = Math.min(1, e / s);
    return this.slerp(t, r), this;
  }
  identity() {
    return this.set(0, 0, 0, 1);
  }
  invert() {
    return this.conjugate();
  }
  conjugate() {
    return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
  }
  dot(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 s = t._x, r = t._y, l = t._z, c = t._w, f = e._x, d = e._y, h = e._z, m = e._w;
    return this._x = s * m + c * f + r * h - l * d, this._y = r * m + c * d + l * f - s * h, this._z = l * m + c * h + s * d - r * f, this._w = c * m - s * f - r * d - l * h, this._onChangeCallback(), this;
  }
  slerp(t, e) {
    if (e === 0) return this;
    if (e === 1) return this.copy(t);
    const s = this._x, r = this._y, l = this._z, c = this._w;
    let f = c * t._w + s * t._x + r * t._y + l * t._z;
    if (f < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, f = -f) : this.copy(t), f >= 1)
      return this._w = c, this._x = s, this._y = r, this._z = l, this;
    const d = 1 - f * f;
    if (d <= Number.EPSILON) {
      const x = 1 - e;
      return this._w = x * c + e * this._w, this._x = x * s + e * this._x, this._y = x * r + e * this._y, this._z = x * l + e * this._z, this.normalize(), this;
    }
    const h = Math.sqrt(d), m = Math.atan2(h, f), p = Math.sin((1 - e) * m) / h, _ = Math.sin(e * m) / h;
    return this._w = c * p + this._w * _, this._x = s * p + this._x * _, this._y = r * p + this._y * _, this._z = l * p + this._z * _, this._onChangeCallback(), this;
  }
  slerpQuaternions(t, e, s) {
    return this.copy(t).slerp(e, s);
  }
  random() {
    const t = 2 * Math.PI * Math.random(), e = 2 * Math.PI * Math.random(), s = Math.random(), r = Math.sqrt(1 - s), l = Math.sqrt(s);
    return this.set(
      r * Math.sin(t),
      r * Math.cos(t),
      l * Math.sin(e),
      l * 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 at {
  constructor(t = 0, e = 0, s = 0) {
    at.prototype.isVector3 = !0, this.x = t, this.y = e, this.z = s;
  }
  set(t, e, s) {
    return s === void 0 && (s = this.z), this.x = t, this.y = e, this.z = s, 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(Ex.setFromEuler(t));
  }
  applyAxisAngle(t, e) {
    return this.applyQuaternion(Ex.setFromAxisAngle(t, e));
  }
  applyMatrix3(t) {
    const e = this.x, s = this.y, r = this.z, l = t.elements;
    return this.x = l[0] * e + l[3] * s + l[6] * r, this.y = l[1] * e + l[4] * s + l[7] * r, this.z = l[2] * e + l[5] * s + l[8] * r, this;
  }
  applyNormalMatrix(t) {
    return this.applyMatrix3(t).normalize();
  }
  applyMatrix4(t) {
    const e = this.x, s = this.y, r = this.z, l = t.elements, c = 1 / (l[3] * e + l[7] * s + l[11] * r + l[15]);
    return this.x = (l[0] * e + l[4] * s + l[8] * r + l[12]) * c, this.y = (l[1] * e + l[5] * s + l[9] * r + l[13]) * c, this.z = (l[2] * e + l[6] * s + l[10] * r + l[14]) * c, this;
  }
  applyQuaternion(t) {
    const e = this.x, s = this.y, r = this.z, l = t.x, c = t.y, f = t.z, d = t.w, h = 2 * (c * r - f * s), m = 2 * (f * e - l * r), p = 2 * (l * s - c * e);
    return this.x = e + d * h + c * p - f * m, this.y = s + d * m + f * h - l * p, this.z = r + d * p + l * m - 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, s = this.y, r = this.z, l = t.elements;
    return this.x = l[0] * e + l[4] * s + l[8] * r, this.y = l[1] * e + l[5] * s + l[9] * r, this.z = l[2] * e + l[6] * s + l[10] * r, 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 = Ae(this.x, t.x, e.x), this.y = Ae(this.y, t.y, e.y), this.z = Ae(this.z, t.z, e.z), this;
  }
  clampScalar(t, e) {
    return this.x = Ae(this.x, t, e), this.y = Ae(this.y, t, e), this.z = Ae(this.z, t, e), this;
  }
  clampLength(t, e) {
    const s = this.length();
    return this.divideScalar(s || 1).multiplyScalar(Ae(s, 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, s) {
    return this.x = t.x + (e.x - t.x) * s, this.y = t.y + (e.y - t.y) * s, this.z = t.z + (e.z - t.z) * s, this;
  }
  cross(t) {
    return this.crossVectors(this, t);
  }
  crossVectors(t, e) {
    const s = t.x, r = t.y, l = t.z, c = e.x, f = e.y, d = e.z;
    return this.x = r * d - l * f, this.y = l * c - s * d, this.z = s * f - r * c, this;
  }
  projectOnVector(t) {
    const e = t.lengthSq();
    if (e === 0) return this.set(0, 0, 0);
    const s = t.dot(this) / e;
    return this.copy(t).multiplyScalar(s);
  }
  projectOnPlane(t) {
    return kp.copy(this).projectOnVector(t), this.sub(kp);
  }
  reflect(t) {
    return this.sub(kp.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 s = this.dot(t) / e;
    return Math.acos(Ae(s, -1, 1));
  }
  distanceTo(t) {
    return Math.sqrt(this.distanceToSquared(t));
  }
  distanceToSquared(t) {
    const e = this.x - t.x, s = this.y - t.y, r = this.z - t.z;
    return e * e + s * s + r * r;
  }
  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, s) {
    const r = Math.sin(e) * t;
    return this.x = r * Math.sin(s), this.y = Math.cos(e) * t, this.z = r * Math.cos(s), this;
  }
  setFromCylindrical(t) {
    return this.setFromCylindricalCoords(t.radius, t.theta, t.y);
  }
  setFromCylindricalCoords(t, e, s) {
    return this.x = t * Math.sin(e), this.y = s, 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(), s = this.setFromMatrixColumn(t, 1).length(), r = this.setFromMatrixColumn(t, 2).length();
    return this.x = e, this.y = s, this.z = r, 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, s = Math.sqrt(1 - e * e);
    return this.x = s * Math.cos(t), this.y = e, this.z = s * Math.sin(t), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z;
  }
}
const kp = /* @__PURE__ */ new at(), Ex = /* @__PURE__ */ new La();
class Er {
  constructor(t = new at(1 / 0, 1 / 0, 1 / 0), e = new at(-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, s = t.length; e < s; e += 3)
      this.expandByPoint(Vi.fromArray(t, e));
    return this;
  }
  setFromBufferAttribute(t) {
    this.makeEmpty();
    for (let e = 0, s = t.count; e < s; e++)
      this.expandByPoint(Vi.fromBufferAttribute(t, e));
    return this;
  }
  setFromPoints(t) {
    this.makeEmpty();
    for (let e = 0, s = t.length; e < s; e++)
      this.expandByPoint(t[e]);
    return this;
  }
  setFromCenterAndSize(t, e) {
    const s = Vi.copy(e).multiplyScalar(0.5);
    return this.min.copy(t).sub(s), this.max.copy(t).add(s), 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 s = t.geometry;
    if (s !== void 0) {
      const l = s.getAttribute("position");
      if (e === !0 && l !== void 0 && t.isInstancedMesh !== !0)
        for (let c = 0, f = l.count; c < f; c++)
          t.isMesh === !0 ? t.getVertexPosition(c, Vi) : Vi.fromBufferAttribute(l, c), Vi.applyMatrix4(t.matrixWorld), this.expandByPoint(Vi);
      else
        t.boundingBox !== void 0 ? (t.boundingBox === null && t.computeBoundingBox(), qu.copy(t.boundingBox)) : (s.boundingBox === null && s.computeBoundingBox(), qu.copy(s.boundingBox)), qu.applyMatrix4(t.matrixWorld), this.union(qu);
    }
    const r = t.children;
    for (let l = 0, c = r.length; l < c; l++)
      this.expandByObject(r[l], 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, Vi), Vi.distanceToSquared(t.center) <= t.radius * t.radius;
  }
  intersectsPlane(t) {
    let e, s;
    return t.normal.x > 0 ? (e = t.normal.x * this.min.x, s = t.normal.x * this.max.x) : (e = t.normal.x * this.max.x, s = t.normal.x * this.min.x), t.normal.y > 0 ? (e += t.normal.y * this.min.y, s += t.normal.y * this.max.y) : (e += t.normal.y * this.max.y, s += t.normal.y * this.min.y), t.normal.z > 0 ? (e += t.normal.z * this.min.z, s += t.normal.z * this.max.z) : (e += t.normal.z * this.max.z, s += t.normal.z * this.min.z), e <= -t.constant && s >= -t.constant;
  }
  intersectsTriangle(t) {
    if (this.isEmpty())
      return !1;
    this.getCenter(ql), Zu.subVectors(this.max, ql), co.subVectors(t.a, ql), uo.subVectors(t.b, ql), fo.subVectors(t.c, ql), ma.subVectors(uo, co), ga.subVectors(fo, uo), tr.subVectors(co, fo);
    let e = [
      0,
      -ma.z,
      ma.y,
      0,
      -ga.z,
      ga.y,
      0,
      -tr.z,
      tr.y,
      ma.z,
      0,
      -ma.x,
      ga.z,
      0,
      -ga.x,
      tr.z,
      0,
      -tr.x,
      -ma.y,
      ma.x,
      0,
      -ga.y,
      ga.x,
      0,
      -tr.y,
      tr.x,
      0
    ];
    return !Xp(e, co, uo, fo, Zu) || (e = [1, 0, 0, 0, 1, 0, 0, 0, 1], !Xp(e, co, uo, fo, Zu)) ? !1 : (Ku.crossVectors(ma, ga), e = [Ku.x, Ku.y, Ku.z], Xp(e, co, uo, fo, Zu));
  }
  clampPoint(t, e) {
    return e.copy(t).clamp(this.min, this.max);
  }
  distanceToPoint(t) {
    return this.clampPoint(t, Vi).distanceTo(t);
  }
  getBoundingSphere(t) {
    return this.isEmpty() ? t.makeEmpty() : (this.getCenter(t.center), t.radius = this.getSize(Vi).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 : (Cs[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(t), Cs[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(t), Cs[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(t), Cs[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(t), Cs[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(t), Cs[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(t), Cs[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(t), Cs[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(t), this.setFromPoints(Cs), 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 Cs = [
  /* @__PURE__ */ new at(),
  /* @__PURE__ */ new at(),
  /* @__PURE__ */ new at(),
  /* @__PURE__ */ new at(),
  /* @__PURE__ */ new at(),
  /* @__PURE__ */ new at(),
  /* @__PURE__ */ new at(),
  /* @__PURE__ */ new at()
], Vi = /* @__PURE__ */ new at(), qu = /* @__PURE__ */ new Er(), co = /* @__PURE__ */ new at(), uo = /* @__PURE__ */ new at(), fo = /* @__PURE__ */ new at(), ma = /* @__PURE__ */ new at(), ga = /* @__PURE__ */ new at(), tr = /* @__PURE__ */ new at(), ql = /* @__PURE__ */ new at(), Zu = /* @__PURE__ */ new at(), Ku = /* @__PURE__ */ new at(), er = /* @__PURE__ */ new at();
function Xp(n, t, e, s, r) {
  for (let l = 0, c = n.length - 3; l <= c; l += 3) {
    er.fromArray(n, l);
    const f = r.x * Math.abs(er.x) + r.y * Math.abs(er.y) + r.z * Math.abs(er.z), d = t.dot(er), h = e.dot(er), m = s.dot(er);
    if (Math.max(-Math.max(d, h, m), Math.min(d, h, m)) > f)
      return !1;
  }
  return !0;
}
const v2 = /* @__PURE__ */ new Er(), Zl = /* @__PURE__ */ new at(), Wp = /* @__PURE__ */ new at();
class nl {
  constructor(t = new at(), 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 s = this.center;
    e !== void 0 ? s.copy(e) : v2.setFromPoints(t).getCenter(s);
    let r = 0;
    for (let l = 0, c = t.length; l < c; l++)
      r = Math.max(r, s.distanceToSquared(t[l]));
    return this.radius = Math.sqrt(r), 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 s = this.center.distanceToSquared(t);
    return e.copy(t), s > 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;
    Zl.subVectors(t, this.center);
    const e = Zl.lengthSq();
    if (e > this.radius * this.radius) {
      const s = Math.sqrt(e), r = (s - this.radius) * 0.5;
      this.center.addScaledVector(Zl, r / s), this.radius += r;
    }
    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) : (Wp.subVectors(t.center, this.center).setLength(t.radius), this.expandByPoint(Zl.copy(t.center).add(Wp)), this.expandByPoint(Zl.copy(t.center).sub(Wp))), this);
  }
  equals(t) {
    return t.center.equals(this.center) && t.radius === this.radius;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const Rs = /* @__PURE__ */ new at(), Yp = /* @__PURE__ */ new at(), $u = /* @__PURE__ */ new at(), _a = /* @__PURE__ */ new at(), jp = /* @__PURE__ */ new at(), Qu = /* @__PURE__ */ new at(), qp = /* @__PURE__ */ new at();
class Qg {
  constructor(t = new at(), e = new at(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, Rs)), this;
  }
  closestPointToPoint(t, e) {
    e.subVectors(t, this.origin);
    const s = e.dot(this.direction);
    return s < 0 ? e.copy(this.origin) : e.copy(this.origin).addScaledVector(this.direction, s);
  }
  distanceToPoint(t) {
    return Math.sqrt(this.distanceSqToPoint(t));
  }
  distanceSqToPoint(t) {
    const e = Rs.subVectors(t, this.origin).dot(this.direction);
    return e < 0 ? this.origin.distanceToSquared(t) : (Rs.copy(this.origin).addScaledVector(this.direction, e), Rs.distanceToSquared(t));
  }
  distanceSqToSegment(t, e, s, r) {
    Yp.copy(t).add(e).multiplyScalar(0.5), $u.copy(e).sub(t).normalize(), _a.copy(this.origin).sub(Yp);
    const l = t.distanceTo(e) * 0.5, c = -this.direction.dot($u), f = _a.dot(this.direction), d = -_a.dot($u), h = _a.lengthSq(), m = Math.abs(1 - c * c);
    let p, _, x, b;
    if (m > 0)
      if (p = c * d - f, _ = c * f - d, b = l * m, p >= 0)
        if (_ >= -b)
          if (_ <= b) {
            const M = 1 / m;
            p *= M, _ *= M, x = p * (p + c * _ + 2 * f) + _ * (c * p + _ + 2 * d) + h;
          } else
            _ = l, p = Math.max(0, -(c * _ + f)), x = -p * p + _ * (_ + 2 * d) + h;
        else
          _ = -l, p = Math.max(0, -(c * _ + f)), x = -p * p + _ * (_ + 2 * d) + h;
      else
        _ <= -b ? (p = Math.max(0, -(-c * l + f)), _ = p > 0 ? -l : Math.min(Math.max(-l, -d), l), x = -p * p + _ * (_ + 2 * d) + h) : _ <= b ? (p = 0, _ = Math.min(Math.max(-l, -d), l), x = _ * (_ + 2 * d) + h) : (p = Math.max(0, -(c * l + f)), _ = p > 0 ? l : Math.min(Math.max(-l, -d), l), x = -p * p + _ * (_ + 2 * d) + h);
    else
      _ = c > 0 ? -l : l, p = Math.max(0, -(c * _ + f)), x = -p * p + _ * (_ + 2 * d) + h;
    return s && s.copy(this.origin).addScaledVector(this.direction, p), r && r.copy(Yp).addScaledVector($u, _), x;
  }
  intersectSphere(t, e) {
    Rs.subVectors(t.center, this.origin);
    const s = Rs.dot(this.direction), r = Rs.dot(Rs) - s * s, l = t.radius * t.radius;
    if (r > l) return null;
    const c = Math.sqrt(l - r), f = s - c, d = s + c;
    return d < 0 ? null : f < 0 ? this.at(d, e) : this.at(f, 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 s = -(this.origin.dot(t.normal) + t.constant) / e;
    return s >= 0 ? s : null;
  }
  intersectPlane(t, e) {
    const s = this.distanceToPlane(t);
    return s === null ? null : this.at(s, e);
  }
  intersectsPlane(t) {
    const e = t.distanceToPoint(this.origin);
    return e === 0 || t.normal.dot(this.direction) * e < 0;
  }
  intersectBox(t, e) {
    let s, r, l, c, f, d;
    const h = 1 / this.direction.x, m = 1 / this.direction.y, p = 1 / this.direction.z, _ = this.origin;
    return h >= 0 ? (s = (t.min.x - _.x) * h, r = (t.max.x - _.x) * h) : (s = (t.max.x - _.x) * h, r = (t.min.x - _.x) * h), m >= 0 ? (l = (t.min.y - _.y) * m, c = (t.max.y - _.y) * m) : (l = (t.max.y - _.y) * m, c = (t.min.y - _.y) * m), s > c || l > r || ((l > s || isNaN(s)) && (s = l), (c < r || isNaN(r)) && (r = c), p >= 0 ? (f = (t.min.z - _.z) * p, d = (t.max.z - _.z) * p) : (f = (t.max.z - _.z) * p, d = (t.min.z - _.z) * p), s > d || f > r) || ((f > s || s !== s) && (s = f), (d < r || r !== r) && (r = d), r < 0) ? null : this.at(s >= 0 ? s : r, e);
  }
  intersectsBox(t) {
    return this.intersectBox(t, Rs) !== null;
  }
  intersectTriangle(t, e, s, r, l) {
    jp.subVectors(e, t), Qu.subVectors(s, t), qp.crossVectors(jp, Qu);
    let c = this.direction.dot(qp), f;
    if (c > 0) {
      if (r) return null;
      f = 1;
    } else if (c < 0)
      f = -1, c = -c;
    else
      return null;
    _a.subVectors(this.origin, t);
    const d = f * this.direction.dot(Qu.crossVectors(_a, Qu));
    if (d < 0)
      return null;
    const h = f * this.direction.dot(jp.cross(_a));
    if (h < 0 || d + h > c)
      return null;
    const m = -f * _a.dot(qp);
    return m < 0 ? null : this.at(m / c, l);
  }
  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 qe {
  constructor(t, e, s, r, l, c, f, d, h, m, p, _, x, b, M, S) {
    qe.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, s, r, l, c, f, d, h, m, p, _, x, b, M, S);
  }
  set(t, e, s, r, l, c, f, d, h, m, p, _, x, b, M, S) {
    const y = this.elements;
    return y[0] = t, y[4] = e, y[8] = s, y[12] = r, y[1] = l, y[5] = c, y[9] = f, y[13] = d, y[2] = h, y[6] = m, y[10] = p, y[14] = _, y[3] = x, y[7] = b, y[11] = M, 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 qe().fromArray(this.elements);
  }
  copy(t) {
    const e = this.elements, s = t.elements;
    return e[0] = s[0], e[1] = s[1], e[2] = s[2], e[3] = s[3], e[4] = s[4], e[5] = s[5], e[6] = s[6], e[7] = s[7], e[8] = s[8], e[9] = s[9], e[10] = s[10], e[11] = s[11], e[12] = s[12], e[13] = s[13], e[14] = s[14], e[15] = s[15], this;
  }
  copyPosition(t) {
    const e = this.elements, s = t.elements;
    return e[12] = s[12], e[13] = s[13], e[14] = s[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, s) {
    return t.setFromMatrixColumn(this, 0), e.setFromMatrixColumn(this, 1), s.setFromMatrixColumn(this, 2), this;
  }
  makeBasis(t, e, s) {
    return this.set(
      t.x,
      e.x,
      s.x,
      0,
      t.y,
      e.y,
      s.y,
      0,
      t.z,
      e.z,
      s.z,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractRotation(t) {
    const e = this.elements, s = t.elements, r = 1 / ho.setFromMatrixColumn(t, 0).length(), l = 1 / ho.setFromMatrixColumn(t, 1).length(), c = 1 / ho.setFromMatrixColumn(t, 2).length();
    return e[0] = s[0] * r, e[1] = s[1] * r, e[2] = s[2] * r, e[3] = 0, e[4] = s[4] * l, e[5] = s[5] * l, e[6] = s[6] * l, e[7] = 0, e[8] = s[8] * c, e[9] = s[9] * c, e[10] = s[10] * c, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
  }
  makeRotationFromEuler(t) {
    const e = this.elements, s = t.x, r = t.y, l = t.z, c = Math.cos(s), f = Math.sin(s), d = Math.cos(r), h = Math.sin(r), m = Math.cos(l), p = Math.sin(l);
    if (t.order === "XYZ") {
      const _ = c * m, x = c * p, b = f * m, M = f * p;
      e[0] = d * m, e[4] = -d * p, e[8] = h, e[1] = x + b * h, e[5] = _ - M * h, e[9] = -f * d, e[2] = M - _ * h, e[6] = b + x * h, e[10] = c * d;
    } else if (t.order === "YXZ") {
      const _ = d * m, x = d * p, b = h * m, M = h * p;
      e[0] = _ + M * f, e[4] = b * f - x, e[8] = c * h, e[1] = c * p, e[5] = c * m, e[9] = -f, e[2] = x * f - b, e[6] = M + _ * f, e[10] = c * d;
    } else if (t.order === "ZXY") {
      const _ = d * m, x = d * p, b = h * m, M = h * p;
      e[0] = _ - M * f, e[4] = -c * p, e[8] = b + x * f, e[1] = x + b * f, e[5] = c * m, e[9] = M - _ * f, e[2] = -c * h, e[6] = f, e[10] = c * d;
    } else if (t.order === "ZYX") {
      const _ = c * m, x = c * p, b = f * m, M = f * p;
      e[0] = d * m, e[4] = b * h - x, e[8] = _ * h + M, e[1] = d * p, e[5] = M * h + _, e[9] = x * h - b, e[2] = -h, e[6] = f * d, e[10] = c * d;
    } else if (t.order === "YZX") {
      const _ = c * d, x = c * h, b = f * d, M = f * h;
      e[0] = d * m, e[4] = M - _ * p, e[8] = b * p + x, e[1] = p, e[5] = c * m, e[9] = -f * m, e[2] = -h * m, e[6] = x * p + b, e[10] = _ - M * p;
    } else if (t.order === "XZY") {
      const _ = c * d, x = c * h, b = f * d, M = f * h;
      e[0] = d * m, e[4] = -p, e[8] = h * m, e[1] = _ * p + M, e[5] = c * m, e[9] = x * p - b, e[2] = b * p - x, e[6] = f * m, e[10] = M * p + _;
    }
    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(y2, t, x2);
  }
  lookAt(t, e, s) {
    const r = this.elements;
    return vi.subVectors(t, e), vi.lengthSq() === 0 && (vi.z = 1), vi.normalize(), va.crossVectors(s, vi), va.lengthSq() === 0 && (Math.abs(s.z) === 1 ? vi.x += 1e-4 : vi.z += 1e-4, vi.normalize(), va.crossVectors(s, vi)), va.normalize(), Ju.crossVectors(vi, va), r[0] = va.x, r[4] = Ju.x, r[8] = vi.x, r[1] = va.y, r[5] = Ju.y, r[9] = vi.y, r[2] = va.z, r[6] = Ju.z, r[10] = vi.z, this;
  }
  multiply(t) {
    return this.multiplyMatrices(this, t);
  }
  premultiply(t) {
    return this.multiplyMatrices(t, this);
  }
  multiplyMatrices(t, e) {
    const s = t.elements, r = e.elements, l = this.elements, c = s[0], f = s[4], d = s[8], h = s[12], m = s[1], p = s[5], _ = s[9], x = s[13], b = s[2], M = s[6], S = s[10], y = s[14], C = s[3], T = s[7], E = s[11], O = s[15], N = r[0], D = r[4], z = r[8], A = r[12], R = r[1], L = r[5], H = r[9], k = r[13], P = r[2], Y = r[6], U = r[10], X = r[14], V = r[3], W = r[7], J = r[11], I = r[15];
    return l[0] = c * N + f * R + d * P + h * V, l[4] = c * D + f * L + d * Y + h * W, l[8] = c * z + f * H + d * U + h * J, l[12] = c * A + f * k + d * X + h * I, l[1] = m * N + p * R + _ * P + x * V, l[5] = m * D + p * L + _ * Y + x * W, l[9] = m * z + p * H + _ * U + x * J, l[13] = m * A + p * k + _ * X + x * I, l[2] = b * N + M * R + S * P + y * V, l[6] = b * D + M * L + S * Y + y * W, l[10] = b * z + M * H + S * U + y * J, l[14] = b * A + M * k + S * X + y * I, l[3] = C * N + T * R + E * P + O * V, l[7] = C * D + T * L + E * Y + O * W, l[11] = C * z + T * H + E * U + O * J, l[15] = C * A + T * k + E * X + O * I, 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], s = t[4], r = t[8], l = t[12], c = t[1], f = t[5], d = t[9], h = t[13], m = t[2], p = t[6], _ = t[10], x = t[14], b = t[3], M = t[7], S = t[11], y = t[15];
    return b * (+l * d * p - r * h * p - l * f * _ + s * h * _ + r * f * x - s * d * x) + M * (+e * d * x - e * h * _ + l * c * _ - r * c * x + r * h * m - l * d * m) + S * (+e * h * p - e * f * x - l * c * p + s * c * x + l * f * m - s * h * m) + y * (-r * f * m - e * d * p + e * f * _ + r * c * p - s * c * _ + s * d * m);
  }
  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, s) {
    const r = this.elements;
    return t.isVector3 ? (r[12] = t.x, r[13] = t.y, r[14] = t.z) : (r[12] = t, r[13] = e, r[14] = s), this;
  }
  invert() {
    const t = this.elements, e = t[0], s = t[1], r = t[2], l = t[3], c = t[4], f = t[5], d = t[6], h = t[7], m = t[8], p = t[9], _ = t[10], x = t[11], b = t[12], M = t[13], S = t[14], y = t[15], C = p * S * h - M * _ * h + M * d * x - f * S * x - p * d * y + f * _ * y, T = b * _ * h - m * S * h - b * d * x + c * S * x + m * d * y - c * _ * y, E = m * M * h - b * p * h + b * f * x - c * M * x - m * f * y + c * p * y, O = b * p * d - m * M * d - b * f * _ + c * M * _ + m * f * S - c * p * S, N = e * C + s * T + r * E + l * O;
    if (N === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    const D = 1 / N;
    return t[0] = C * D, t[1] = (M * _ * l - p * S * l - M * r * x + s * S * x + p * r * y - s * _ * y) * D, t[2] = (f * S * l - M * d * l + M * r * h - s * S * h - f * r * y + s * d * y) * D, t[3] = (p * d * l - f * _ * l - p * r * h + s * _ * h + f * r * x - s * d * x) * D, t[4] = T * D, t[5] = (m * S * l - b * _ * l + b * r * x - e * S * x - m * r * y + e * _ * y) * D, t[6] = (b * d * l - c * S * l - b * r * h + e * S * h + c * r * y - e * d * y) * D, t[7] = (c * _ * l - m * d * l + m * r * h - e * _ * h - c * r * x + e * d * x) * D, t[8] = E * D, t[9] = (b * p * l - m * M * l - b * s * x + e * M * x + m * s * y - e * p * y) * D, t[10] = (c * M * l - b * f * l + b * s * h - e * M * h - c * s * y + e * f * y) * D, t[11] = (m * f * l - c * p * l - m * s * h + e * p * h + c * s * x - e * f * x) * D, t[12] = O * D, t[13] = (m * M * r - b * p * r + b * s * _ - e * M * _ - m * s * S + e * p * S) * D, t[14] = (b * f * r - c * M * r - b * s * d + e * M * d + c * s * S - e * f * S) * D, t[15] = (c * p * r - m * f * r + m * s * d - e * p * d - c * s * _ + e * f * _) * D, this;
  }
  scale(t) {
    const e = this.elements, s = t.x, r = t.y, l = t.z;
    return e[0] *= s, e[4] *= r, e[8] *= l, e[1] *= s, e[5] *= r, e[9] *= l, e[2] *= s, e[6] *= r, e[10] *= l, e[3] *= s, e[7] *= r, e[11] *= l, this;
  }
  getMaxScaleOnAxis() {
    const t = this.elements, e = t[0] * t[0] + t[1] * t[1] + t[2] * t[2], s = t[4] * t[4] + t[5] * t[5] + t[6] * t[6], r = t[8] * t[8] + t[9] * t[9] + t[10] * t[10];
    return Math.sqrt(Math.max(e, s, r));
  }
  makeTranslation(t, e, s) {
    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,
      s,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationX(t) {
    const e = Math.cos(t), s = Math.sin(t);
    return this.set(
      1,
      0,
      0,
      0,
      0,
      e,
      -s,
      0,
      0,
      s,
      e,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationY(t) {
    const e = Math.cos(t), s = Math.sin(t);
    return this.set(
      e,
      0,
      s,
      0,
      0,
      1,
      0,
      0,
      -s,
      0,
      e,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationZ(t) {
    const e = Math.cos(t), s = Math.sin(t);
    return this.set(
      e,
      -s,
      0,
      0,
      s,
      e,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationAxis(t, e) {
    const s = Math.cos(e), r = Math.sin(e), l = 1 - s, c = t.x, f = t.y, d = t.z, h = l * c, m = l * f;
    return this.set(
      h * c + s,
      h * f - r * d,
      h * d + r * f,
      0,
      h * f + r * d,
      m * f + s,
      m * d - r * c,
      0,
      h * d - r * f,
      m * d + r * c,
      l * d * d + s,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(t, e, s) {
    return this.set(
      t,
      0,
      0,
      0,
      0,
      e,
      0,
      0,
      0,
      0,
      s,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeShear(t, e, s, r, l, c) {
    return this.set(
      1,
      s,
      l,
      0,
      t,
      1,
      c,
      0,
      e,
      r,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  compose(t, e, s) {
    const r = this.elements, l = e._x, c = e._y, f = e._z, d = e._w, h = l + l, m = c + c, p = f + f, _ = l * h, x = l * m, b = l * p, M = c * m, S = c * p, y = f * p, C = d * h, T = d * m, E = d * p, O = s.x, N = s.y, D = s.z;
    return r[0] = (1 - (M + y)) * O, r[1] = (x + E) * O, r[2] = (b - T) * O, r[3] = 0, r[4] = (x - E) * N, r[5] = (1 - (_ + y)) * N, r[6] = (S + C) * N, r[7] = 0, r[8] = (b + T) * D, r[9] = (S - C) * D, r[10] = (1 - (_ + M)) * D, r[11] = 0, r[12] = t.x, r[13] = t.y, r[14] = t.z, r[15] = 1, this;
  }
  decompose(t, e, s) {
    const r = this.elements;
    let l = ho.set(r[0], r[1], r[2]).length();
    const c = ho.set(r[4], r[5], r[6]).length(), f = ho.set(r[8], r[9], r[10]).length();
    this.determinant() < 0 && (l = -l), t.x = r[12], t.y = r[13], t.z = r[14], Gi.copy(this);
    const h = 1 / l, m = 1 / c, p = 1 / f;
    return Gi.elements[0] *= h, Gi.elements[1] *= h, Gi.elements[2] *= h, Gi.elements[4] *= m, Gi.elements[5] *= m, Gi.elements[6] *= m, Gi.elements[8] *= p, Gi.elements[9] *= p, Gi.elements[10] *= p, e.setFromRotationMatrix(Gi), s.x = l, s.y = c, s.z = f, this;
  }
  makePerspective(t, e, s, r, l, c, f = Ps) {
    const d = this.elements, h = 2 * l / (e - t), m = 2 * l / (s - r), p = (e + t) / (e - t), _ = (s + r) / (s - r);
    let x, b;
    if (f === Ps)
      x = -(c + l) / (c - l), b = -2 * c * l / (c - l);
    else if (f === $f)
      x = -c / (c - l), b = -c * l / (c - l);
    else
      throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + f);
    return d[0] = h, d[4] = 0, d[8] = p, d[12] = 0, d[1] = 0, d[5] = m, d[9] = _, d[13] = 0, d[2] = 0, d[6] = 0, d[10] = x, d[14] = b, d[3] = 0, d[7] = 0, d[11] = -1, d[15] = 0, this;
  }
  makeOrthographic(t, e, s, r, l, c, f = Ps) {
    const d = this.elements, h = 1 / (e - t), m = 1 / (s - r), p = 1 / (c - l), _ = (e + t) * h, x = (s + r) * m;
    let b, M;
    if (f === Ps)
      b = (c + l) * p, M = -2 * p;
    else if (f === $f)
      b = l * p, M = -1 * p;
    else
      throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + f);
    return d[0] = 2 * h, d[4] = 0, d[8] = 0, d[12] = -_, d[1] = 0, d[5] = 2 * m, d[9] = 0, d[13] = -x, d[2] = 0, d[6] = 0, d[10] = M, d[14] = -b, d[3] = 0, d[7] = 0, d[11] = 0, d[15] = 1, this;
  }
  equals(t) {
    const e = this.elements, s = t.elements;
    for (let r = 0; r < 16; r++)
      if (e[r] !== s[r]) return !1;
    return !0;
  }
  fromArray(t, e = 0) {
    for (let s = 0; s < 16; s++)
      this.elements[s] = t[s + e];
    return this;
  }
  toArray(t = [], e = 0) {
    const s = this.elements;
    return t[e] = s[0], t[e + 1] = s[1], t[e + 2] = s[2], t[e + 3] = s[3], t[e + 4] = s[4], t[e + 5] = s[5], t[e + 6] = s[6], t[e + 7] = s[7], t[e + 8] = s[8], t[e + 9] = s[9], t[e + 10] = s[10], t[e + 11] = s[11], t[e + 12] = s[12], t[e + 13] = s[13], t[e + 14] = s[14], t[e + 15] = s[15], t;
  }
}
const ho = /* @__PURE__ */ new at(), Gi = /* @__PURE__ */ new qe(), y2 = /* @__PURE__ */ new at(0, 0, 0), x2 = /* @__PURE__ */ new at(1, 1, 1), va = /* @__PURE__ */ new at(), Ju = /* @__PURE__ */ new at(), vi = /* @__PURE__ */ new at(), Tx = /* @__PURE__ */ new qe(), Ax = /* @__PURE__ */ new La();
class as {
  constructor(t = 0, e = 0, s = 0, r = as.DEFAULT_ORDER) {
    this.isEuler = !0, this._x = t, this._y = e, this._z = s, this._order = r;
  }
  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, s, r = this._order) {
    return this._x = t, this._y = e, this._z = s, this._order = r, 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, s = !0) {
    const r = t.elements, l = r[0], c = r[4], f = r[8], d = r[1], h = r[5], m = r[9], p = r[2], _ = r[6], x = r[10];
    switch (e) {
      case "XYZ":
        this._y = Math.asin(Ae(f, -1, 1)), Math.abs(f) < 0.9999999 ? (this._x = Math.atan2(-m, x), this._z = Math.atan2(-c, l)) : (this._x = Math.atan2(_, h), this._z = 0);
        break;
      case "YXZ":
        this._x = Math.asin(-Ae(m, -1, 1)), Math.abs(m) < 0.9999999 ? (this._y = Math.atan2(f, x), this._z = Math.atan2(d, h)) : (this._y = Math.atan2(-p, l), this._z = 0);
        break;
      case "ZXY":
        this._x = Math.asin(Ae(_, -1, 1)), Math.abs(_) < 0.9999999 ? (this._y = Math.atan2(-p, x), this._z = Math.atan2(-c, h)) : (this._y = 0, this._z = Math.atan2(d, l));
        break;
      case "ZYX":
        this._y = Math.asin(-Ae(p, -1, 1)), Math.abs(p) < 0.9999999 ? (this._x = Math.atan2(_, x), this._z = Math.atan2(d, l)) : (this._x = 0, this._z = Math.atan2(-c, h));
        break;
      case "YZX":
        this._z = Math.asin(Ae(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._x = Math.atan2(-m, h), this._y = Math.atan2(-p, l)) : (this._x = 0, this._y = Math.atan2(f, x));
        break;
      case "XZY":
        this._z = Math.asin(-Ae(c, -1, 1)), Math.abs(c) < 0.9999999 ? (this._x = Math.atan2(_, h), this._y = Math.atan2(f, l)) : (this._x = Math.atan2(-m, x), this._y = 0);
        break;
      default:
        console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + e);
    }
    return this._order = e, s === !0 && this._onChangeCallback(), this;
  }
  setFromQuaternion(t, e, s) {
    return Tx.makeRotationFromQuaternion(t), this.setFromRotationMatrix(Tx, e, s);
  }
  setFromVector3(t, e = this._order) {
    return this.set(t.x, t.y, t.z, e);
  }
  reorder(t) {
    return Ax.setFromEuler(this), this.setFromQuaternion(Ax, 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;
  }
}
as.DEFAULT_ORDER = "XYZ";
class NM {
  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 S2 = 0;
const wx = /* @__PURE__ */ new at(), po = /* @__PURE__ */ new La(), Ds = /* @__PURE__ */ new qe(), tf = /* @__PURE__ */ new at(), Kl = /* @__PURE__ */ new at(), b2 = /* @__PURE__ */ new at(), M2 = /* @__PURE__ */ new La(), Cx = /* @__PURE__ */ new at(1, 0, 0), Rx = /* @__PURE__ */ new at(0, 1, 0), Dx = /* @__PURE__ */ new at(0, 0, 1), Nx = { type: "added" }, E2 = { type: "removed" }, mo = { type: "childadded", child: null }, Zp = { type: "childremoved", child: null };
class Sn extends Mr {
  constructor() {
    super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: S2++ }), this.uuid = Da(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = Sn.DEFAULT_UP.clone();
    const t = new at(), e = new as(), s = new La(), r = new at(1, 1, 1);
    function l() {
      s.setFromEuler(e, !1);
    }
    function c() {
      e.setFromQuaternion(s, void 0, !1);
    }
    e._onChange(l), s._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: s
      },
      scale: {
        configurable: !0,
        enumerable: !0,
        value: r
      },
      modelViewMatrix: {
        value: new qe()
      },
      normalMatrix: {
        value: new _e()
      }
    }), this.matrix = new qe(), this.matrixWorld = new qe(), this.matrixAutoUpdate = Sn.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = Sn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new NM(), 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 po.setFromAxisAngle(t, e), this.quaternion.multiply(po), this;
  }
  rotateOnWorldAxis(t, e) {
    return po.setFromAxisAngle(t, e), this.quaternion.premultiply(po), this;
  }
  rotateX(t) {
    return this.rotateOnAxis(Cx, t);
  }
  rotateY(t) {
    return this.rotateOnAxis(Rx, t);
  }
  rotateZ(t) {
    return this.rotateOnAxis(Dx, t);
  }
  translateOnAxis(t, e) {
    return wx.copy(t).applyQuaternion(this.quaternion), this.position.add(wx.multiplyScalar(e)), this;
  }
  translateX(t) {
    return this.translateOnAxis(Cx, t);
  }
  translateY(t) {
    return this.translateOnAxis(Rx, t);
  }
  translateZ(t) {
    return this.translateOnAxis(Dx, t);
  }
  localToWorld(t) {
    return this.updateWorldMatrix(!0, !1), t.applyMatrix4(this.matrixWorld);
  }
  worldToLocal(t) {
    return this.updateWorldMatrix(!0, !1), t.applyMatrix4(Ds.copy(this.matrixWorld).invert());
  }
  lookAt(t, e, s) {
    t.isVector3 ? tf.copy(t) : tf.set(t, e, s);
    const r = this.parent;
    this.updateWorldMatrix(!0, !1), Kl.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Ds.lookAt(Kl, tf, this.up) : Ds.lookAt(tf, Kl, this.up), this.quaternion.setFromRotationMatrix(Ds), r && (Ds.extractRotation(r.matrixWorld), po.setFromRotationMatrix(Ds), this.quaternion.premultiply(po.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(Nx), mo.child = t, this.dispatchEvent(mo), mo.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", t), this);
  }
  remove(t) {
    if (arguments.length > 1) {
      for (let s = 0; s < arguments.length; s++)
        this.remove(arguments[s]);
      return this;
    }
    const e = this.children.indexOf(t);
    return e !== -1 && (t.parent = null, this.children.splice(e, 1), t.dispatchEvent(E2), Zp.child = t, this.dispatchEvent(Zp), Zp.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), Ds.copy(this.matrixWorld).invert(), t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), Ds.multiply(t.parent.matrixWorld)), t.applyMatrix4(Ds), t.removeFromParent(), t.parent = this, this.children.push(t), t.updateWorldMatrix(!1, !0), t.dispatchEvent(Nx), mo.child = t, this.dispatchEvent(mo), mo.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 s = 0, r = this.children.length; s < r; s++) {
      const c = this.children[s].getObjectByProperty(t, e);
      if (c !== void 0)
        return c;
    }
  }
  getObjectsByProperty(t, e, s = []) {
    this[t] === e && s.push(this);
    const r = this.children;
    for (let l = 0, c = r.length; l < c; l++)
      r[l].getObjectsByProperty(t, e, s);
    return s;
  }
  getWorldPosition(t) {
    return this.updateWorldMatrix(!0, !1), t.setFromMatrixPosition(this.matrixWorld);
  }
  getWorldQuaternion(t) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Kl, t, b2), t;
  }
  getWorldScale(t) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Kl, M2, 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 s = 0, r = e.length; s < r; s++)
      e[s].traverse(t);
  }
  traverseVisible(t) {
    if (this.visible === !1) return;
    t(this);
    const e = this.children;
    for (let s = 0, r = e.length; s < r; s++)
      e[s].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 s = 0, r = e.length; s < r; s++)
      e[s].updateMatrixWorld(t);
  }
  updateWorldMatrix(t, e) {
    const s = this.parent;
    if (t === !0 && s !== null && s.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 r = this.children;
      for (let l = 0, c = r.length; l < c; l++)
        r[l].updateWorldMatrix(!1, !0);
    }
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string", s = {};
    e && (t = {
      geometries: {},
      materials: {},
      textures: {},
      images: {},
      shapes: {},
      skeletons: {},
      animations: {},
      nodes: {}
    }, s.metadata = {
      version: 4.6,
      type: "Object",
      generator: "Object3D.toJSON"
    });
    const r = {};
    r.uuid = this.uuid, r.type = this.type, this.name !== "" && (r.name = this.name), this.castShadow === !0 && (r.castShadow = !0), this.receiveShadow === !0 && (r.receiveShadow = !0), this.visible === !1 && (r.visible = !1), this.frustumCulled === !1 && (r.frustumCulled = !1), this.renderOrder !== 0 && (r.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (r.userData = this.userData), r.layers = this.layers.mask, r.matrix = this.matrix.toArray(), r.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1), this.isInstancedMesh && (r.type = "InstancedMesh", r.count = this.count, r.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (r.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (r.type = "BatchedMesh", r.perObjectFrustumCulled = this.perObjectFrustumCulled, r.sortObjects = this.sortObjects, r.drawRanges = this._drawRanges, r.reservedRanges = this._reservedRanges, r.visibility = this._visibility, r.active = this._active, r.bounds = this._bounds.map((f) => ({
      boxInitialized: f.boxInitialized,
      boxMin: f.box.min.toArray(),
      boxMax: f.box.max.toArray(),
      sphereInitialized: f.sphereInitialized,
      sphereRadius: f.sphere.radius,
      sphereCenter: f.sphere.center.toArray()
    })), r.maxInstanceCount = this._maxInstanceCount, r.maxVertexCount = this._maxVertexCount, r.maxIndexCount = this._maxIndexCount, r.geometryInitialized = this._geometryInitialized, r.geometryCount = this._geometryCount, r.matricesTexture = this._matricesTexture.toJSON(t), this._colorsTexture !== null && (r.colorsTexture = this._colorsTexture.toJSON(t)), this.boundingSphere !== null && (r.boundingSphere = {
      center: r.boundingSphere.center.toArray(),
      radius: r.boundingSphere.radius
    }), this.boundingBox !== null && (r.boundingBox = {
      min: r.boundingBox.min.toArray(),
      max: r.boundingBox.max.toArray()
    }));
    function l(f, d) {
      return f[d.uuid] === void 0 && (f[d.uuid] = d.toJSON(t)), d.uuid;
    }
    if (this.isScene)
      this.background && (this.background.isColor ? r.background = this.background.toJSON() : this.background.isTexture && (r.background = this.background.toJSON(t).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (r.environment = this.environment.toJSON(t).uuid);
    else if (this.isMesh || this.isLine || this.isPoints) {
      r.geometry = l(t.geometries, this.geometry);
      const f = this.geometry.parameters;
      if (f !== void 0 && f.shapes !== void 0) {
        const d = f.shapes;
        if (Array.isArray(d))
          for (let h = 0, m = d.length; h < m; h++) {
            const p = d[h];
            l(t.shapes, p);
          }
        else
          l(t.shapes, d);
      }
    }
    if (this.isSkinnedMesh && (r.bindMode = this.bindMode, r.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (l(t.skeletons, this.skeleton), r.skeleton = this.skeleton.uuid)), this.material !== void 0)
      if (Array.isArray(this.material)) {
        const f = [];
        for (let d = 0, h = this.material.length; d < h; d++)
          f.push(l(t.materials, this.material[d]));
        r.material = f;
      } else
        r.material = l(t.materials, this.material);
    if (this.children.length > 0) {
      r.children = [];
      for (let f = 0; f < this.children.length; f++)
        r.children.push(this.children[f].toJSON(t).object);
    }
    if (this.animations.length > 0) {
      r.animations = [];
      for (let f = 0; f < this.animations.length; f++) {
        const d = this.animations[f];
        r.animations.push(l(t.animations, d));
      }
    }
    if (e) {
      const f = c(t.geometries), d = c(t.materials), h = c(t.textures), m = c(t.images), p = c(t.shapes), _ = c(t.skeletons), x = c(t.animations), b = c(t.nodes);
      f.length > 0 && (s.geometries = f), d.length > 0 && (s.materials = d), h.length > 0 && (s.textures = h), m.length > 0 && (s.images = m), p.length > 0 && (s.shapes = p), _.length > 0 && (s.skeletons = _), x.length > 0 && (s.animations = x), b.length > 0 && (s.nodes = b);
    }
    return s.object = r, s;
    function c(f) {
      const d = [];
      for (const h in f) {
        const m = f[h];
        delete m.metadata, d.push(m);
      }
      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 s = 0; s < t.children.length; s++) {
        const r = t.children[s];
        this.add(r.clone());
      }
    return this;
  }
}
Sn.DEFAULT_UP = /* @__PURE__ */ new at(0, 1, 0);
Sn.DEFAULT_MATRIX_AUTO_UPDATE = !0;
Sn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
const ki = /* @__PURE__ */ new at(), Ns = /* @__PURE__ */ new at(), Kp = /* @__PURE__ */ new at(), Ls = /* @__PURE__ */ new at(), go = /* @__PURE__ */ new at(), _o = /* @__PURE__ */ new at(), Lx = /* @__PURE__ */ new at(), $p = /* @__PURE__ */ new at(), Qp = /* @__PURE__ */ new at(), Jp = /* @__PURE__ */ new at(), tm = /* @__PURE__ */ new on(), em = /* @__PURE__ */ new on(), nm = /* @__PURE__ */ new on();
class zi {
  constructor(t = new at(), e = new at(), s = new at()) {
    this.a = t, this.b = e, this.c = s;
  }
  static getNormal(t, e, s, r) {
    r.subVectors(s, e), ki.subVectors(t, e), r.cross(ki);
    const l = r.lengthSq();
    return l > 0 ? r.multiplyScalar(1 / Math.sqrt(l)) : r.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, s, r, l) {
    ki.subVectors(r, e), Ns.subVectors(s, e), Kp.subVectors(t, e);
    const c = ki.dot(ki), f = ki.dot(Ns), d = ki.dot(Kp), h = Ns.dot(Ns), m = Ns.dot(Kp), p = c * h - f * f;
    if (p === 0)
      return l.set(0, 0, 0), null;
    const _ = 1 / p, x = (h * d - f * m) * _, b = (c * m - f * d) * _;
    return l.set(1 - x - b, b, x);
  }
  static containsPoint(t, e, s, r) {
    return this.getBarycoord(t, e, s, r, Ls) === null ? !1 : Ls.x >= 0 && Ls.y >= 0 && Ls.x + Ls.y <= 1;
  }
  static getInterpolation(t, e, s, r, l, c, f, d) {
    return this.getBarycoord(t, e, s, r, Ls) === 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(l, Ls.x), d.addScaledVector(c, Ls.y), d.addScaledVector(f, Ls.z), d);
  }
  static getInterpolatedAttribute(t, e, s, r, l, c) {
    return tm.setScalar(0), em.setScalar(0), nm.setScalar(0), tm.fromBufferAttribute(t, e), em.fromBufferAttribute(t, s), nm.fromBufferAttribute(t, r), c.setScalar(0), c.addScaledVector(tm, l.x), c.addScaledVector(em, l.y), c.addScaledVector(nm, l.z), c;
  }
  static isFrontFacing(t, e, s, r) {
    return ki.subVectors(s, e), Ns.subVectors(t, e), ki.cross(Ns).dot(r) < 0;
  }
  set(t, e, s) {
    return this.a.copy(t), this.b.copy(e), this.c.copy(s), this;
  }
  setFromPointsAndIndices(t, e, s, r) {
    return this.a.copy(t[e]), this.b.copy(t[s]), this.c.copy(t[r]), this;
  }
  setFromAttributeAndIndices(t, e, s, r) {
    return this.a.fromBufferAttribute(t, e), this.b.fromBufferAttribute(t, s), this.c.fromBufferAttribute(t, r), 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 ki.subVectors(this.c, this.b), Ns.subVectors(this.a, this.b), ki.cross(Ns).length() * 0.5;
  }
  getMidpoint(t) {
    return t.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
  }
  getNormal(t) {
    return zi.getNormal(this.a, this.b, this.c, t);
  }
  getPlane(t) {
    return t.setFromCoplanarPoints(this.a, this.b, this.c);
  }
  getBarycoord(t, e) {
    return zi.getBarycoord(t, this.a, this.b, this.c, e);
  }
  getInterpolation(t, e, s, r, l) {
    return zi.getInterpolation(t, this.a, this.b, this.c, e, s, r, l);
  }
  containsPoint(t) {
    return zi.containsPoint(t, this.a, this.b, this.c);
  }
  isFrontFacing(t) {
    return zi.isFrontFacing(this.a, this.b, this.c, t);
  }
  intersectsBox(t) {
    return t.intersectsTriangle(this);
  }
  closestPointToPoint(t, e) {
    const s = this.a, r = this.b, l = this.c;
    let c, f;
    go.subVectors(r, s), _o.subVectors(l, s), $p.subVectors(t, s);
    const d = go.dot($p), h = _o.dot($p);
    if (d <= 0 && h <= 0)
      return e.copy(s);
    Qp.subVectors(t, r);
    const m = go.dot(Qp), p = _o.dot(Qp);
    if (m >= 0 && p <= m)
      return e.copy(r);
    const _ = d * p - m * h;
    if (_ <= 0 && d >= 0 && m <= 0)
      return c = d / (d - m), e.copy(s).addScaledVector(go, c);
    Jp.subVectors(t, l);
    const x = go.dot(Jp), b = _o.dot(Jp);
    if (b >= 0 && x <= b)
      return e.copy(l);
    const M = x * h - d * b;
    if (M <= 0 && h >= 0 && b <= 0)
      return f = h / (h - b), e.copy(s).addScaledVector(_o, f);
    const S = m * b - x * p;
    if (S <= 0 && p - m >= 0 && x - b >= 0)
      return Lx.subVectors(l, r), f = (p - m) / (p - m + (x - b)), e.copy(r).addScaledVector(Lx, f);
    const y = 1 / (S + M + _);
    return c = M * y, f = _ * y, e.copy(s).addScaledVector(go, c).addScaledVector(_o, f);
  }
  equals(t) {
    return t.a.equals(this.a) && t.b.equals(this.b) && t.c.equals(this.c);
  }
}
const LM = {
  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
}, ya = { h: 0, s: 0, l: 0 }, ef = { h: 0, s: 0, l: 0 };
function im(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 we = class {
  constructor(t, e, s) {
    return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(t, e, s);
  }
  set(t, e, s) {
    if (e === void 0 && s === void 0) {
      const r = t;
      r && r.isColor ? this.copy(r) : typeof r == "number" ? this.setHex(r) : typeof r == "string" && this.setStyle(r);
    } else
      this.setRGB(t, e, s);
    return this;
  }
  setScalar(t) {
    return this.r = t, this.g = t, this.b = t, this;
  }
  setHex(t, e = Pi) {
    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, s, r = Ie.workingColorSpace) {
    return this.r = t, this.g = e, this.b = s, Ie.toWorkingColorSpace(this, r), this;
  }
  setHSL(t, e, s, r = Ie.workingColorSpace) {
    if (t = r2(t, 1), e = Ae(e, 0, 1), s = Ae(s, 0, 1), e === 0)
      this.r = this.g = this.b = s;
    else {
      const l = s <= 0.5 ? s * (1 + e) : s + e - s * e, c = 2 * s - l;
      this.r = im(c, l, t + 1 / 3), this.g = im(c, l, t), this.b = im(c, l, t - 1 / 3);
    }
    return Ie.toWorkingColorSpace(this, r), this;
  }
  setStyle(t, e = Pi) {
    function s(l) {
      l !== void 0 && parseFloat(l) < 1 && console.warn("THREE.Color: Alpha component of " + t + " will be ignored.");
    }
    let r;
    if (r = /^(\w+)\(([^\)]*)\)/.exec(t)) {
      let l;
      const c = r[1], f = r[2];
      switch (c) {
        case "rgb":
        case "rgba":
          if (l = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(f))
            return s(l[4]), this.setRGB(
              Math.min(255, parseInt(l[1], 10)) / 255,
              Math.min(255, parseInt(l[2], 10)) / 255,
              Math.min(255, parseInt(l[3], 10)) / 255,
              e
            );
          if (l = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(f))
            return s(l[4]), this.setRGB(
              Math.min(100, parseInt(l[1], 10)) / 100,
              Math.min(100, parseInt(l[2], 10)) / 100,
              Math.min(100, parseInt(l[3], 10)) / 100,
              e
            );
          break;
        case "hsl":
        case "hsla":
          if (l = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(f))
            return s(l[4]), this.setHSL(
              parseFloat(l[1]) / 360,
              parseFloat(l[2]) / 100,
              parseFloat(l[3]) / 100,
              e
            );
          break;
        default:
          console.warn("THREE.Color: Unknown color model " + t);
      }
    } else if (r = /^\#([A-Fa-f\d]+)$/.exec(t)) {
      const l = r[1], c = l.length;
      if (c === 3)
        return this.setRGB(
          parseInt(l.charAt(0), 16) / 15,
          parseInt(l.charAt(1), 16) / 15,
          parseInt(l.charAt(2), 16) / 15,
          e
        );
      if (c === 6)
        return this.setHex(parseInt(l, 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 = Pi) {
    const s = LM[t.toLowerCase()];
    return s !== void 0 ? this.setHex(s, 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 = Bs(t.r), this.g = Bs(t.g), this.b = Bs(t.b), this;
  }
  copyLinearToSRGB(t) {
    return this.r = Bo(t.r), this.g = Bo(t.g), this.b = Bo(t.b), this;
  }
  convertSRGBToLinear() {
    return this.copySRGBToLinear(this), this;
  }
  convertLinearToSRGB() {
    return this.copyLinearToSRGB(this), this;
  }
  getHex(t = Pi) {
    return Ie.fromWorkingColorSpace(Yn.copy(this), t), Math.round(Ae(Yn.r * 255, 0, 255)) * 65536 + Math.round(Ae(Yn.g * 255, 0, 255)) * 256 + Math.round(Ae(Yn.b * 255, 0, 255));
  }
  getHexString(t = Pi) {
    return ("000000" + this.getHex(t).toString(16)).slice(-6);
  }
  getHSL(t, e = Ie.workingColorSpace) {
    Ie.fromWorkingColorSpace(Yn.copy(this), e);
    const s = Yn.r, r = Yn.g, l = Yn.b, c = Math.max(s, r, l), f = Math.min(s, r, l);
    let d, h;
    const m = (f + c) / 2;
    if (f === c)
      d = 0, h = 0;
    else {
      const p = c - f;
      switch (h = m <= 0.5 ? p / (c + f) : p / (2 - c - f), c) {
        case s:
          d = (r - l) / p + (r < l ? 6 : 0);
          break;
        case r:
          d = (l - s) / p + 2;
          break;
        case l:
          d = (s - r) / p + 4;
          break;
      }
      d /= 6;
    }
    return t.h = d, t.s = h, t.l = m, t;
  }
  getRGB(t, e = Ie.workingColorSpace) {
    return Ie.fromWorkingColorSpace(Yn.copy(this), e), t.r = Yn.r, t.g = Yn.g, t.b = Yn.b, t;
  }
  getStyle(t = Pi) {
    Ie.fromWorkingColorSpace(Yn.copy(this), t);
    const e = Yn.r, s = Yn.g, r = Yn.b;
    return t !== Pi ? `color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${r.toFixed(3)})` : `rgb(${Math.round(e * 255)},${Math.round(s * 255)},${Math.round(r * 255)})`;
  }
  offsetHSL(t, e, s) {
    return this.getHSL(ya), this.setHSL(ya.h + t, ya.s + e, ya.l + s);
  }
  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, s) {
    return this.r = t.r + (e.r - t.r) * s, this.g = t.g + (e.g - t.g) * s, this.b = t.b + (e.b - t.b) * s, this;
  }
  lerpHSL(t, e) {
    this.getHSL(ya), t.getHSL(ef);
    const s = Hp(ya.h, ef.h, e), r = Hp(ya.s, ef.s, e), l = Hp(ya.l, ef.l, e);
    return this.setHSL(s, r, l), this;
  }
  setFromVector3(t) {
    return this.r = t.x, this.g = t.y, this.b = t.z, this;
  }
  applyMatrix3(t) {
    const e = this.r, s = this.g, r = this.b, l = t.elements;
    return this.r = l[0] * e + l[3] * s + l[6] * r, this.g = l[1] * e + l[4] * s + l[7] * r, this.b = l[2] * e + l[5] * s + l[8] * r, 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 Yn = /* @__PURE__ */ new we();
we.NAMES = LM;
let T2 = 0;
class Tr extends Mr {
  constructor() {
    super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: T2++ }), this.uuid = Da(), this.name = "", this.type = "Material", this.blending = zo, this.side = Na, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = Im, this.blendDst = Bm, this.blendEquation = cr, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new we(0, 0, 0), this.blendAlpha = 0, this.depthFunc = Vo, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = xx, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = ro, this.stencilZFail = ro, this.stencilZPass = ro, 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 s = t[e];
        if (s === void 0) {
          console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);
          continue;
        }
        const r = this[e];
        if (r === void 0) {
          console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);
          continue;
        }
        r && r.isColor ? r.set(s) : r && r.isVector3 && s && s.isVector3 ? r.copy(s) : this[e] = s;
      }
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string";
    e && (t = {
      textures: {},
      images: {}
    });
    const s = {
      metadata: {
        version: 4.6,
        type: "Material",
        generator: "Material.toJSON"
      }
    };
    s.uuid = this.uuid, s.type = this.type, this.name !== "" && (s.name = this.name), this.color && this.color.isColor && (s.color = this.color.getHex()), this.roughness !== void 0 && (s.roughness = this.roughness), this.metalness !== void 0 && (s.metalness = this.metalness), this.sheen !== void 0 && (s.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (s.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (s.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (s.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (s.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (s.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (s.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (s.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (s.shininess = this.shininess), this.clearcoat !== void 0 && (s.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (s.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (s.clearcoatMap = this.clearcoatMap.toJSON(t).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (s.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(t).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (s.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(t).uuid, s.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.dispersion !== void 0 && (s.dispersion = this.dispersion), this.iridescence !== void 0 && (s.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (s.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (s.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (s.iridescenceMap = this.iridescenceMap.toJSON(t).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (s.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(t).uuid), this.anisotropy !== void 0 && (s.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (s.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (s.anisotropyMap = this.anisotropyMap.toJSON(t).uuid), this.map && this.map.isTexture && (s.map = this.map.toJSON(t).uuid), this.matcap && this.matcap.isTexture && (s.matcap = this.matcap.toJSON(t).uuid), this.alphaMap && this.alphaMap.isTexture && (s.alphaMap = this.alphaMap.toJSON(t).uuid), this.lightMap && this.lightMap.isTexture && (s.lightMap = this.lightMap.toJSON(t).uuid, s.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (s.aoMap = this.aoMap.toJSON(t).uuid, s.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (s.bumpMap = this.bumpMap.toJSON(t).uuid, s.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (s.normalMap = this.normalMap.toJSON(t).uuid, s.normalMapType = this.normalMapType, s.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (s.displacementMap = this.displacementMap.toJSON(t).uuid, s.displacementScale = this.displacementScale, s.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (s.roughnessMap = this.roughnessMap.toJSON(t).uuid), this.metalnessMap && this.metalnessMap.isTexture && (s.metalnessMap = this.metalnessMap.toJSON(t).uuid), this.emissiveMap && this.emissiveMap.isTexture && (s.emissiveMap = this.emissiveMap.toJSON(t).uuid), this.specularMap && this.specularMap.isTexture && (s.specularMap = this.specularMap.toJSON(t).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (s.specularIntensityMap = this.specularIntensityMap.toJSON(t).uuid), this.specularColorMap && this.specularColorMap.isTexture && (s.specularColorMap = this.specularColorMap.toJSON(t).uuid), this.envMap && this.envMap.isTexture && (s.envMap = this.envMap.toJSON(t).uuid, this.combine !== void 0 && (s.combine = this.combine)), this.envMapRotation !== void 0 && (s.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (s.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (s.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (s.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (s.gradientMap = this.gradientMap.toJSON(t).uuid), this.transmission !== void 0 && (s.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (s.transmissionMap = this.transmissionMap.toJSON(t).uuid), this.thickness !== void 0 && (s.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (s.thicknessMap = this.thicknessMap.toJSON(t).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (s.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (s.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (s.size = this.size), this.shadowSide !== null && (s.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (s.sizeAttenuation = this.sizeAttenuation), this.blending !== zo && (s.blending = this.blending), this.side !== Na && (s.side = this.side), this.vertexColors === !0 && (s.vertexColors = !0), this.opacity < 1 && (s.opacity = this.opacity), this.transparent === !0 && (s.transparent = !0), this.blendSrc !== Im && (s.blendSrc = this.blendSrc), this.blendDst !== Bm && (s.blendDst = this.blendDst), this.blendEquation !== cr && (s.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (s.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (s.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (s.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (s.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (s.blendAlpha = this.blendAlpha), this.depthFunc !== Vo && (s.depthFunc = this.depthFunc), this.depthTest === !1 && (s.depthTest = this.depthTest), this.depthWrite === !1 && (s.depthWrite = this.depthWrite), this.colorWrite === !1 && (s.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (s.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== xx && (s.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (s.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (s.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== ro && (s.stencilFail = this.stencilFail), this.stencilZFail !== ro && (s.stencilZFail = this.stencilZFail), this.stencilZPass !== ro && (s.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (s.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (s.rotation = this.rotation), this.polygonOffset === !0 && (s.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (s.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (s.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (s.linewidth = this.linewidth), this.dashSize !== void 0 && (s.dashSize = this.dashSize), this.gapSize !== void 0 && (s.gapSize = this.gapSize), this.scale !== void 0 && (s.scale = this.scale), this.dithering === !0 && (s.dithering = !0), this.alphaTest > 0 && (s.alphaTest = this.alphaTest), this.alphaHash === !0 && (s.alphaHash = !0), this.alphaToCoverage === !0 && (s.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (s.premultipliedAlpha = !0), this.forceSinglePass === !0 && (s.forceSinglePass = !0), this.wireframe === !0 && (s.wireframe = !0), this.wireframeLinewidth > 1 && (s.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (s.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (s.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (s.flatShading = !0), this.visible === !1 && (s.visible = !1), this.toneMapped === !1 && (s.toneMapped = !1), this.fog === !1 && (s.fog = !1), Object.keys(this.userData).length > 0 && (s.userData = this.userData);
    function r(l) {
      const c = [];
      for (const f in l) {
        const d = l[f];
        delete d.metadata, c.push(d);
      }
      return c;
    }
    if (e) {
      const l = r(t.textures), c = r(t.images);
      l.length > 0 && (s.textures = l), c.length > 0 && (s.images = c);
    }
    return s;
  }
  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 s = null;
    if (e !== null) {
      const r = e.length;
      s = new Array(r);
      for (let l = 0; l !== r; ++l)
        s[l] = e[l].clone();
    }
    return this.clippingPlanes = s, 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 pd extends Tr {
  constructor(t) {
    super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new we(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 as(), this.combine = Xg, 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 xn = /* @__PURE__ */ new at(), nf = /* @__PURE__ */ new le();
class ln {
  constructor(t, e, s = !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 = s, this.usage = hr, this.updateRanges = [], this.gpuType = Ii, 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, s) {
    t *= this.itemSize, s *= e.itemSize;
    for (let r = 0, l = this.itemSize; r < l; r++)
      this.array[t + r] = e.array[s + r];
    return this;
  }
  copyArray(t) {
    return this.array.set(t), this;
  }
  applyMatrix3(t) {
    if (this.itemSize === 2)
      for (let e = 0, s = this.count; e < s; e++)
        nf.fromBufferAttribute(this, e), nf.applyMatrix3(t), this.setXY(e, nf.x, nf.y);
    else if (this.itemSize === 3)
      for (let e = 0, s = this.count; e < s; e++)
        xn.fromBufferAttribute(this, e), xn.applyMatrix3(t), this.setXYZ(e, xn.x, xn.y, xn.z);
    return this;
  }
  applyMatrix4(t) {
    for (let e = 0, s = this.count; e < s; e++)
      xn.fromBufferAttribute(this, e), xn.applyMatrix4(t), this.setXYZ(e, xn.x, xn.y, xn.z);
    return this;
  }
  applyNormalMatrix(t) {
    for (let e = 0, s = this.count; e < s; e++)
      xn.fromBufferAttribute(this, e), xn.applyNormalMatrix(t), this.setXYZ(e, xn.x, xn.y, xn.z);
    return this;
  }
  transformDirection(t) {
    for (let e = 0, s = this.count; e < s; e++)
      xn.fromBufferAttribute(this, e), xn.transformDirection(t), this.setXYZ(e, xn.x, xn.y, xn.z);
    return this;
  }
  set(t, e = 0) {
    return this.array.set(t, e), this;
  }
  getComponent(t, e) {
    let s = this.array[t * this.itemSize + e];
    return this.normalized && (s = ns(s, this.array)), s;
  }
  setComponent(t, e, s) {
    return this.normalized && (s = Ye(s, this.array)), this.array[t * this.itemSize + e] = s, this;
  }
  getX(t) {
    let e = this.array[t * this.itemSize];
    return this.normalized && (e = ns(e, this.array)), e;
  }
  setX(t, e) {
    return this.normalized && (e = Ye(e, this.array)), this.array[t * this.itemSize] = e, this;
  }
  getY(t) {
    let e = this.array[t * this.itemSize + 1];
    return this.normalized && (e = ns(e, this.array)), e;
  }
  setY(t, e) {
    return this.normalized && (e = Ye(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 = ns(e, this.array)), e;
  }
  setZ(t, e) {
    return this.normalized && (e = Ye(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 = ns(e, this.array)), e;
  }
  setW(t, e) {
    return this.normalized && (e = Ye(e, this.array)), this.array[t * this.itemSize + 3] = e, this;
  }
  setXY(t, e, s) {
    return t *= this.itemSize, this.normalized && (e = Ye(e, this.array), s = Ye(s, this.array)), this.array[t + 0] = e, this.array[t + 1] = s, this;
  }
  setXYZ(t, e, s, r) {
    return t *= this.itemSize, this.normalized && (e = Ye(e, this.array), s = Ye(s, this.array), r = Ye(r, this.array)), this.array[t + 0] = e, this.array[t + 1] = s, this.array[t + 2] = r, this;
  }
  setXYZW(t, e, s, r, l) {
    return t *= this.itemSize, this.normalized && (e = Ye(e, this.array), s = Ye(s, this.array), r = Ye(r, this.array), l = Ye(l, this.array)), this.array[t + 0] = e, this.array[t + 1] = s, this.array[t + 2] = r, this.array[t + 3] = l, 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 !== hr && (t.usage = this.usage), t;
  }
}
class UM extends ln {
  constructor(t, e, s) {
    super(new Uint16Array(t), e, s);
  }
}
class OM extends ln {
  constructor(t, e, s) {
    super(new Uint32Array(t), e, s);
  }
}
class qn extends ln {
  constructor(t, e, s) {
    super(new Float32Array(t), e, s);
  }
}
let A2 = 0;
const Oi = /* @__PURE__ */ new qe(), sm = /* @__PURE__ */ new Sn(), vo = /* @__PURE__ */ new at(), yi = /* @__PURE__ */ new Er(), $l = /* @__PURE__ */ new Er(), Ln = /* @__PURE__ */ new at();
class Gn extends Mr {
  constructor() {
    super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: A2++ }), this.uuid = Da(), 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 (CM(t) ? OM : UM)(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, s = 0) {
    this.groups.push({
      start: t,
      count: e,
      materialIndex: s
    });
  }
  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 s = this.attributes.normal;
    if (s !== void 0) {
      const l = new _e().getNormalMatrix(t);
      s.applyNormalMatrix(l), s.needsUpdate = !0;
    }
    const r = this.attributes.tangent;
    return r !== void 0 && (r.transformDirection(t), r.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;
  }
  applyQuaternion(t) {
    return Oi.makeRotationFromQuaternion(t), this.applyMatrix4(Oi), this;
  }
  rotateX(t) {
    return Oi.makeRotationX(t), this.applyMatrix4(Oi), this;
  }
  rotateY(t) {
    return Oi.makeRotationY(t), this.applyMatrix4(Oi), this;
  }
  rotateZ(t) {
    return Oi.makeRotationZ(t), this.applyMatrix4(Oi), this;
  }
  translate(t, e, s) {
    return Oi.makeTranslation(t, e, s), this.applyMatrix4(Oi), this;
  }
  scale(t, e, s) {
    return Oi.makeScale(t, e, s), this.applyMatrix4(Oi), this;
  }
  lookAt(t) {
    return sm.lookAt(t), sm.updateMatrix(), this.applyMatrix4(sm.matrix), this;
  }
  center() {
    return this.computeBoundingBox(), this.boundingBox.getCenter(vo).negate(), this.translate(vo.x, vo.y, vo.z), this;
  }
  setFromPoints(t) {
    const e = this.getAttribute("position");
    if (e === void 0) {
      const s = [];
      for (let r = 0, l = t.length; r < l; r++) {
        const c = t[r];
        s.push(c.x, c.y, c.z || 0);
      }
      this.setAttribute("position", new qn(s, 3));
    } else {
      const s = Math.min(t.length, e.count);
      for (let r = 0; r < s; r++) {
        const l = t[r];
        e.setXYZ(r, l.x, l.y, l.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 Er());
    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 at(-1 / 0, -1 / 0, -1 / 0),
        new at(1 / 0, 1 / 0, 1 / 0)
      );
      return;
    }
    if (t !== void 0) {
      if (this.boundingBox.setFromBufferAttribute(t), e)
        for (let s = 0, r = e.length; s < r; s++) {
          const l = e[s];
          yi.setFromBufferAttribute(l), this.morphTargetsRelative ? (Ln.addVectors(this.boundingBox.min, yi.min), this.boundingBox.expandByPoint(Ln), Ln.addVectors(this.boundingBox.max, yi.max), this.boundingBox.expandByPoint(Ln)) : (this.boundingBox.expandByPoint(yi.min), this.boundingBox.expandByPoint(yi.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 nl());
    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 at(), 1 / 0);
      return;
    }
    if (t) {
      const s = this.boundingSphere.center;
      if (yi.setFromBufferAttribute(t), e)
        for (let l = 0, c = e.length; l < c; l++) {
          const f = e[l];
          $l.setFromBufferAttribute(f), this.morphTargetsRelative ? (Ln.addVectors(yi.min, $l.min), yi.expandByPoint(Ln), Ln.addVectors(yi.max, $l.max), yi.expandByPoint(Ln)) : (yi.expandByPoint($l.min), yi.expandByPoint($l.max));
        }
      yi.getCenter(s);
      let r = 0;
      for (let l = 0, c = t.count; l < c; l++)
        Ln.fromBufferAttribute(t, l), r = Math.max(r, s.distanceToSquared(Ln));
      if (e)
        for (let l = 0, c = e.length; l < c; l++) {
          const f = e[l], d = this.morphTargetsRelative;
          for (let h = 0, m = f.count; h < m; h++)
            Ln.fromBufferAttribute(f, h), d && (vo.fromBufferAttribute(t, h), Ln.add(vo)), r = Math.max(r, s.distanceToSquared(Ln));
        }
      this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
    }
  }
  computeTangents() {
    const 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 s = e.position, r = e.normal, l = e.uv;
    this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new ln(new Float32Array(4 * s.count), 4));
    const c = this.getAttribute("tangent"), f = [], d = [];
    for (let z = 0; z < s.count; z++)
      f[z] = new at(), d[z] = new at();
    const h = new at(), m = new at(), p = new at(), _ = new le(), x = new le(), b = new le(), M = new at(), S = new at();
    function y(z, A, R) {
      h.fromBufferAttribute(s, z), m.fromBufferAttribute(s, A), p.fromBufferAttribute(s, R), _.fromBufferAttribute(l, z), x.fromBufferAttribute(l, A), b.fromBufferAttribute(l, R), m.sub(h), p.sub(h), x.sub(_), b.sub(_);
      const L = 1 / (x.x * b.y - b.x * x.y);
      isFinite(L) && (M.copy(m).multiplyScalar(b.y).addScaledVector(p, -x.y).multiplyScalar(L), S.copy(p).multiplyScalar(x.x).addScaledVector(m, -b.x).multiplyScalar(L), f[z].add(M), f[A].add(M), f[R].add(M), d[z].add(S), d[A].add(S), d[R].add(S));
    }
    let C = this.groups;
    C.length === 0 && (C = [{
      start: 0,
      count: t.count
    }]);
    for (let z = 0, A = C.length; z < A; ++z) {
      const R = C[z], L = R.start, H = R.count;
      for (let k = L, P = L + H; k < P; k += 3)
        y(
          t.getX(k + 0),
          t.getX(k + 1),
          t.getX(k + 2)
        );
    }
    const T = new at(), E = new at(), O = new at(), N = new at();
    function D(z) {
      O.fromBufferAttribute(r, z), N.copy(O);
      const A = f[z];
      T.copy(A), T.sub(O.multiplyScalar(O.dot(A))).normalize(), E.crossVectors(N, A);
      const L = E.dot(d[z]) < 0 ? -1 : 1;
      c.setXYZW(z, T.x, T.y, T.z, L);
    }
    for (let z = 0, A = C.length; z < A; ++z) {
      const R = C[z], L = R.start, H = R.count;
      for (let k = L, P = L + H; k < P; k += 3)
        D(t.getX(k + 0)), D(t.getX(k + 1)), D(t.getX(k + 2));
    }
  }
  computeVertexNormals() {
    const t = this.index, e = this.getAttribute("position");
    if (e !== void 0) {
      let s = this.getAttribute("normal");
      if (s === void 0)
        s = new ln(new Float32Array(e.count * 3), 3), this.setAttribute("normal", s);
      else
        for (let _ = 0, x = s.count; _ < x; _++)
          s.setXYZ(_, 0, 0, 0);
      const r = new at(), l = new at(), c = new at(), f = new at(), d = new at(), h = new at(), m = new at(), p = new at();
      if (t)
        for (let _ = 0, x = t.count; _ < x; _ += 3) {
          const b = t.getX(_ + 0), M = t.getX(_ + 1), S = t.getX(_ + 2);
          r.fromBufferAttribute(e, b), l.fromBufferAttribute(e, M), c.fromBufferAttribute(e, S), m.subVectors(c, l), p.subVectors(r, l), m.cross(p), f.fromBufferAttribute(s, b), d.fromBufferAttribute(s, M), h.fromBufferAttribute(s, S), f.add(m), d.add(m), h.add(m), s.setXYZ(b, f.x, f.y, f.z), s.setXYZ(M, d.x, d.y, d.z), s.setXYZ(S, h.x, h.y, h.z);
        }
      else
        for (let _ = 0, x = e.count; _ < x; _ += 3)
          r.fromBufferAttribute(e, _ + 0), l.fromBufferAttribute(e, _ + 1), c.fromBufferAttribute(e, _ + 2), m.subVectors(c, l), p.subVectors(r, l), m.cross(p), s.setXYZ(_ + 0, m.x, m.y, m.z), s.setXYZ(_ + 1, m.x, m.y, m.z), s.setXYZ(_ + 2, m.x, m.y, m.z);
      this.normalizeNormals(), s.needsUpdate = !0;
    }
  }
  normalizeNormals() {
    const t = this.attributes.normal;
    for (let e = 0, s = t.count; e < s; e++)
      Ln.fromBufferAttribute(t, e), Ln.normalize(), t.setXYZ(e, Ln.x, Ln.y, Ln.z);
  }
  toNonIndexed() {
    function t(f, d) {
      const h = f.array, m = f.itemSize, p = f.normalized, _ = new h.constructor(d.length * m);
      let x = 0, b = 0;
      for (let M = 0, S = d.length; M < S; M++) {
        f.isInterleavedBufferAttribute ? x = d[M] * f.data.stride + f.offset : x = d[M] * m;
        for (let y = 0; y < m; y++)
          _[b++] = h[x++];
      }
      return new ln(_, m, p);
    }
    if (this.index === null)
      return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;
    const e = new Gn(), s = this.index.array, r = this.attributes;
    for (const f in r) {
      const d = r[f], h = t(d, s);
      e.setAttribute(f, h);
    }
    const l = this.morphAttributes;
    for (const f in l) {
      const d = [], h = l[f];
      for (let m = 0, p = h.length; m < p; m++) {
        const _ = h[m], x = t(_, s);
        d.push(x);
      }
      e.morphAttributes[f] = d;
    }
    e.morphTargetsRelative = this.morphTargetsRelative;
    const c = this.groups;
    for (let f = 0, d = c.length; f < d; f++) {
      const h = c[f];
      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 s = this.attributes;
    for (const d in s) {
      const h = s[d];
      t.data.attributes[d] = h.toJSON(t.data);
    }
    const r = {};
    let l = !1;
    for (const d in this.morphAttributes) {
      const h = this.morphAttributes[d], m = [];
      for (let p = 0, _ = h.length; p < _; p++) {
        const x = h[p];
        m.push(x.toJSON(t.data));
      }
      m.length > 0 && (r[d] = m, l = !0);
    }
    l && (t.data.morphAttributes = r, t.data.morphTargetsRelative = this.morphTargetsRelative);
    const c = this.groups;
    c.length > 0 && (t.data.groups = JSON.parse(JSON.stringify(c)));
    const f = this.boundingSphere;
    return f !== null && (t.data.boundingSphere = {
      center: f.center.toArray(),
      radius: f.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 s = t.index;
    s !== null && this.setIndex(s.clone(e));
    const r = t.attributes;
    for (const h in r) {
      const m = r[h];
      this.setAttribute(h, m.clone(e));
    }
    const l = t.morphAttributes;
    for (const h in l) {
      const m = [], p = l[h];
      for (let _ = 0, x = p.length; _ < x; _++)
        m.push(p[_].clone(e));
      this.morphAttributes[h] = m;
    }
    this.morphTargetsRelative = t.morphTargetsRelative;
    const c = t.groups;
    for (let h = 0, m = c.length; h < m; h++) {
      const p = c[h];
      this.addGroup(p.start, p.count, p.materialIndex);
    }
    const f = t.boundingBox;
    f !== null && (this.boundingBox = f.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 Ux = /* @__PURE__ */ new qe(), nr = /* @__PURE__ */ new Qg(), sf = /* @__PURE__ */ new nl(), Ox = /* @__PURE__ */ new at(), af = /* @__PURE__ */ new at(), rf = /* @__PURE__ */ new at(), of = /* @__PURE__ */ new at(), am = /* @__PURE__ */ new at(), lf = /* @__PURE__ */ new at(), Px = /* @__PURE__ */ new at(), cf = /* @__PURE__ */ new at();
class Un extends Sn {
  constructor(t = new Gn(), e = new pd()) {
    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, s = Object.keys(e);
    if (s.length > 0) {
      const r = e[s[0]];
      if (r !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let l = 0, c = r.length; l < c; l++) {
          const f = r[l].name || String(l);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[f] = l;
        }
      }
    }
  }
  getVertexPosition(t, e) {
    const s = this.geometry, r = s.attributes.position, l = s.morphAttributes.position, c = s.morphTargetsRelative;
    e.fromBufferAttribute(r, t);
    const f = this.morphTargetInfluences;
    if (l && f) {
      lf.set(0, 0, 0);
      for (let d = 0, h = l.length; d < h; d++) {
        const m = f[d], p = l[d];
        m !== 0 && (am.fromBufferAttribute(p, t), c ? lf.addScaledVector(am, m) : lf.addScaledVector(am.sub(e), m));
      }
      e.add(lf);
    }
    return e;
  }
  raycast(t, e) {
    const s = this.geometry, r = this.material, l = this.matrixWorld;
    r !== void 0 && (s.boundingSphere === null && s.computeBoundingSphere(), sf.copy(s.boundingSphere), sf.applyMatrix4(l), nr.copy(t.ray).recast(t.near), !(sf.containsPoint(nr.origin) === !1 && (nr.intersectSphere(sf, Ox) === null || nr.origin.distanceToSquared(Ox) > (t.far - t.near) ** 2)) && (Ux.copy(l).invert(), nr.copy(t.ray).applyMatrix4(Ux), !(s.boundingBox !== null && nr.intersectsBox(s.boundingBox) === !1) && this._computeIntersections(t, e, nr)));
  }
  _computeIntersections(t, e, s) {
    let r;
    const l = this.geometry, c = this.material, f = l.index, d = l.attributes.position, h = l.attributes.uv, m = l.attributes.uv1, p = l.attributes.normal, _ = l.groups, x = l.drawRange;
    if (f !== null)
      if (Array.isArray(c))
        for (let b = 0, M = _.length; b < M; b++) {
          const S = _[b], y = c[S.materialIndex], C = Math.max(S.start, x.start), T = Math.min(f.count, Math.min(S.start + S.count, x.start + x.count));
          for (let E = C, O = T; E < O; E += 3) {
            const N = f.getX(E), D = f.getX(E + 1), z = f.getX(E + 2);
            r = uf(this, y, t, s, h, m, p, N, D, z), r && (r.faceIndex = Math.floor(E / 3), r.face.materialIndex = S.materialIndex, e.push(r));
          }
        }
      else {
        const b = Math.max(0, x.start), M = Math.min(f.count, x.start + x.count);
        for (let S = b, y = M; S < y; S += 3) {
          const C = f.getX(S), T = f.getX(S + 1), E = f.getX(S + 2);
          r = uf(this, c, t, s, h, m, p, C, T, E), r && (r.faceIndex = Math.floor(S / 3), e.push(r));
        }
      }
    else if (d !== void 0)
      if (Array.isArray(c))
        for (let b = 0, M = _.length; b < M; b++) {
          const S = _[b], y = c[S.materialIndex], C = Math.max(S.start, x.start), T = Math.min(d.count, Math.min(S.start + S.count, x.start + x.count));
          for (let E = C, O = T; E < O; E += 3) {
            const N = E, D = E + 1, z = E + 2;
            r = uf(this, y, t, s, h, m, p, N, D, z), r && (r.faceIndex = Math.floor(E / 3), r.face.materialIndex = S.materialIndex, e.push(r));
          }
        }
      else {
        const b = Math.max(0, x.start), M = Math.min(d.count, x.start + x.count);
        for (let S = b, y = M; S < y; S += 3) {
          const C = S, T = S + 1, E = S + 2;
          r = uf(this, c, t, s, h, m, p, C, T, E), r && (r.faceIndex = Math.floor(S / 3), e.push(r));
        }
      }
  }
}
function w2(n, t, e, s, r, l, c, f) {
  let d;
  if (t.side === li ? d = s.intersectTriangle(c, l, r, !0, f) : d = s.intersectTriangle(r, l, c, t.side === Na, f), d === null) return null;
  cf.copy(f), cf.applyMatrix4(n.matrixWorld);
  const h = e.ray.origin.distanceTo(cf);
  return h < e.near || h > e.far ? null : {
    distance: h,
    point: cf.clone(),
    object: n
  };
}
function uf(n, t, e, s, r, l, c, f, d, h) {
  n.getVertexPosition(f, af), n.getVertexPosition(d, rf), n.getVertexPosition(h, of);
  const m = w2(n, t, e, s, af, rf, of, Px);
  if (m) {
    const p = new at();
    zi.getBarycoord(Px, af, rf, of, p), r && (m.uv = zi.getInterpolatedAttribute(r, f, d, h, p, new le())), l && (m.uv1 = zi.getInterpolatedAttribute(l, f, d, h, p, new le())), c && (m.normal = zi.getInterpolatedAttribute(c, f, d, h, p, new at()), m.normal.dot(s.direction) > 0 && m.normal.multiplyScalar(-1));
    const _ = {
      a: f,
      b: d,
      c: h,
      normal: new at(),
      materialIndex: 0
    };
    zi.getNormal(af, rf, of, _.normal), m.face = _, m.barycoord = p;
  }
  return m;
}
class Rc extends Gn {
  constructor(t = 1, e = 1, s = 1, r = 1, l = 1, c = 1) {
    super(), this.type = "BoxGeometry", this.parameters = {
      width: t,
      height: e,
      depth: s,
      widthSegments: r,
      heightSegments: l,
      depthSegments: c
    };
    const f = this;
    r = Math.floor(r), l = Math.floor(l), c = Math.floor(c);
    const d = [], h = [], m = [], p = [];
    let _ = 0, x = 0;
    b("z", "y", "x", -1, -1, s, e, t, c, l, 0), b("z", "y", "x", 1, -1, s, e, -t, c, l, 1), b("x", "z", "y", 1, 1, t, s, e, r, c, 2), b("x", "z", "y", 1, -1, t, s, -e, r, c, 3), b("x", "y", "z", 1, -1, t, e, s, r, l, 4), b("x", "y", "z", -1, -1, t, e, -s, r, l, 5), this.setIndex(d), this.setAttribute("position", new qn(h, 3)), this.setAttribute("normal", new qn(m, 3)), this.setAttribute("uv", new qn(p, 2));
    function b(M, S, y, C, T, E, O, N, D, z, A) {
      const R = E / D, L = O / z, H = E / 2, k = O / 2, P = N / 2, Y = D + 1, U = z + 1;
      let X = 0, V = 0;
      const W = new at();
      for (let J = 0; J < U; J++) {
        const I = J * L - k;
        for (let q = 0; q < Y; q++) {
          const lt = q * R - H;
          W[M] = lt * C, W[S] = I * T, W[y] = P, h.push(W.x, W.y, W.z), W[M] = 0, W[S] = 0, W[y] = N > 0 ? 1 : -1, m.push(W.x, W.y, W.z), p.push(q / D), p.push(1 - J / z), X += 1;
        }
      }
      for (let J = 0; J < z; J++)
        for (let I = 0; I < D; I++) {
          const q = _ + I + Y * J, lt = _ + I + Y * (J + 1), $ = _ + (I + 1) + Y * (J + 1), ot = _ + (I + 1) + Y * J;
          d.push(q, lt, ot), d.push(lt, $, ot), V += 6;
        }
      f.addGroup(x, V, A), x += V, _ += X;
    }
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new Rc(t.width, t.height, t.depth, t.widthSegments, t.heightSegments, t.depthSegments);
  }
}
function jo(n) {
  const t = {};
  for (const e in n) {
    t[e] = {};
    for (const s in n[e]) {
      const r = n[e][s];
      r && (r.isColor || r.isMatrix3 || r.isMatrix4 || r.isVector2 || r.isVector3 || r.isVector4 || r.isTexture || r.isQuaternion) ? r.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), t[e][s] = null) : t[e][s] = r.clone() : Array.isArray(r) ? t[e][s] = r.slice() : t[e][s] = r;
    }
  }
  return t;
}
function $n(n) {
  const t = {};
  for (let e = 0; e < n.length; e++) {
    const s = jo(n[e]);
    for (const r in s)
      t[r] = s[r];
  }
  return t;
}
function C2(n) {
  const t = [];
  for (let e = 0; e < n.length; e++)
    t.push(n[e].clone());
  return t;
}
function PM(n) {
  const t = n.getRenderTarget();
  return t === null ? n.outputColorSpace : t.isXRRenderTarget === !0 ? t.texture.colorSpace : Ie.workingColorSpace;
}
const R2 = { clone: jo, merge: $n };
var D2 = `void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`, N2 = `void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;
class Vs extends Tr {
  constructor(t) {
    super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = D2, this.fragmentShader = N2, 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 = jo(t.uniforms), this.uniformsGroups = C2(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 r in this.uniforms) {
      const c = this.uniforms[r].value;
      c && c.isTexture ? e.uniforms[r] = {
        type: "t",
        value: c.toJSON(t).uuid
      } : c && c.isColor ? e.uniforms[r] = {
        type: "c",
        value: c.getHex()
      } : c && c.isVector2 ? e.uniforms[r] = {
        type: "v2",
        value: c.toArray()
      } : c && c.isVector3 ? e.uniforms[r] = {
        type: "v3",
        value: c.toArray()
      } : c && c.isVector4 ? e.uniforms[r] = {
        type: "v4",
        value: c.toArray()
      } : c && c.isMatrix3 ? e.uniforms[r] = {
        type: "m3",
        value: c.toArray()
      } : c && c.isMatrix4 ? e.uniforms[r] = {
        type: "m4",
        value: c.toArray()
      } : e.uniforms[r] = {
        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 s = {};
    for (const r in this.extensions)
      this.extensions[r] === !0 && (s[r] = !0);
    return Object.keys(s).length > 0 && (e.extensions = s), e;
  }
}
class zM extends Sn {
  constructor() {
    super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new qe(), this.projectionMatrix = new qe(), this.projectionMatrixInverse = new qe(), this.coordinateSystem = Ps;
  }
  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 xa = /* @__PURE__ */ new at(), zx = /* @__PURE__ */ new le(), Ix = /* @__PURE__ */ new le();
class xi extends zM {
  constructor(t = 50, e = 1, s = 0.1, r = 2e3) {
    super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = t, this.zoom = 1, this.near = s, this.far = r, 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 = bg * 2 * Math.atan(e), this.updateProjectionMatrix();
  }
  /**
   * Calculates the focal length from the current .fov and .filmGauge.
   *
   * @returns {number}
   */
  getFocalLength() {
    const t = Math.tan(Hf * 0.5 * this.fov);
    return 0.5 * this.getFilmHeight() / t;
  }
  getEffectiveFOV() {
    return bg * 2 * Math.atan(
      Math.tan(Hf * 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, s) {
    xa.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), e.set(xa.x, xa.y).multiplyScalar(-t / xa.z), xa.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), s.set(xa.x, xa.y).multiplyScalar(-t / xa.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, zx, Ix), e.subVectors(Ix, zx);
  }
  /**
   * 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, s, r, l, 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 = s, this.view.offsetY = r, this.view.width = l, 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(Hf * 0.5 * this.fov) / this.zoom, s = 2 * e, r = this.aspect * s, l = -0.5 * r;
    const c = this.view;
    if (this.view !== null && this.view.enabled) {
      const d = c.fullWidth, h = c.fullHeight;
      l += c.offsetX * r / d, e -= c.offsetY * s / h, r *= c.width / d, s *= c.height / h;
    }
    const f = this.filmOffset;
    f !== 0 && (l += t * f / this.getFilmWidth()), this.projectionMatrix.makePerspective(l, l + r, e, e - s, 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 yo = -90, xo = 1;
class L2 extends Sn {
  constructor(t, e, s) {
    super(), this.type = "CubeCamera", this.renderTarget = s, this.coordinateSystem = null, this.activeMipmapLevel = 0;
    const r = new xi(yo, xo, t, e);
    r.layers = this.layers, this.add(r);
    const l = new xi(yo, xo, t, e);
    l.layers = this.layers, this.add(l);
    const c = new xi(yo, xo, t, e);
    c.layers = this.layers, this.add(c);
    const f = new xi(yo, xo, t, e);
    f.layers = this.layers, this.add(f);
    const d = new xi(yo, xo, t, e);
    d.layers = this.layers, this.add(d);
    const h = new xi(yo, xo, t, e);
    h.layers = this.layers, this.add(h);
  }
  updateCoordinateSystem() {
    const t = this.coordinateSystem, e = this.children.concat(), [s, r, l, c, f, d] = e;
    for (const h of e) this.remove(h);
    if (t === Ps)
      s.up.set(0, 1, 0), s.lookAt(1, 0, 0), r.up.set(0, 1, 0), r.lookAt(-1, 0, 0), l.up.set(0, 0, -1), l.lookAt(0, 1, 0), c.up.set(0, 0, 1), c.lookAt(0, -1, 0), f.up.set(0, 1, 0), f.lookAt(0, 0, 1), d.up.set(0, 1, 0), d.lookAt(0, 0, -1);
    else if (t === $f)
      s.up.set(0, -1, 0), s.lookAt(-1, 0, 0), r.up.set(0, -1, 0), r.lookAt(1, 0, 0), l.up.set(0, 0, 1), l.lookAt(0, 1, 0), c.up.set(0, 0, -1), c.lookAt(0, -1, 0), f.up.set(0, -1, 0), f.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: s, activeMipmapLevel: r } = this;
    this.coordinateSystem !== t.coordinateSystem && (this.coordinateSystem = t.coordinateSystem, this.updateCoordinateSystem());
    const [l, c, f, d, h, m] = this.children, p = t.getRenderTarget(), _ = t.getActiveCubeFace(), x = t.getActiveMipmapLevel(), b = t.xr.enabled;
    t.xr.enabled = !1;
    const M = s.texture.generateMipmaps;
    s.texture.generateMipmaps = !1, t.setRenderTarget(s, 0, r), t.render(e, l), t.setRenderTarget(s, 1, r), t.render(e, c), t.setRenderTarget(s, 2, r), t.render(e, f), t.setRenderTarget(s, 3, r), t.render(e, d), t.setRenderTarget(s, 4, r), t.render(e, h), s.texture.generateMipmaps = M, t.setRenderTarget(s, 5, r), t.render(e, m), t.setRenderTarget(p, _, x), t.xr.enabled = b, s.texture.needsPMREMUpdate = !0;
  }
}
class IM extends jn {
  constructor(t, e, s, r, l, c, f, d, h, m) {
    t = t !== void 0 ? t : [], e = e !== void 0 ? e : Go, super(t, e, s, r, l, c, f, d, h, m), this.isCubeTexture = !0, this.flipY = !1;
  }
  get images() {
    return this.image;
  }
  set images(t) {
    this.image = t;
  }
}
class U2 extends vr {
  constructor(t = 1, e = {}) {
    super(t, t, e), this.isWebGLCubeRenderTarget = !0;
    const s = { width: t, height: t, depth: 1 }, r = [s, s, s, s, s, s];
    this.texture = new IM(r, 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 : is;
  }
  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 s = {
      uniforms: {
        tEquirect: { value: null }
      },
      vertexShader: (
        /* glsl */
        `

				varying vec3 vWorldDirection;

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

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

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

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

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`
      )
    }, r = new Rc(5, 5, 5), l = new Vs({
      name: "CubemapFromEquirect",
      uniforms: jo(s.uniforms),
      vertexShader: s.vertexShader,
      fragmentShader: s.fragmentShader,
      side: li,
      blending: Ca
    });
    l.uniforms.tEquirect.value = e;
    const c = new Un(r, l), f = e.minFilter;
    return e.minFilter === dr && (e.minFilter = is), new L2(1, 10, this).update(t, c), e.minFilter = f, c.geometry.dispose(), c.material.dispose(), this;
  }
  clear(t, e, s, r) {
    const l = t.getRenderTarget();
    for (let c = 0; c < 6; c++)
      t.setRenderTarget(this, c), t.clear(e, s, r);
    t.setRenderTarget(l);
  }
}
class BM extends Sn {
  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 as(), this.environmentIntensity = 1, this.environmentRotation = new as(), 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 O2 {
  constructor(t, e) {
    this.isInterleavedBuffer = !0, this.array = t, this.stride = e, this.count = t !== void 0 ? t.length / e : 0, this.usage = hr, this.updateRanges = [], this.version = 0, this.uuid = Da();
  }
  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, s) {
    t *= this.stride, s *= e.stride;
    for (let r = 0, l = this.stride; r < l; r++)
      this.array[t + r] = e.array[s + r];
    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 = Da()), 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]), s = new this.constructor(e, this.stride);
    return s.setUsage(this.usage), s;
  }
  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 = Da()), 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 Kn = /* @__PURE__ */ new at();
class Jf {
  constructor(t, e, s, r = !1) {
    this.isInterleavedBufferAttribute = !0, this.name = "", this.data = t, this.itemSize = e, this.offset = s, this.normalized = r;
  }
  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, s = this.data.count; e < s; e++)
      Kn.fromBufferAttribute(this, e), Kn.applyMatrix4(t), this.setXYZ(e, Kn.x, Kn.y, Kn.z);
    return this;
  }
  applyNormalMatrix(t) {
    for (let e = 0, s = this.count; e < s; e++)
      Kn.fromBufferAttribute(this, e), Kn.applyNormalMatrix(t), this.setXYZ(e, Kn.x, Kn.y, Kn.z);
    return this;
  }
  transformDirection(t) {
    for (let e = 0, s = this.count; e < s; e++)
      Kn.fromBufferAttribute(this, e), Kn.transformDirection(t), this.setXYZ(e, Kn.x, Kn.y, Kn.z);
    return this;
  }
  getComponent(t, e) {
    let s = this.array[t * this.data.stride + this.offset + e];
    return this.normalized && (s = ns(s, this.array)), s;
  }
  setComponent(t, e, s) {
    return this.normalized && (s = Ye(s, this.array)), this.data.array[t * this.data.stride + this.offset + e] = s, this;
  }
  setX(t, e) {
    return this.normalized && (e = Ye(e, this.array)), this.data.array[t * this.data.stride + this.offset] = e, this;
  }
  setY(t, e) {
    return this.normalized && (e = Ye(e, this.array)), this.data.array[t * this.data.stride + this.offset + 1] = e, this;
  }
  setZ(t, e) {
    return this.normalized && (e = Ye(e, this.array)), this.data.array[t * this.data.stride + this.offset + 2] = e, this;
  }
  setW(t, e) {
    return this.normalized && (e = Ye(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 = ns(e, this.array)), e;
  }
  getY(t) {
    let e = this.data.array[t * this.data.stride + this.offset + 1];
    return this.normalized && (e = ns(e, this.array)), e;
  }
  getZ(t) {
    let e = this.data.array[t * this.data.stride + this.offset + 2];
    return this.normalized && (e = ns(e, this.array)), e;
  }
  getW(t) {
    let e = this.data.array[t * this.data.stride + this.offset + 3];
    return this.normalized && (e = ns(e, this.array)), e;
  }
  setXY(t, e, s) {
    return t = t * this.data.stride + this.offset, this.normalized && (e = Ye(e, this.array), s = Ye(s, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = s, this;
  }
  setXYZ(t, e, s, r) {
    return t = t * this.data.stride + this.offset, this.normalized && (e = Ye(e, this.array), s = Ye(s, this.array), r = Ye(r, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = s, this.data.array[t + 2] = r, this;
  }
  setXYZW(t, e, s, r, l) {
    return t = t * this.data.stride + this.offset, this.normalized && (e = Ye(e, this.array), s = Ye(s, this.array), r = Ye(r, this.array), l = Ye(l, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = s, this.data.array[t + 2] = r, this.data.array[t + 3] = l, 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 s = 0; s < this.count; s++) {
        const r = s * this.data.stride + this.offset;
        for (let l = 0; l < this.itemSize; l++)
          e.push(this.data.array[r + l]);
      }
      return new ln(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 Jf(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 s = 0; s < this.count; s++) {
        const r = s * this.data.stride + this.offset;
        for (let l = 0; l < this.itemSize; l++)
          e.push(this.data.array[r + l]);
      }
      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 Mg extends Tr {
  constructor(t) {
    super(), this.isSpriteMaterial = !0, this.type = "SpriteMaterial", this.color = new we(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 So;
const Ql = /* @__PURE__ */ new at(), bo = /* @__PURE__ */ new at(), Mo = /* @__PURE__ */ new at(), Eo = /* @__PURE__ */ new le(), Jl = /* @__PURE__ */ new le(), FM = /* @__PURE__ */ new qe(), ff = /* @__PURE__ */ new at(), tc = /* @__PURE__ */ new at(), df = /* @__PURE__ */ new at(), Bx = /* @__PURE__ */ new le(), rm = /* @__PURE__ */ new le(), Fx = /* @__PURE__ */ new le();
class om extends Sn {
  constructor(t = new Mg()) {
    if (super(), this.isSprite = !0, this.type = "Sprite", So === void 0) {
      So = new Gn();
      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
      ]), s = new O2(e, 5);
      So.setIndex([0, 1, 2, 0, 2, 3]), So.setAttribute("position", new Jf(s, 3, 0, !1)), So.setAttribute("uv", new Jf(s, 2, 3, !1));
    }
    this.geometry = So, this.material = t, this.center = new le(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.'), bo.setFromMatrixScale(this.matrixWorld), FM.copy(t.camera.matrixWorld), this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse, this.matrixWorld), Mo.setFromMatrixPosition(this.modelViewMatrix), t.camera.isPerspectiveCamera && this.material.sizeAttenuation === !1 && bo.multiplyScalar(-Mo.z);
    const s = this.material.rotation;
    let r, l;
    s !== 0 && (l = Math.cos(s), r = Math.sin(s));
    const c = this.center;
    hf(ff.set(-0.5, -0.5, 0), Mo, c, bo, r, l), hf(tc.set(0.5, -0.5, 0), Mo, c, bo, r, l), hf(df.set(0.5, 0.5, 0), Mo, c, bo, r, l), Bx.set(0, 0), rm.set(1, 0), Fx.set(1, 1);
    let f = t.ray.intersectTriangle(ff, tc, df, !1, Ql);
    if (f === null && (hf(tc.set(-0.5, 0.5, 0), Mo, c, bo, r, l), rm.set(0, 1), f = t.ray.intersectTriangle(ff, df, tc, !1, Ql), f === null))
      return;
    const d = t.ray.origin.distanceTo(Ql);
    d < t.near || d > t.far || e.push({
      distance: d,
      point: Ql.clone(),
      uv: zi.getInterpolation(Ql, ff, tc, df, Bx, rm, Fx, new le()),
      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 hf(n, t, e, s, r, l) {
  Eo.subVectors(n, e).addScalar(0.5).multiply(s), r !== void 0 ? (Jl.x = l * Eo.x - r * Eo.y, Jl.y = r * Eo.x + l * Eo.y) : Jl.copy(Eo), n.copy(t), n.x += Jl.x, n.y += Jl.y, n.applyMatrix4(FM);
}
class Eg extends jn {
  constructor(t = null, e = 1, s = 1, r, l, c, f, d, h = Vn, m = Vn, p, _) {
    super(null, c, f, d, h, m, r, l, p, _), this.isDataTexture = !0, this.image = { data: t, width: e, height: s }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class wn extends ln {
  constructor(t, e, s, r = 1) {
    super(t, e, s), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = r;
  }
  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 To = /* @__PURE__ */ new qe(), Hx = /* @__PURE__ */ new qe(), pf = [], Vx = /* @__PURE__ */ new Er(), P2 = /* @__PURE__ */ new qe(), ec = /* @__PURE__ */ new Un(), nc = /* @__PURE__ */ new nl();
class Gx extends Un {
  constructor(t, e, s) {
    super(t, e), this.isInstancedMesh = !0, this.instanceMatrix = new wn(new Float32Array(s * 16), 16), this.instanceColor = null, this.morphTexture = null, this.count = s, this.boundingBox = null, this.boundingSphere = null;
    for (let r = 0; r < s; r++)
      this.setMatrixAt(r, P2);
  }
  computeBoundingBox() {
    const t = this.geometry, e = this.count;
    this.boundingBox === null && (this.boundingBox = new Er()), t.boundingBox === null && t.computeBoundingBox(), this.boundingBox.makeEmpty();
    for (let s = 0; s < e; s++)
      this.getMatrixAt(s, To), Vx.copy(t.boundingBox).applyMatrix4(To), this.boundingBox.union(Vx);
  }
  computeBoundingSphere() {
    const t = this.geometry, e = this.count;
    this.boundingSphere === null && (this.boundingSphere = new nl()), t.boundingSphere === null && t.computeBoundingSphere(), this.boundingSphere.makeEmpty();
    for (let s = 0; s < e; s++)
      this.getMatrixAt(s, To), nc.copy(t.boundingSphere).applyMatrix4(To), this.boundingSphere.union(nc);
  }
  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 s = e.morphTargetInfluences, r = this.morphTexture.source.data.data, l = s.length + 1, c = t * l + 1;
    for (let f = 0; f < s.length; f++)
      s[f] = r[c + f];
  }
  raycast(t, e) {
    const s = this.matrixWorld, r = this.count;
    if (ec.geometry = this.geometry, ec.material = this.material, ec.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), nc.copy(this.boundingSphere), nc.applyMatrix4(s), t.ray.intersectsSphere(nc) !== !1))
      for (let l = 0; l < r; l++) {
        this.getMatrixAt(l, To), Hx.multiplyMatrices(s, To), ec.matrixWorld = Hx, ec.raycast(t, pf);
        for (let c = 0, f = pf.length; c < f; c++) {
          const d = pf[c];
          d.instanceId = l, d.object = this, e.push(d);
        }
        pf.length = 0;
      }
  }
  setColorAt(t, e) {
    this.instanceColor === null && (this.instanceColor = new wn(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 s = e.morphTargetInfluences, r = s.length + 1;
    this.morphTexture === null && (this.morphTexture = new Eg(new Float32Array(r * this.count), r, this.count, qg, Ii));
    const l = this.morphTexture.source.data.data;
    let c = 0;
    for (let h = 0; h < s.length; h++)
      c += s[h];
    const f = this.geometry.morphTargetsRelative ? 1 : 1 - c, d = r * t;
    l[d] = f, l.set(s, d + 1);
  }
  updateMorphTargets() {
  }
  dispose() {
    return this.dispatchEvent({ type: "dispose" }), this.morphTexture !== null && (this.morphTexture.dispose(), this.morphTexture = null), this;
  }
}
const lm = /* @__PURE__ */ new at(), z2 = /* @__PURE__ */ new at(), I2 = /* @__PURE__ */ new _e();
class Ea {
  constructor(t = new at(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, s, r) {
    return this.normal.set(t, e, s), this.constant = r, this;
  }
  setFromNormalAndCoplanarPoint(t, e) {
    return this.normal.copy(t), this.constant = -e.dot(this.normal), this;
  }
  setFromCoplanarPoints(t, e, s) {
    const r = lm.subVectors(s, e).cross(z2.subVectors(t, e)).normalize();
    return this.setFromNormalAndCoplanarPoint(r, 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 s = t.delta(lm), r = this.normal.dot(s);
    if (r === 0)
      return this.distanceToPoint(t.start) === 0 ? e.copy(t.start) : null;
    const l = -(t.start.dot(this.normal) + this.constant) / r;
    return l < 0 || l > 1 ? null : e.copy(t.start).addScaledVector(s, l);
  }
  intersectsLine(t) {
    const e = this.distanceToPoint(t.start), s = this.distanceToPoint(t.end);
    return e < 0 && s > 0 || s < 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 s = e || I2.getNormalMatrix(t), r = this.coplanarPoint(lm).applyMatrix4(t), l = this.normal.applyMatrix3(s).normalize();
    return this.constant = -r.dot(l), 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 ir = /* @__PURE__ */ new nl(), mf = /* @__PURE__ */ new at();
class Jg {
  constructor(t = new Ea(), e = new Ea(), s = new Ea(), r = new Ea(), l = new Ea(), c = new Ea()) {
    this.planes = [t, e, s, r, l, c];
  }
  set(t, e, s, r, l, c) {
    const f = this.planes;
    return f[0].copy(t), f[1].copy(e), f[2].copy(s), f[3].copy(r), f[4].copy(l), f[5].copy(c), this;
  }
  copy(t) {
    const e = this.planes;
    for (let s = 0; s < 6; s++)
      e[s].copy(t.planes[s]);
    return this;
  }
  setFromProjectionMatrix(t, e = Ps) {
    const s = this.planes, r = t.elements, l = r[0], c = r[1], f = r[2], d = r[3], h = r[4], m = r[5], p = r[6], _ = r[7], x = r[8], b = r[9], M = r[10], S = r[11], y = r[12], C = r[13], T = r[14], E = r[15];
    if (s[0].setComponents(d - l, _ - h, S - x, E - y).normalize(), s[1].setComponents(d + l, _ + h, S + x, E + y).normalize(), s[2].setComponents(d + c, _ + m, S + b, E + C).normalize(), s[3].setComponents(d - c, _ - m, S - b, E - C).normalize(), s[4].setComponents(d - f, _ - p, S - M, E - T).normalize(), e === Ps)
      s[5].setComponents(d + f, _ + p, S + M, E + T).normalize();
    else if (e === $f)
      s[5].setComponents(f, p, M, T).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(), ir.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);
    else {
      const e = t.geometry;
      e.boundingSphere === null && e.computeBoundingSphere(), ir.copy(e.boundingSphere).applyMatrix4(t.matrixWorld);
    }
    return this.intersectsSphere(ir);
  }
  intersectsSprite(t) {
    return ir.center.set(0, 0, 0), ir.radius = 0.7071067811865476, ir.applyMatrix4(t.matrixWorld), this.intersectsSphere(ir);
  }
  intersectsSphere(t) {
    const e = this.planes, s = t.center, r = -t.radius;
    for (let l = 0; l < 6; l++)
      if (e[l].distanceToPoint(s) < r)
        return !1;
    return !0;
  }
  intersectsBox(t) {
    const e = this.planes;
    for (let s = 0; s < 6; s++) {
      const r = e[s];
      if (mf.x = r.normal.x > 0 ? t.max.x : t.min.x, mf.y = r.normal.y > 0 ? t.max.y : t.min.y, mf.z = r.normal.z > 0 ? t.max.z : t.min.z, r.distanceToPoint(mf) < 0)
        return !1;
    }
    return !0;
  }
  containsPoint(t) {
    const e = this.planes;
    for (let s = 0; s < 6; s++)
      if (e[s].distanceToPoint(t) < 0)
        return !1;
    return !0;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Dc extends Tr {
  constructor(t) {
    super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new we(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 td = /* @__PURE__ */ new at(), ed = /* @__PURE__ */ new at(), kx = /* @__PURE__ */ new qe(), ic = /* @__PURE__ */ new Qg(), gf = /* @__PURE__ */ new nl(), cm = /* @__PURE__ */ new at(), Xx = /* @__PURE__ */ new at();
class mc extends Sn {
  constructor(t = new Gn(), e = new Dc()) {
    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, s = [0];
      for (let r = 1, l = e.count; r < l; r++)
        td.fromBufferAttribute(e, r - 1), ed.fromBufferAttribute(e, r), s[r] = s[r - 1], s[r] += td.distanceTo(ed);
      t.setAttribute("lineDistance", new qn(s, 1));
    } else
      console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
  raycast(t, e) {
    const s = this.geometry, r = this.matrixWorld, l = t.params.Line.threshold, c = s.drawRange;
    if (s.boundingSphere === null && s.computeBoundingSphere(), gf.copy(s.boundingSphere), gf.applyMatrix4(r), gf.radius += l, t.ray.intersectsSphere(gf) === !1) return;
    kx.copy(r).invert(), ic.copy(t.ray).applyMatrix4(kx);
    const f = l / ((this.scale.x + this.scale.y + this.scale.z) / 3), d = f * f, h = this.isLineSegments ? 2 : 1, m = s.index, _ = s.attributes.position;
    if (m !== null) {
      const x = Math.max(0, c.start), b = Math.min(m.count, c.start + c.count);
      for (let M = x, S = b - 1; M < S; M += h) {
        const y = m.getX(M), C = m.getX(M + 1), T = _f(this, t, ic, d, y, C);
        T && e.push(T);
      }
      if (this.isLineLoop) {
        const M = m.getX(b - 1), S = m.getX(x), y = _f(this, t, ic, d, M, S);
        y && e.push(y);
      }
    } else {
      const x = Math.max(0, c.start), b = Math.min(_.count, c.start + c.count);
      for (let M = x, S = b - 1; M < S; M += h) {
        const y = _f(this, t, ic, d, M, M + 1);
        y && e.push(y);
      }
      if (this.isLineLoop) {
        const M = _f(this, t, ic, d, b - 1, x);
        M && e.push(M);
      }
    }
  }
  updateMorphTargets() {
    const e = this.geometry.morphAttributes, s = Object.keys(e);
    if (s.length > 0) {
      const r = e[s[0]];
      if (r !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let l = 0, c = r.length; l < c; l++) {
          const f = r[l].name || String(l);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[f] = l;
        }
      }
    }
  }
}
function _f(n, t, e, s, r, l) {
  const c = n.geometry.attributes.position;
  if (td.fromBufferAttribute(c, r), ed.fromBufferAttribute(c, l), e.distanceSqToSegment(td, ed, cm, Xx) > s) return;
  cm.applyMatrix4(n.matrixWorld);
  const d = t.ray.origin.distanceTo(cm);
  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: Xx.clone().applyMatrix4(n.matrixWorld),
      index: r,
      face: null,
      faceIndex: null,
      barycoord: null,
      object: n
    };
}
const Wx = /* @__PURE__ */ new at(), Yx = /* @__PURE__ */ new at();
class HM extends mc {
  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, s = [];
      for (let r = 0, l = e.count; r < l; r += 2)
        Wx.fromBufferAttribute(e, r), Yx.fromBufferAttribute(e, r + 1), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + Wx.distanceTo(Yx);
      t.setAttribute("lineDistance", new qn(s, 1));
    } else
      console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
}
class wa extends Sn {
  constructor() {
    super(), this.isGroup = !0, this.type = "Group";
  }
}
class B2 extends jn {
  constructor(t, e, s, r, l, c, f, d, h) {
    super(t, e, s, r, l, c, f, d, h), this.isCanvasTexture = !0, this.needsUpdate = !0;
  }
}
class VM extends jn {
  constructor(t, e, s, r, l, c, f, d, h, m = Io) {
    if (m !== Io && m !== Wo)
      throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
    s === void 0 && m === Io && (s = _r), s === void 0 && m === Wo && (s = Xo), super(null, r, l, c, f, d, m, s, h), this.isDepthTexture = !0, this.image = { width: t, height: e }, this.magFilter = f !== void 0 ? f : Vn, this.minFilter = d !== void 0 ? d : Vn, 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 Nc extends Gn {
  constructor(t = 1, e = 1, s = 1, r = 32, l = 1, c = !1, f = 0, d = Math.PI * 2) {
    super(), this.type = "CylinderGeometry", this.parameters = {
      radiusTop: t,
      radiusBottom: e,
      height: s,
      radialSegments: r,
      heightSegments: l,
      openEnded: c,
      thetaStart: f,
      thetaLength: d
    };
    const h = this;
    r = Math.floor(r), l = Math.floor(l);
    const m = [], p = [], _ = [], x = [];
    let b = 0;
    const M = [], S = s / 2;
    let y = 0;
    C(), c === !1 && (t > 0 && T(!0), e > 0 && T(!1)), this.setIndex(m), this.setAttribute("position", new qn(p, 3)), this.setAttribute("normal", new qn(_, 3)), this.setAttribute("uv", new qn(x, 2));
    function C() {
      const E = new at(), O = new at();
      let N = 0;
      const D = (e - t) / s;
      for (let z = 0; z <= l; z++) {
        const A = [], R = z / l, L = R * (e - t) + t;
        for (let H = 0; H <= r; H++) {
          const k = H / r, P = k * d + f, Y = Math.sin(P), U = Math.cos(P);
          O.x = L * Y, O.y = -R * s + S, O.z = L * U, p.push(O.x, O.y, O.z), E.set(Y, D, U).normalize(), _.push(E.x, E.y, E.z), x.push(k, 1 - R), A.push(b++);
        }
        M.push(A);
      }
      for (let z = 0; z < r; z++)
        for (let A = 0; A < l; A++) {
          const R = M[A][z], L = M[A + 1][z], H = M[A + 1][z + 1], k = M[A][z + 1];
          (t > 0 || A !== 0) && (m.push(R, L, k), N += 3), (e > 0 || A !== l - 1) && (m.push(L, H, k), N += 3);
        }
      h.addGroup(y, N, 0), y += N;
    }
    function T(E) {
      const O = b, N = new le(), D = new at();
      let z = 0;
      const A = E === !0 ? t : e, R = E === !0 ? 1 : -1;
      for (let H = 1; H <= r; H++)
        p.push(0, S * R, 0), _.push(0, R, 0), x.push(0.5, 0.5), b++;
      const L = b;
      for (let H = 0; H <= r; H++) {
        const P = H / r * d + f, Y = Math.cos(P), U = Math.sin(P);
        D.x = A * U, D.y = S * R, D.z = A * Y, p.push(D.x, D.y, D.z), _.push(0, R, 0), N.x = Y * 0.5 + 0.5, N.y = U * 0.5 * R + 0.5, x.push(N.x, N.y), b++;
      }
      for (let H = 0; H < r; H++) {
        const k = O + H, P = L + H;
        E === !0 ? m.push(P, P + 1, k) : m.push(P + 1, P, k), z += 3;
      }
      h.addGroup(y, z, E === !0 ? 1 : 2), y += z;
    }
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new Nc(t.radiusTop, t.radiusBottom, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength);
  }
}
class t0 extends Nc {
  constructor(t = 1, e = 1, s = 32, r = 1, l = !1, c = 0, f = Math.PI * 2) {
    super(0, t, e, s, r, l, c, f), this.type = "ConeGeometry", this.parameters = {
      radius: t,
      height: e,
      radialSegments: s,
      heightSegments: r,
      openEnded: l,
      thetaStart: c,
      thetaLength: f
    };
  }
  static fromJSON(t) {
    return new t0(t.radius, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength);
  }
}
class md extends Gn {
  constructor(t = 1, e = 1, s = 1, r = 1) {
    super(), this.type = "PlaneGeometry", this.parameters = {
      width: t,
      height: e,
      widthSegments: s,
      heightSegments: r
    };
    const l = t / 2, c = e / 2, f = Math.floor(s), d = Math.floor(r), h = f + 1, m = d + 1, p = t / f, _ = e / d, x = [], b = [], M = [], S = [];
    for (let y = 0; y < m; y++) {
      const C = y * _ - c;
      for (let T = 0; T < h; T++) {
        const E = T * p - l;
        b.push(E, -C, 0), M.push(0, 0, 1), S.push(T / f), S.push(1 - y / d);
      }
    }
    for (let y = 0; y < d; y++)
      for (let C = 0; C < f; C++) {
        const T = C + h * y, E = C + h * (y + 1), O = C + 1 + h * (y + 1), N = C + 1 + h * y;
        x.push(T, E, N), x.push(E, O, N);
      }
    this.setIndex(x), this.setAttribute("position", new qn(b, 3)), this.setAttribute("normal", new qn(M, 3)), this.setAttribute("uv", new qn(S, 2));
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new md(t.width, t.height, t.widthSegments, t.heightSegments);
  }
}
class e0 extends Gn {
  constructor(t = 1, e = 32, s = 16, r = 0, l = Math.PI * 2, c = 0, f = Math.PI) {
    super(), this.type = "SphereGeometry", this.parameters = {
      radius: t,
      widthSegments: e,
      heightSegments: s,
      phiStart: r,
      phiLength: l,
      thetaStart: c,
      thetaLength: f
    }, e = Math.max(3, Math.floor(e)), s = Math.max(2, Math.floor(s));
    const d = Math.min(c + f, Math.PI);
    let h = 0;
    const m = [], p = new at(), _ = new at(), x = [], b = [], M = [], S = [];
    for (let y = 0; y <= s; y++) {
      const C = [], T = y / s;
      let E = 0;
      y === 0 && c === 0 ? E = 0.5 / e : y === s && d === Math.PI && (E = -0.5 / e);
      for (let O = 0; O <= e; O++) {
        const N = O / e;
        p.x = -t * Math.cos(r + N * l) * Math.sin(c + T * f), p.y = t * Math.cos(c + T * f), p.z = t * Math.sin(r + N * l) * Math.sin(c + T * f), b.push(p.x, p.y, p.z), _.copy(p).normalize(), M.push(_.x, _.y, _.z), S.push(N + E, 1 - T), C.push(h++);
      }
      m.push(C);
    }
    for (let y = 0; y < s; y++)
      for (let C = 0; C < e; C++) {
        const T = m[y][C + 1], E = m[y][C], O = m[y + 1][C], N = m[y + 1][C + 1];
        (y !== 0 || c > 0) && x.push(T, E, N), (y !== s - 1 || d < Math.PI) && x.push(E, O, N);
      }
    this.setIndex(x), this.setAttribute("position", new qn(b, 3)), this.setAttribute("normal", new qn(M, 3)), this.setAttribute("uv", new qn(S, 2));
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new e0(t.radius, t.widthSegments, t.heightSegments, t.phiStart, t.phiLength, t.thetaStart, t.thetaLength);
  }
}
class GM extends Vs {
  constructor(t) {
    super(t), this.isRawShaderMaterial = !0, this.type = "RawShaderMaterial";
  }
}
class Tg extends Tr {
  constructor(t) {
    super(), this.isMeshPhongMaterial = !0, this.type = "MeshPhongMaterial", this.color = new we(16777215), this.specular = new we(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new we(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = AM, this.normalScale = new le(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new as(), this.combine = Xg, 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 F2 extends Tr {
  constructor(t) {
    super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = Kw, 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 H2 extends Tr {
  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 n0 extends Sn {
  constructor(t, e = 1) {
    super(), this.isLight = !0, this.type = "Light", this.color = new we(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 V2 extends n0 {
  constructor(t, e, s) {
    super(t, s), this.isHemisphereLight = !0, this.type = "HemisphereLight", this.position.copy(Sn.DEFAULT_UP), this.updateMatrix(), this.groundColor = new we(e);
  }
  copy(t, e) {
    return super.copy(t, e), this.groundColor.copy(t.groundColor), this;
  }
}
const um = /* @__PURE__ */ new qe(), jx = /* @__PURE__ */ new at(), qx = /* @__PURE__ */ new at();
class G2 {
  constructor(t) {
    this.camera = t, this.intensity = 1, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new le(512, 512), this.map = null, this.mapPass = null, this.matrix = new qe(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new Jg(), this._frameExtents = new le(1, 1), this._viewportCount = 1, this._viewports = [
      new on(0, 0, 1, 1)
    ];
  }
  getViewportCount() {
    return this._viewportCount;
  }
  getFrustum() {
    return this._frustum;
  }
  updateMatrices(t) {
    const e = this.camera, s = this.matrix;
    jx.setFromMatrixPosition(t.matrixWorld), e.position.copy(jx), qx.setFromMatrixPosition(t.target.matrixWorld), e.lookAt(qx), e.updateMatrixWorld(), um.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), this._frustum.setFromProjectionMatrix(um), s.set(
      0.5,
      0,
      0,
      0.5,
      0,
      0.5,
      0,
      0.5,
      0,
      0,
      0.5,
      0.5,
      0,
      0,
      0,
      1
    ), s.multiply(um);
  }
  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 zs extends zM {
  constructor(t = -1, e = 1, s = 1, r = -1, l = 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 = s, this.bottom = r, this.near = l, 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, s, r, l, 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 = s, this.view.offsetY = r, this.view.width = l, 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), s = (this.right + this.left) / 2, r = (this.top + this.bottom) / 2;
    let l = s - t, c = s + t, f = r + e, d = r - e;
    if (this.view !== null && this.view.enabled) {
      const h = (this.right - this.left) / this.view.fullWidth / this.zoom, m = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
      l += h * this.view.offsetX, c = l + h * this.view.width, f -= m * this.view.offsetY, d = f - m * this.view.height;
    }
    this.projectionMatrix.makeOrthographic(l, c, f, 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 k2 extends G2 {
  constructor() {
    super(new zs(-5, 5, 5, -5, 0.5, 500)), this.isDirectionalLightShadow = !0;
  }
}
class Vf extends n0 {
  constructor(t, e) {
    super(t, e), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(Sn.DEFAULT_UP), this.updateMatrix(), this.target = new Sn(), this.shadow = new k2();
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(t) {
    return super.copy(t), this.target = t.target.clone(), this.shadow = t.shadow.clone(), this;
  }
}
class X2 extends n0 {
  constructor(t, e) {
    super(t, e), this.isAmbientLight = !0, this.type = "AmbientLight";
  }
}
class kM extends Gn {
  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 W2 extends xi {
  constructor(t = []) {
    super(), this.isArrayCamera = !0, this.cameras = t;
  }
}
class Zx {
  constructor(t = 1, e = 0, s = 0) {
    return this.radius = t, this.phi = e, this.theta = s, this;
  }
  set(t, e, s) {
    return this.radius = t, this.phi = e, this.theta = s, 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 = Ae(this.phi, 1e-6, Math.PI - 1e-6), this;
  }
  setFromVector3(t) {
    return this.setFromCartesianCoords(t.x, t.y, t.z);
  }
  setFromCartesianCoords(t, e, s) {
    return this.radius = Math.sqrt(t * t + e * e + s * s), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(t, s), this.phi = Math.acos(Ae(e / this.radius, -1, 1))), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const Kx = /* @__PURE__ */ new at();
let vf, fm;
class Y2 extends Sn {
  // dir is assumed to be normalized
  constructor(t = new at(0, 0, 1), e = new at(0, 0, 0), s = 1, r = 16776960, l = s * 0.2, c = l * 0.2) {
    super(), this.type = "ArrowHelper", vf === void 0 && (vf = new Gn(), vf.setAttribute("position", new qn([0, 0, 0, 0, 1, 0], 3)), fm = new Nc(0, 0.5, 1, 5, 1), fm.translate(0, -0.5, 0)), this.position.copy(e), this.line = new mc(vf, new Dc({ color: r, toneMapped: !1 })), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new Un(fm, new pd({ color: r, toneMapped: !1 })), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(t), this.setLength(s, l, 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 {
      Kx.set(t.z, 0, -t.x).normalize();
      const e = Math.acos(t.y);
      this.quaternion.setFromAxisAngle(Kx, e);
    }
  }
  setLength(t, e = t * 0.2, s = e * 0.2) {
    this.line.scale.set(1, Math.max(1e-4, t - e), 1), this.line.updateMatrix(), this.cone.scale.set(s, e, s), 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 j2 = class extends Mr {
  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 $x(n, t, e, s) {
  const r = q2(s);
  switch (e) {
    // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
    case xM:
      return n * t;
    case bM:
      return n * t;
    case MM:
      return n * t * 2;
    case qg:
      return n * t / r.components * r.byteLength;
    case Zg:
      return n * t / r.components * r.byteLength;
    case EM:
      return n * t * 2 / r.components * r.byteLength;
    case Kg:
      return n * t * 2 / r.components * r.byteLength;
    case SM:
      return n * t * 3 / r.components * r.byteLength;
    case bi:
      return n * t * 4 / r.components * r.byteLength;
    case $g:
      return n * t * 4 / r.components * r.byteLength;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
    case Pf:
    case zf:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 8;
    case If:
    case Bf:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
    case $m:
    case Jm:
      return Math.max(n, 16) * Math.max(t, 8) / 4;
    case Km:
    case Qm:
      return Math.max(n, 8) * Math.max(t, 8) / 2;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
    case tg:
    case eg:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 8;
    case ng:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
    case ig:
      return Math.floor((n + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    case sg:
      return Math.floor((n + 4) / 5) * Math.floor((t + 3) / 4) * 16;
    case ag:
      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 og:
      return Math.floor((n + 5) / 6) * Math.floor((t + 5) / 6) * 16;
    case lg:
      return Math.floor((n + 7) / 8) * Math.floor((t + 4) / 5) * 16;
    case cg:
      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 fg:
      return Math.floor((n + 9) / 10) * Math.floor((t + 4) / 5) * 16;
    case dg:
      return Math.floor((n + 9) / 10) * Math.floor((t + 5) / 6) * 16;
    case hg:
      return Math.floor((n + 9) / 10) * Math.floor((t + 7) / 8) * 16;
    case pg:
      return Math.floor((n + 9) / 10) * Math.floor((t + 9) / 10) * 16;
    case mg:
      return Math.floor((n + 11) / 12) * Math.floor((t + 9) / 10) * 16;
    case gg:
      return Math.floor((n + 11) / 12) * Math.floor((t + 11) / 12) * 16;
    // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
    case Ff:
    case _g:
    case vg:
      return Math.ceil(n / 4) * Math.ceil(t / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
    case TM:
    case yg:
      return Math.ceil(n / 4) * Math.ceil(t / 4) * 8;
    case xg:
    case Sg:
      return Math.ceil(n / 4) * Math.ceil(t / 4) * 16;
  }
  throw new Error(
    `Unable to determine texture byte length for ${e} format.`
  );
}
function q2(n) {
  switch (n) {
    case Hs:
    case _M:
      return { byteLength: 1, components: 1 };
    case pc:
    case vM:
    case Cc:
      return { byteLength: 2, components: 1 };
    case Yg:
    case jg:
      return { byteLength: 2, components: 4 };
    case _r:
    case Wg:
    case Ii:
      return { byteLength: 4, components: 1 };
    case yM:
      return { byteLength: 4, components: 3 };
  }
  throw new Error(`Unknown texture type ${n}.`);
}
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  revision: kg
} }));
typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = kg);
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
function XM() {
  let n = null, t = !1, e = null, s = null;
  function r(l, c) {
    e(l, c), s = n.requestAnimationFrame(r);
  }
  return {
    start: function() {
      t !== !0 && e !== null && (s = n.requestAnimationFrame(r), t = !0);
    },
    stop: function() {
      n.cancelAnimationFrame(s), t = !1;
    },
    setAnimationLoop: function(l) {
      e = l;
    },
    setContext: function(l) {
      n = l;
    }
  };
}
function Z2(n) {
  const t = /* @__PURE__ */ new WeakMap();
  function e(f, d) {
    const h = f.array, m = f.usage, p = h.byteLength, _ = n.createBuffer();
    n.bindBuffer(d, _), n.bufferData(d, h, m), f.onUploadCallback();
    let x;
    if (h instanceof Float32Array)
      x = n.FLOAT;
    else if (h instanceof Uint16Array)
      f.isFloat16BufferAttribute ? x = n.HALF_FLOAT : x = n.UNSIGNED_SHORT;
    else if (h instanceof Int16Array)
      x = n.SHORT;
    else if (h instanceof Uint32Array)
      x = n.UNSIGNED_INT;
    else if (h instanceof Int32Array)
      x = n.INT;
    else if (h instanceof Int8Array)
      x = n.BYTE;
    else if (h instanceof Uint8Array)
      x = n.UNSIGNED_BYTE;
    else if (h instanceof Uint8ClampedArray)
      x = n.UNSIGNED_BYTE;
    else
      throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + h);
    return {
      buffer: _,
      type: x,
      bytesPerElement: h.BYTES_PER_ELEMENT,
      version: f.version,
      size: p
    };
  }
  function s(f, d, h) {
    const m = d.array, p = d.updateRanges;
    if (n.bindBuffer(h, f), p.length === 0)
      n.bufferSubData(h, 0, m);
    else {
      p.sort((x, b) => x.start - b.start);
      let _ = 0;
      for (let x = 1; x < p.length; x++) {
        const b = p[_], M = p[x];
        M.start <= b.start + b.count + 1 ? b.count = Math.max(
          b.count,
          M.start + M.count - b.start
        ) : (++_, p[_] = M);
      }
      p.length = _ + 1;
      for (let x = 0, b = p.length; x < b; x++) {
        const M = p[x];
        n.bufferSubData(
          h,
          M.start * m.BYTES_PER_ELEMENT,
          m,
          M.start,
          M.count
        );
      }
      d.clearUpdateRanges();
    }
    d.onUploadCallback();
  }
  function r(f) {
    return f.isInterleavedBufferAttribute && (f = f.data), t.get(f);
  }
  function l(f) {
    f.isInterleavedBufferAttribute && (f = f.data);
    const d = t.get(f);
    d && (n.deleteBuffer(d.buffer), t.delete(f));
  }
  function c(f, d) {
    if (f.isInterleavedBufferAttribute && (f = f.data), f.isGLBufferAttribute) {
      const m = t.get(f);
      (!m || m.version < f.version) && t.set(f, {
        buffer: f.buffer,
        type: f.type,
        bytesPerElement: f.elementSize,
        version: f.version
      });
      return;
    }
    const h = t.get(f);
    if (h === void 0)
      t.set(f, e(f, d));
    else if (h.version < f.version) {
      if (h.size !== f.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.");
      s(h.buffer, f, d), h.version = f.version;
    }
  }
  return {
    get: r,
    remove: l,
    update: c
  };
}
var K2 = `#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`, $2 = `#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`, Q2 = `#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`, J2 = `#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, tC = `#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`, eC = `#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`, nC = `#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`, iC = `#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`, sC = `#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`, aC = `#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`, rC = `vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`, oC = `vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`, lC = `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`, cC = `#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`, uC = `#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`, fC = `#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`, dC = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`, hC = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`, pC = `#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`, mC = `#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`, gC = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`, _C = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`, vC = `#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`, yC = `#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`, xC = `#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`, SC = `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`, bC = `#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`, MC = `#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`, EC = `#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`, TC = `#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`, AC = "gl_FragColor = linearToOutputTexel( gl_FragColor );", wC = `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 );
}`, CC = `#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`, RC = `#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`, DC = `#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`, NC = `#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`, LC = `#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`, UC = `#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`, OC = `#ifdef USE_FOG
	varying float vFogDepth;
#endif`, PC = `#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`, zC = `#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`, IC = `#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
}`, BC = `#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`, FC = `LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`, HC = `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`, VC = `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`, GC = `#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`, kC = `ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`, XC = `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`, WC = `BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`, YC = `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`, jC = `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`, qC = `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 );
}`, ZC = `
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`, KC = `#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`, $C = `#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`, QC = `#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`, JC = `#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, tR = `#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, eR = `#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`, nR = `#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`, iR = `#ifdef USE_MAP
	uniform sampler2D map;
#endif`, sR = `#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`, aR = `#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`, rR = `float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`, oR = `#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`, lR = `#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`, cR = `#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`, uR = `#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`, fR = `#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`, dR = `#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`, hR = `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;`, pR = `#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`, mR = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, gR = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, _R = `#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`, vR = `#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`, yR = `#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`, xR = `#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`, SR = `#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`, bR = `#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`, MR = `#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, ER = `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 );
}`, TR = `#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`, AR = `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;`, wR = `#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`, CR = `#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`, RR = `float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`, DR = `#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`, NR = `#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`, LR = `#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`, UR = `#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`, OR = `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;
}`, PR = `#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`, zR = `#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`, IR = `#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`, BR = `#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`, FR = `float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`, HR = `#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`, VR = `#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`, GR = `#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; }`, kR = `#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`, XR = `#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`, WR = `#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`, YR = `#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`, jR = `#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`, qR = `#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 ZR = `varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`, KR = `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>
}`, $R = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, QR = `#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>
}`, JR = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, t3 = `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>
}`, e3 = `#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;
}`, n3 = `#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
}`, i3 = `#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;
}`, s3 = `#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 );
}`, a3 = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`, r3 = `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>
}`, o3 = `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>
}`, l3 = `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>
}`, c3 = `#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>
}`, u3 = `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>
}`, f3 = `#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>
}`, d3 = `#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>
}`, h3 = `#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;
}`, p3 = `#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>
}`, m3 = `#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
}`, g3 = `#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
}`, _3 = `#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>
}`, v3 = `#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>
}`, y3 = `#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
}`, x3 = `#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>
}`, S3 = `#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>
}`, b3 = `#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>
}`, M3 = `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>
}`, E3 = `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>
}`, T3 = `#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>
}`, A3 = `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>
}`, w3 = `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>
}`, C3 = `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: K2,
  alphahash_pars_fragment: $2,
  alphamap_fragment: Q2,
  alphamap_pars_fragment: J2,
  alphatest_fragment: tC,
  alphatest_pars_fragment: eC,
  aomap_fragment: nC,
  aomap_pars_fragment: iC,
  batching_pars_vertex: sC,
  batching_vertex: aC,
  begin_vertex: rC,
  beginnormal_vertex: oC,
  bsdfs: lC,
  iridescence_fragment: cC,
  bumpmap_pars_fragment: uC,
  clipping_planes_fragment: fC,
  clipping_planes_pars_fragment: dC,
  clipping_planes_pars_vertex: hC,
  clipping_planes_vertex: pC,
  color_fragment: mC,
  color_pars_fragment: gC,
  color_pars_vertex: _C,
  color_vertex: vC,
  common: yC,
  cube_uv_reflection_fragment: xC,
  defaultnormal_vertex: SC,
  displacementmap_pars_vertex: bC,
  displacementmap_vertex: MC,
  emissivemap_fragment: EC,
  emissivemap_pars_fragment: TC,
  colorspace_fragment: AC,
  colorspace_pars_fragment: wC,
  envmap_fragment: CC,
  envmap_common_pars_fragment: RC,
  envmap_pars_fragment: DC,
  envmap_pars_vertex: NC,
  envmap_physical_pars_fragment: GC,
  envmap_vertex: LC,
  fog_vertex: UC,
  fog_pars_vertex: OC,
  fog_fragment: PC,
  fog_pars_fragment: zC,
  gradientmap_pars_fragment: IC,
  lightmap_pars_fragment: BC,
  lights_lambert_fragment: FC,
  lights_lambert_pars_fragment: HC,
  lights_pars_begin: VC,
  lights_toon_fragment: kC,
  lights_toon_pars_fragment: XC,
  lights_phong_fragment: WC,
  lights_phong_pars_fragment: YC,
  lights_physical_fragment: jC,
  lights_physical_pars_fragment: qC,
  lights_fragment_begin: ZC,
  lights_fragment_maps: KC,
  lights_fragment_end: $C,
  logdepthbuf_fragment: QC,
  logdepthbuf_pars_fragment: JC,
  logdepthbuf_pars_vertex: tR,
  logdepthbuf_vertex: eR,
  map_fragment: nR,
  map_pars_fragment: iR,
  map_particle_fragment: sR,
  map_particle_pars_fragment: aR,
  metalnessmap_fragment: rR,
  metalnessmap_pars_fragment: oR,
  morphinstance_vertex: lR,
  morphcolor_vertex: cR,
  morphnormal_vertex: uR,
  morphtarget_pars_vertex: fR,
  morphtarget_vertex: dR,
  normal_fragment_begin: hR,
  normal_fragment_maps: pR,
  normal_pars_fragment: mR,
  normal_pars_vertex: gR,
  normal_vertex: _R,
  normalmap_pars_fragment: vR,
  clearcoat_normal_fragment_begin: yR,
  clearcoat_normal_fragment_maps: xR,
  clearcoat_pars_fragment: SR,
  iridescence_pars_fragment: bR,
  opaque_fragment: MR,
  packing: ER,
  premultiplied_alpha_fragment: TR,
  project_vertex: AR,
  dithering_fragment: wR,
  dithering_pars_fragment: CR,
  roughnessmap_fragment: RR,
  roughnessmap_pars_fragment: DR,
  shadowmap_pars_fragment: NR,
  shadowmap_pars_vertex: LR,
  shadowmap_vertex: UR,
  shadowmask_pars_fragment: OR,
  skinbase_vertex: PR,
  skinning_pars_vertex: zR,
  skinning_vertex: IR,
  skinnormal_vertex: BR,
  specularmap_fragment: FR,
  specularmap_pars_fragment: HR,
  tonemapping_fragment: VR,
  tonemapping_pars_fragment: GR,
  transmission_fragment: kR,
  transmission_pars_fragment: XR,
  uv_pars_fragment: WR,
  uv_pars_vertex: YR,
  uv_vertex: jR,
  worldpos_vertex: qR,
  background_vert: ZR,
  background_frag: KR,
  backgroundCube_vert: $R,
  backgroundCube_frag: QR,
  cube_vert: JR,
  cube_frag: t3,
  depth_vert: e3,
  depth_frag: n3,
  distanceRGBA_vert: i3,
  distanceRGBA_frag: s3,
  equirect_vert: a3,
  equirect_frag: r3,
  linedashed_vert: o3,
  linedashed_frag: l3,
  meshbasic_vert: c3,
  meshbasic_frag: u3,
  meshlambert_vert: f3,
  meshlambert_frag: d3,
  meshmatcap_vert: h3,
  meshmatcap_frag: p3,
  meshnormal_vert: m3,
  meshnormal_frag: g3,
  meshphong_vert: _3,
  meshphong_frag: v3,
  meshphysical_vert: y3,
  meshphysical_frag: x3,
  meshtoon_vert: S3,
  meshtoon_frag: b3,
  points_vert: M3,
  points_frag: E3,
  shadow_vert: T3,
  shadow_frag: A3,
  sprite_vert: w3,
  sprite_frag: C3
}, Ht = {
  common: {
    diffuse: { value: /* @__PURE__ */ new we(16777215) },
    opacity: { value: 1 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new _e() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new _e() },
    alphaTest: { value: 0 }
  },
  specularmap: {
    specularMap: { value: null },
    specularMapTransform: { value: /* @__PURE__ */ new _e() }
  },
  envmap: {
    envMap: { value: null },
    envMapRotation: { value: /* @__PURE__ */ new _e() },
    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 _e() }
  },
  lightmap: {
    lightMap: { value: null },
    lightMapIntensity: { value: 1 },
    lightMapTransform: { value: /* @__PURE__ */ new _e() }
  },
  bumpmap: {
    bumpMap: { value: null },
    bumpMapTransform: { value: /* @__PURE__ */ new _e() },
    bumpScale: { value: 1 }
  },
  normalmap: {
    normalMap: { value: null },
    normalMapTransform: { value: /* @__PURE__ */ new _e() },
    normalScale: { value: /* @__PURE__ */ new le(1, 1) }
  },
  displacementmap: {
    displacementMap: { value: null },
    displacementMapTransform: { value: /* @__PURE__ */ new _e() },
    displacementScale: { value: 1 },
    displacementBias: { value: 0 }
  },
  emissivemap: {
    emissiveMap: { value: null },
    emissiveMapTransform: { value: /* @__PURE__ */ new _e() }
  },
  metalnessmap: {
    metalnessMap: { value: null },
    metalnessMapTransform: { value: /* @__PURE__ */ new _e() }
  },
  roughnessmap: {
    roughnessMap: { value: null },
    roughnessMapTransform: { value: /* @__PURE__ */ new _e() }
  },
  gradientmap: {
    gradientMap: { value: null }
  },
  fog: {
    fogDensity: { value: 25e-5 },
    fogNear: { value: 1 },
    fogFar: { value: 2e3 },
    fogColor: { value: /* @__PURE__ */ new we(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 we(16777215) },
    opacity: { value: 1 },
    size: { value: 1 },
    scale: { value: 1 },
    map: { value: null },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new _e() },
    alphaTest: { value: 0 },
    uvTransform: { value: /* @__PURE__ */ new _e() }
  },
  sprite: {
    diffuse: { value: /* @__PURE__ */ new we(16777215) },
    opacity: { value: 1 },
    center: { value: /* @__PURE__ */ new le(0.5, 0.5) },
    rotation: { value: 0 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new _e() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new _e() },
    alphaTest: { value: 0 }
  }
}, Ji = {
  basic: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.specularmap,
      Ht.envmap,
      Ht.aomap,
      Ht.lightmap,
      Ht.fog
    ]),
    vertexShader: ye.meshbasic_vert,
    fragmentShader: ye.meshbasic_frag
  },
  lambert: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.specularmap,
      Ht.envmap,
      Ht.aomap,
      Ht.lightmap,
      Ht.emissivemap,
      Ht.bumpmap,
      Ht.normalmap,
      Ht.displacementmap,
      Ht.fog,
      Ht.lights,
      {
        emissive: { value: /* @__PURE__ */ new we(0) }
      }
    ]),
    vertexShader: ye.meshlambert_vert,
    fragmentShader: ye.meshlambert_frag
  },
  phong: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.specularmap,
      Ht.envmap,
      Ht.aomap,
      Ht.lightmap,
      Ht.emissivemap,
      Ht.bumpmap,
      Ht.normalmap,
      Ht.displacementmap,
      Ht.fog,
      Ht.lights,
      {
        emissive: { value: /* @__PURE__ */ new we(0) },
        specular: { value: /* @__PURE__ */ new we(1118481) },
        shininess: { value: 30 }
      }
    ]),
    vertexShader: ye.meshphong_vert,
    fragmentShader: ye.meshphong_frag
  },
  standard: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.envmap,
      Ht.aomap,
      Ht.lightmap,
      Ht.emissivemap,
      Ht.bumpmap,
      Ht.normalmap,
      Ht.displacementmap,
      Ht.roughnessmap,
      Ht.metalnessmap,
      Ht.fog,
      Ht.lights,
      {
        emissive: { value: /* @__PURE__ */ new we(0) },
        roughness: { value: 1 },
        metalness: { value: 0 },
        envMapIntensity: { value: 1 }
      }
    ]),
    vertexShader: ye.meshphysical_vert,
    fragmentShader: ye.meshphysical_frag
  },
  toon: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.aomap,
      Ht.lightmap,
      Ht.emissivemap,
      Ht.bumpmap,
      Ht.normalmap,
      Ht.displacementmap,
      Ht.gradientmap,
      Ht.fog,
      Ht.lights,
      {
        emissive: { value: /* @__PURE__ */ new we(0) }
      }
    ]),
    vertexShader: ye.meshtoon_vert,
    fragmentShader: ye.meshtoon_frag
  },
  matcap: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.bumpmap,
      Ht.normalmap,
      Ht.displacementmap,
      Ht.fog,
      {
        matcap: { value: null }
      }
    ]),
    vertexShader: ye.meshmatcap_vert,
    fragmentShader: ye.meshmatcap_frag
  },
  points: {
    uniforms: /* @__PURE__ */ $n([
      Ht.points,
      Ht.fog
    ]),
    vertexShader: ye.points_vert,
    fragmentShader: ye.points_frag
  },
  dashed: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.fog,
      {
        scale: { value: 1 },
        dashSize: { value: 1 },
        totalSize: { value: 2 }
      }
    ]),
    vertexShader: ye.linedashed_vert,
    fragmentShader: ye.linedashed_frag
  },
  depth: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.displacementmap
    ]),
    vertexShader: ye.depth_vert,
    fragmentShader: ye.depth_frag
  },
  normal: {
    uniforms: /* @__PURE__ */ $n([
      Ht.common,
      Ht.bumpmap,
      Ht.normalmap,
      Ht.displacementmap,
      {
        opacity: { value: 1 }
      }
    ]),
    vertexShader: ye.meshnormal_vert,
    fragmentShader: ye.meshnormal_frag
  },
  sprite: {
    uniforms: /* @__PURE__ */ $n([
      Ht.sprite,
      Ht.fog
    ]),
    vertexShader: ye.sprite_vert,
    fragmentShader: ye.sprite_frag
  },
  background: {
    uniforms: {
      uvTransform: { value: /* @__PURE__ */ new _e() },
      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 _e() }
    },
    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__ */ $n([
      Ht.common,
      Ht.displacementmap,
      {
        referencePosition: { value: /* @__PURE__ */ new at() },
        nearDistance: { value: 1 },
        farDistance: { value: 1e3 }
      }
    ]),
    vertexShader: ye.distanceRGBA_vert,
    fragmentShader: ye.distanceRGBA_frag
  },
  shadow: {
    uniforms: /* @__PURE__ */ $n([
      Ht.lights,
      Ht.fog,
      {
        color: { value: /* @__PURE__ */ new we(0) },
        opacity: { value: 1 }
      }
    ]),
    vertexShader: ye.shadow_vert,
    fragmentShader: ye.shadow_frag
  }
};
Ji.physical = {
  uniforms: /* @__PURE__ */ $n([
    Ji.standard.uniforms,
    {
      clearcoat: { value: 0 },
      clearcoatMap: { value: null },
      clearcoatMapTransform: { value: /* @__PURE__ */ new _e() },
      clearcoatNormalMap: { value: null },
      clearcoatNormalMapTransform: { value: /* @__PURE__ */ new _e() },
      clearcoatNormalScale: { value: /* @__PURE__ */ new le(1, 1) },
      clearcoatRoughness: { value: 0 },
      clearcoatRoughnessMap: { value: null },
      clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new _e() },
      dispersion: { value: 0 },
      iridescence: { value: 0 },
      iridescenceMap: { value: null },
      iridescenceMapTransform: { value: /* @__PURE__ */ new _e() },
      iridescenceIOR: { value: 1.3 },
      iridescenceThicknessMinimum: { value: 100 },
      iridescenceThicknessMaximum: { value: 400 },
      iridescenceThicknessMap: { value: null },
      iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new _e() },
      sheen: { value: 0 },
      sheenColor: { value: /* @__PURE__ */ new we(0) },
      sheenColorMap: { value: null },
      sheenColorMapTransform: { value: /* @__PURE__ */ new _e() },
      sheenRoughness: { value: 1 },
      sheenRoughnessMap: { value: null },
      sheenRoughnessMapTransform: { value: /* @__PURE__ */ new _e() },
      transmission: { value: 0 },
      transmissionMap: { value: null },
      transmissionMapTransform: { value: /* @__PURE__ */ new _e() },
      transmissionSamplerSize: { value: /* @__PURE__ */ new le() },
      transmissionSamplerMap: { value: null },
      thickness: { value: 0 },
      thicknessMap: { value: null },
      thicknessMapTransform: { value: /* @__PURE__ */ new _e() },
      attenuationDistance: { value: 0 },
      attenuationColor: { value: /* @__PURE__ */ new we(0) },
      specularColor: { value: /* @__PURE__ */ new we(1, 1, 1) },
      specularColorMap: { value: null },
      specularColorMapTransform: { value: /* @__PURE__ */ new _e() },
      specularIntensity: { value: 1 },
      specularIntensityMap: { value: null },
      specularIntensityMapTransform: { value: /* @__PURE__ */ new _e() },
      anisotropyVector: { value: /* @__PURE__ */ new le() },
      anisotropyMap: { value: null },
      anisotropyMapTransform: { value: /* @__PURE__ */ new _e() }
    }
  ]),
  vertexShader: ye.meshphysical_vert,
  fragmentShader: ye.meshphysical_frag
};
const yf = { r: 0, b: 0, g: 0 }, sr = /* @__PURE__ */ new as(), R3 = /* @__PURE__ */ new qe();
function D3(n, t, e, s, r, l, c) {
  const f = new we(0);
  let d = l === !0 ? 0 : 1, h, m, p = null, _ = 0, x = null;
  function b(T) {
    let E = T.isScene === !0 ? T.background : null;
    return E && E.isTexture && (E = (T.backgroundBlurriness > 0 ? e : t).get(E)), E;
  }
  function M(T) {
    let E = !1;
    const O = b(T);
    O === null ? y(f, d) : O && O.isColor && (y(O, 1), E = !0);
    const N = n.xr.getEnvironmentBlendMode();
    N === "additive" ? s.buffers.color.setClear(0, 0, 0, 1, c) : N === "alpha-blend" && s.buffers.color.setClear(0, 0, 0, 0, c), (n.autoClear || E) && (s.buffers.depth.setTest(!0), s.buffers.depth.setMask(!0), s.buffers.color.setMask(!0), n.clear(n.autoClearColor, n.autoClearDepth, n.autoClearStencil));
  }
  function S(T, E) {
    const O = b(E);
    O && (O.isCubeTexture || O.mapping === hd) ? (m === void 0 && (m = new Un(
      new Rc(1, 1, 1),
      new Vs({
        name: "BackgroundCubeMaterial",
        uniforms: jo(Ji.backgroundCube.uniforms),
        vertexShader: Ji.backgroundCube.vertexShader,
        fragmentShader: Ji.backgroundCube.fragmentShader,
        side: li,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), m.geometry.deleteAttribute("normal"), m.geometry.deleteAttribute("uv"), m.onBeforeRender = function(N, D, z) {
      this.matrixWorld.copyPosition(z.matrixWorld);
    }, Object.defineProperty(m.material, "envMap", {
      get: function() {
        return this.uniforms.envMap.value;
      }
    }), r.update(m)), sr.copy(E.backgroundRotation), sr.x *= -1, sr.y *= -1, sr.z *= -1, O.isCubeTexture && O.isRenderTargetTexture === !1 && (sr.y *= -1, sr.z *= -1), m.material.uniforms.envMap.value = O, m.material.uniforms.flipEnvMap.value = O.isCubeTexture && O.isRenderTargetTexture === !1 ? -1 : 1, m.material.uniforms.backgroundBlurriness.value = E.backgroundBlurriness, m.material.uniforms.backgroundIntensity.value = E.backgroundIntensity, m.material.uniforms.backgroundRotation.value.setFromMatrix4(R3.makeRotationFromEuler(sr)), m.material.toneMapped = Ie.getTransfer(O.colorSpace) !== We, (p !== O || _ !== O.version || x !== n.toneMapping) && (m.material.needsUpdate = !0, p = O, _ = O.version, x = n.toneMapping), m.layers.enableAll(), T.unshift(m, m.geometry, m.material, 0, 0, null)) : O && O.isTexture && (h === void 0 && (h = new Un(
      new md(2, 2),
      new Vs({
        name: "BackgroundMaterial",
        uniforms: jo(Ji.background.uniforms),
        vertexShader: Ji.background.vertexShader,
        fragmentShader: Ji.background.fragmentShader,
        side: Na,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), h.geometry.deleteAttribute("normal"), Object.defineProperty(h.material, "map", {
      get: function() {
        return this.uniforms.t2D.value;
      }
    }), r.update(h)), h.material.uniforms.t2D.value = O, h.material.uniforms.backgroundIntensity.value = E.backgroundIntensity, h.material.toneMapped = Ie.getTransfer(O.colorSpace) !== We, O.matrixAutoUpdate === !0 && O.updateMatrix(), h.material.uniforms.uvTransform.value.copy(O.matrix), (p !== O || _ !== O.version || x !== n.toneMapping) && (h.material.needsUpdate = !0, p = O, _ = O.version, x = n.toneMapping), h.layers.enableAll(), T.unshift(h, h.geometry, h.material, 0, 0, null));
  }
  function y(T, E) {
    T.getRGB(yf, PM(n)), s.buffers.color.setClear(yf.r, yf.g, yf.b, E, c);
  }
  function C() {
    m !== void 0 && (m.geometry.dispose(), m.material.dispose()), h !== void 0 && (h.geometry.dispose(), h.material.dispose());
  }
  return {
    getClearColor: function() {
      return f;
    },
    setClearColor: function(T, E = 1) {
      f.set(T), d = E, y(f, d);
    },
    getClearAlpha: function() {
      return d;
    },
    setClearAlpha: function(T) {
      d = T, y(f, d);
    },
    render: M,
    addToRenderList: S,
    dispose: C
  };
}
function N3(n, t) {
  const e = n.getParameter(n.MAX_VERTEX_ATTRIBS), s = {}, r = _(null);
  let l = r, c = !1;
  function f(R, L, H, k, P) {
    let Y = !1;
    const U = p(k, H, L);
    l !== U && (l = U, h(l.object)), Y = x(R, k, H, P), Y && b(R, k, H, P), P !== null && t.update(P, n.ELEMENT_ARRAY_BUFFER), (Y || c) && (c = !1, E(R, L, H, k), P !== null && n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, t.get(P).buffer));
  }
  function d() {
    return n.createVertexArray();
  }
  function h(R) {
    return n.bindVertexArray(R);
  }
  function m(R) {
    return n.deleteVertexArray(R);
  }
  function p(R, L, H) {
    const k = H.wireframe === !0;
    let P = s[R.id];
    P === void 0 && (P = {}, s[R.id] = P);
    let Y = P[L.id];
    Y === void 0 && (Y = {}, P[L.id] = Y);
    let U = Y[k];
    return U === void 0 && (U = _(d()), Y[k] = U), U;
  }
  function _(R) {
    const L = [], H = [], k = [];
    for (let P = 0; P < e; P++)
      L[P] = 0, H[P] = 0, k[P] = 0;
    return {
      // for backward compatibility on non-VAO support browser
      geometry: null,
      program: null,
      wireframe: !1,
      newAttributes: L,
      enabledAttributes: H,
      attributeDivisors: k,
      object: R,
      attributes: {},
      index: null
    };
  }
  function x(R, L, H, k) {
    const P = l.attributes, Y = L.attributes;
    let U = 0;
    const X = H.getAttributes();
    for (const V in X)
      if (X[V].location >= 0) {
        const J = P[V];
        let I = Y[V];
        if (I === void 0 && (V === "instanceMatrix" && R.instanceMatrix && (I = R.instanceMatrix), V === "instanceColor" && R.instanceColor && (I = R.instanceColor)), J === void 0 || J.attribute !== I || I && J.data !== I.data) return !0;
        U++;
      }
    return l.attributesNum !== U || l.index !== k;
  }
  function b(R, L, H, k) {
    const P = {}, Y = L.attributes;
    let U = 0;
    const X = H.getAttributes();
    for (const V in X)
      if (X[V].location >= 0) {
        let J = Y[V];
        J === void 0 && (V === "instanceMatrix" && R.instanceMatrix && (J = R.instanceMatrix), V === "instanceColor" && R.instanceColor && (J = R.instanceColor));
        const I = {};
        I.attribute = J, J && J.data && (I.data = J.data), P[V] = I, U++;
      }
    l.attributes = P, l.attributesNum = U, l.index = k;
  }
  function M() {
    const R = l.newAttributes;
    for (let L = 0, H = R.length; L < H; L++)
      R[L] = 0;
  }
  function S(R) {
    y(R, 0);
  }
  function y(R, L) {
    const H = l.newAttributes, k = l.enabledAttributes, P = l.attributeDivisors;
    H[R] = 1, k[R] === 0 && (n.enableVertexAttribArray(R), k[R] = 1), P[R] !== L && (n.vertexAttribDivisor(R, L), P[R] = L);
  }
  function C() {
    const R = l.newAttributes, L = l.enabledAttributes;
    for (let H = 0, k = L.length; H < k; H++)
      L[H] !== R[H] && (n.disableVertexAttribArray(H), L[H] = 0);
  }
  function T(R, L, H, k, P, Y, U) {
    U === !0 ? n.vertexAttribIPointer(R, L, H, P, Y) : n.vertexAttribPointer(R, L, H, k, P, Y);
  }
  function E(R, L, H, k) {
    M();
    const P = k.attributes, Y = H.getAttributes(), U = L.defaultAttributeValues;
    for (const X in Y) {
      const V = Y[X];
      if (V.location >= 0) {
        let W = P[X];
        if (W === void 0 && (X === "instanceMatrix" && R.instanceMatrix && (W = R.instanceMatrix), X === "instanceColor" && R.instanceColor && (W = R.instanceColor)), W !== void 0) {
          const J = W.normalized, I = W.itemSize, q = t.get(W);
          if (q === void 0) continue;
          const lt = q.buffer, $ = q.type, ot = q.bytesPerElement, gt = $ === n.INT || $ === n.UNSIGNED_INT || W.gpuType === Wg;
          if (W.isInterleavedBufferAttribute) {
            const ht = W.data, _t = ht.stride, Et = W.offset;
            if (ht.isInstancedInterleavedBuffer) {
              for (let Lt = 0; Lt < V.locationSize; Lt++)
                y(V.location + Lt, ht.meshPerAttribute);
              R.isInstancedMesh !== !0 && k._maxInstanceCount === void 0 && (k._maxInstanceCount = ht.meshPerAttribute * ht.count);
            } else
              for (let Lt = 0; Lt < V.locationSize; Lt++)
                S(V.location + Lt);
            n.bindBuffer(n.ARRAY_BUFFER, lt);
            for (let Lt = 0; Lt < V.locationSize; Lt++)
              T(
                V.location + Lt,
                I / V.locationSize,
                $,
                J,
                _t * ot,
                (Et + I / V.locationSize * Lt) * ot,
                gt
              );
          } else {
            if (W.isInstancedBufferAttribute) {
              for (let ht = 0; ht < V.locationSize; ht++)
                y(V.location + ht, W.meshPerAttribute);
              R.isInstancedMesh !== !0 && k._maxInstanceCount === void 0 && (k._maxInstanceCount = W.meshPerAttribute * W.count);
            } else
              for (let ht = 0; ht < V.locationSize; ht++)
                S(V.location + ht);
            n.bindBuffer(n.ARRAY_BUFFER, lt);
            for (let ht = 0; ht < V.locationSize; ht++)
              T(
                V.location + ht,
                I / V.locationSize,
                $,
                J,
                I * ot,
                I / V.locationSize * ht * ot,
                gt
              );
          }
        } else if (U !== void 0) {
          const J = U[X];
          if (J !== void 0)
            switch (J.length) {
              case 2:
                n.vertexAttrib2fv(V.location, J);
                break;
              case 3:
                n.vertexAttrib3fv(V.location, J);
                break;
              case 4:
                n.vertexAttrib4fv(V.location, J);
                break;
              default:
                n.vertexAttrib1fv(V.location, J);
            }
        }
      }
    }
    C();
  }
  function O() {
    z();
    for (const R in s) {
      const L = s[R];
      for (const H in L) {
        const k = L[H];
        for (const P in k)
          m(k[P].object), delete k[P];
        delete L[H];
      }
      delete s[R];
    }
  }
  function N(R) {
    if (s[R.id] === void 0) return;
    const L = s[R.id];
    for (const H in L) {
      const k = L[H];
      for (const P in k)
        m(k[P].object), delete k[P];
      delete L[H];
    }
    delete s[R.id];
  }
  function D(R) {
    for (const L in s) {
      const H = s[L];
      if (H[R.id] === void 0) continue;
      const k = H[R.id];
      for (const P in k)
        m(k[P].object), delete k[P];
      delete H[R.id];
    }
  }
  function z() {
    A(), c = !0, l !== r && (l = r, h(l.object));
  }
  function A() {
    r.geometry = null, r.program = null, r.wireframe = !1;
  }
  return {
    setup: f,
    reset: z,
    resetDefaultState: A,
    dispose: O,
    releaseStatesOfGeometry: N,
    releaseStatesOfProgram: D,
    initAttributes: M,
    enableAttribute: S,
    disableUnusedAttributes: C
  };
}
function L3(n, t, e) {
  let s;
  function r(h) {
    s = h;
  }
  function l(h, m) {
    n.drawArrays(s, h, m), e.update(m, s, 1);
  }
  function c(h, m, p) {
    p !== 0 && (n.drawArraysInstanced(s, h, m, p), e.update(m, s, p));
  }
  function f(h, m, p) {
    if (p === 0) return;
    t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(s, h, 0, m, 0, p);
    let x = 0;
    for (let b = 0; b < p; b++)
      x += m[b];
    e.update(x, s, 1);
  }
  function d(h, m, p, _) {
    if (p === 0) return;
    const x = t.get("WEBGL_multi_draw");
    if (x === null)
      for (let b = 0; b < h.length; b++)
        c(h[b], m[b], _[b]);
    else {
      x.multiDrawArraysInstancedWEBGL(s, h, 0, m, 0, _, 0, p);
      let b = 0;
      for (let M = 0; M < p; M++)
        b += m[M] * _[M];
      e.update(b, s, 1);
    }
  }
  this.setMode = r, this.render = l, this.renderInstances = c, this.renderMultiDraw = f, this.renderMultiDrawInstances = d;
}
function U3(n, t, e, s) {
  let r;
  function l() {
    if (r !== void 0) return r;
    if (t.has("EXT_texture_filter_anisotropic") === !0) {
      const D = t.get("EXT_texture_filter_anisotropic");
      r = n.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
    } else
      r = 0;
    return r;
  }
  function c(D) {
    return !(D !== bi && s.convert(D) !== n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT));
  }
  function f(D) {
    const z = D === Cc && (t.has("EXT_color_buffer_half_float") || t.has("EXT_color_buffer_float"));
    return !(D !== Hs && s.convert(D) !== n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)
    D !== Ii && !z);
  }
  function d(D) {
    if (D === "highp") {
      if (n.getShaderPrecisionFormat(n.VERTEX_SHADER, n.HIGH_FLOAT).precision > 0 && n.getShaderPrecisionFormat(n.FRAGMENT_SHADER, n.HIGH_FLOAT).precision > 0)
        return "highp";
      D = "mediump";
    }
    return D === "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 m = d(h);
  m !== h && (console.warn("THREE.WebGLRenderer:", h, "not supported, using", m, "instead."), h = m);
  const p = e.logarithmicDepthBuffer === !0, _ = e.reverseDepthBuffer === !0 && t.has("EXT_clip_control"), x = n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS), b = n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS), M = n.getParameter(n.MAX_TEXTURE_SIZE), S = n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE), y = n.getParameter(n.MAX_VERTEX_ATTRIBS), C = n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS), T = n.getParameter(n.MAX_VARYING_VECTORS), E = n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS), O = b > 0, N = n.getParameter(n.MAX_SAMPLES);
  return {
    isWebGL2: !0,
    // keeping this for backwards compatibility
    getMaxAnisotropy: l,
    getMaxPrecision: d,
    textureFormatReadable: c,
    textureTypeReadable: f,
    precision: h,
    logarithmicDepthBuffer: p,
    reverseDepthBuffer: _,
    maxTextures: x,
    maxVertexTextures: b,
    maxTextureSize: M,
    maxCubemapSize: S,
    maxAttributes: y,
    maxVertexUniforms: C,
    maxVaryings: T,
    maxFragmentUniforms: E,
    vertexTextures: O,
    maxSamples: N
  };
}
function O3(n) {
  const t = this;
  let e = null, s = 0, r = !1, l = !1;
  const c = new Ea(), f = new _e(), d = { value: null, needsUpdate: !1 };
  this.uniform = d, this.numPlanes = 0, this.numIntersection = 0, this.init = function(p, _) {
    const x = p.length !== 0 || _ || // enable state of previous frame - the clipping code has to
    // run another frame in order to reset the state:
    s !== 0 || r;
    return r = _, s = p.length, x;
  }, this.beginShadows = function() {
    l = !0, m(null);
  }, this.endShadows = function() {
    l = !1;
  }, this.setGlobalState = function(p, _) {
    e = m(p, _, 0);
  }, this.setState = function(p, _, x) {
    const b = p.clippingPlanes, M = p.clipIntersection, S = p.clipShadows, y = n.get(p);
    if (!r || b === null || b.length === 0 || l && !S)
      l ? m(null) : h();
    else {
      const C = l ? 0 : s, T = C * 4;
      let E = y.clippingState || null;
      d.value = E, E = m(b, _, T, x);
      for (let O = 0; O !== T; ++O)
        E[O] = e[O];
      y.clippingState = E, this.numIntersection = M ? this.numPlanes : 0, this.numPlanes += C;
    }
  };
  function h() {
    d.value !== e && (d.value = e, d.needsUpdate = s > 0), t.numPlanes = s, t.numIntersection = 0;
  }
  function m(p, _, x, b) {
    const M = p !== null ? p.length : 0;
    let S = null;
    if (M !== 0) {
      if (S = d.value, b !== !0 || S === null) {
        const y = x + M * 4, C = _.matrixWorldInverse;
        f.getNormalMatrix(C), (S === null || S.length < y) && (S = new Float32Array(y));
        for (let T = 0, E = x; T !== M; ++T, E += 4)
          c.copy(p[T]).applyMatrix4(C, f), c.normal.toArray(S, E), S[E + 3] = c.constant;
      }
      d.value = S, d.needsUpdate = !0;
    }
    return t.numPlanes = M, t.numIntersection = 0, S;
  }
}
function P3(n) {
  let t = /* @__PURE__ */ new WeakMap();
  function e(c, f) {
    return f === Ym ? c.mapping = Go : f === jm && (c.mapping = ko), c;
  }
  function s(c) {
    if (c && c.isTexture) {
      const f = c.mapping;
      if (f === Ym || f === jm)
        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 U2(d.height);
            return h.fromEquirectangularTexture(n, c), t.set(c, h), c.addEventListener("dispose", r), e(h.texture, c.mapping);
          } else
            return null;
        }
    }
    return c;
  }
  function r(c) {
    const f = c.target;
    f.removeEventListener("dispose", r);
    const d = t.get(f);
    d !== void 0 && (t.delete(f), d.dispose());
  }
  function l() {
    t = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: s,
    dispose: l
  };
}
const Lo = 4, Qx = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], ur = 20, dm = /* @__PURE__ */ new zs(), Jx = /* @__PURE__ */ new we();
let hm = null, pm = 0, mm = 0, gm = !1;
const or = (1 + Math.sqrt(5)) / 2, Ao = 1 / or, tS = [
  /* @__PURE__ */ new at(-or, Ao, 0),
  /* @__PURE__ */ new at(or, Ao, 0),
  /* @__PURE__ */ new at(-Ao, 0, or),
  /* @__PURE__ */ new at(Ao, 0, or),
  /* @__PURE__ */ new at(0, or, -Ao),
  /* @__PURE__ */ new at(0, or, Ao),
  /* @__PURE__ */ new at(-1, 1, -1),
  /* @__PURE__ */ new at(1, 1, -1),
  /* @__PURE__ */ new at(-1, 1, 1),
  /* @__PURE__ */ new at(1, 1, 1)
];
class eS {
  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, s = 0.1, r = 100) {
    hm = this._renderer.getRenderTarget(), pm = this._renderer.getActiveCubeFace(), mm = this._renderer.getActiveMipmapLevel(), gm = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(256);
    const l = this._allocateTargets();
    return l.depthBuffer = !0, this._sceneToCubeUV(t, s, r, l), e > 0 && this._blur(l, 0, 0, e), this._applyPMREM(l), this._cleanup(l), l;
  }
  /**
   * 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 = sS(), 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 = iS(), 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(hm, pm, mm), this._renderer.xr.enabled = gm, t.scissorTest = !1, xf(t, 0, 0, t.width, t.height);
  }
  _fromTexture(t, e) {
    t.mapping === Go || t.mapping === ko ? this._setSize(t.image.length === 0 ? 16 : t.image[0].width || t.image[0].image.width) : this._setSize(t.image.width / 4), hm = this._renderer.getRenderTarget(), pm = this._renderer.getActiveCubeFace(), mm = this._renderer.getActiveMipmapLevel(), gm = this._renderer.xr.enabled, this._renderer.xr.enabled = !1;
    const s = e || this._allocateTargets();
    return this._textureToCubeUV(t, s), this._applyPMREM(s), this._cleanup(s), s;
  }
  _allocateTargets() {
    const t = 3 * Math.max(this._cubeSize, 112), e = 4 * this._cubeSize, s = {
      magFilter: is,
      minFilter: is,
      generateMipmaps: !1,
      type: Cc,
      format: bi,
      colorSpace: Yo,
      depthBuffer: !1
    }, r = nS(t, e, s);
    if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== t || this._pingPongRenderTarget.height !== e) {
      this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = nS(t, e, s);
      const { _lodMax: l } = this;
      ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = z3(l)), this._blurMaterial = I3(l, t, e);
    }
    return r;
  }
  _compileMaterial(t) {
    const e = new Un(this._lodPlanes[0], t);
    this._renderer.compile(e, dm);
  }
  _sceneToCubeUV(t, e, s, r) {
    const f = new xi(90, 1, e, s), d = [1, -1, 1, 1, 1, 1], h = [1, 1, 1, -1, -1, -1], m = this._renderer, p = m.autoClear, _ = m.toneMapping;
    m.getClearColor(Jx), m.toneMapping = Ra, m.autoClear = !1;
    const x = new pd({
      name: "PMREM.Background",
      side: li,
      depthWrite: !1,
      depthTest: !1
    }), b = new Un(new Rc(), x);
    let M = !1;
    const S = t.background;
    S ? S.isColor && (x.color.copy(S), t.background = null, M = !0) : (x.color.copy(Jx), M = !0);
    for (let y = 0; y < 6; y++) {
      const C = y % 3;
      C === 0 ? (f.up.set(0, d[y], 0), f.lookAt(h[y], 0, 0)) : C === 1 ? (f.up.set(0, 0, d[y]), f.lookAt(0, h[y], 0)) : (f.up.set(0, d[y], 0), f.lookAt(0, 0, h[y]));
      const T = this._cubeSize;
      xf(r, C * T, y > 2 ? T : 0, T, T), m.setRenderTarget(r), M && m.render(b, f), m.render(t, f);
    }
    b.geometry.dispose(), b.material.dispose(), m.toneMapping = _, m.autoClear = p, t.background = S;
  }
  _textureToCubeUV(t, e) {
    const s = this._renderer, r = t.mapping === Go || t.mapping === ko;
    r ? (this._cubemapMaterial === null && (this._cubemapMaterial = sS()), this._cubemapMaterial.uniforms.flipEnvMap.value = t.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = iS());
    const l = r ? this._cubemapMaterial : this._equirectMaterial, c = new Un(this._lodPlanes[0], l), f = l.uniforms;
    f.envMap.value = t;
    const d = this._cubeSize;
    xf(e, 0, 0, 3 * d, 2 * d), s.setRenderTarget(e), s.render(c, dm);
  }
  _applyPMREM(t) {
    const e = this._renderer, s = e.autoClear;
    e.autoClear = !1;
    const r = this._lodPlanes.length;
    for (let l = 1; l < r; l++) {
      const c = Math.sqrt(this._sigmas[l] * this._sigmas[l] - this._sigmas[l - 1] * this._sigmas[l - 1]), f = tS[(r - l - 1) % tS.length];
      this._blur(t, l - 1, l, c, f);
    }
    e.autoClear = s;
  }
  /**
   * 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, s, r, l) {
    const c = this._pingPongRenderTarget;
    this._halfBlur(
      t,
      c,
      e,
      s,
      r,
      "latitudinal",
      l
    ), this._halfBlur(
      c,
      t,
      s,
      s,
      r,
      "longitudinal",
      l
    );
  }
  _halfBlur(t, e, s, r, l, c, f) {
    const d = this._renderer, h = this._blurMaterial;
    c !== "latitudinal" && c !== "longitudinal" && console.error(
      "blur direction must be either latitudinal or longitudinal!"
    );
    const m = 3, p = new Un(this._lodPlanes[r], h), _ = h.uniforms, x = this._sizeLods[s] - 1, b = isFinite(l) ? Math.PI / (2 * x) : 2 * Math.PI / (2 * ur - 1), M = l / b, S = isFinite(l) ? 1 + Math.floor(m * M) : ur;
    S > ur && console.warn(`sigmaRadians, ${l}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${ur}`);
    const y = [];
    let C = 0;
    for (let D = 0; D < ur; ++D) {
      const z = D / M, A = Math.exp(-z * z / 2);
      y.push(A), D === 0 ? C += A : D < S && (C += 2 * A);
    }
    for (let D = 0; D < y.length; D++)
      y[D] = y[D] / C;
    _.envMap.value = t.texture, _.samples.value = S, _.weights.value = y, _.latitudinal.value = c === "latitudinal", f && (_.poleAxis.value = f);
    const { _lodMax: T } = this;
    _.dTheta.value = b, _.mipInt.value = T - s;
    const E = this._sizeLods[r], O = 3 * E * (r > T - Lo ? r - T + Lo : 0), N = 4 * (this._cubeSize - E);
    xf(e, O, N, 3 * E, 2 * E), d.setRenderTarget(e), d.render(p, dm);
  }
}
function z3(n) {
  const t = [], e = [], s = [];
  let r = n;
  const l = n - Lo + 1 + Qx.length;
  for (let c = 0; c < l; c++) {
    const f = Math.pow(2, r);
    e.push(f);
    let d = 1 / f;
    c > n - Lo ? d = Qx[c - n + Lo - 1] : c === 0 && (d = 0), s.push(d);
    const h = 1 / (f - 2), m = -h, p = 1 + h, _ = [m, m, p, m, p, p, m, m, p, p, m, p], x = 6, b = 6, M = 3, S = 2, y = 1, C = new Float32Array(M * b * x), T = new Float32Array(S * b * x), E = new Float32Array(y * b * x);
    for (let N = 0; N < x; N++) {
      const D = N % 3 * 2 / 3 - 1, z = N > 2 ? 0 : -1, A = [
        D,
        z,
        0,
        D + 2 / 3,
        z,
        0,
        D + 2 / 3,
        z + 1,
        0,
        D,
        z,
        0,
        D + 2 / 3,
        z + 1,
        0,
        D,
        z + 1,
        0
      ];
      C.set(A, M * b * N), T.set(_, S * b * N);
      const R = [N, N, N, N, N, N];
      E.set(R, y * b * N);
    }
    const O = new Gn();
    O.setAttribute("position", new ln(C, M)), O.setAttribute("uv", new ln(T, S)), O.setAttribute("faceIndex", new ln(E, y)), t.push(O), r > Lo && r--;
  }
  return { lodPlanes: t, sizeLods: e, sigmas: s };
}
function nS(n, t, e) {
  const s = new vr(n, t, e);
  return s.texture.mapping = hd, s.texture.name = "PMREM.cubeUv", s.scissorTest = !0, s;
}
function xf(n, t, e, s, r) {
  n.viewport.set(t, e, s, r), n.scissor.set(t, e, s, r);
}
function I3(n, t, e) {
  const s = new Float32Array(ur), r = new at(0, 1, 0);
  return new Vs({
    name: "SphericalGaussianBlur",
    defines: {
      n: ur,
      CUBEUV_TEXEL_WIDTH: 1 / t,
      CUBEUV_TEXEL_HEIGHT: 1 / e,
      CUBEUV_MAX_MIP: `${n}.0`
    },
    uniforms: {
      envMap: { value: null },
      samples: { value: 1 },
      weights: { value: s },
      latitudinal: { value: !1 },
      dTheta: { value: 0 },
      mipInt: { value: 0 },
      poleAxis: { value: r }
    },
    vertexShader: i0(),
    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: Ca,
    depthTest: !1,
    depthWrite: !1
  });
}
function iS() {
  return new Vs({
    name: "EquirectangularToCubeUV",
    uniforms: {
      envMap: { value: null }
    },
    vertexShader: i0(),
    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: Ca,
    depthTest: !1,
    depthWrite: !1
  });
}
function sS() {
  return new Vs({
    name: "CubemapToCubeUV",
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 }
    },
    vertexShader: i0(),
    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: Ca,
    depthTest: !1,
    depthWrite: !1
  });
}
function i0() {
  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 B3(n) {
  let t = /* @__PURE__ */ new WeakMap(), e = null;
  function s(f) {
    if (f && f.isTexture) {
      const d = f.mapping, h = d === Ym || d === jm, m = d === Go || d === ko;
      if (h || m) {
        let p = t.get(f);
        const _ = p !== void 0 ? p.texture.pmremVersion : 0;
        if (f.isRenderTargetTexture && f.pmremVersion !== _)
          return e === null && (e = new eS(n)), p = h ? e.fromEquirectangular(f, p) : e.fromCubemap(f, p), p.texture.pmremVersion = f.pmremVersion, t.set(f, p), p.texture;
        if (p !== void 0)
          return p.texture;
        {
          const x = f.image;
          return h && x && x.height > 0 || m && x && r(x) ? (e === null && (e = new eS(n)), p = h ? e.fromEquirectangular(f) : e.fromCubemap(f), p.texture.pmremVersion = f.pmremVersion, t.set(f, p), f.addEventListener("dispose", l), p.texture) : null;
        }
      }
    }
    return f;
  }
  function r(f) {
    let d = 0;
    const h = 6;
    for (let m = 0; m < h; m++)
      f[m] !== void 0 && d++;
    return d === h;
  }
  function l(f) {
    const d = f.target;
    d.removeEventListener("dispose", l);
    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: s,
    dispose: c
  };
}
function F3(n) {
  const t = {};
  function e(s) {
    if (t[s] !== void 0)
      return t[s];
    let r;
    switch (s) {
      case "WEBGL_depth_texture":
        r = n.getExtension("WEBGL_depth_texture") || n.getExtension("MOZ_WEBGL_depth_texture") || n.getExtension("WEBKIT_WEBGL_depth_texture");
        break;
      case "EXT_texture_filter_anisotropic":
        r = 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":
        r = 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":
        r = n.getExtension("WEBGL_compressed_texture_pvrtc") || n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
        break;
      default:
        r = n.getExtension(s);
    }
    return t[s] = r, r;
  }
  return {
    has: function(s) {
      return e(s) !== 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(s) {
      const r = e(s);
      return r === null && Ro("THREE.WebGLRenderer: " + s + " extension not supported."), r;
    }
  };
}
function H3(n, t, e, s) {
  const r = {}, l = /* @__PURE__ */ new WeakMap();
  function c(p) {
    const _ = p.target;
    _.index !== null && t.remove(_.index);
    for (const b in _.attributes)
      t.remove(_.attributes[b]);
    _.removeEventListener("dispose", c), delete r[_.id];
    const x = l.get(_);
    x && (t.remove(x), l.delete(_)), s.releaseStatesOfGeometry(_), _.isInstancedBufferGeometry === !0 && delete _._maxInstanceCount, e.memory.geometries--;
  }
  function f(p, _) {
    return r[_.id] === !0 || (_.addEventListener("dispose", c), r[_.id] = !0, e.memory.geometries++), _;
  }
  function d(p) {
    const _ = p.attributes;
    for (const x in _)
      t.update(_[x], n.ARRAY_BUFFER);
  }
  function h(p) {
    const _ = [], x = p.index, b = p.attributes.position;
    let M = 0;
    if (x !== null) {
      const C = x.array;
      M = x.version;
      for (let T = 0, E = C.length; T < E; T += 3) {
        const O = C[T + 0], N = C[T + 1], D = C[T + 2];
        _.push(O, N, N, D, D, O);
      }
    } else if (b !== void 0) {
      const C = b.array;
      M = b.version;
      for (let T = 0, E = C.length / 3 - 1; T < E; T += 3) {
        const O = T + 0, N = T + 1, D = T + 2;
        _.push(O, N, N, D, D, O);
      }
    } else
      return;
    const S = new (CM(_) ? OM : UM)(_, 1);
    S.version = M;
    const y = l.get(p);
    y && t.remove(y), l.set(p, S);
  }
  function m(p) {
    const _ = l.get(p);
    if (_) {
      const x = p.index;
      x !== null && _.version < x.version && h(p);
    } else
      h(p);
    return l.get(p);
  }
  return {
    get: f,
    update: d,
    getWireframeAttribute: m
  };
}
function V3(n, t, e) {
  let s;
  function r(_) {
    s = _;
  }
  let l, c;
  function f(_) {
    l = _.type, c = _.bytesPerElement;
  }
  function d(_, x) {
    n.drawElements(s, x, l, _ * c), e.update(x, s, 1);
  }
  function h(_, x, b) {
    b !== 0 && (n.drawElementsInstanced(s, x, l, _ * c, b), e.update(x, s, b));
  }
  function m(_, x, b) {
    if (b === 0) return;
    t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(s, x, 0, l, _, 0, b);
    let S = 0;
    for (let y = 0; y < b; y++)
      S += x[y];
    e.update(S, s, 1);
  }
  function p(_, x, b, M) {
    if (b === 0) return;
    const S = t.get("WEBGL_multi_draw");
    if (S === null)
      for (let y = 0; y < _.length; y++)
        h(_[y] / c, x[y], M[y]);
    else {
      S.multiDrawElementsInstancedWEBGL(s, x, 0, l, _, 0, M, 0, b);
      let y = 0;
      for (let C = 0; C < b; C++)
        y += x[C] * M[C];
      e.update(y, s, 1);
    }
  }
  this.setMode = r, this.setIndex = f, this.render = d, this.renderInstances = h, this.renderMultiDraw = m, this.renderMultiDrawInstances = p;
}
function G3(n) {
  const t = {
    geometries: 0,
    textures: 0
  }, e = {
    frame: 0,
    calls: 0,
    triangles: 0,
    points: 0,
    lines: 0
  };
  function s(l, c, f) {
    switch (e.calls++, c) {
      case n.TRIANGLES:
        e.triangles += f * (l / 3);
        break;
      case n.LINES:
        e.lines += f * (l / 2);
        break;
      case n.LINE_STRIP:
        e.lines += f * (l - 1);
        break;
      case n.LINE_LOOP:
        e.lines += f * l;
        break;
      case n.POINTS:
        e.points += f * l;
        break;
      default:
        console.error("THREE.WebGLInfo: Unknown draw mode:", c);
        break;
    }
  }
  function r() {
    e.calls = 0, e.triangles = 0, e.points = 0, e.lines = 0;
  }
  return {
    memory: t,
    render: e,
    programs: null,
    autoReset: !0,
    reset: r,
    update: s
  };
}
function k3(n, t, e) {
  const s = /* @__PURE__ */ new WeakMap(), r = new on();
  function l(c, f, d) {
    const h = c.morphTargetInfluences, m = f.morphAttributes.position || f.morphAttributes.normal || f.morphAttributes.color, p = m !== void 0 ? m.length : 0;
    let _ = s.get(f);
    if (_ === void 0 || _.count !== p) {
      let A = function() {
        D.dispose(), s.delete(f), f.removeEventListener("dispose", A);
      };
      _ !== void 0 && _.texture.dispose();
      const x = f.morphAttributes.position !== void 0, b = f.morphAttributes.normal !== void 0, M = f.morphAttributes.color !== void 0, S = f.morphAttributes.position || [], y = f.morphAttributes.normal || [], C = f.morphAttributes.color || [];
      let T = 0;
      x === !0 && (T = 1), b === !0 && (T = 2), M === !0 && (T = 3);
      let E = f.attributes.position.count * T, O = 1;
      E > t.maxTextureSize && (O = Math.ceil(E / t.maxTextureSize), E = t.maxTextureSize);
      const N = new Float32Array(E * O * 4 * p), D = new DM(N, E, O, p);
      D.type = Ii, D.needsUpdate = !0;
      const z = T * 4;
      for (let R = 0; R < p; R++) {
        const L = S[R], H = y[R], k = C[R], P = E * O * 4 * R;
        for (let Y = 0; Y < L.count; Y++) {
          const U = Y * z;
          x === !0 && (r.fromBufferAttribute(L, Y), N[P + U + 0] = r.x, N[P + U + 1] = r.y, N[P + U + 2] = r.z, N[P + U + 3] = 0), b === !0 && (r.fromBufferAttribute(H, Y), N[P + U + 4] = r.x, N[P + U + 5] = r.y, N[P + U + 6] = r.z, N[P + U + 7] = 0), M === !0 && (r.fromBufferAttribute(k, Y), N[P + U + 8] = r.x, N[P + U + 9] = r.y, N[P + U + 10] = r.z, N[P + U + 11] = k.itemSize === 4 ? r.w : 1);
        }
      }
      _ = {
        count: p,
        texture: D,
        size: new le(E, O)
      }, s.set(f, _), f.addEventListener("dispose", A);
    }
    if (c.isInstancedMesh === !0 && c.morphTexture !== null)
      d.getUniforms().setValue(n, "morphTexture", c.morphTexture, e);
    else {
      let x = 0;
      for (let M = 0; M < h.length; M++)
        x += h[M];
      const b = f.morphTargetsRelative ? 1 : 1 - x;
      d.getUniforms().setValue(n, "morphTargetBaseInfluence", b), d.getUniforms().setValue(n, "morphTargetInfluences", h);
    }
    d.getUniforms().setValue(n, "morphTargetsTexture", _.texture, e), d.getUniforms().setValue(n, "morphTargetsTextureSize", _.size);
  }
  return {
    update: l
  };
}
function X3(n, t, e, s) {
  let r = /* @__PURE__ */ new WeakMap();
  function l(d) {
    const h = s.render.frame, m = d.geometry, p = t.get(d, m);
    if (r.get(p) !== h && (t.update(p), r.set(p, h)), d.isInstancedMesh && (d.hasEventListener("dispose", f) === !1 && d.addEventListener("dispose", f), r.get(d) !== h && (e.update(d.instanceMatrix, n.ARRAY_BUFFER), d.instanceColor !== null && e.update(d.instanceColor, n.ARRAY_BUFFER), r.set(d, h))), d.isSkinnedMesh) {
      const _ = d.skeleton;
      r.get(_) !== h && (_.update(), r.set(_, h));
    }
    return p;
  }
  function c() {
    r = /* @__PURE__ */ new WeakMap();
  }
  function f(d) {
    const h = d.target;
    h.removeEventListener("dispose", f), e.remove(h.instanceMatrix), h.instanceColor !== null && e.remove(h.instanceColor);
  }
  return {
    update: l,
    dispose: c
  };
}
const WM = /* @__PURE__ */ new jn(), aS = /* @__PURE__ */ new VM(1, 1), YM = /* @__PURE__ */ new DM(), jM = /* @__PURE__ */ new _2(), qM = /* @__PURE__ */ new IM(), rS = [], oS = [], lS = new Float32Array(16), cS = new Float32Array(9), uS = new Float32Array(4);
function il(n, t, e) {
  const s = n[0];
  if (s <= 0 || s > 0) return n;
  const r = t * e;
  let l = rS[r];
  if (l === void 0 && (l = new Float32Array(r), rS[r] = l), t !== 0) {
    s.toArray(l, 0);
    for (let c = 1, f = 0; c !== t; ++c)
      f += e, n[c].toArray(l, f);
  }
  return l;
}
function Cn(n, t) {
  if (n.length !== t.length) return !1;
  for (let e = 0, s = n.length; e < s; e++)
    if (n[e] !== t[e]) return !1;
  return !0;
}
function Rn(n, t) {
  for (let e = 0, s = t.length; e < s; e++)
    n[e] = t[e];
}
function gd(n, t) {
  let e = oS[t];
  e === void 0 && (e = new Int32Array(t), oS[t] = e);
  for (let s = 0; s !== t; ++s)
    e[s] = n.allocateTextureUnit();
  return e;
}
function W3(n, t) {
  const e = this.cache;
  e[0] !== t && (n.uniform1f(this.addr, t), e[0] = t);
}
function Y3(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 (Cn(e, t)) return;
    n.uniform2fv(this.addr, t), Rn(e, t);
  }
}
function j3(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 (Cn(e, t)) return;
    n.uniform3fv(this.addr, t), Rn(e, t);
  }
}
function q3(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 (Cn(e, t)) return;
    n.uniform4fv(this.addr, t), Rn(e, t);
  }
}
function Z3(n, t) {
  const e = this.cache, s = t.elements;
  if (s === void 0) {
    if (Cn(e, t)) return;
    n.uniformMatrix2fv(this.addr, !1, t), Rn(e, t);
  } else {
    if (Cn(e, s)) return;
    uS.set(s), n.uniformMatrix2fv(this.addr, !1, uS), Rn(e, s);
  }
}
function K3(n, t) {
  const e = this.cache, s = t.elements;
  if (s === void 0) {
    if (Cn(e, t)) return;
    n.uniformMatrix3fv(this.addr, !1, t), Rn(e, t);
  } else {
    if (Cn(e, s)) return;
    cS.set(s), n.uniformMatrix3fv(this.addr, !1, cS), Rn(e, s);
  }
}
function $3(n, t) {
  const e = this.cache, s = t.elements;
  if (s === void 0) {
    if (Cn(e, t)) return;
    n.uniformMatrix4fv(this.addr, !1, t), Rn(e, t);
  } else {
    if (Cn(e, s)) return;
    lS.set(s), n.uniformMatrix4fv(this.addr, !1, lS), Rn(e, s);
  }
}
function Q3(n, t) {
  const e = this.cache;
  e[0] !== t && (n.uniform1i(this.addr, t), e[0] = t);
}
function J3(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 (Cn(e, t)) return;
    n.uniform2iv(this.addr, t), Rn(e, t);
  }
}
function tD(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 (Cn(e, t)) return;
    n.uniform3iv(this.addr, t), Rn(e, t);
  }
}
function eD(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 (Cn(e, t)) return;
    n.uniform4iv(this.addr, t), Rn(e, t);
  }
}
function nD(n, t) {
  const e = this.cache;
  e[0] !== t && (n.uniform1ui(this.addr, t), e[0] = t);
}
function iD(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 (Cn(e, t)) return;
    n.uniform2uiv(this.addr, t), Rn(e, t);
  }
}
function sD(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 (Cn(e, t)) return;
    n.uniform3uiv(this.addr, t), Rn(e, t);
  }
}
function aD(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 (Cn(e, t)) return;
    n.uniform4uiv(this.addr, t), Rn(e, t);
  }
}
function rD(n, t, e) {
  const s = this.cache, r = e.allocateTextureUnit();
  s[0] !== r && (n.uniform1i(this.addr, r), s[0] = r);
  let l;
  this.type === n.SAMPLER_2D_SHADOW ? (aS.compareFunction = wM, l = aS) : l = WM, e.setTexture2D(t || l, r);
}
function oD(n, t, e) {
  const s = this.cache, r = e.allocateTextureUnit();
  s[0] !== r && (n.uniform1i(this.addr, r), s[0] = r), e.setTexture3D(t || jM, r);
}
function lD(n, t, e) {
  const s = this.cache, r = e.allocateTextureUnit();
  s[0] !== r && (n.uniform1i(this.addr, r), s[0] = r), e.setTextureCube(t || qM, r);
}
function cD(n, t, e) {
  const s = this.cache, r = e.allocateTextureUnit();
  s[0] !== r && (n.uniform1i(this.addr, r), s[0] = r), e.setTexture2DArray(t || YM, r);
}
function uD(n) {
  switch (n) {
    case 5126:
      return W3;
    // FLOAT
    case 35664:
      return Y3;
    // _VEC2
    case 35665:
      return j3;
    // _VEC3
    case 35666:
      return q3;
    // _VEC4
    case 35674:
      return Z3;
    // _MAT2
    case 35675:
      return K3;
    // _MAT3
    case 35676:
      return $3;
    // _MAT4
    case 5124:
    case 35670:
      return Q3;
    // INT, BOOL
    case 35667:
    case 35671:
      return J3;
    // _VEC2
    case 35668:
    case 35672:
      return tD;
    // _VEC3
    case 35669:
    case 35673:
      return eD;
    // _VEC4
    case 5125:
      return nD;
    // UINT
    case 36294:
      return iD;
    // _VEC2
    case 36295:
      return sD;
    // _VEC3
    case 36296:
      return aD;
    // _VEC4
    case 35678:
    // SAMPLER_2D
    case 36198:
    // SAMPLER_EXTERNAL_OES
    case 36298:
    // INT_SAMPLER_2D
    case 36306:
    // UNSIGNED_INT_SAMPLER_2D
    case 35682:
      return rD;
    case 35679:
    // SAMPLER_3D
    case 36299:
    // INT_SAMPLER_3D
    case 36307:
      return oD;
    case 35680:
    // SAMPLER_CUBE
    case 36300:
    // INT_SAMPLER_CUBE
    case 36308:
    // UNSIGNED_INT_SAMPLER_CUBE
    case 36293:
      return lD;
    case 36289:
    // SAMPLER_2D_ARRAY
    case 36303:
    // INT_SAMPLER_2D_ARRAY
    case 36311:
    // UNSIGNED_INT_SAMPLER_2D_ARRAY
    case 36292:
      return cD;
  }
}
function fD(n, t) {
  n.uniform1fv(this.addr, t);
}
function dD(n, t) {
  const e = il(t, this.size, 2);
  n.uniform2fv(this.addr, e);
}
function hD(n, t) {
  const e = il(t, this.size, 3);
  n.uniform3fv(this.addr, e);
}
function pD(n, t) {
  const e = il(t, this.size, 4);
  n.uniform4fv(this.addr, e);
}
function mD(n, t) {
  const e = il(t, this.size, 4);
  n.uniformMatrix2fv(this.addr, !1, e);
}
function gD(n, t) {
  const e = il(t, this.size, 9);
  n.uniformMatrix3fv(this.addr, !1, e);
}
function _D(n, t) {
  const e = il(t, this.size, 16);
  n.uniformMatrix4fv(this.addr, !1, e);
}
function vD(n, t) {
  n.uniform1iv(this.addr, t);
}
function yD(n, t) {
  n.uniform2iv(this.addr, t);
}
function xD(n, t) {
  n.uniform3iv(this.addr, t);
}
function SD(n, t) {
  n.uniform4iv(this.addr, t);
}
function bD(n, t) {
  n.uniform1uiv(this.addr, t);
}
function MD(n, t) {
  n.uniform2uiv(this.addr, t);
}
function ED(n, t) {
  n.uniform3uiv(this.addr, t);
}
function TD(n, t) {
  n.uniform4uiv(this.addr, t);
}
function AD(n, t, e) {
  const s = this.cache, r = t.length, l = gd(e, r);
  Cn(s, l) || (n.uniform1iv(this.addr, l), Rn(s, l));
  for (let c = 0; c !== r; ++c)
    e.setTexture2D(t[c] || WM, l[c]);
}
function wD(n, t, e) {
  const s = this.cache, r = t.length, l = gd(e, r);
  Cn(s, l) || (n.uniform1iv(this.addr, l), Rn(s, l));
  for (let c = 0; c !== r; ++c)
    e.setTexture3D(t[c] || jM, l[c]);
}
function CD(n, t, e) {
  const s = this.cache, r = t.length, l = gd(e, r);
  Cn(s, l) || (n.uniform1iv(this.addr, l), Rn(s, l));
  for (let c = 0; c !== r; ++c)
    e.setTextureCube(t[c] || qM, l[c]);
}
function RD(n, t, e) {
  const s = this.cache, r = t.length, l = gd(e, r);
  Cn(s, l) || (n.uniform1iv(this.addr, l), Rn(s, l));
  for (let c = 0; c !== r; ++c)
    e.setTexture2DArray(t[c] || YM, l[c]);
}
function DD(n) {
  switch (n) {
    case 5126:
      return fD;
    // FLOAT
    case 35664:
      return dD;
    // _VEC2
    case 35665:
      return hD;
    // _VEC3
    case 35666:
      return pD;
    // _VEC4
    case 35674:
      return mD;
    // _MAT2
    case 35675:
      return gD;
    // _MAT3
    case 35676:
      return _D;
    // _MAT4
    case 5124:
    case 35670:
      return vD;
    // INT, BOOL
    case 35667:
    case 35671:
      return yD;
    // _VEC2
    case 35668:
    case 35672:
      return xD;
    // _VEC3
    case 35669:
    case 35673:
      return SD;
    // _VEC4
    case 5125:
      return bD;
    // UINT
    case 36294:
      return MD;
    // _VEC2
    case 36295:
      return ED;
    // _VEC3
    case 36296:
      return TD;
    // _VEC4
    case 35678:
    // SAMPLER_2D
    case 36198:
    // SAMPLER_EXTERNAL_OES
    case 36298:
    // INT_SAMPLER_2D
    case 36306:
    // UNSIGNED_INT_SAMPLER_2D
    case 35682:
      return AD;
    case 35679:
    // SAMPLER_3D
    case 36299:
    // INT_SAMPLER_3D
    case 36307:
      return wD;
    case 35680:
    // SAMPLER_CUBE
    case 36300:
    // INT_SAMPLER_CUBE
    case 36308:
    // UNSIGNED_INT_SAMPLER_CUBE
    case 36293:
      return CD;
    case 36289:
    // SAMPLER_2D_ARRAY
    case 36303:
    // INT_SAMPLER_2D_ARRAY
    case 36311:
    // UNSIGNED_INT_SAMPLER_2D_ARRAY
    case 36292:
      return RD;
  }
}
class ND {
  constructor(t, e, s) {
    this.id = t, this.addr = s, this.cache = [], this.type = e.type, this.setValue = uD(e.type);
  }
}
class LD {
  constructor(t, e, s) {
    this.id = t, this.addr = s, this.cache = [], this.type = e.type, this.size = e.size, this.setValue = DD(e.type);
  }
}
class UD {
  constructor(t) {
    this.id = t, this.seq = [], this.map = {};
  }
  setValue(t, e, s) {
    const r = this.seq;
    for (let l = 0, c = r.length; l !== c; ++l) {
      const f = r[l];
      f.setValue(t, e[f.id], s);
    }
  }
}
const _m = /(\w+)(\])?(\[|\.)?/g;
function fS(n, t) {
  n.seq.push(t), n.map[t.id] = t;
}
function OD(n, t, e) {
  const s = n.name, r = s.length;
  for (_m.lastIndex = 0; ; ) {
    const l = _m.exec(s), c = _m.lastIndex;
    let f = l[1];
    const d = l[2] === "]", h = l[3];
    if (d && (f = f | 0), h === void 0 || h === "[" && c + 2 === r) {
      fS(e, h === void 0 ? new ND(f, n, t) : new LD(f, n, t));
      break;
    } else {
      let p = e.map[f];
      p === void 0 && (p = new UD(f), fS(e, p)), e = p;
    }
  }
}
class Gf {
  constructor(t, e) {
    this.seq = [], this.map = {};
    const s = t.getProgramParameter(e, t.ACTIVE_UNIFORMS);
    for (let r = 0; r < s; ++r) {
      const l = t.getActiveUniform(e, r), c = t.getUniformLocation(e, l.name);
      OD(l, c, this);
    }
  }
  setValue(t, e, s, r) {
    const l = this.map[e];
    l !== void 0 && l.setValue(t, s, r);
  }
  setOptional(t, e, s) {
    const r = e[s];
    r !== void 0 && this.setValue(t, s, r);
  }
  static upload(t, e, s, r) {
    for (let l = 0, c = e.length; l !== c; ++l) {
      const f = e[l], d = s[f.id];
      d.needsUpdate !== !1 && f.setValue(t, d.value, r);
    }
  }
  static seqWithValue(t, e) {
    const s = [];
    for (let r = 0, l = t.length; r !== l; ++r) {
      const c = t[r];
      c.id in e && s.push(c);
    }
    return s;
  }
}
function dS(n, t, e) {
  const s = n.createShader(t);
  return n.shaderSource(s, e), n.compileShader(s), s;
}
const PD = 37297;
let zD = 0;
function ID(n, t) {
  const e = n.split(`
`), s = [], r = Math.max(t - 6, 0), l = Math.min(t + 6, e.length);
  for (let c = r; c < l; c++) {
    const f = c + 1;
    s.push(`${f === t ? ">" : " "} ${f}: ${e[c]}`);
  }
  return s.join(`
`);
}
const hS = /* @__PURE__ */ new _e();
function BD(n) {
  Ie._getMatrix(hS, Ie.workingColorSpace, n);
  const t = `mat3( ${hS.elements.map((e) => e.toFixed(4))} )`;
  switch (Ie.getTransfer(n)) {
    case Zf:
      return [t, "LinearTransferOETF"];
    case We:
      return [t, "sRGBTransferOETF"];
    default:
      return console.warn("THREE.WebGLProgram: Unsupported color space: ", n), [t, "LinearTransferOETF"];
  }
}
function pS(n, t, e) {
  const s = n.getShaderParameter(t, n.COMPILE_STATUS), r = n.getShaderInfoLog(t).trim();
  if (s && r === "") return "";
  const l = /ERROR: 0:(\d+)/.exec(r);
  if (l) {
    const c = parseInt(l[1]);
    return e.toUpperCase() + `

` + r + `

` + ID(n.getShaderSource(t), c);
  } else
    return r;
}
function FD(n, t) {
  const e = BD(t);
  return [
    `vec4 ${n}( vec4 value ) {`,
    `	return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,
    "}"
  ].join(`
`);
}
function HD(n, t) {
  let e;
  switch (t) {
    case Gw:
      e = "Linear";
      break;
    case kw:
      e = "Reinhard";
      break;
    case Xw:
      e = "Cineon";
      break;
    case Ww:
      e = "ACESFilmic";
      break;
    case jw:
      e = "AgX";
      break;
    case qw:
      e = "Neutral";
      break;
    case Yw:
      e = "Custom";
      break;
    default:
      console.warn("THREE.WebGLProgram: Unsupported toneMapping:", t), e = "Linear";
  }
  return "vec3 " + n + "( vec3 color ) { return " + e + "ToneMapping( color ); }";
}
const Sf = /* @__PURE__ */ new at();
function VD() {
  Ie.getLuminanceCoefficients(Sf);
  const n = Sf.x.toFixed(4), t = Sf.y.toFixed(4), e = Sf.z.toFixed(4);
  return [
    "float luminance( const in vec3 rgb ) {",
    `	const vec3 weights = vec3( ${n}, ${t}, ${e} );`,
    "	return dot( weights, rgb );",
    "}"
  ].join(`
`);
}
function GD(n) {
  return [
    n.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "",
    n.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""
  ].filter(cc).join(`
`);
}
function kD(n) {
  const t = [];
  for (const e in n) {
    const s = n[e];
    s !== !1 && t.push("#define " + e + " " + s);
  }
  return t.join(`
`);
}
function XD(n, t) {
  const e = {}, s = n.getProgramParameter(t, n.ACTIVE_ATTRIBUTES);
  for (let r = 0; r < s; r++) {
    const l = n.getActiveAttrib(t, r), c = l.name;
    let f = 1;
    l.type === n.FLOAT_MAT2 && (f = 2), l.type === n.FLOAT_MAT3 && (f = 3), l.type === n.FLOAT_MAT4 && (f = 4), e[c] = {
      type: l.type,
      location: n.getAttribLocation(t, c),
      locationSize: f
    };
  }
  return e;
}
function cc(n) {
  return n !== "";
}
function mS(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 gS(n, t) {
  return n.replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection);
}
const WD = /^[ \t]*#include +<([\w\d./]+)>/gm;
function Ag(n) {
  return n.replace(WD, jD);
}
const YD = /* @__PURE__ */ new Map();
function jD(n, t) {
  let e = ye[t];
  if (e === void 0) {
    const s = YD.get(t);
    if (s !== void 0)
      e = ye[s], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', t, s);
    else
      throw new Error("Can not resolve #include <" + t + ">");
  }
  return Ag(e);
}
const qD = /#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(qD, ZD);
}
function ZD(n, t, e, s) {
  let r = "";
  for (let l = parseInt(t); l < parseInt(e); l++)
    r += s.replace(/\[\s*i\s*\]/g, "[ " + l + " ]").replace(/UNROLLED_LOOP_INDEX/g, l);
  return r;
}
function vS(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 KD(n) {
  let t = "SHADOWMAP_TYPE_BASIC";
  return n.shadowMapType === mM ? t = "SHADOWMAP_TYPE_PCF" : n.shadowMapType === Sw ? t = "SHADOWMAP_TYPE_PCF_SOFT" : n.shadowMapType === Os && (t = "SHADOWMAP_TYPE_VSM"), t;
}
function $D(n) {
  let t = "ENVMAP_TYPE_CUBE";
  if (n.envMap)
    switch (n.envMapMode) {
      case Go:
      case ko:
        t = "ENVMAP_TYPE_CUBE";
        break;
      case hd:
        t = "ENVMAP_TYPE_CUBE_UV";
        break;
    }
  return t;
}
function QD(n) {
  let t = "ENVMAP_MODE_REFLECTION";
  if (n.envMap)
    switch (n.envMapMode) {
      case ko:
        t = "ENVMAP_MODE_REFRACTION";
        break;
    }
  return t;
}
function JD(n) {
  let t = "ENVMAP_BLENDING_NONE";
  if (n.envMap)
    switch (n.combine) {
      case Xg:
        t = "ENVMAP_BLENDING_MULTIPLY";
        break;
      case Hw:
        t = "ENVMAP_BLENDING_MIX";
        break;
      case Vw:
        t = "ENVMAP_BLENDING_ADD";
        break;
    }
  return t;
}
function tN(n) {
  const t = n.envMapCubeUVHeight;
  if (t === null) return null;
  const e = Math.log2(t) - 2, s = 1 / t;
  return { texelWidth: 1 / (3 * Math.max(Math.pow(2, e), 112)), texelHeight: s, maxMip: e };
}
function eN(n, t, e, s) {
  const r = n.getContext(), l = e.defines;
  let c = e.vertexShader, f = e.fragmentShader;
  const d = KD(e), h = $D(e), m = QD(e), p = JD(e), _ = tN(e), x = GD(e), b = kD(l), M = r.createProgram();
  let S, y, C = e.glslVersion ? "#version " + e.glslVersion + `
` : "";
  e.isRawShaderMaterial ? (S = [
    "#define SHADER_TYPE " + e.shaderType,
    "#define SHADER_NAME " + e.shaderName,
    b
  ].filter(cc).join(`
`), S.length > 0 && (S += `
`), y = [
    "#define SHADER_TYPE " + e.shaderType,
    "#define SHADER_NAME " + e.shaderName,
    b
  ].filter(cc).join(`
`), y.length > 0 && (y += `
`)) : (S = [
    vS(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 " + m : "",
    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(cc).join(`
`), y = [
    vS(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 " + m : "",
    e.envMap ? "#define " + p : "",
    _ ? "#define CUBEUV_TEXEL_WIDTH " + _.texelWidth : "",
    _ ? "#define CUBEUV_TEXEL_HEIGHT " + _.texelHeight : "",
    _ ? "#define CUBEUV_MAX_MIP " + _.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 !== Ra ? "#define TONE_MAPPING" : "",
    e.toneMapping !== Ra ? ye.tonemapping_pars_fragment : "",
    // this code is required here because it is used by the toneMapping() function defined below
    e.toneMapping !== Ra ? HD("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
    FD("linearToOutputTexel", e.outputColorSpace),
    VD(),
    e.useDepthPacking ? "#define DEPTH_PACKING " + e.depthPacking : "",
    `
`
  ].filter(cc).join(`
`)), c = Ag(c), c = mS(c, e), c = gS(c, e), f = Ag(f), f = mS(f, e), f = gS(f, e), c = _S(c), f = _S(f), e.isRawShaderMaterial !== !0 && (C = `#version 300 es
`, S = [
    x,
    "#define attribute in",
    "#define varying out",
    "#define texture2D texture"
  ].join(`
`) + `
` + S, y = [
    "#define varying in",
    e.glslVersion === Kf ? "" : "layout(location = 0) out highp vec4 pc_fragColor;",
    e.glslVersion === Kf ? "" : "#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 T = C + S + c, E = C + y + f, O = dS(r, r.VERTEX_SHADER, T), N = dS(r, r.FRAGMENT_SHADER, E);
  r.attachShader(M, O), r.attachShader(M, N), e.index0AttributeName !== void 0 ? r.bindAttribLocation(M, 0, e.index0AttributeName) : e.morphTargets === !0 && r.bindAttribLocation(M, 0, "position"), r.linkProgram(M);
  function D(L) {
    if (n.debug.checkShaderErrors) {
      const H = r.getProgramInfoLog(M).trim(), k = r.getShaderInfoLog(O).trim(), P = r.getShaderInfoLog(N).trim();
      let Y = !0, U = !0;
      if (r.getProgramParameter(M, r.LINK_STATUS) === !1)
        if (Y = !1, typeof n.debug.onShaderError == "function")
          n.debug.onShaderError(r, M, O, N);
        else {
          const X = pS(r, O, "vertex"), V = pS(r, N, "fragment");
          console.error(
            "THREE.WebGLProgram: Shader Error " + r.getError() + " - VALIDATE_STATUS " + r.getProgramParameter(M, r.VALIDATE_STATUS) + `

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

Program Info Log: ` + H + `
` + X + `
` + V
          );
        }
      else H !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", H) : (k === "" || P === "") && (U = !1);
      U && (L.diagnostics = {
        runnable: Y,
        programLog: H,
        vertexShader: {
          log: k,
          prefix: S
        },
        fragmentShader: {
          log: P,
          prefix: y
        }
      });
    }
    r.deleteShader(O), r.deleteShader(N), z = new Gf(r, M), A = XD(r, M);
  }
  let z;
  this.getUniforms = function() {
    return z === void 0 && D(this), z;
  };
  let A;
  this.getAttributes = function() {
    return A === void 0 && D(this), A;
  };
  let R = e.rendererExtensionParallelShaderCompile === !1;
  return this.isReady = function() {
    return R === !1 && (R = r.getProgramParameter(M, PD)), R;
  }, this.destroy = function() {
    s.releaseStatesOfProgram(this), r.deleteProgram(M), this.program = void 0;
  }, this.type = e.shaderType, this.name = e.shaderName, this.id = zD++, this.cacheKey = t, this.usedTimes = 1, this.program = M, this.vertexShader = O, this.fragmentShader = N, this;
}
let nN = 0;
class iN {
  constructor() {
    this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();
  }
  update(t) {
    const e = t.vertexShader, s = t.fragmentShader, r = this._getShaderStage(e), l = this._getShaderStage(s), c = this._getShaderCacheForMaterial(t);
    return c.has(r) === !1 && (c.add(r), r.usedTimes++), c.has(l) === !1 && (c.add(l), l.usedTimes++), this;
  }
  remove(t) {
    const e = this.materialCache.get(t);
    for (const s of e)
      s.usedTimes--, s.usedTimes === 0 && this.shaderCache.delete(s.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 s = e.get(t);
    return s === void 0 && (s = /* @__PURE__ */ new Set(), e.set(t, s)), s;
  }
  _getShaderStage(t) {
    const e = this.shaderCache;
    let s = e.get(t);
    return s === void 0 && (s = new sN(t), e.set(t, s)), s;
  }
}
class sN {
  constructor(t) {
    this.id = nN++, this.code = t, this.usedTimes = 0;
  }
}
function aN(n, t, e, s, r, l, c) {
  const f = new NM(), d = new iN(), h = /* @__PURE__ */ new Set(), m = [], p = r.logarithmicDepthBuffer, _ = r.vertexTextures;
  let x = r.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 M(A) {
    return h.add(A), A === 0 ? "uv" : `uv${A}`;
  }
  function S(A, R, L, H, k) {
    const P = H.fog, Y = k.geometry, U = A.isMeshStandardMaterial ? H.environment : null, X = (A.isMeshStandardMaterial ? e : t).get(A.envMap || U), V = X && X.mapping === hd ? X.image.height : null, W = b[A.type];
    A.precision !== null && (x = r.getMaxPrecision(A.precision), x !== A.precision && console.warn("THREE.WebGLProgram.getParameters:", A.precision, "not supported, using", x, "instead."));
    const J = Y.morphAttributes.position || Y.morphAttributes.normal || Y.morphAttributes.color, I = J !== void 0 ? J.length : 0;
    let q = 0;
    Y.morphAttributes.position !== void 0 && (q = 1), Y.morphAttributes.normal !== void 0 && (q = 2), Y.morphAttributes.color !== void 0 && (q = 3);
    let lt, $, ot, gt;
    if (W) {
      const De = Ji[W];
      lt = De.vertexShader, $ = De.fragmentShader;
    } else
      lt = A.vertexShader, $ = A.fragmentShader, d.update(A), ot = d.getVertexShaderID(A), gt = d.getFragmentShaderID(A);
    const ht = n.getRenderTarget(), _t = n.state.buffers.depth.getReversed(), Et = k.isInstancedMesh === !0, Lt = k.isBatchedMesh === !0, Gt = !!A.map, Nt = !!A.matcap, Bt = !!X, K = !!A.aoMap, pe = !!A.lightMap, Xt = !!A.bumpMap, se = !!A.normalMap, qt = !!A.displacementMap, xe = !!A.emissiveMap, jt = !!A.metalnessMap, j = !!A.roughnessMap, B = A.anisotropy > 0, ft = A.clearcoat > 0, St = A.dispersion > 0, wt = A.iridescence > 0, bt = A.sheen > 0, Zt = A.transmission > 0, Ut = B && !!A.anisotropyMap, Wt = ft && !!A.clearcoatMap, ve = ft && !!A.clearcoatNormalMap, Dt = ft && !!A.clearcoatRoughnessMap, Yt = wt && !!A.iridescenceMap, Jt = wt && !!A.iridescenceThicknessMap, $t = bt && !!A.sheenColorMap, Vt = bt && !!A.sheenRoughnessMap, re = !!A.specularMap, de = !!A.specularColorMap, Fe = !!A.specularIntensityMap, nt = Zt && !!A.transmissionMap, Ot = Zt && !!A.thicknessMap, yt = !!A.gradientMap, At = !!A.alphaMap, Pt = A.alphaTest > 0, zt = !!A.alphaHash, ce = !!A.extensions;
    let $e = Ra;
    A.toneMapped && (ht === null || ht.isXRRenderTarget === !0) && ($e = n.toneMapping);
    const fn = {
      shaderID: W,
      shaderType: A.type,
      shaderName: A.name,
      vertexShader: lt,
      fragmentShader: $,
      defines: A.defines,
      customVertexShaderID: ot,
      customFragmentShaderID: gt,
      isRawShaderMaterial: A.isRawShaderMaterial === !0,
      glslVersion: A.glslVersion,
      precision: x,
      batching: Lt,
      batchingColor: Lt && k._colorsTexture !== null,
      instancing: Et,
      instancingColor: Et && k.instanceColor !== null,
      instancingMorph: Et && k.morphTexture !== null,
      supportsVertexTextures: _,
      outputColorSpace: ht === null ? n.outputColorSpace : ht.isXRRenderTarget === !0 ? ht.texture.colorSpace : Yo,
      alphaToCoverage: !!A.alphaToCoverage,
      map: Gt,
      matcap: Nt,
      envMap: Bt,
      envMapMode: Bt && X.mapping,
      envMapCubeUVHeight: V,
      aoMap: K,
      lightMap: pe,
      bumpMap: Xt,
      normalMap: se,
      displacementMap: _ && qt,
      emissiveMap: xe,
      normalMapObjectSpace: se && A.normalMapType === Qw,
      normalMapTangentSpace: se && A.normalMapType === AM,
      metalnessMap: jt,
      roughnessMap: j,
      anisotropy: B,
      anisotropyMap: Ut,
      clearcoat: ft,
      clearcoatMap: Wt,
      clearcoatNormalMap: ve,
      clearcoatRoughnessMap: Dt,
      dispersion: St,
      iridescence: wt,
      iridescenceMap: Yt,
      iridescenceThicknessMap: Jt,
      sheen: bt,
      sheenColorMap: $t,
      sheenRoughnessMap: Vt,
      specularMap: re,
      specularColorMap: de,
      specularIntensityMap: Fe,
      transmission: Zt,
      transmissionMap: nt,
      thicknessMap: Ot,
      gradientMap: yt,
      opaque: A.transparent === !1 && A.blending === zo && A.alphaToCoverage === !1,
      alphaMap: At,
      alphaTest: Pt,
      alphaHash: zt,
      combine: A.combine,
      //
      mapUv: Gt && M(A.map.channel),
      aoMapUv: K && M(A.aoMap.channel),
      lightMapUv: pe && M(A.lightMap.channel),
      bumpMapUv: Xt && M(A.bumpMap.channel),
      normalMapUv: se && M(A.normalMap.channel),
      displacementMapUv: qt && M(A.displacementMap.channel),
      emissiveMapUv: xe && M(A.emissiveMap.channel),
      metalnessMapUv: jt && M(A.metalnessMap.channel),
      roughnessMapUv: j && M(A.roughnessMap.channel),
      anisotropyMapUv: Ut && M(A.anisotropyMap.channel),
      clearcoatMapUv: Wt && M(A.clearcoatMap.channel),
      clearcoatNormalMapUv: ve && M(A.clearcoatNormalMap.channel),
      clearcoatRoughnessMapUv: Dt && M(A.clearcoatRoughnessMap.channel),
      iridescenceMapUv: Yt && M(A.iridescenceMap.channel),
      iridescenceThicknessMapUv: Jt && M(A.iridescenceThicknessMap.channel),
      sheenColorMapUv: $t && M(A.sheenColorMap.channel),
      sheenRoughnessMapUv: Vt && M(A.sheenRoughnessMap.channel),
      specularMapUv: re && M(A.specularMap.channel),
      specularColorMapUv: de && M(A.specularColorMap.channel),
      specularIntensityMapUv: Fe && M(A.specularIntensityMap.channel),
      transmissionMapUv: nt && M(A.transmissionMap.channel),
      thicknessMapUv: Ot && M(A.thicknessMap.channel),
      alphaMapUv: At && M(A.alphaMap.channel),
      //
      vertexTangents: !!Y.attributes.tangent && (se || B),
      vertexColors: A.vertexColors,
      vertexAlphas: A.vertexColors === !0 && !!Y.attributes.color && Y.attributes.color.itemSize === 4,
      pointsUvs: k.isPoints === !0 && !!Y.attributes.uv && (Gt || At),
      fog: !!P,
      useFog: A.fog === !0,
      fogExp2: !!P && P.isFogExp2,
      flatShading: A.flatShading === !0,
      sizeAttenuation: A.sizeAttenuation === !0,
      logarithmicDepthBuffer: p,
      reverseDepthBuffer: _t,
      skinning: k.isSkinnedMesh === !0,
      morphTargets: Y.morphAttributes.position !== void 0,
      morphNormals: Y.morphAttributes.normal !== void 0,
      morphColors: Y.morphAttributes.color !== void 0,
      morphTargetsCount: I,
      morphTextureStride: q,
      numDirLights: R.directional.length,
      numPointLights: R.point.length,
      numSpotLights: R.spot.length,
      numSpotLightMaps: R.spotLightMap.length,
      numRectAreaLights: R.rectArea.length,
      numHemiLights: R.hemi.length,
      numDirLightShadows: R.directionalShadowMap.length,
      numPointLightShadows: R.pointShadowMap.length,
      numSpotLightShadows: R.spotShadowMap.length,
      numSpotLightShadowsWithMaps: R.numSpotLightShadowsWithMaps,
      numLightProbes: R.numLightProbes,
      numClippingPlanes: c.numPlanes,
      numClipIntersection: c.numIntersection,
      dithering: A.dithering,
      shadowMapEnabled: n.shadowMap.enabled && L.length > 0,
      shadowMapType: n.shadowMap.type,
      toneMapping: $e,
      decodeVideoTexture: Gt && A.map.isVideoTexture === !0 && Ie.getTransfer(A.map.colorSpace) === We,
      decodeVideoTextureEmissive: xe && A.emissiveMap.isVideoTexture === !0 && Ie.getTransfer(A.emissiveMap.colorSpace) === We,
      premultipliedAlpha: A.premultipliedAlpha,
      doubleSided: A.side === es,
      flipSided: A.side === li,
      useDepthPacking: A.depthPacking >= 0,
      depthPacking: A.depthPacking || 0,
      index0AttributeName: A.index0AttributeName,
      extensionClipCullDistance: ce && A.extensions.clipCullDistance === !0 && s.has("WEBGL_clip_cull_distance"),
      extensionMultiDraw: (ce && A.extensions.multiDraw === !0 || Lt) && s.has("WEBGL_multi_draw"),
      rendererExtensionParallelShaderCompile: s.has("KHR_parallel_shader_compile"),
      customProgramCacheKey: A.customProgramCacheKey()
    };
    return fn.vertexUv1s = h.has(1), fn.vertexUv2s = h.has(2), fn.vertexUv3s = h.has(3), h.clear(), fn;
  }
  function y(A) {
    const R = [];
    if (A.shaderID ? R.push(A.shaderID) : (R.push(A.customVertexShaderID), R.push(A.customFragmentShaderID)), A.defines !== void 0)
      for (const L in A.defines)
        R.push(L), R.push(A.defines[L]);
    return A.isRawShaderMaterial === !1 && (C(R, A), T(R, A), R.push(n.outputColorSpace)), R.push(A.customProgramCacheKey), R.join();
  }
  function C(A, R) {
    A.push(R.precision), A.push(R.outputColorSpace), A.push(R.envMapMode), A.push(R.envMapCubeUVHeight), A.push(R.mapUv), A.push(R.alphaMapUv), A.push(R.lightMapUv), A.push(R.aoMapUv), A.push(R.bumpMapUv), A.push(R.normalMapUv), A.push(R.displacementMapUv), A.push(R.emissiveMapUv), A.push(R.metalnessMapUv), A.push(R.roughnessMapUv), A.push(R.anisotropyMapUv), A.push(R.clearcoatMapUv), A.push(R.clearcoatNormalMapUv), A.push(R.clearcoatRoughnessMapUv), A.push(R.iridescenceMapUv), A.push(R.iridescenceThicknessMapUv), A.push(R.sheenColorMapUv), A.push(R.sheenRoughnessMapUv), A.push(R.specularMapUv), A.push(R.specularColorMapUv), A.push(R.specularIntensityMapUv), A.push(R.transmissionMapUv), A.push(R.thicknessMapUv), A.push(R.combine), A.push(R.fogExp2), A.push(R.sizeAttenuation), A.push(R.morphTargetsCount), A.push(R.morphAttributeCount), A.push(R.numDirLights), A.push(R.numPointLights), A.push(R.numSpotLights), A.push(R.numSpotLightMaps), A.push(R.numHemiLights), A.push(R.numRectAreaLights), A.push(R.numDirLightShadows), A.push(R.numPointLightShadows), A.push(R.numSpotLightShadows), A.push(R.numSpotLightShadowsWithMaps), A.push(R.numLightProbes), A.push(R.shadowMapType), A.push(R.toneMapping), A.push(R.numClippingPlanes), A.push(R.numClipIntersection), A.push(R.depthPacking);
  }
  function T(A, R) {
    f.disableAll(), R.supportsVertexTextures && f.enable(0), R.instancing && f.enable(1), R.instancingColor && f.enable(2), R.instancingMorph && f.enable(3), R.matcap && f.enable(4), R.envMap && f.enable(5), R.normalMapObjectSpace && f.enable(6), R.normalMapTangentSpace && f.enable(7), R.clearcoat && f.enable(8), R.iridescence && f.enable(9), R.alphaTest && f.enable(10), R.vertexColors && f.enable(11), R.vertexAlphas && f.enable(12), R.vertexUv1s && f.enable(13), R.vertexUv2s && f.enable(14), R.vertexUv3s && f.enable(15), R.vertexTangents && f.enable(16), R.anisotropy && f.enable(17), R.alphaHash && f.enable(18), R.batching && f.enable(19), R.dispersion && f.enable(20), R.batchingColor && f.enable(21), A.push(f.mask), f.disableAll(), R.fog && f.enable(0), R.useFog && f.enable(1), R.flatShading && f.enable(2), R.logarithmicDepthBuffer && f.enable(3), R.reverseDepthBuffer && f.enable(4), R.skinning && f.enable(5), R.morphTargets && f.enable(6), R.morphNormals && f.enable(7), R.morphColors && f.enable(8), R.premultipliedAlpha && f.enable(9), R.shadowMapEnabled && f.enable(10), R.doubleSided && f.enable(11), R.flipSided && f.enable(12), R.useDepthPacking && f.enable(13), R.dithering && f.enable(14), R.transmission && f.enable(15), R.sheen && f.enable(16), R.opaque && f.enable(17), R.pointsUvs && f.enable(18), R.decodeVideoTexture && f.enable(19), R.decodeVideoTextureEmissive && f.enable(20), R.alphaToCoverage && f.enable(21), A.push(f.mask);
  }
  function E(A) {
    const R = b[A.type];
    let L;
    if (R) {
      const H = Ji[R];
      L = R2.clone(H.uniforms);
    } else
      L = A.uniforms;
    return L;
  }
  function O(A, R) {
    let L;
    for (let H = 0, k = m.length; H < k; H++) {
      const P = m[H];
      if (P.cacheKey === R) {
        L = P, ++L.usedTimes;
        break;
      }
    }
    return L === void 0 && (L = new eN(n, R, A, l), m.push(L)), L;
  }
  function N(A) {
    if (--A.usedTimes === 0) {
      const R = m.indexOf(A);
      m[R] = m[m.length - 1], m.pop(), A.destroy();
    }
  }
  function D(A) {
    d.remove(A);
  }
  function z() {
    d.dispose();
  }
  return {
    getParameters: S,
    getProgramCacheKey: y,
    getUniforms: E,
    acquireProgram: O,
    releaseProgram: N,
    releaseShaderCache: D,
    // Exposed for resource monitoring & error feedback via renderer.info:
    programs: m,
    dispose: z
  };
}
function rN() {
  let n = /* @__PURE__ */ new WeakMap();
  function t(c) {
    return n.has(c);
  }
  function e(c) {
    let f = n.get(c);
    return f === void 0 && (f = {}, n.set(c, f)), f;
  }
  function s(c) {
    n.delete(c);
  }
  function r(c, f, d) {
    n.get(c)[f] = d;
  }
  function l() {
    n = /* @__PURE__ */ new WeakMap();
  }
  return {
    has: t,
    get: e,
    remove: s,
    update: r,
    dispose: l
  };
}
function oN(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 yS(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 xS() {
  const n = [];
  let t = 0;
  const e = [], s = [], r = [];
  function l() {
    t = 0, e.length = 0, s.length = 0, r.length = 0;
  }
  function c(p, _, x, b, M, S) {
    let y = n[t];
    return y === void 0 ? (y = {
      id: p.id,
      object: p,
      geometry: _,
      material: x,
      groupOrder: b,
      renderOrder: p.renderOrder,
      z: M,
      group: S
    }, n[t] = y) : (y.id = p.id, y.object = p, y.geometry = _, y.material = x, y.groupOrder = b, y.renderOrder = p.renderOrder, y.z = M, y.group = S), t++, y;
  }
  function f(p, _, x, b, M, S) {
    const y = c(p, _, x, b, M, S);
    x.transmission > 0 ? s.push(y) : x.transparent === !0 ? r.push(y) : e.push(y);
  }
  function d(p, _, x, b, M, S) {
    const y = c(p, _, x, b, M, S);
    x.transmission > 0 ? s.unshift(y) : x.transparent === !0 ? r.unshift(y) : e.unshift(y);
  }
  function h(p, _) {
    e.length > 1 && e.sort(p || oN), s.length > 1 && s.sort(_ || yS), r.length > 1 && r.sort(_ || yS);
  }
  function m() {
    for (let p = t, _ = n.length; p < _; p++) {
      const x = n[p];
      if (x.id === null) break;
      x.id = null, x.object = null, x.geometry = null, x.material = null, x.group = null;
    }
  }
  return {
    opaque: e,
    transmissive: s,
    transparent: r,
    init: l,
    push: f,
    unshift: d,
    finish: m,
    sort: h
  };
}
function lN() {
  let n = /* @__PURE__ */ new WeakMap();
  function t(s, r) {
    const l = n.get(s);
    let c;
    return l === void 0 ? (c = new xS(), n.set(s, [c])) : r >= l.length ? (c = new xS(), l.push(c)) : c = l[r], c;
  }
  function e() {
    n = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: t,
    dispose: e
  };
}
function cN() {
  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 at(),
            color: new we()
          };
          break;
        case "SpotLight":
          e = {
            position: new at(),
            direction: new at(),
            color: new we(),
            distance: 0,
            coneCos: 0,
            penumbraCos: 0,
            decay: 0
          };
          break;
        case "PointLight":
          e = {
            position: new at(),
            color: new we(),
            distance: 0,
            decay: 0
          };
          break;
        case "HemisphereLight":
          e = {
            direction: new at(),
            skyColor: new we(),
            groundColor: new we()
          };
          break;
        case "RectAreaLight":
          e = {
            color: new we(),
            position: new at(),
            halfWidth: new at(),
            halfHeight: new at()
          };
          break;
      }
      return n[t.id] = e, e;
    }
  };
}
function uN() {
  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 le()
          };
          break;
        case "SpotLight":
          e = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new le()
          };
          break;
        case "PointLight":
          e = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new le(),
            shadowCameraNear: 1,
            shadowCameraFar: 1e3
          };
          break;
      }
      return n[t.id] = e, e;
    }
  };
}
let fN = 0;
function dN(n, t) {
  return (t.castShadow ? 2 : 0) - (n.castShadow ? 2 : 0) + (t.map ? 1 : 0) - (n.map ? 1 : 0);
}
function hN(n) {
  const t = new cN(), e = uN(), s = {
    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++) s.probe.push(new at());
  const r = new at(), l = new qe(), c = new qe();
  function f(h) {
    let m = 0, p = 0, _ = 0;
    for (let A = 0; A < 9; A++) s.probe[A].set(0, 0, 0);
    let x = 0, b = 0, M = 0, S = 0, y = 0, C = 0, T = 0, E = 0, O = 0, N = 0, D = 0;
    h.sort(dN);
    for (let A = 0, R = h.length; A < R; A++) {
      const L = h[A], H = L.color, k = L.intensity, P = L.distance, Y = L.shadow && L.shadow.map ? L.shadow.map.texture : null;
      if (L.isAmbientLight)
        m += H.r * k, p += H.g * k, _ += H.b * k;
      else if (L.isLightProbe) {
        for (let U = 0; U < 9; U++)
          s.probe[U].addScaledVector(L.sh.coefficients[U], k);
        D++;
      } else if (L.isDirectionalLight) {
        const U = t.get(L);
        if (U.color.copy(L.color).multiplyScalar(L.intensity), L.castShadow) {
          const X = L.shadow, V = e.get(L);
          V.shadowIntensity = X.intensity, V.shadowBias = X.bias, V.shadowNormalBias = X.normalBias, V.shadowRadius = X.radius, V.shadowMapSize = X.mapSize, s.directionalShadow[x] = V, s.directionalShadowMap[x] = Y, s.directionalShadowMatrix[x] = L.shadow.matrix, C++;
        }
        s.directional[x] = U, x++;
      } else if (L.isSpotLight) {
        const U = t.get(L);
        U.position.setFromMatrixPosition(L.matrixWorld), U.color.copy(H).multiplyScalar(k), U.distance = P, U.coneCos = Math.cos(L.angle), U.penumbraCos = Math.cos(L.angle * (1 - L.penumbra)), U.decay = L.decay, s.spot[M] = U;
        const X = L.shadow;
        if (L.map && (s.spotLightMap[O] = L.map, O++, X.updateMatrices(L), L.castShadow && N++), s.spotLightMatrix[M] = X.matrix, L.castShadow) {
          const V = e.get(L);
          V.shadowIntensity = X.intensity, V.shadowBias = X.bias, V.shadowNormalBias = X.normalBias, V.shadowRadius = X.radius, V.shadowMapSize = X.mapSize, s.spotShadow[M] = V, s.spotShadowMap[M] = Y, E++;
        }
        M++;
      } else if (L.isRectAreaLight) {
        const U = t.get(L);
        U.color.copy(H).multiplyScalar(k), U.halfWidth.set(L.width * 0.5, 0, 0), U.halfHeight.set(0, L.height * 0.5, 0), s.rectArea[S] = U, S++;
      } else if (L.isPointLight) {
        const U = t.get(L);
        if (U.color.copy(L.color).multiplyScalar(L.intensity), U.distance = L.distance, U.decay = L.decay, L.castShadow) {
          const X = L.shadow, V = e.get(L);
          V.shadowIntensity = X.intensity, V.shadowBias = X.bias, V.shadowNormalBias = X.normalBias, V.shadowRadius = X.radius, V.shadowMapSize = X.mapSize, V.shadowCameraNear = X.camera.near, V.shadowCameraFar = X.camera.far, s.pointShadow[b] = V, s.pointShadowMap[b] = Y, s.pointShadowMatrix[b] = L.shadow.matrix, T++;
        }
        s.point[b] = U, b++;
      } else if (L.isHemisphereLight) {
        const U = t.get(L);
        U.skyColor.copy(L.color).multiplyScalar(k), U.groundColor.copy(L.groundColor).multiplyScalar(k), s.hemi[y] = U, y++;
      }
    }
    S > 0 && (n.has("OES_texture_float_linear") === !0 ? (s.rectAreaLTC1 = Ht.LTC_FLOAT_1, s.rectAreaLTC2 = Ht.LTC_FLOAT_2) : (s.rectAreaLTC1 = Ht.LTC_HALF_1, s.rectAreaLTC2 = Ht.LTC_HALF_2)), s.ambient[0] = m, s.ambient[1] = p, s.ambient[2] = _;
    const z = s.hash;
    (z.directionalLength !== x || z.pointLength !== b || z.spotLength !== M || z.rectAreaLength !== S || z.hemiLength !== y || z.numDirectionalShadows !== C || z.numPointShadows !== T || z.numSpotShadows !== E || z.numSpotMaps !== O || z.numLightProbes !== D) && (s.directional.length = x, s.spot.length = M, s.rectArea.length = S, s.point.length = b, s.hemi.length = y, s.directionalShadow.length = C, s.directionalShadowMap.length = C, s.pointShadow.length = T, s.pointShadowMap.length = T, s.spotShadow.length = E, s.spotShadowMap.length = E, s.directionalShadowMatrix.length = C, s.pointShadowMatrix.length = T, s.spotLightMatrix.length = E + O - N, s.spotLightMap.length = O, s.numSpotLightShadowsWithMaps = N, s.numLightProbes = D, z.directionalLength = x, z.pointLength = b, z.spotLength = M, z.rectAreaLength = S, z.hemiLength = y, z.numDirectionalShadows = C, z.numPointShadows = T, z.numSpotShadows = E, z.numSpotMaps = O, z.numLightProbes = D, s.version = fN++);
  }
  function d(h, m) {
    let p = 0, _ = 0, x = 0, b = 0, M = 0;
    const S = m.matrixWorldInverse;
    for (let y = 0, C = h.length; y < C; y++) {
      const T = h[y];
      if (T.isDirectionalLight) {
        const E = s.directional[p];
        E.direction.setFromMatrixPosition(T.matrixWorld), r.setFromMatrixPosition(T.target.matrixWorld), E.direction.sub(r), E.direction.transformDirection(S), p++;
      } else if (T.isSpotLight) {
        const E = s.spot[x];
        E.position.setFromMatrixPosition(T.matrixWorld), E.position.applyMatrix4(S), E.direction.setFromMatrixPosition(T.matrixWorld), r.setFromMatrixPosition(T.target.matrixWorld), E.direction.sub(r), E.direction.transformDirection(S), x++;
      } else if (T.isRectAreaLight) {
        const E = s.rectArea[b];
        E.position.setFromMatrixPosition(T.matrixWorld), E.position.applyMatrix4(S), c.identity(), l.copy(T.matrixWorld), l.premultiply(S), c.extractRotation(l), E.halfWidth.set(T.width * 0.5, 0, 0), E.halfHeight.set(0, T.height * 0.5, 0), E.halfWidth.applyMatrix4(c), E.halfHeight.applyMatrix4(c), b++;
      } else if (T.isPointLight) {
        const E = s.point[_];
        E.position.setFromMatrixPosition(T.matrixWorld), E.position.applyMatrix4(S), _++;
      } else if (T.isHemisphereLight) {
        const E = s.hemi[M];
        E.direction.setFromMatrixPosition(T.matrixWorld), E.direction.transformDirection(S), M++;
      }
    }
  }
  return {
    setup: f,
    setupView: d,
    state: s
  };
}
function SS(n) {
  const t = new hN(n), e = [], s = [];
  function r(m) {
    h.camera = m, e.length = 0, s.length = 0;
  }
  function l(m) {
    e.push(m);
  }
  function c(m) {
    s.push(m);
  }
  function f() {
    t.setup(e);
  }
  function d(m) {
    t.setupView(e, m);
  }
  const h = {
    lightsArray: e,
    shadowsArray: s,
    camera: null,
    lights: t,
    transmissionRenderTarget: {}
  };
  return {
    init: r,
    state: h,
    setupLights: f,
    setupLightsView: d,
    pushLight: l,
    pushShadow: c
  };
}
function pN(n) {
  let t = /* @__PURE__ */ new WeakMap();
  function e(r, l = 0) {
    const c = t.get(r);
    let f;
    return c === void 0 ? (f = new SS(n), t.set(r, [f])) : l >= c.length ? (f = new SS(n), c.push(f)) : f = c[l], f;
  }
  function s() {
    t = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: e,
    dispose: s
  };
}
const mN = `void main() {
	gl_Position = vec4( position, 1.0 );
}`, gN = `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 _N(n, t, e) {
  let s = new Jg();
  const r = new le(), l = new le(), c = new on(), f = new F2({ depthPacking: $w }), d = new H2(), h = {}, m = e.maxTextureSize, p = { [Na]: li, [li]: Na, [es]: es }, _ = new Vs({
    defines: {
      VSM_SAMPLES: 8
    },
    uniforms: {
      shadow_pass: { value: null },
      resolution: { value: new le() },
      radius: { value: 4 }
    },
    vertexShader: mN,
    fragmentShader: gN
  }), x = _.clone();
  x.defines.HORIZONTAL_PASS = 1;
  const b = new Gn();
  b.setAttribute(
    "position",
    new ln(
      new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),
      3
    )
  );
  const M = new Un(b, _), S = this;
  this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = mM;
  let y = this.type;
  this.render = function(N, D, z) {
    if (S.enabled === !1 || S.autoUpdate === !1 && S.needsUpdate === !1 || N.length === 0) return;
    const A = n.getRenderTarget(), R = n.getActiveCubeFace(), L = n.getActiveMipmapLevel(), H = n.state;
    H.setBlending(Ca), H.buffers.color.setClear(1, 1, 1, 1), H.buffers.depth.setTest(!0), H.setScissorTest(!1);
    const k = y !== Os && this.type === Os, P = y === Os && this.type !== Os;
    for (let Y = 0, U = N.length; Y < U; Y++) {
      const X = N[Y], V = X.shadow;
      if (V === void 0) {
        console.warn("THREE.WebGLShadowMap:", X, "has no shadow.");
        continue;
      }
      if (V.autoUpdate === !1 && V.needsUpdate === !1) continue;
      r.copy(V.mapSize);
      const W = V.getFrameExtents();
      if (r.multiply(W), l.copy(V.mapSize), (r.x > m || r.y > m) && (r.x > m && (l.x = Math.floor(m / W.x), r.x = l.x * W.x, V.mapSize.x = l.x), r.y > m && (l.y = Math.floor(m / W.y), r.y = l.y * W.y, V.mapSize.y = l.y)), V.map === null || k === !0 || P === !0) {
        const I = this.type !== Os ? { minFilter: Vn, magFilter: Vn } : {};
        V.map !== null && V.map.dispose(), V.map = new vr(r.x, r.y, I), V.map.texture.name = X.name + ".shadowMap", V.camera.updateProjectionMatrix();
      }
      n.setRenderTarget(V.map), n.clear();
      const J = V.getViewportCount();
      for (let I = 0; I < J; I++) {
        const q = V.getViewport(I);
        c.set(
          l.x * q.x,
          l.y * q.y,
          l.x * q.z,
          l.y * q.w
        ), H.viewport(c), V.updateMatrices(X, I), s = V.getFrustum(), E(D, z, V.camera, X, this.type);
      }
      V.isPointLightShadow !== !0 && this.type === Os && C(V, z), V.needsUpdate = !1;
    }
    y = this.type, S.needsUpdate = !1, n.setRenderTarget(A, R, L);
  };
  function C(N, D) {
    const z = t.update(M);
    _.defines.VSM_SAMPLES !== N.blurSamples && (_.defines.VSM_SAMPLES = N.blurSamples, x.defines.VSM_SAMPLES = N.blurSamples, _.needsUpdate = !0, x.needsUpdate = !0), N.mapPass === null && (N.mapPass = new vr(r.x, r.y)), _.uniforms.shadow_pass.value = N.map.texture, _.uniforms.resolution.value = N.mapSize, _.uniforms.radius.value = N.radius, n.setRenderTarget(N.mapPass), n.clear(), n.renderBufferDirect(D, null, z, _, M, null), x.uniforms.shadow_pass.value = N.mapPass.texture, x.uniforms.resolution.value = N.mapSize, x.uniforms.radius.value = N.radius, n.setRenderTarget(N.map), n.clear(), n.renderBufferDirect(D, null, z, x, M, null);
  }
  function T(N, D, z, A) {
    let R = null;
    const L = z.isPointLight === !0 ? N.customDistanceMaterial : N.customDepthMaterial;
    if (L !== void 0)
      R = L;
    else if (R = z.isPointLight === !0 ? d : f, n.localClippingEnabled && D.clipShadows === !0 && Array.isArray(D.clippingPlanes) && D.clippingPlanes.length !== 0 || D.displacementMap && D.displacementScale !== 0 || D.alphaMap && D.alphaTest > 0 || D.map && D.alphaTest > 0) {
      const H = R.uuid, k = D.uuid;
      let P = h[H];
      P === void 0 && (P = {}, h[H] = P);
      let Y = P[k];
      Y === void 0 && (Y = R.clone(), P[k] = Y, D.addEventListener("dispose", O)), R = Y;
    }
    if (R.visible = D.visible, R.wireframe = D.wireframe, A === Os ? R.side = D.shadowSide !== null ? D.shadowSide : D.side : R.side = D.shadowSide !== null ? D.shadowSide : p[D.side], R.alphaMap = D.alphaMap, R.alphaTest = D.alphaTest, R.map = D.map, R.clipShadows = D.clipShadows, R.clippingPlanes = D.clippingPlanes, R.clipIntersection = D.clipIntersection, R.displacementMap = D.displacementMap, R.displacementScale = D.displacementScale, R.displacementBias = D.displacementBias, R.wireframeLinewidth = D.wireframeLinewidth, R.linewidth = D.linewidth, z.isPointLight === !0 && R.isMeshDistanceMaterial === !0) {
      const H = n.properties.get(R);
      H.light = z;
    }
    return R;
  }
  function E(N, D, z, A, R) {
    if (N.visible === !1) return;
    if (N.layers.test(D.layers) && (N.isMesh || N.isLine || N.isPoints) && (N.castShadow || N.receiveShadow && R === Os) && (!N.frustumCulled || s.intersectsObject(N))) {
      N.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse, N.matrixWorld);
      const k = t.update(N), P = N.material;
      if (Array.isArray(P)) {
        const Y = k.groups;
        for (let U = 0, X = Y.length; U < X; U++) {
          const V = Y[U], W = P[V.materialIndex];
          if (W && W.visible) {
            const J = T(N, W, A, R);
            N.onBeforeShadow(n, N, D, z, k, J, V), n.renderBufferDirect(z, null, k, J, N, V), N.onAfterShadow(n, N, D, z, k, J, V);
          }
        }
      } else if (P.visible) {
        const Y = T(N, P, A, R);
        N.onBeforeShadow(n, N, D, z, k, Y, null), n.renderBufferDirect(z, null, k, Y, N, null), N.onAfterShadow(n, N, D, z, k, Y, null);
      }
    }
    const H = N.children;
    for (let k = 0, P = H.length; k < P; k++)
      E(H[k], D, z, A, R);
  }
  function O(N) {
    N.target.removeEventListener("dispose", O);
    for (const z in h) {
      const A = h[z], R = N.target.uuid;
      R in A && (A[R].dispose(), delete A[R]);
    }
  }
}
const vN = {
  [Fm]: Hm,
  [Vm]: Xm,
  [Gm]: Wm,
  [Vo]: km,
  [Hm]: Fm,
  [Xm]: Vm,
  [Wm]: Gm,
  [km]: Vo
};
function yN(n, t) {
  function e() {
    let nt = !1;
    const Ot = new on();
    let yt = null;
    const At = new on(0, 0, 0, 0);
    return {
      setMask: function(Pt) {
        yt !== Pt && !nt && (n.colorMask(Pt, Pt, Pt, Pt), yt = Pt);
      },
      setLocked: function(Pt) {
        nt = Pt;
      },
      setClear: function(Pt, zt, ce, $e, fn) {
        fn === !0 && (Pt *= $e, zt *= $e, ce *= $e), Ot.set(Pt, zt, ce, $e), At.equals(Ot) === !1 && (n.clearColor(Pt, zt, ce, $e), At.copy(Ot));
      },
      reset: function() {
        nt = !1, yt = null, At.set(-1, 0, 0, 0);
      }
    };
  }
  function s() {
    let nt = !1, Ot = !1, yt = null, At = null, Pt = null;
    return {
      setReversed: function(zt) {
        if (Ot !== zt) {
          const ce = t.get("EXT_clip_control");
          Ot ? ce.clipControlEXT(ce.LOWER_LEFT_EXT, ce.ZERO_TO_ONE_EXT) : ce.clipControlEXT(ce.LOWER_LEFT_EXT, ce.NEGATIVE_ONE_TO_ONE_EXT);
          const $e = Pt;
          Pt = null, this.setClear($e);
        }
        Ot = zt;
      },
      getReversed: function() {
        return Ot;
      },
      setTest: function(zt) {
        zt ? ht(n.DEPTH_TEST) : _t(n.DEPTH_TEST);
      },
      setMask: function(zt) {
        yt !== zt && !nt && (n.depthMask(zt), yt = zt);
      },
      setFunc: function(zt) {
        if (Ot && (zt = vN[zt]), At !== zt) {
          switch (zt) {
            case Fm:
              n.depthFunc(n.NEVER);
              break;
            case Hm:
              n.depthFunc(n.ALWAYS);
              break;
            case Vm:
              n.depthFunc(n.LESS);
              break;
            case Vo:
              n.depthFunc(n.LEQUAL);
              break;
            case Gm:
              n.depthFunc(n.EQUAL);
              break;
            case km:
              n.depthFunc(n.GEQUAL);
              break;
            case Xm:
              n.depthFunc(n.GREATER);
              break;
            case Wm:
              n.depthFunc(n.NOTEQUAL);
              break;
            default:
              n.depthFunc(n.LEQUAL);
          }
          At = zt;
        }
      },
      setLocked: function(zt) {
        nt = zt;
      },
      setClear: function(zt) {
        Pt !== zt && (Ot && (zt = 1 - zt), n.clearDepth(zt), Pt = zt);
      },
      reset: function() {
        nt = !1, yt = null, At = null, Pt = null, Ot = !1;
      }
    };
  }
  function r() {
    let nt = !1, Ot = null, yt = null, At = null, Pt = null, zt = null, ce = null, $e = null, fn = null;
    return {
      setTest: function(De) {
        nt || (De ? ht(n.STENCIL_TEST) : _t(n.STENCIL_TEST));
      },
      setMask: function(De) {
        Ot !== De && !nt && (n.stencilMask(De), Ot = De);
      },
      setFunc: function(De, Mn, ci) {
        (yt !== De || At !== Mn || Pt !== ci) && (n.stencilFunc(De, Mn, ci), yt = De, At = Mn, Pt = ci);
      },
      setOp: function(De, Mn, ci) {
        (zt !== De || ce !== Mn || $e !== ci) && (n.stencilOp(De, Mn, ci), zt = De, ce = Mn, $e = ci);
      },
      setLocked: function(De) {
        nt = De;
      },
      setClear: function(De) {
        fn !== De && (n.clearStencil(De), fn = De);
      },
      reset: function() {
        nt = !1, Ot = null, yt = null, At = null, Pt = null, zt = null, ce = null, $e = null, fn = null;
      }
    };
  }
  const l = new e(), c = new s(), f = new r(), d = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap();
  let m = {}, p = {}, _ = /* @__PURE__ */ new WeakMap(), x = [], b = null, M = !1, S = null, y = null, C = null, T = null, E = null, O = null, N = null, D = new we(0, 0, 0), z = 0, A = !1, R = null, L = null, H = null, k = null, P = null;
  const Y = n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  let U = !1, X = 0;
  const V = n.getParameter(n.VERSION);
  V.indexOf("WebGL") !== -1 ? (X = parseFloat(/^WebGL (\d)/.exec(V)[1]), U = X >= 1) : V.indexOf("OpenGL ES") !== -1 && (X = parseFloat(/^OpenGL ES (\d)/.exec(V)[1]), U = X >= 2);
  let W = null, J = {};
  const I = n.getParameter(n.SCISSOR_BOX), q = n.getParameter(n.VIEWPORT), lt = new on().fromArray(I), $ = new on().fromArray(q);
  function ot(nt, Ot, yt, At) {
    const Pt = new Uint8Array(4), zt = n.createTexture();
    n.bindTexture(nt, zt), n.texParameteri(nt, n.TEXTURE_MIN_FILTER, n.NEAREST), n.texParameteri(nt, n.TEXTURE_MAG_FILTER, n.NEAREST);
    for (let ce = 0; ce < yt; ce++)
      nt === n.TEXTURE_3D || nt === n.TEXTURE_2D_ARRAY ? n.texImage3D(Ot, 0, n.RGBA, 1, 1, At, 0, n.RGBA, n.UNSIGNED_BYTE, Pt) : n.texImage2D(Ot + ce, 0, n.RGBA, 1, 1, 0, n.RGBA, n.UNSIGNED_BYTE, Pt);
    return zt;
  }
  const gt = {};
  gt[n.TEXTURE_2D] = ot(n.TEXTURE_2D, n.TEXTURE_2D, 1), gt[n.TEXTURE_CUBE_MAP] = ot(n.TEXTURE_CUBE_MAP, n.TEXTURE_CUBE_MAP_POSITIVE_X, 6), gt[n.TEXTURE_2D_ARRAY] = ot(n.TEXTURE_2D_ARRAY, n.TEXTURE_2D_ARRAY, 1, 1), gt[n.TEXTURE_3D] = ot(n.TEXTURE_3D, n.TEXTURE_3D, 1, 1), l.setClear(0, 0, 0, 1), c.setClear(1), f.setClear(0), ht(n.DEPTH_TEST), c.setFunc(Vo), Xt(!1), se(gx), ht(n.CULL_FACE), K(Ca);
  function ht(nt) {
    m[nt] !== !0 && (n.enable(nt), m[nt] = !0);
  }
  function _t(nt) {
    m[nt] !== !1 && (n.disable(nt), m[nt] = !1);
  }
  function Et(nt, Ot) {
    return p[nt] !== Ot ? (n.bindFramebuffer(nt, Ot), p[nt] = Ot, nt === n.DRAW_FRAMEBUFFER && (p[n.FRAMEBUFFER] = Ot), nt === n.FRAMEBUFFER && (p[n.DRAW_FRAMEBUFFER] = Ot), !0) : !1;
  }
  function Lt(nt, Ot) {
    let yt = x, At = !1;
    if (nt) {
      yt = _.get(Ot), yt === void 0 && (yt = [], _.set(Ot, yt));
      const Pt = nt.textures;
      if (yt.length !== Pt.length || yt[0] !== n.COLOR_ATTACHMENT0) {
        for (let zt = 0, ce = Pt.length; zt < ce; zt++)
          yt[zt] = n.COLOR_ATTACHMENT0 + zt;
        yt.length = Pt.length, At = !0;
      }
    } else
      yt[0] !== n.BACK && (yt[0] = n.BACK, At = !0);
    At && n.drawBuffers(yt);
  }
  function Gt(nt) {
    return b !== nt ? (n.useProgram(nt), b = nt, !0) : !1;
  }
  const Nt = {
    [cr]: n.FUNC_ADD,
    [Mw]: n.FUNC_SUBTRACT,
    [Ew]: n.FUNC_REVERSE_SUBTRACT
  };
  Nt[Tw] = n.MIN, Nt[Aw] = n.MAX;
  const Bt = {
    [ww]: n.ZERO,
    [Cw]: n.ONE,
    [Rw]: n.SRC_COLOR,
    [Im]: n.SRC_ALPHA,
    [Pw]: n.SRC_ALPHA_SATURATE,
    [Uw]: n.DST_COLOR,
    [Nw]: n.DST_ALPHA,
    [Dw]: n.ONE_MINUS_SRC_COLOR,
    [Bm]: n.ONE_MINUS_SRC_ALPHA,
    [Ow]: n.ONE_MINUS_DST_COLOR,
    [Lw]: n.ONE_MINUS_DST_ALPHA,
    [zw]: n.CONSTANT_COLOR,
    [Iw]: n.ONE_MINUS_CONSTANT_COLOR,
    [Bw]: n.CONSTANT_ALPHA,
    [Fw]: n.ONE_MINUS_CONSTANT_ALPHA
  };
  function K(nt, Ot, yt, At, Pt, zt, ce, $e, fn, De) {
    if (nt === Ca) {
      M === !0 && (_t(n.BLEND), M = !1);
      return;
    }
    if (M === !1 && (ht(n.BLEND), M = !0), nt !== bw) {
      if (nt !== S || De !== A) {
        if ((y !== cr || E !== cr) && (n.blendEquation(n.FUNC_ADD), y = cr, E = cr), De)
          switch (nt) {
            case zo:
              n.blendFuncSeparate(n.ONE, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA);
              break;
            case _x:
              n.blendFunc(n.ONE, n.ONE);
              break;
            case vx:
              n.blendFuncSeparate(n.ZERO, n.ONE_MINUS_SRC_COLOR, n.ZERO, n.ONE);
              break;
            case yx:
              n.blendFuncSeparate(n.ZERO, n.SRC_COLOR, n.ZERO, n.SRC_ALPHA);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", nt);
              break;
          }
        else
          switch (nt) {
            case zo:
              n.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA);
              break;
            case _x:
              n.blendFunc(n.SRC_ALPHA, n.ONE);
              break;
            case vx:
              n.blendFuncSeparate(n.ZERO, n.ONE_MINUS_SRC_COLOR, n.ZERO, n.ONE);
              break;
            case yx:
              n.blendFunc(n.ZERO, n.SRC_COLOR);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", nt);
              break;
          }
        C = null, T = null, O = null, N = null, D.set(0, 0, 0), z = 0, S = nt, A = De;
      }
      return;
    }
    Pt = Pt || Ot, zt = zt || yt, ce = ce || At, (Ot !== y || Pt !== E) && (n.blendEquationSeparate(Nt[Ot], Nt[Pt]), y = Ot, E = Pt), (yt !== C || At !== T || zt !== O || ce !== N) && (n.blendFuncSeparate(Bt[yt], Bt[At], Bt[zt], Bt[ce]), C = yt, T = At, O = zt, N = ce), ($e.equals(D) === !1 || fn !== z) && (n.blendColor($e.r, $e.g, $e.b, fn), D.copy($e), z = fn), S = nt, A = !1;
  }
  function pe(nt, Ot) {
    nt.side === es ? _t(n.CULL_FACE) : ht(n.CULL_FACE);
    let yt = nt.side === li;
    Ot && (yt = !yt), Xt(yt), nt.blending === zo && nt.transparent === !1 ? K(Ca) : K(nt.blending, nt.blendEquation, nt.blendSrc, nt.blendDst, nt.blendEquationAlpha, nt.blendSrcAlpha, nt.blendDstAlpha, nt.blendColor, nt.blendAlpha, nt.premultipliedAlpha), c.setFunc(nt.depthFunc), c.setTest(nt.depthTest), c.setMask(nt.depthWrite), l.setMask(nt.colorWrite);
    const At = nt.stencilWrite;
    f.setTest(At), At && (f.setMask(nt.stencilWriteMask), f.setFunc(nt.stencilFunc, nt.stencilRef, nt.stencilFuncMask), f.setOp(nt.stencilFail, nt.stencilZFail, nt.stencilZPass)), xe(nt.polygonOffset, nt.polygonOffsetFactor, nt.polygonOffsetUnits), nt.alphaToCoverage === !0 ? ht(n.SAMPLE_ALPHA_TO_COVERAGE) : _t(n.SAMPLE_ALPHA_TO_COVERAGE);
  }
  function Xt(nt) {
    R !== nt && (nt ? n.frontFace(n.CW) : n.frontFace(n.CCW), R = nt);
  }
  function se(nt) {
    nt !== yw ? (ht(n.CULL_FACE), nt !== L && (nt === gx ? n.cullFace(n.BACK) : nt === xw ? n.cullFace(n.FRONT) : n.cullFace(n.FRONT_AND_BACK))) : _t(n.CULL_FACE), L = nt;
  }
  function qt(nt) {
    nt !== H && (U && n.lineWidth(nt), H = nt);
  }
  function xe(nt, Ot, yt) {
    nt ? (ht(n.POLYGON_OFFSET_FILL), (k !== Ot || P !== yt) && (n.polygonOffset(Ot, yt), k = Ot, P = yt)) : _t(n.POLYGON_OFFSET_FILL);
  }
  function jt(nt) {
    nt ? ht(n.SCISSOR_TEST) : _t(n.SCISSOR_TEST);
  }
  function j(nt) {
    nt === void 0 && (nt = n.TEXTURE0 + Y - 1), W !== nt && (n.activeTexture(nt), W = nt);
  }
  function B(nt, Ot, yt) {
    yt === void 0 && (W === null ? yt = n.TEXTURE0 + Y - 1 : yt = W);
    let At = J[yt];
    At === void 0 && (At = { type: void 0, texture: void 0 }, J[yt] = At), (At.type !== nt || At.texture !== Ot) && (W !== yt && (n.activeTexture(yt), W = yt), n.bindTexture(nt, Ot || gt[nt]), At.type = nt, At.texture = Ot);
  }
  function ft() {
    const nt = J[W];
    nt !== void 0 && nt.type !== void 0 && (n.bindTexture(nt.type, null), nt.type = void 0, nt.texture = void 0);
  }
  function St() {
    try {
      n.compressedTexImage2D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function wt() {
    try {
      n.compressedTexImage3D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function bt() {
    try {
      n.texSubImage2D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function Zt() {
    try {
      n.texSubImage3D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function Ut() {
    try {
      n.compressedTexSubImage2D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function Wt() {
    try {
      n.compressedTexSubImage3D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function ve() {
    try {
      n.texStorage2D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function Dt() {
    try {
      n.texStorage3D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function Yt() {
    try {
      n.texImage2D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function Jt() {
    try {
      n.texImage3D.apply(n, arguments);
    } catch (nt) {
      console.error("THREE.WebGLState:", nt);
    }
  }
  function $t(nt) {
    lt.equals(nt) === !1 && (n.scissor(nt.x, nt.y, nt.z, nt.w), lt.copy(nt));
  }
  function Vt(nt) {
    $.equals(nt) === !1 && (n.viewport(nt.x, nt.y, nt.z, nt.w), $.copy(nt));
  }
  function re(nt, Ot) {
    let yt = h.get(Ot);
    yt === void 0 && (yt = /* @__PURE__ */ new WeakMap(), h.set(Ot, yt));
    let At = yt.get(nt);
    At === void 0 && (At = n.getUniformBlockIndex(Ot, nt.name), yt.set(nt, At));
  }
  function de(nt, Ot) {
    const At = h.get(Ot).get(nt);
    d.get(Ot) !== At && (n.uniformBlockBinding(Ot, At, nt.__bindingPointIndex), d.set(Ot, At));
  }
  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), m = {}, W = null, J = {}, p = {}, _ = /* @__PURE__ */ new WeakMap(), x = [], b = null, M = !1, S = null, y = null, C = null, T = null, E = null, O = null, N = null, D = new we(0, 0, 0), z = 0, A = !1, R = null, L = null, H = null, k = null, P = null, lt.set(0, 0, n.canvas.width, n.canvas.height), $.set(0, 0, n.canvas.width, n.canvas.height), l.reset(), c.reset(), f.reset();
  }
  return {
    buffers: {
      color: l,
      depth: c,
      stencil: f
    },
    enable: ht,
    disable: _t,
    bindFramebuffer: Et,
    drawBuffers: Lt,
    useProgram: Gt,
    setBlending: K,
    setMaterial: pe,
    setFlipSided: Xt,
    setCullFace: se,
    setLineWidth: qt,
    setPolygonOffset: xe,
    setScissorTest: jt,
    activeTexture: j,
    bindTexture: B,
    unbindTexture: ft,
    compressedTexImage2D: St,
    compressedTexImage3D: wt,
    texImage2D: Yt,
    texImage3D: Jt,
    updateUBOMapping: re,
    uniformBlockBinding: de,
    texStorage2D: ve,
    texStorage3D: Dt,
    texSubImage2D: bt,
    texSubImage3D: Zt,
    compressedTexSubImage2D: Ut,
    compressedTexSubImage3D: Wt,
    scissor: $t,
    viewport: Vt,
    reset: Fe
  };
}
function xN(n, t, e, s, r, l, c) {
  const f = 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 le(), m = /* @__PURE__ */ new WeakMap();
  let p;
  const _ = /* @__PURE__ */ new WeakMap();
  let x = !1;
  try {
    x = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
  } catch {
  }
  function b(j, B) {
    return x ? (
      // eslint-disable-next-line compat/compat
      new OffscreenCanvas(j, B)
    ) : Qf("canvas");
  }
  function M(j, B, ft) {
    let St = 1;
    const wt = jt(j);
    if ((wt.width > ft || wt.height > ft) && (St = ft / Math.max(wt.width, wt.height)), St < 1)
      if (typeof HTMLImageElement < "u" && j instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && j instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && j instanceof ImageBitmap || typeof VideoFrame < "u" && j instanceof VideoFrame) {
        const bt = Math.floor(St * wt.width), Zt = Math.floor(St * wt.height);
        p === void 0 && (p = b(bt, Zt));
        const Ut = B ? b(bt, Zt) : p;
        return Ut.width = bt, Ut.height = Zt, Ut.getContext("2d").drawImage(j, 0, 0, bt, Zt), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + wt.width + "x" + wt.height + ") to (" + bt + "x" + Zt + ")."), Ut;
      } else
        return "data" in j && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + wt.width + "x" + wt.height + ")."), j;
    return j;
  }
  function S(j) {
    return j.generateMipmaps;
  }
  function y(j) {
    n.generateMipmap(j);
  }
  function C(j) {
    return j.isWebGLCubeRenderTarget ? n.TEXTURE_CUBE_MAP : j.isWebGL3DRenderTarget ? n.TEXTURE_3D : j.isWebGLArrayRenderTarget || j.isCompressedArrayTexture ? n.TEXTURE_2D_ARRAY : n.TEXTURE_2D;
  }
  function T(j, B, ft, St, wt = !1) {
    if (j !== null) {
      if (n[j] !== void 0) return n[j];
      console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + j + "'");
    }
    let bt = B;
    if (B === n.RED && (ft === n.FLOAT && (bt = n.R32F), ft === n.HALF_FLOAT && (bt = n.R16F), ft === n.UNSIGNED_BYTE && (bt = n.R8)), B === n.RED_INTEGER && (ft === n.UNSIGNED_BYTE && (bt = n.R8UI), ft === n.UNSIGNED_SHORT && (bt = n.R16UI), ft === n.UNSIGNED_INT && (bt = n.R32UI), ft === n.BYTE && (bt = n.R8I), ft === n.SHORT && (bt = n.R16I), ft === n.INT && (bt = n.R32I)), B === n.RG && (ft === n.FLOAT && (bt = n.RG32F), ft === n.HALF_FLOAT && (bt = n.RG16F), ft === n.UNSIGNED_BYTE && (bt = n.RG8)), B === n.RG_INTEGER && (ft === n.UNSIGNED_BYTE && (bt = n.RG8UI), ft === n.UNSIGNED_SHORT && (bt = n.RG16UI), ft === n.UNSIGNED_INT && (bt = n.RG32UI), ft === n.BYTE && (bt = n.RG8I), ft === n.SHORT && (bt = n.RG16I), ft === n.INT && (bt = n.RG32I)), B === n.RGB_INTEGER && (ft === n.UNSIGNED_BYTE && (bt = n.RGB8UI), ft === n.UNSIGNED_SHORT && (bt = n.RGB16UI), ft === n.UNSIGNED_INT && (bt = n.RGB32UI), ft === n.BYTE && (bt = n.RGB8I), ft === n.SHORT && (bt = n.RGB16I), ft === n.INT && (bt = n.RGB32I)), B === n.RGBA_INTEGER && (ft === n.UNSIGNED_BYTE && (bt = n.RGBA8UI), ft === n.UNSIGNED_SHORT && (bt = n.RGBA16UI), ft === n.UNSIGNED_INT && (bt = n.RGBA32UI), ft === n.BYTE && (bt = n.RGBA8I), ft === n.SHORT && (bt = n.RGBA16I), ft === n.INT && (bt = n.RGBA32I)), B === n.RGB && ft === n.UNSIGNED_INT_5_9_9_9_REV && (bt = n.RGB9_E5), B === n.RGBA) {
      const Zt = wt ? Zf : Ie.getTransfer(St);
      ft === n.FLOAT && (bt = n.RGBA32F), ft === n.HALF_FLOAT && (bt = n.RGBA16F), ft === n.UNSIGNED_BYTE && (bt = Zt === We ? n.SRGB8_ALPHA8 : n.RGBA8), ft === n.UNSIGNED_SHORT_4_4_4_4 && (bt = n.RGBA4), ft === n.UNSIGNED_SHORT_5_5_5_1 && (bt = n.RGB5_A1);
    }
    return (bt === n.R16F || bt === n.R32F || bt === n.RG16F || bt === n.RG32F || bt === n.RGBA16F || bt === n.RGBA32F) && t.get("EXT_color_buffer_float"), bt;
  }
  function E(j, B) {
    let ft;
    return j ? B === null || B === _r || B === Xo ? ft = n.DEPTH24_STENCIL8 : B === Ii ? ft = n.DEPTH32F_STENCIL8 : B === pc && (ft = n.DEPTH24_STENCIL8, console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : B === null || B === _r || B === Xo ? ft = n.DEPTH_COMPONENT24 : B === Ii ? ft = n.DEPTH_COMPONENT32F : B === pc && (ft = n.DEPTH_COMPONENT16), ft;
  }
  function O(j, B) {
    return S(j) === !0 || j.isFramebufferTexture && j.minFilter !== Vn && j.minFilter !== is ? Math.log2(Math.max(B.width, B.height)) + 1 : j.mipmaps !== void 0 && j.mipmaps.length > 0 ? j.mipmaps.length : j.isCompressedTexture && Array.isArray(j.image) ? B.mipmaps.length : 1;
  }
  function N(j) {
    const B = j.target;
    B.removeEventListener("dispose", N), z(B), B.isVideoTexture && m.delete(B);
  }
  function D(j) {
    const B = j.target;
    B.removeEventListener("dispose", D), R(B);
  }
  function z(j) {
    const B = s.get(j);
    if (B.__webglInit === void 0) return;
    const ft = j.source, St = _.get(ft);
    if (St) {
      const wt = St[B.__cacheKey];
      wt.usedTimes--, wt.usedTimes === 0 && A(j), Object.keys(St).length === 0 && _.delete(ft);
    }
    s.remove(j);
  }
  function A(j) {
    const B = s.get(j);
    n.deleteTexture(B.__webglTexture);
    const ft = j.source, St = _.get(ft);
    delete St[B.__cacheKey], c.memory.textures--;
  }
  function R(j) {
    const B = s.get(j);
    if (j.depthTexture && (j.depthTexture.dispose(), s.remove(j.depthTexture)), j.isWebGLCubeRenderTarget)
      for (let St = 0; St < 6; St++) {
        if (Array.isArray(B.__webglFramebuffer[St]))
          for (let wt = 0; wt < B.__webglFramebuffer[St].length; wt++) n.deleteFramebuffer(B.__webglFramebuffer[St][wt]);
        else
          n.deleteFramebuffer(B.__webglFramebuffer[St]);
        B.__webglDepthbuffer && n.deleteRenderbuffer(B.__webglDepthbuffer[St]);
      }
    else {
      if (Array.isArray(B.__webglFramebuffer))
        for (let St = 0; St < B.__webglFramebuffer.length; St++) n.deleteFramebuffer(B.__webglFramebuffer[St]);
      else
        n.deleteFramebuffer(B.__webglFramebuffer);
      if (B.__webglDepthbuffer && n.deleteRenderbuffer(B.__webglDepthbuffer), B.__webglMultisampledFramebuffer && n.deleteFramebuffer(B.__webglMultisampledFramebuffer), B.__webglColorRenderbuffer)
        for (let St = 0; St < B.__webglColorRenderbuffer.length; St++)
          B.__webglColorRenderbuffer[St] && n.deleteRenderbuffer(B.__webglColorRenderbuffer[St]);
      B.__webglDepthRenderbuffer && n.deleteRenderbuffer(B.__webglDepthRenderbuffer);
    }
    const ft = j.textures;
    for (let St = 0, wt = ft.length; St < wt; St++) {
      const bt = s.get(ft[St]);
      bt.__webglTexture && (n.deleteTexture(bt.__webglTexture), c.memory.textures--), s.remove(ft[St]);
    }
    s.remove(j);
  }
  let L = 0;
  function H() {
    L = 0;
  }
  function k() {
    const j = L;
    return j >= r.maxTextures && console.warn("THREE.WebGLTextures: Trying to use " + j + " texture units while this GPU supports only " + r.maxTextures), L += 1, j;
  }
  function P(j) {
    const B = [];
    return B.push(j.wrapS), B.push(j.wrapT), B.push(j.wrapR || 0), B.push(j.magFilter), B.push(j.minFilter), B.push(j.anisotropy), B.push(j.internalFormat), B.push(j.format), B.push(j.type), B.push(j.generateMipmaps), B.push(j.premultiplyAlpha), B.push(j.flipY), B.push(j.unpackAlignment), B.push(j.colorSpace), B.join();
  }
  function Y(j, B) {
    const ft = s.get(j);
    if (j.isVideoTexture && qt(j), j.isRenderTargetTexture === !1 && j.version > 0 && ft.__version !== j.version) {
      const St = j.image;
      if (St === null)
        console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");
      else if (St.complete === !1)
        console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");
      else {
        $(ft, j, B);
        return;
      }
    }
    e.bindTexture(n.TEXTURE_2D, ft.__webglTexture, n.TEXTURE0 + B);
  }
  function U(j, B) {
    const ft = s.get(j);
    if (j.version > 0 && ft.__version !== j.version) {
      $(ft, j, B);
      return;
    }
    e.bindTexture(n.TEXTURE_2D_ARRAY, ft.__webglTexture, n.TEXTURE0 + B);
  }
  function X(j, B) {
    const ft = s.get(j);
    if (j.version > 0 && ft.__version !== j.version) {
      $(ft, j, B);
      return;
    }
    e.bindTexture(n.TEXTURE_3D, ft.__webglTexture, n.TEXTURE0 + B);
  }
  function V(j, B) {
    const ft = s.get(j);
    if (j.version > 0 && ft.__version !== j.version) {
      ot(ft, j, B);
      return;
    }
    e.bindTexture(n.TEXTURE_CUBE_MAP, ft.__webglTexture, n.TEXTURE0 + B);
  }
  const W = {
    [qm]: n.REPEAT,
    [fr]: n.CLAMP_TO_EDGE,
    [Zm]: n.MIRRORED_REPEAT
  }, J = {
    [Vn]: n.NEAREST,
    [Zw]: n.NEAREST_MIPMAP_NEAREST,
    [ju]: n.NEAREST_MIPMAP_LINEAR,
    [is]: n.LINEAR,
    [Fp]: n.LINEAR_MIPMAP_NEAREST,
    [dr]: n.LINEAR_MIPMAP_LINEAR
  }, I = {
    [Jw]: n.NEVER,
    [a2]: n.ALWAYS,
    [t2]: n.LESS,
    [wM]: n.LEQUAL,
    [e2]: n.EQUAL,
    [s2]: n.GEQUAL,
    [n2]: n.GREATER,
    [i2]: n.NOTEQUAL
  };
  function q(j, B) {
    if (B.type === Ii && t.has("OES_texture_float_linear") === !1 && (B.magFilter === is || B.magFilter === Fp || B.magFilter === ju || B.magFilter === dr || B.minFilter === is || B.minFilter === Fp || B.minFilter === ju || B.minFilter === dr) && console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), n.texParameteri(j, n.TEXTURE_WRAP_S, W[B.wrapS]), n.texParameteri(j, n.TEXTURE_WRAP_T, W[B.wrapT]), (j === n.TEXTURE_3D || j === n.TEXTURE_2D_ARRAY) && n.texParameteri(j, n.TEXTURE_WRAP_R, W[B.wrapR]), n.texParameteri(j, n.TEXTURE_MAG_FILTER, J[B.magFilter]), n.texParameteri(j, n.TEXTURE_MIN_FILTER, J[B.minFilter]), B.compareFunction && (n.texParameteri(j, n.TEXTURE_COMPARE_MODE, n.COMPARE_REF_TO_TEXTURE), n.texParameteri(j, n.TEXTURE_COMPARE_FUNC, I[B.compareFunction])), t.has("EXT_texture_filter_anisotropic") === !0) {
      if (B.magFilter === Vn || B.minFilter !== ju && B.minFilter !== dr || B.type === Ii && t.has("OES_texture_float_linear") === !1) return;
      if (B.anisotropy > 1 || s.get(B).__currentAnisotropy) {
        const ft = t.get("EXT_texture_filter_anisotropic");
        n.texParameterf(j, ft.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(B.anisotropy, r.getMaxAnisotropy())), s.get(B).__currentAnisotropy = B.anisotropy;
      }
    }
  }
  function lt(j, B) {
    let ft = !1;
    j.__webglInit === void 0 && (j.__webglInit = !0, B.addEventListener("dispose", N));
    const St = B.source;
    let wt = _.get(St);
    wt === void 0 && (wt = {}, _.set(St, wt));
    const bt = P(B);
    if (bt !== j.__cacheKey) {
      wt[bt] === void 0 && (wt[bt] = {
        texture: n.createTexture(),
        usedTimes: 0
      }, c.memory.textures++, ft = !0), wt[bt].usedTimes++;
      const Zt = wt[j.__cacheKey];
      Zt !== void 0 && (wt[j.__cacheKey].usedTimes--, Zt.usedTimes === 0 && A(B)), j.__cacheKey = bt, j.__webglTexture = wt[bt].texture;
    }
    return ft;
  }
  function $(j, B, ft) {
    let St = n.TEXTURE_2D;
    (B.isDataArrayTexture || B.isCompressedArrayTexture) && (St = n.TEXTURE_2D_ARRAY), B.isData3DTexture && (St = n.TEXTURE_3D);
    const wt = lt(j, B), bt = B.source;
    e.bindTexture(St, j.__webglTexture, n.TEXTURE0 + ft);
    const Zt = s.get(bt);
    if (bt.version !== Zt.__version || wt === !0) {
      e.activeTexture(n.TEXTURE0 + ft);
      const Ut = Ie.getPrimaries(Ie.workingColorSpace), Wt = B.colorSpace === Ta ? null : Ie.getPrimaries(B.colorSpace), ve = B.colorSpace === Ta || Ut === Wt ? n.NONE : n.BROWSER_DEFAULT_WEBGL;
      n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, B.flipY), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, B.premultiplyAlpha), n.pixelStorei(n.UNPACK_ALIGNMENT, B.unpackAlignment), n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL, ve);
      let Dt = M(B.image, !1, r.maxTextureSize);
      Dt = xe(B, Dt);
      const Yt = l.convert(B.format, B.colorSpace), Jt = l.convert(B.type);
      let $t = T(B.internalFormat, Yt, Jt, B.colorSpace, B.isVideoTexture);
      q(St, B);
      let Vt;
      const re = B.mipmaps, de = B.isVideoTexture !== !0, Fe = Zt.__version === void 0 || wt === !0, nt = bt.dataReady, Ot = O(B, Dt);
      if (B.isDepthTexture)
        $t = E(B.format === Wo, B.type), Fe && (de ? e.texStorage2D(n.TEXTURE_2D, 1, $t, Dt.width, Dt.height) : e.texImage2D(n.TEXTURE_2D, 0, $t, Dt.width, Dt.height, 0, Yt, Jt, null));
      else if (B.isDataTexture)
        if (re.length > 0) {
          de && Fe && e.texStorage2D(n.TEXTURE_2D, Ot, $t, re[0].width, re[0].height);
          for (let yt = 0, At = re.length; yt < At; yt++)
            Vt = re[yt], de ? nt && e.texSubImage2D(n.TEXTURE_2D, yt, 0, 0, Vt.width, Vt.height, Yt, Jt, Vt.data) : e.texImage2D(n.TEXTURE_2D, yt, $t, Vt.width, Vt.height, 0, Yt, Jt, Vt.data);
          B.generateMipmaps = !1;
        } else
          de ? (Fe && e.texStorage2D(n.TEXTURE_2D, Ot, $t, Dt.width, Dt.height), nt && e.texSubImage2D(n.TEXTURE_2D, 0, 0, 0, Dt.width, Dt.height, Yt, Jt, Dt.data)) : e.texImage2D(n.TEXTURE_2D, 0, $t, Dt.width, Dt.height, 0, Yt, Jt, Dt.data);
      else if (B.isCompressedTexture)
        if (B.isCompressedArrayTexture) {
          de && Fe && e.texStorage3D(n.TEXTURE_2D_ARRAY, Ot, $t, re[0].width, re[0].height, Dt.depth);
          for (let yt = 0, At = re.length; yt < At; yt++)
            if (Vt = re[yt], B.format !== bi)
              if (Yt !== null)
                if (de) {
                  if (nt)
                    if (B.layerUpdates.size > 0) {
                      const Pt = $x(Vt.width, Vt.height, B.format, B.type);
                      for (const zt of B.layerUpdates) {
                        const ce = Vt.data.subarray(
                          zt * Pt / Vt.data.BYTES_PER_ELEMENT,
                          (zt + 1) * Pt / Vt.data.BYTES_PER_ELEMENT
                        );
                        e.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY, yt, 0, 0, zt, Vt.width, Vt.height, 1, Yt, ce);
                      }
                      B.clearLayerUpdates();
                    } else
                      e.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY, yt, 0, 0, 0, Vt.width, Vt.height, Dt.depth, Yt, Vt.data);
                } else
                  e.compressedTexImage3D(n.TEXTURE_2D_ARRAY, yt, $t, Vt.width, Vt.height, Dt.depth, 0, Vt.data, 0, 0);
              else
                console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");
            else
              de ? nt && e.texSubImage3D(n.TEXTURE_2D_ARRAY, yt, 0, 0, 0, Vt.width, Vt.height, Dt.depth, Yt, Jt, Vt.data) : e.texImage3D(n.TEXTURE_2D_ARRAY, yt, $t, Vt.width, Vt.height, Dt.depth, 0, Yt, Jt, Vt.data);
        } else {
          de && Fe && e.texStorage2D(n.TEXTURE_2D, Ot, $t, re[0].width, re[0].height);
          for (let yt = 0, At = re.length; yt < At; yt++)
            Vt = re[yt], B.format !== bi ? Yt !== null ? de ? nt && e.compressedTexSubImage2D(n.TEXTURE_2D, yt, 0, 0, Vt.width, Vt.height, Yt, Vt.data) : e.compressedTexImage2D(n.TEXTURE_2D, yt, $t, Vt.width, Vt.height, 0, Vt.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : de ? nt && e.texSubImage2D(n.TEXTURE_2D, yt, 0, 0, Vt.width, Vt.height, Yt, Jt, Vt.data) : e.texImage2D(n.TEXTURE_2D, yt, $t, Vt.width, Vt.height, 0, Yt, Jt, Vt.data);
        }
      else if (B.isDataArrayTexture)
        if (de) {
          if (Fe && e.texStorage3D(n.TEXTURE_2D_ARRAY, Ot, $t, Dt.width, Dt.height, Dt.depth), nt)
            if (B.layerUpdates.size > 0) {
              const yt = $x(Dt.width, Dt.height, B.format, B.type);
              for (const At of B.layerUpdates) {
                const Pt = Dt.data.subarray(
                  At * yt / Dt.data.BYTES_PER_ELEMENT,
                  (At + 1) * yt / Dt.data.BYTES_PER_ELEMENT
                );
                e.texSubImage3D(n.TEXTURE_2D_ARRAY, 0, 0, 0, At, Dt.width, Dt.height, 1, Yt, Jt, Pt);
              }
              B.clearLayerUpdates();
            } else
              e.texSubImage3D(n.TEXTURE_2D_ARRAY, 0, 0, 0, 0, Dt.width, Dt.height, Dt.depth, Yt, Jt, Dt.data);
        } else
          e.texImage3D(n.TEXTURE_2D_ARRAY, 0, $t, Dt.width, Dt.height, Dt.depth, 0, Yt, Jt, Dt.data);
      else if (B.isData3DTexture)
        de ? (Fe && e.texStorage3D(n.TEXTURE_3D, Ot, $t, Dt.width, Dt.height, Dt.depth), nt && e.texSubImage3D(n.TEXTURE_3D, 0, 0, 0, 0, Dt.width, Dt.height, Dt.depth, Yt, Jt, Dt.data)) : e.texImage3D(n.TEXTURE_3D, 0, $t, Dt.width, Dt.height, Dt.depth, 0, Yt, Jt, Dt.data);
      else if (B.isFramebufferTexture) {
        if (Fe)
          if (de)
            e.texStorage2D(n.TEXTURE_2D, Ot, $t, Dt.width, Dt.height);
          else {
            let yt = Dt.width, At = Dt.height;
            for (let Pt = 0; Pt < Ot; Pt++)
              e.texImage2D(n.TEXTURE_2D, Pt, $t, yt, At, 0, Yt, Jt, null), yt >>= 1, At >>= 1;
          }
      } else if (re.length > 0) {
        if (de && Fe) {
          const yt = jt(re[0]);
          e.texStorage2D(n.TEXTURE_2D, Ot, $t, yt.width, yt.height);
        }
        for (let yt = 0, At = re.length; yt < At; yt++)
          Vt = re[yt], de ? nt && e.texSubImage2D(n.TEXTURE_2D, yt, 0, 0, Yt, Jt, Vt) : e.texImage2D(n.TEXTURE_2D, yt, $t, Yt, Jt, Vt);
        B.generateMipmaps = !1;
      } else if (de) {
        if (Fe) {
          const yt = jt(Dt);
          e.texStorage2D(n.TEXTURE_2D, Ot, $t, yt.width, yt.height);
        }
        nt && e.texSubImage2D(n.TEXTURE_2D, 0, 0, 0, Yt, Jt, Dt);
      } else
        e.texImage2D(n.TEXTURE_2D, 0, $t, Yt, Jt, Dt);
      S(B) && y(St), Zt.__version = bt.version, B.onUpdate && B.onUpdate(B);
    }
    j.__version = B.version;
  }
  function ot(j, B, ft) {
    if (B.image.length !== 6) return;
    const St = lt(j, B), wt = B.source;
    e.bindTexture(n.TEXTURE_CUBE_MAP, j.__webglTexture, n.TEXTURE0 + ft);
    const bt = s.get(wt);
    if (wt.version !== bt.__version || St === !0) {
      e.activeTexture(n.TEXTURE0 + ft);
      const Zt = Ie.getPrimaries(Ie.workingColorSpace), Ut = B.colorSpace === Ta ? null : Ie.getPrimaries(B.colorSpace), Wt = B.colorSpace === Ta || Zt === Ut ? n.NONE : n.BROWSER_DEFAULT_WEBGL;
      n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, B.flipY), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, B.premultiplyAlpha), n.pixelStorei(n.UNPACK_ALIGNMENT, B.unpackAlignment), n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL, Wt);
      const ve = B.isCompressedTexture || B.image[0].isCompressedTexture, Dt = B.image[0] && B.image[0].isDataTexture, Yt = [];
      for (let At = 0; At < 6; At++)
        !ve && !Dt ? Yt[At] = M(B.image[At], !0, r.maxCubemapSize) : Yt[At] = Dt ? B.image[At].image : B.image[At], Yt[At] = xe(B, Yt[At]);
      const Jt = Yt[0], $t = l.convert(B.format, B.colorSpace), Vt = l.convert(B.type), re = T(B.internalFormat, $t, Vt, B.colorSpace), de = B.isVideoTexture !== !0, Fe = bt.__version === void 0 || St === !0, nt = wt.dataReady;
      let Ot = O(B, Jt);
      q(n.TEXTURE_CUBE_MAP, B);
      let yt;
      if (ve) {
        de && Fe && e.texStorage2D(n.TEXTURE_CUBE_MAP, Ot, re, Jt.width, Jt.height);
        for (let At = 0; At < 6; At++) {
          yt = Yt[At].mipmaps;
          for (let Pt = 0; Pt < yt.length; Pt++) {
            const zt = yt[Pt];
            B.format !== bi ? $t !== null ? de ? nt && e.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, Pt, 0, 0, zt.width, zt.height, $t, zt.data) : e.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, Pt, re, zt.width, zt.height, 0, zt.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : de ? nt && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, Pt, 0, 0, zt.width, zt.height, $t, Vt, zt.data) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, Pt, re, zt.width, zt.height, 0, $t, Vt, zt.data);
          }
        }
      } else {
        if (yt = B.mipmaps, de && Fe) {
          yt.length > 0 && Ot++;
          const At = jt(Yt[0]);
          e.texStorage2D(n.TEXTURE_CUBE_MAP, Ot, re, At.width, At.height);
        }
        for (let At = 0; At < 6; At++)
          if (Dt) {
            de ? nt && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, 0, 0, 0, Yt[At].width, Yt[At].height, $t, Vt, Yt[At].data) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, 0, re, Yt[At].width, Yt[At].height, 0, $t, Vt, Yt[At].data);
            for (let Pt = 0; Pt < yt.length; Pt++) {
              const ce = yt[Pt].image[At].image;
              de ? nt && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, Pt + 1, 0, 0, ce.width, ce.height, $t, Vt, ce.data) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, Pt + 1, re, ce.width, ce.height, 0, $t, Vt, ce.data);
            }
          } else {
            de ? nt && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, 0, 0, 0, $t, Vt, Yt[At]) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, 0, re, $t, Vt, Yt[At]);
            for (let Pt = 0; Pt < yt.length; Pt++) {
              const zt = yt[Pt];
              de ? nt && e.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, Pt + 1, 0, 0, $t, Vt, zt.image[At]) : e.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + At, Pt + 1, re, $t, Vt, zt.image[At]);
            }
          }
      }
      S(B) && y(n.TEXTURE_CUBE_MAP), bt.__version = wt.version, B.onUpdate && B.onUpdate(B);
    }
    j.__version = B.version;
  }
  function gt(j, B, ft, St, wt, bt) {
    const Zt = l.convert(ft.format, ft.colorSpace), Ut = l.convert(ft.type), Wt = T(ft.internalFormat, Zt, Ut, ft.colorSpace), ve = s.get(B), Dt = s.get(ft);
    if (Dt.__renderTarget = B, !ve.__hasExternalTextures) {
      const Yt = Math.max(1, B.width >> bt), Jt = Math.max(1, B.height >> bt);
      wt === n.TEXTURE_3D || wt === n.TEXTURE_2D_ARRAY ? e.texImage3D(wt, bt, Wt, Yt, Jt, B.depth, 0, Zt, Ut, null) : e.texImage2D(wt, bt, Wt, Yt, Jt, 0, Zt, Ut, null);
    }
    e.bindFramebuffer(n.FRAMEBUFFER, j), se(B) ? f.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, St, wt, Dt.__webglTexture, 0, Xt(B)) : (wt === n.TEXTURE_2D || wt >= n.TEXTURE_CUBE_MAP_POSITIVE_X && wt <= n.TEXTURE_CUBE_MAP_NEGATIVE_Z) && n.framebufferTexture2D(n.FRAMEBUFFER, St, wt, Dt.__webglTexture, bt), e.bindFramebuffer(n.FRAMEBUFFER, null);
  }
  function ht(j, B, ft) {
    if (n.bindRenderbuffer(n.RENDERBUFFER, j), B.depthBuffer) {
      const St = B.depthTexture, wt = St && St.isDepthTexture ? St.type : null, bt = E(B.stencilBuffer, wt), Zt = B.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, Ut = Xt(B);
      se(B) ? f.renderbufferStorageMultisampleEXT(n.RENDERBUFFER, Ut, bt, B.width, B.height) : ft ? n.renderbufferStorageMultisample(n.RENDERBUFFER, Ut, bt, B.width, B.height) : n.renderbufferStorage(n.RENDERBUFFER, bt, B.width, B.height), n.framebufferRenderbuffer(n.FRAMEBUFFER, Zt, n.RENDERBUFFER, j);
    } else {
      const St = B.textures;
      for (let wt = 0; wt < St.length; wt++) {
        const bt = St[wt], Zt = l.convert(bt.format, bt.colorSpace), Ut = l.convert(bt.type), Wt = T(bt.internalFormat, Zt, Ut, bt.colorSpace), ve = Xt(B);
        ft && se(B) === !1 ? n.renderbufferStorageMultisample(n.RENDERBUFFER, ve, Wt, B.width, B.height) : se(B) ? f.renderbufferStorageMultisampleEXT(n.RENDERBUFFER, ve, Wt, B.width, B.height) : n.renderbufferStorage(n.RENDERBUFFER, Wt, B.width, B.height);
      }
    }
    n.bindRenderbuffer(n.RENDERBUFFER, null);
  }
  function _t(j, B) {
    if (B && B.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported");
    if (e.bindFramebuffer(n.FRAMEBUFFER, j), !(B.depthTexture && B.depthTexture.isDepthTexture))
      throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
    const St = s.get(B.depthTexture);
    St.__renderTarget = B, (!St.__webglTexture || B.depthTexture.image.width !== B.width || B.depthTexture.image.height !== B.height) && (B.depthTexture.image.width = B.width, B.depthTexture.image.height = B.height, B.depthTexture.needsUpdate = !0), Y(B.depthTexture, 0);
    const wt = St.__webglTexture, bt = Xt(B);
    if (B.depthTexture.format === Io)
      se(B) ? f.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, n.DEPTH_ATTACHMENT, n.TEXTURE_2D, wt, 0, bt) : n.framebufferTexture2D(n.FRAMEBUFFER, n.DEPTH_ATTACHMENT, n.TEXTURE_2D, wt, 0);
    else if (B.depthTexture.format === Wo)
      se(B) ? f.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, n.DEPTH_STENCIL_ATTACHMENT, n.TEXTURE_2D, wt, 0, bt) : n.framebufferTexture2D(n.FRAMEBUFFER, n.DEPTH_STENCIL_ATTACHMENT, n.TEXTURE_2D, wt, 0);
    else
      throw new Error("Unknown depthTexture format");
  }
  function Et(j) {
    const B = s.get(j), ft = j.isWebGLCubeRenderTarget === !0;
    if (B.__boundDepthTexture !== j.depthTexture) {
      const St = j.depthTexture;
      if (B.__depthDisposeCallback && B.__depthDisposeCallback(), St) {
        const wt = () => {
          delete B.__boundDepthTexture, delete B.__depthDisposeCallback, St.removeEventListener("dispose", wt);
        };
        St.addEventListener("dispose", wt), B.__depthDisposeCallback = wt;
      }
      B.__boundDepthTexture = St;
    }
    if (j.depthTexture && !B.__autoAllocateDepthBuffer) {
      if (ft) throw new Error("target.depthTexture not supported in Cube render targets");
      _t(B.__webglFramebuffer, j);
    } else if (ft) {
      B.__webglDepthbuffer = [];
      for (let St = 0; St < 6; St++)
        if (e.bindFramebuffer(n.FRAMEBUFFER, B.__webglFramebuffer[St]), B.__webglDepthbuffer[St] === void 0)
          B.__webglDepthbuffer[St] = n.createRenderbuffer(), ht(B.__webglDepthbuffer[St], j, !1);
        else {
          const wt = j.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, bt = B.__webglDepthbuffer[St];
          n.bindRenderbuffer(n.RENDERBUFFER, bt), n.framebufferRenderbuffer(n.FRAMEBUFFER, wt, n.RENDERBUFFER, bt);
        }
    } else if (e.bindFramebuffer(n.FRAMEBUFFER, B.__webglFramebuffer), B.__webglDepthbuffer === void 0)
      B.__webglDepthbuffer = n.createRenderbuffer(), ht(B.__webglDepthbuffer, j, !1);
    else {
      const St = j.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, wt = B.__webglDepthbuffer;
      n.bindRenderbuffer(n.RENDERBUFFER, wt), n.framebufferRenderbuffer(n.FRAMEBUFFER, St, n.RENDERBUFFER, wt);
    }
    e.bindFramebuffer(n.FRAMEBUFFER, null);
  }
  function Lt(j, B, ft) {
    const St = s.get(j);
    B !== void 0 && gt(St.__webglFramebuffer, j, j.texture, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, 0), ft !== void 0 && Et(j);
  }
  function Gt(j) {
    const B = j.texture, ft = s.get(j), St = s.get(B);
    j.addEventListener("dispose", D);
    const wt = j.textures, bt = j.isWebGLCubeRenderTarget === !0, Zt = wt.length > 1;
    if (Zt || (St.__webglTexture === void 0 && (St.__webglTexture = n.createTexture()), St.__version = B.version, c.memory.textures++), bt) {
      ft.__webglFramebuffer = [];
      for (let Ut = 0; Ut < 6; Ut++)
        if (B.mipmaps && B.mipmaps.length > 0) {
          ft.__webglFramebuffer[Ut] = [];
          for (let Wt = 0; Wt < B.mipmaps.length; Wt++)
            ft.__webglFramebuffer[Ut][Wt] = n.createFramebuffer();
        } else
          ft.__webglFramebuffer[Ut] = n.createFramebuffer();
    } else {
      if (B.mipmaps && B.mipmaps.length > 0) {
        ft.__webglFramebuffer = [];
        for (let Ut = 0; Ut < B.mipmaps.length; Ut++)
          ft.__webglFramebuffer[Ut] = n.createFramebuffer();
      } else
        ft.__webglFramebuffer = n.createFramebuffer();
      if (Zt)
        for (let Ut = 0, Wt = wt.length; Ut < Wt; Ut++) {
          const ve = s.get(wt[Ut]);
          ve.__webglTexture === void 0 && (ve.__webglTexture = n.createTexture(), c.memory.textures++);
        }
      if (j.samples > 0 && se(j) === !1) {
        ft.__webglMultisampledFramebuffer = n.createFramebuffer(), ft.__webglColorRenderbuffer = [], e.bindFramebuffer(n.FRAMEBUFFER, ft.__webglMultisampledFramebuffer);
        for (let Ut = 0; Ut < wt.length; Ut++) {
          const Wt = wt[Ut];
          ft.__webglColorRenderbuffer[Ut] = n.createRenderbuffer(), n.bindRenderbuffer(n.RENDERBUFFER, ft.__webglColorRenderbuffer[Ut]);
          const ve = l.convert(Wt.format, Wt.colorSpace), Dt = l.convert(Wt.type), Yt = T(Wt.internalFormat, ve, Dt, Wt.colorSpace, j.isXRRenderTarget === !0), Jt = Xt(j);
          n.renderbufferStorageMultisample(n.RENDERBUFFER, Jt, Yt, j.width, j.height), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Ut, n.RENDERBUFFER, ft.__webglColorRenderbuffer[Ut]);
        }
        n.bindRenderbuffer(n.RENDERBUFFER, null), j.depthBuffer && (ft.__webglDepthRenderbuffer = n.createRenderbuffer(), ht(ft.__webglDepthRenderbuffer, j, !0)), e.bindFramebuffer(n.FRAMEBUFFER, null);
      }
    }
    if (bt) {
      e.bindTexture(n.TEXTURE_CUBE_MAP, St.__webglTexture), q(n.TEXTURE_CUBE_MAP, B);
      for (let Ut = 0; Ut < 6; Ut++)
        if (B.mipmaps && B.mipmaps.length > 0)
          for (let Wt = 0; Wt < B.mipmaps.length; Wt++)
            gt(ft.__webglFramebuffer[Ut][Wt], j, B, n.COLOR_ATTACHMENT0, n.TEXTURE_CUBE_MAP_POSITIVE_X + Ut, Wt);
        else
          gt(ft.__webglFramebuffer[Ut], j, B, n.COLOR_ATTACHMENT0, n.TEXTURE_CUBE_MAP_POSITIVE_X + Ut, 0);
      S(B) && y(n.TEXTURE_CUBE_MAP), e.unbindTexture();
    } else if (Zt) {
      for (let Ut = 0, Wt = wt.length; Ut < Wt; Ut++) {
        const ve = wt[Ut], Dt = s.get(ve);
        e.bindTexture(n.TEXTURE_2D, Dt.__webglTexture), q(n.TEXTURE_2D, ve), gt(ft.__webglFramebuffer, j, ve, n.COLOR_ATTACHMENT0 + Ut, n.TEXTURE_2D, 0), S(ve) && y(n.TEXTURE_2D);
      }
      e.unbindTexture();
    } else {
      let Ut = n.TEXTURE_2D;
      if ((j.isWebGL3DRenderTarget || j.isWebGLArrayRenderTarget) && (Ut = j.isWebGL3DRenderTarget ? n.TEXTURE_3D : n.TEXTURE_2D_ARRAY), e.bindTexture(Ut, St.__webglTexture), q(Ut, B), B.mipmaps && B.mipmaps.length > 0)
        for (let Wt = 0; Wt < B.mipmaps.length; Wt++)
          gt(ft.__webglFramebuffer[Wt], j, B, n.COLOR_ATTACHMENT0, Ut, Wt);
      else
        gt(ft.__webglFramebuffer, j, B, n.COLOR_ATTACHMENT0, Ut, 0);
      S(B) && y(Ut), e.unbindTexture();
    }
    j.depthBuffer && Et(j);
  }
  function Nt(j) {
    const B = j.textures;
    for (let ft = 0, St = B.length; ft < St; ft++) {
      const wt = B[ft];
      if (S(wt)) {
        const bt = C(j), Zt = s.get(wt).__webglTexture;
        e.bindTexture(bt, Zt), y(bt), e.unbindTexture();
      }
    }
  }
  const Bt = [], K = [];
  function pe(j) {
    if (j.samples > 0) {
      if (se(j) === !1) {
        const B = j.textures, ft = j.width, St = j.height;
        let wt = n.COLOR_BUFFER_BIT;
        const bt = j.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, Zt = s.get(j), Ut = B.length > 1;
        if (Ut)
          for (let Wt = 0; Wt < B.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 < B.length; Wt++) {
          if (j.resolveDepthBuffer && (j.depthBuffer && (wt |= n.DEPTH_BUFFER_BIT), j.stencilBuffer && j.resolveStencilBuffer && (wt |= n.STENCIL_BUFFER_BIT)), Ut) {
            n.framebufferRenderbuffer(n.READ_FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.RENDERBUFFER, Zt.__webglColorRenderbuffer[Wt]);
            const ve = s.get(B[Wt]).__webglTexture;
            n.framebufferTexture2D(n.DRAW_FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, ve, 0);
          }
          n.blitFramebuffer(0, 0, ft, St, 0, 0, ft, St, wt, n.NEAREST), d === !0 && (Bt.length = 0, K.length = 0, Bt.push(n.COLOR_ATTACHMENT0 + Wt), j.depthBuffer && j.resolveDepthBuffer === !1 && (Bt.push(bt), K.push(bt), n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER, K)), n.invalidateFramebuffer(n.READ_FRAMEBUFFER, Bt));
        }
        if (e.bindFramebuffer(n.READ_FRAMEBUFFER, null), e.bindFramebuffer(n.DRAW_FRAMEBUFFER, null), Ut)
          for (let Wt = 0; Wt < B.length; Wt++) {
            e.bindFramebuffer(n.FRAMEBUFFER, Zt.__webglMultisampledFramebuffer), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Wt, n.RENDERBUFFER, Zt.__webglColorRenderbuffer[Wt]);
            const ve = s.get(B[Wt]).__webglTexture;
            e.bindFramebuffer(n.FRAMEBUFFER, Zt.__webglFramebuffer), n.framebufferTexture2D(n.DRAW_FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Wt, n.TEXTURE_2D, ve, 0);
          }
        e.bindFramebuffer(n.DRAW_FRAMEBUFFER, Zt.__webglMultisampledFramebuffer);
      } else if (j.depthBuffer && j.resolveDepthBuffer === !1 && d) {
        const B = j.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT;
        n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER, [B]);
      }
    }
  }
  function Xt(j) {
    return Math.min(r.maxSamples, j.samples);
  }
  function se(j) {
    const B = s.get(j);
    return j.samples > 0 && t.has("WEBGL_multisampled_render_to_texture") === !0 && B.__useRenderToTexture !== !1;
  }
  function qt(j) {
    const B = c.render.frame;
    m.get(j) !== B && (m.set(j, B), j.update());
  }
  function xe(j, B) {
    const ft = j.colorSpace, St = j.format, wt = j.type;
    return j.isCompressedTexture === !0 || j.isVideoTexture === !0 || ft !== Yo && ft !== Ta && (Ie.getTransfer(ft) === We ? (St !== bi || wt !== Hs) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", ft)), B;
  }
  function jt(j) {
    return typeof HTMLImageElement < "u" && j instanceof HTMLImageElement ? (h.width = j.naturalWidth || j.width, h.height = j.naturalHeight || j.height) : typeof VideoFrame < "u" && j instanceof VideoFrame ? (h.width = j.displayWidth, h.height = j.displayHeight) : (h.width = j.width, h.height = j.height), h;
  }
  this.allocateTextureUnit = k, this.resetTextureUnits = H, this.setTexture2D = Y, this.setTexture2DArray = U, this.setTexture3D = X, this.setTextureCube = V, this.rebindTextures = Lt, this.setupRenderTarget = Gt, this.updateRenderTargetMipmap = Nt, this.updateMultisampleRenderTarget = pe, this.setupDepthRenderbuffer = Et, this.setupFrameBufferTexture = gt, this.useMultisampledRTT = se;
}
function SN(n, t) {
  function e(s, r = Ta) {
    let l;
    const c = Ie.getTransfer(r);
    if (s === Hs) return n.UNSIGNED_BYTE;
    if (s === Yg) return n.UNSIGNED_SHORT_4_4_4_4;
    if (s === jg) return n.UNSIGNED_SHORT_5_5_5_1;
    if (s === yM) return n.UNSIGNED_INT_5_9_9_9_REV;
    if (s === _M) return n.BYTE;
    if (s === vM) return n.SHORT;
    if (s === pc) return n.UNSIGNED_SHORT;
    if (s === Wg) return n.INT;
    if (s === _r) return n.UNSIGNED_INT;
    if (s === Ii) return n.FLOAT;
    if (s === Cc) return n.HALF_FLOAT;
    if (s === xM) return n.ALPHA;
    if (s === SM) return n.RGB;
    if (s === bi) return n.RGBA;
    if (s === bM) return n.LUMINANCE;
    if (s === MM) return n.LUMINANCE_ALPHA;
    if (s === Io) return n.DEPTH_COMPONENT;
    if (s === Wo) return n.DEPTH_STENCIL;
    if (s === qg) return n.RED;
    if (s === Zg) return n.RED_INTEGER;
    if (s === EM) return n.RG;
    if (s === Kg) return n.RG_INTEGER;
    if (s === $g) return n.RGBA_INTEGER;
    if (s === Pf || s === zf || s === If || s === Bf)
      if (c === We)
        if (l = t.get("WEBGL_compressed_texture_s3tc_srgb"), l !== null) {
          if (s === Pf) return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;
          if (s === zf) return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
          if (s === If) return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
          if (s === Bf) return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
        } else
          return null;
      else if (l = t.get("WEBGL_compressed_texture_s3tc"), l !== null) {
        if (s === Pf) return l.COMPRESSED_RGB_S3TC_DXT1_EXT;
        if (s === zf) return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;
        if (s === If) return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;
        if (s === Bf) return l.COMPRESSED_RGBA_S3TC_DXT5_EXT;
      } else
        return null;
    if (s === Km || s === $m || s === Qm || s === Jm)
      if (l = t.get("WEBGL_compressed_texture_pvrtc"), l !== null) {
        if (s === Km) return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
        if (s === $m) return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
        if (s === Qm) return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
        if (s === Jm) return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
      } else
        return null;
    if (s === tg || s === eg || s === ng)
      if (l = t.get("WEBGL_compressed_texture_etc"), l !== null) {
        if (s === tg || s === eg) return c === We ? l.COMPRESSED_SRGB8_ETC2 : l.COMPRESSED_RGB8_ETC2;
        if (s === ng) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : l.COMPRESSED_RGBA8_ETC2_EAC;
      } else
        return null;
    if (s === ig || s === sg || s === ag || s === rg || s === og || s === lg || s === cg || s === ug || s === fg || s === dg || s === hg || s === pg || s === mg || s === gg)
      if (l = t.get("WEBGL_compressed_texture_astc"), l !== null) {
        if (s === ig) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : l.COMPRESSED_RGBA_ASTC_4x4_KHR;
        if (s === sg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : l.COMPRESSED_RGBA_ASTC_5x4_KHR;
        if (s === ag) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : l.COMPRESSED_RGBA_ASTC_5x5_KHR;
        if (s === rg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : l.COMPRESSED_RGBA_ASTC_6x5_KHR;
        if (s === og) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : l.COMPRESSED_RGBA_ASTC_6x6_KHR;
        if (s === lg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : l.COMPRESSED_RGBA_ASTC_8x5_KHR;
        if (s === cg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : l.COMPRESSED_RGBA_ASTC_8x6_KHR;
        if (s === ug) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : l.COMPRESSED_RGBA_ASTC_8x8_KHR;
        if (s === fg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : l.COMPRESSED_RGBA_ASTC_10x5_KHR;
        if (s === dg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : l.COMPRESSED_RGBA_ASTC_10x6_KHR;
        if (s === hg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : l.COMPRESSED_RGBA_ASTC_10x8_KHR;
        if (s === pg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : l.COMPRESSED_RGBA_ASTC_10x10_KHR;
        if (s === mg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : l.COMPRESSED_RGBA_ASTC_12x10_KHR;
        if (s === gg) return c === We ? l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : l.COMPRESSED_RGBA_ASTC_12x12_KHR;
      } else
        return null;
    if (s === Ff || s === _g || s === vg)
      if (l = t.get("EXT_texture_compression_bptc"), l !== null) {
        if (s === Ff) return c === We ? l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : l.COMPRESSED_RGBA_BPTC_UNORM_EXT;
        if (s === _g) return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
        if (s === vg) return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
      } else
        return null;
    if (s === TM || s === yg || s === xg || s === Sg)
      if (l = t.get("EXT_texture_compression_rgtc"), l !== null) {
        if (s === Ff) return l.COMPRESSED_RED_RGTC1_EXT;
        if (s === yg) return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;
        if (s === xg) return l.COMPRESSED_RED_GREEN_RGTC2_EXT;
        if (s === Sg) return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
      } else
        return null;
    return s === Xo ? n.UNSIGNED_INT_24_8 : n[s] !== void 0 ? n[s] : null;
  }
  return { convert: e };
}
const bN = { type: "move" };
class vm {
  constructor() {
    this._targetRay = null, this._grip = null, this._hand = null;
  }
  getHandSpace() {
    return this._hand === null && (this._hand = new wa(), 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 wa(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new at(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new at()), this._targetRay;
  }
  getGripSpace() {
    return this._grip === null && (this._grip = new wa(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new at(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new at()), 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 s of t.hand.values())
          this._getHandJoint(e, s);
    }
    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, s) {
    let r = null, l = null, c = null;
    const f = this._targetRay, d = this._grip, h = this._hand;
    if (t && e.session.visibilityState !== "visible-blurred") {
      if (h && t.hand) {
        c = !0;
        for (const M of t.hand.values()) {
          const S = e.getJointPose(M, s), y = this._getHandJoint(h, M);
          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 m = h.joints["index-finger-tip"], p = h.joints["thumb-tip"], _ = m.position.distanceTo(p.position), x = 0.02, b = 5e-3;
        h.inputState.pinching && _ > x + b ? (h.inputState.pinching = !1, this.dispatchEvent({
          type: "pinchend",
          handedness: t.handedness,
          target: this
        })) : !h.inputState.pinching && _ <= x - b && (h.inputState.pinching = !0, this.dispatchEvent({
          type: "pinchstart",
          handedness: t.handedness,
          target: this
        }));
      } else
        d !== null && t.gripSpace && (l = e.getPose(t.gripSpace, s), l !== null && (d.matrix.fromArray(l.transform.matrix), d.matrix.decompose(d.position, d.rotation, d.scale), d.matrixWorldNeedsUpdate = !0, l.linearVelocity ? (d.hasLinearVelocity = !0, d.linearVelocity.copy(l.linearVelocity)) : d.hasLinearVelocity = !1, l.angularVelocity ? (d.hasAngularVelocity = !0, d.angularVelocity.copy(l.angularVelocity)) : d.hasAngularVelocity = !1));
      f !== null && (r = e.getPose(t.targetRaySpace, s), r === null && l !== null && (r = l), r !== null && (f.matrix.fromArray(r.transform.matrix), f.matrix.decompose(f.position, f.rotation, f.scale), f.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (f.hasLinearVelocity = !0, f.linearVelocity.copy(r.linearVelocity)) : f.hasLinearVelocity = !1, r.angularVelocity ? (f.hasAngularVelocity = !0, f.angularVelocity.copy(r.angularVelocity)) : f.hasAngularVelocity = !1, this.dispatchEvent(bN)));
    }
    return f !== null && (f.visible = r !== null), d !== null && (d.visible = l !== null), h !== null && (h.visible = c !== null), this;
  }
  // private method
  _getHandJoint(t, e) {
    if (t.joints[e.jointName] === void 0) {
      const s = new wa();
      s.matrixAutoUpdate = !1, s.visible = !1, t.joints[e.jointName] = s, t.add(s);
    }
    return t.joints[e.jointName];
  }
}
const MN = `
void main() {

	gl_Position = vec4( position, 1.0 );

}`, EN = `
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 TN {
  constructor() {
    this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0;
  }
  init(t, e, s) {
    if (this.texture === null) {
      const r = new jn(), l = t.properties.get(r);
      l.__webglTexture = e.texture, (e.depthNear !== s.depthNear || e.depthFar !== s.depthFar) && (this.depthNear = e.depthNear, this.depthFar = e.depthFar), this.texture = r;
    }
  }
  getMesh(t) {
    if (this.texture !== null && this.mesh === null) {
      const e = t.cameras[0].viewport, s = new Vs({
        vertexShader: MN,
        fragmentShader: EN,
        uniforms: {
          depthColor: { value: this.texture },
          depthWidth: { value: e.z },
          depthHeight: { value: e.w }
        }
      });
      this.mesh = new Un(new md(20, 20), s);
    }
    return this.mesh;
  }
  reset() {
    this.texture = null, this.mesh = null;
  }
  getDepthTexture() {
    return this.texture;
  }
}
class AN extends Mr {
  constructor(t, e) {
    super();
    const s = this;
    let r = null, l = 1, c = null, f = "local-floor", d = 1, h = null, m = null, p = null, _ = null, x = null, b = null;
    const M = new TN(), S = e.getContextAttributes();
    let y = null, C = null;
    const T = [], E = [], O = new le();
    let N = null;
    const D = new xi();
    D.viewport = new on();
    const z = new xi();
    z.viewport = new on();
    const A = [D, z], R = new W2();
    let L = null, H = null;
    this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function($) {
      let ot = T[$];
      return ot === void 0 && (ot = new vm(), T[$] = ot), ot.getTargetRaySpace();
    }, this.getControllerGrip = function($) {
      let ot = T[$];
      return ot === void 0 && (ot = new vm(), T[$] = ot), ot.getGripSpace();
    }, this.getHand = function($) {
      let ot = T[$];
      return ot === void 0 && (ot = new vm(), T[$] = ot), ot.getHandSpace();
    };
    function k($) {
      const ot = E.indexOf($.inputSource);
      if (ot === -1)
        return;
      const gt = T[ot];
      gt !== void 0 && (gt.update($.inputSource, $.frame, h || c), gt.dispatchEvent({ type: $.type, data: $.inputSource }));
    }
    function P() {
      r.removeEventListener("select", k), r.removeEventListener("selectstart", k), r.removeEventListener("selectend", k), r.removeEventListener("squeeze", k), r.removeEventListener("squeezestart", k), r.removeEventListener("squeezeend", k), r.removeEventListener("end", P), r.removeEventListener("inputsourceschange", Y);
      for (let $ = 0; $ < T.length; $++) {
        const ot = E[$];
        ot !== null && (E[$] = null, T[$].disconnect(ot));
      }
      L = null, H = null, M.reset(), t.setRenderTarget(y), x = null, _ = null, p = null, r = null, C = null, lt.stop(), s.isPresenting = !1, t.setPixelRatio(N), t.setSize(O.width, O.height, !1), s.dispatchEvent({ type: "sessionend" });
    }
    this.setFramebufferScaleFactor = function($) {
      l = $, s.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.");
    }, this.setReferenceSpaceType = function($) {
      f = $, s.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.");
    }, this.getReferenceSpace = function() {
      return h || c;
    }, this.setReferenceSpace = function($) {
      h = $;
    }, this.getBaseLayer = function() {
      return _ !== null ? _ : x;
    }, this.getBinding = function() {
      return p;
    }, this.getFrame = function() {
      return b;
    }, this.getSession = function() {
      return r;
    }, this.setSession = async function($) {
      if (r = $, r !== null) {
        if (y = t.getRenderTarget(), r.addEventListener("select", k), r.addEventListener("selectstart", k), r.addEventListener("selectend", k), r.addEventListener("squeeze", k), r.addEventListener("squeezestart", k), r.addEventListener("squeezeend", k), r.addEventListener("end", P), r.addEventListener("inputsourceschange", Y), S.xrCompatible !== !0 && await e.makeXRCompatible(), N = t.getPixelRatio(), t.getSize(O), r.enabledFeatures !== void 0 && r.enabledFeatures.includes("layers")) {
          let gt = null, ht = null, _t = null;
          S.depth && (_t = S.stencil ? e.DEPTH24_STENCIL8 : e.DEPTH_COMPONENT24, gt = S.stencil ? Wo : Io, ht = S.stencil ? Xo : _r);
          const Et = {
            colorFormat: e.RGBA8,
            depthFormat: _t,
            scaleFactor: l
          };
          p = new XRWebGLBinding(r, e), _ = p.createProjectionLayer(Et), r.updateRenderState({ layers: [_] }), t.setPixelRatio(1), t.setSize(_.textureWidth, _.textureHeight, !1), C = new vr(
            _.textureWidth,
            _.textureHeight,
            {
              format: bi,
              type: Hs,
              depthTexture: new VM(_.textureWidth, _.textureHeight, ht, void 0, void 0, void 0, void 0, void 0, void 0, gt),
              stencilBuffer: S.stencil,
              colorSpace: t.outputColorSpace,
              samples: S.antialias ? 4 : 0,
              resolveDepthBuffer: _.ignoreDepthValues === !1
            }
          );
        } else {
          const gt = {
            antialias: S.antialias,
            alpha: !0,
            depth: S.depth,
            stencil: S.stencil,
            framebufferScaleFactor: l
          };
          x = new XRWebGLLayer(r, e, gt), r.updateRenderState({ baseLayer: x }), t.setPixelRatio(1), t.setSize(x.framebufferWidth, x.framebufferHeight, !1), C = new vr(
            x.framebufferWidth,
            x.framebufferHeight,
            {
              format: bi,
              type: Hs,
              colorSpace: t.outputColorSpace,
              stencilBuffer: S.stencil
            }
          );
        }
        C.isXRRenderTarget = !0, this.setFoveation(d), h = null, c = await r.requestReferenceSpace(f), lt.setContext(r), lt.start(), s.isPresenting = !0, s.dispatchEvent({ type: "sessionstart" });
      }
    }, this.getEnvironmentBlendMode = function() {
      if (r !== null)
        return r.environmentBlendMode;
    }, this.getDepthTexture = function() {
      return M.getDepthTexture();
    };
    function Y($) {
      for (let ot = 0; ot < $.removed.length; ot++) {
        const gt = $.removed[ot], ht = E.indexOf(gt);
        ht >= 0 && (E[ht] = null, T[ht].disconnect(gt));
      }
      for (let ot = 0; ot < $.added.length; ot++) {
        const gt = $.added[ot];
        let ht = E.indexOf(gt);
        if (ht === -1) {
          for (let Et = 0; Et < T.length; Et++)
            if (Et >= E.length) {
              E.push(gt), ht = Et;
              break;
            } else if (E[Et] === null) {
              E[Et] = gt, ht = Et;
              break;
            }
          if (ht === -1) break;
        }
        const _t = T[ht];
        _t && _t.connect(gt);
      }
    }
    const U = new at(), X = new at();
    function V($, ot, gt) {
      U.setFromMatrixPosition(ot.matrixWorld), X.setFromMatrixPosition(gt.matrixWorld);
      const ht = U.distanceTo(X), _t = ot.projectionMatrix.elements, Et = gt.projectionMatrix.elements, Lt = _t[14] / (_t[10] - 1), Gt = _t[14] / (_t[10] + 1), Nt = (_t[9] + 1) / _t[5], Bt = (_t[9] - 1) / _t[5], K = (_t[8] - 1) / _t[0], pe = (Et[8] + 1) / Et[0], Xt = Lt * K, se = Lt * pe, qt = ht / (-K + pe), xe = qt * -K;
      if (ot.matrixWorld.decompose($.position, $.quaternion, $.scale), $.translateX(xe), $.translateZ(qt), $.matrixWorld.compose($.position, $.quaternion, $.scale), $.matrixWorldInverse.copy($.matrixWorld).invert(), _t[10] === -1)
        $.projectionMatrix.copy(ot.projectionMatrix), $.projectionMatrixInverse.copy(ot.projectionMatrixInverse);
      else {
        const jt = Lt + qt, j = Gt + qt, B = Xt - xe, ft = se + (ht - xe), St = Nt * Gt / j * jt, wt = Bt * Gt / j * jt;
        $.projectionMatrix.makePerspective(B, ft, St, wt, jt, j), $.projectionMatrixInverse.copy($.projectionMatrix).invert();
      }
    }
    function W($, ot) {
      ot === null ? $.matrixWorld.copy($.matrix) : $.matrixWorld.multiplyMatrices(ot.matrixWorld, $.matrix), $.matrixWorldInverse.copy($.matrixWorld).invert();
    }
    this.updateCamera = function($) {
      if (r === null) return;
      let ot = $.near, gt = $.far;
      M.texture !== null && (M.depthNear > 0 && (ot = M.depthNear), M.depthFar > 0 && (gt = M.depthFar)), R.near = z.near = D.near = ot, R.far = z.far = D.far = gt, (L !== R.near || H !== R.far) && (r.updateRenderState({
        depthNear: R.near,
        depthFar: R.far
      }), L = R.near, H = R.far), D.layers.mask = $.layers.mask | 2, z.layers.mask = $.layers.mask | 4, R.layers.mask = D.layers.mask | z.layers.mask;
      const ht = $.parent, _t = R.cameras;
      W(R, ht);
      for (let Et = 0; Et < _t.length; Et++)
        W(_t[Et], ht);
      _t.length === 2 ? V(R, D, z) : R.projectionMatrix.copy(D.projectionMatrix), J($, R, ht);
    };
    function J($, ot, gt) {
      gt === null ? $.matrix.copy(ot.matrixWorld) : ($.matrix.copy(gt.matrixWorld), $.matrix.invert(), $.matrix.multiply(ot.matrixWorld)), $.matrix.decompose($.position, $.quaternion, $.scale), $.updateMatrixWorld(!0), $.projectionMatrix.copy(ot.projectionMatrix), $.projectionMatrixInverse.copy(ot.projectionMatrixInverse), $.isPerspectiveCamera && ($.fov = bg * 2 * Math.atan(1 / $.projectionMatrix.elements[5]), $.zoom = 1);
    }
    this.getCamera = function() {
      return R;
    }, this.getFoveation = function() {
      if (!(_ === null && x === null))
        return d;
    }, this.setFoveation = function($) {
      d = $, _ !== null && (_.fixedFoveation = $), x !== null && x.fixedFoveation !== void 0 && (x.fixedFoveation = $);
    }, this.hasDepthSensing = function() {
      return M.texture !== null;
    }, this.getDepthSensingMesh = function() {
      return M.getMesh(R);
    };
    let I = null;
    function q($, ot) {
      if (m = ot.getViewerPose(h || c), b = ot, m !== null) {
        const gt = m.views;
        x !== null && (t.setRenderTargetFramebuffer(C, x.framebuffer), t.setRenderTarget(C));
        let ht = !1;
        gt.length !== R.cameras.length && (R.cameras.length = 0, ht = !0);
        for (let Et = 0; Et < gt.length; Et++) {
          const Lt = gt[Et];
          let Gt = null;
          if (x !== null)
            Gt = x.getViewport(Lt);
          else {
            const Bt = p.getViewSubImage(_, Lt);
            Gt = Bt.viewport, Et === 0 && (t.setRenderTargetTextures(
              C,
              Bt.colorTexture,
              _.ignoreDepthValues ? void 0 : Bt.depthStencilTexture
            ), t.setRenderTarget(C));
          }
          let Nt = A[Et];
          Nt === void 0 && (Nt = new xi(), Nt.layers.enable(Et), Nt.viewport = new on(), A[Et] = Nt), Nt.matrix.fromArray(Lt.transform.matrix), Nt.matrix.decompose(Nt.position, Nt.quaternion, Nt.scale), Nt.projectionMatrix.fromArray(Lt.projectionMatrix), Nt.projectionMatrixInverse.copy(Nt.projectionMatrix).invert(), Nt.viewport.set(Gt.x, Gt.y, Gt.width, Gt.height), Et === 0 && (R.matrix.copy(Nt.matrix), R.matrix.decompose(R.position, R.quaternion, R.scale)), ht === !0 && R.cameras.push(Nt);
        }
        const _t = r.enabledFeatures;
        if (_t && _t.includes("depth-sensing")) {
          const Et = p.getDepthInformation(gt[0]);
          Et && Et.isValid && Et.texture && M.init(t, Et, r.renderState);
        }
      }
      for (let gt = 0; gt < T.length; gt++) {
        const ht = E[gt], _t = T[gt];
        ht !== null && _t !== void 0 && _t.update(ht, ot, h || c);
      }
      I && I($, ot), ot.detectedPlanes && s.dispatchEvent({ type: "planesdetected", data: ot }), b = null;
    }
    const lt = new XM();
    lt.setAnimationLoop(q), this.setAnimationLoop = function($) {
      I = $;
    }, this.dispose = function() {
    };
  }
}
const ar = /* @__PURE__ */ new as(), wN = /* @__PURE__ */ new qe();
function CN(n, t) {
  function e(S, y) {
    S.matrixAutoUpdate === !0 && S.updateMatrix(), y.value.copy(S.matrix);
  }
  function s(S, y) {
    y.color.getRGB(S.fogColor.value, PM(n)), y.isFog ? (S.fogNear.value = y.near, S.fogFar.value = y.far) : y.isFogExp2 && (S.fogDensity.value = y.density);
  }
  function r(S, y, C, T, E) {
    y.isMeshBasicMaterial || y.isMeshLambertMaterial ? l(S, y) : y.isMeshToonMaterial ? (l(S, y), p(S, y)) : y.isMeshPhongMaterial ? (l(S, y), m(S, y)) : y.isMeshStandardMaterial ? (l(S, y), _(S, y), y.isMeshPhysicalMaterial && x(S, y, E)) : y.isMeshMatcapMaterial ? (l(S, y), b(S, y)) : y.isMeshDepthMaterial ? l(S, y) : y.isMeshDistanceMaterial ? (l(S, y), M(S, y)) : y.isMeshNormalMaterial ? l(S, y) : y.isLineBasicMaterial ? (c(S, y), y.isLineDashedMaterial && f(S, y)) : y.isPointsMaterial ? d(S, y, C, T) : y.isSpriteMaterial ? h(S, y) : y.isShadowMaterial ? (S.color.value.copy(y.color), S.opacity.value = y.opacity) : y.isShaderMaterial && (y.uniformsNeedUpdate = !1);
  }
  function l(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 === li && (S.bumpScale.value *= -1)), y.normalMap && (S.normalMap.value = y.normalMap, e(y.normalMap, S.normalMapTransform), S.normalScale.value.copy(y.normalScale), y.side === li && 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 C = t.get(y), T = C.envMap, E = C.envMapRotation;
    T && (S.envMap.value = T, ar.copy(E), ar.x *= -1, ar.y *= -1, ar.z *= -1, T.isCubeTexture && T.isRenderTargetTexture === !1 && (ar.y *= -1, ar.z *= -1), S.envMapRotation.value.setFromMatrix4(wN.makeRotationFromEuler(ar)), S.flipEnvMap.value = T.isCubeTexture && T.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 f(S, y) {
    S.dashSize.value = y.dashSize, S.totalSize.value = y.dashSize + y.gapSize, S.scale.value = y.scale;
  }
  function d(S, y, C, T) {
    S.diffuse.value.copy(y.color), S.opacity.value = y.opacity, S.size.value = y.size * C, S.scale.value = T * 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 m(S, y) {
    S.specular.value.copy(y.specular), S.shininess.value = Math.max(y.shininess, 1e-4);
  }
  function p(S, y) {
    y.gradientMap && (S.gradientMap.value = y.gradientMap);
  }
  function _(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 x(S, y, C) {
    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 === li && 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 = C.texture, S.transmissionSamplerSize.value.set(C.width, C.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 M(S, y) {
    const C = t.get(y).light;
    S.referencePosition.value.setFromMatrixPosition(C.matrixWorld), S.nearDistance.value = C.shadow.camera.near, S.farDistance.value = C.shadow.camera.far;
  }
  return {
    refreshFogUniforms: s,
    refreshMaterialUniforms: r
  };
}
function RN(n, t, e, s) {
  let r = {}, l = {}, c = [];
  const f = n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);
  function d(C, T) {
    const E = T.program;
    s.uniformBlockBinding(C, E);
  }
  function h(C, T) {
    let E = r[C.id];
    E === void 0 && (b(C), E = m(C), r[C.id] = E, C.addEventListener("dispose", S));
    const O = T.program;
    s.updateUBOMapping(C, O);
    const N = t.render.frame;
    l[C.id] !== N && (_(C), l[C.id] = N);
  }
  function m(C) {
    const T = p();
    C.__bindingPointIndex = T;
    const E = n.createBuffer(), O = C.__size, N = C.usage;
    return n.bindBuffer(n.UNIFORM_BUFFER, E), n.bufferData(n.UNIFORM_BUFFER, O, N), n.bindBuffer(n.UNIFORM_BUFFER, null), n.bindBufferBase(n.UNIFORM_BUFFER, T, E), E;
  }
  function p() {
    for (let C = 0; C < f; C++)
      if (c.indexOf(C) === -1)
        return c.push(C), C;
    return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0;
  }
  function _(C) {
    const T = r[C.id], E = C.uniforms, O = C.__cache;
    n.bindBuffer(n.UNIFORM_BUFFER, T);
    for (let N = 0, D = E.length; N < D; N++) {
      const z = Array.isArray(E[N]) ? E[N] : [E[N]];
      for (let A = 0, R = z.length; A < R; A++) {
        const L = z[A];
        if (x(L, N, A, O) === !0) {
          const H = L.__offset, k = Array.isArray(L.value) ? L.value : [L.value];
          let P = 0;
          for (let Y = 0; Y < k.length; Y++) {
            const U = k[Y], X = M(U);
            typeof U == "number" || typeof U == "boolean" ? (L.__data[0] = U, n.bufferSubData(n.UNIFORM_BUFFER, H + P, L.__data)) : U.isMatrix3 ? (L.__data[0] = U.elements[0], L.__data[1] = U.elements[1], L.__data[2] = U.elements[2], L.__data[3] = 0, L.__data[4] = U.elements[3], L.__data[5] = U.elements[4], L.__data[6] = U.elements[5], L.__data[7] = 0, L.__data[8] = U.elements[6], L.__data[9] = U.elements[7], L.__data[10] = U.elements[8], L.__data[11] = 0) : (U.toArray(L.__data, P), P += X.storage / Float32Array.BYTES_PER_ELEMENT);
          }
          n.bufferSubData(n.UNIFORM_BUFFER, H, L.__data);
        }
      }
    }
    n.bindBuffer(n.UNIFORM_BUFFER, null);
  }
  function x(C, T, E, O) {
    const N = C.value, D = T + "_" + E;
    if (O[D] === void 0)
      return typeof N == "number" || typeof N == "boolean" ? O[D] = N : O[D] = N.clone(), !0;
    {
      const z = O[D];
      if (typeof N == "number" || typeof N == "boolean") {
        if (z !== N)
          return O[D] = N, !0;
      } else if (z.equals(N) === !1)
        return z.copy(N), !0;
    }
    return !1;
  }
  function b(C) {
    const T = C.uniforms;
    let E = 0;
    const O = 16;
    for (let D = 0, z = T.length; D < z; D++) {
      const A = Array.isArray(T[D]) ? T[D] : [T[D]];
      for (let R = 0, L = A.length; R < L; R++) {
        const H = A[R], k = Array.isArray(H.value) ? H.value : [H.value];
        for (let P = 0, Y = k.length; P < Y; P++) {
          const U = k[P], X = M(U), V = E % O, W = V % X.boundary, J = V + W;
          E += W, J !== 0 && O - J < X.storage && (E += O - J), H.__data = new Float32Array(X.storage / Float32Array.BYTES_PER_ELEMENT), H.__offset = E, E += X.storage;
        }
      }
    }
    const N = E % O;
    return N > 0 && (E += O - N), C.__size = E, C.__cache = {}, this;
  }
  function M(C) {
    const T = {
      boundary: 0,
      // bytes
      storage: 0
      // bytes
    };
    return typeof C == "number" || typeof C == "boolean" ? (T.boundary = 4, T.storage = 4) : C.isVector2 ? (T.boundary = 8, T.storage = 8) : C.isVector3 || C.isColor ? (T.boundary = 16, T.storage = 12) : C.isVector4 ? (T.boundary = 16, T.storage = 16) : C.isMatrix3 ? (T.boundary = 48, T.storage = 48) : C.isMatrix4 ? (T.boundary = 64, T.storage = 64) : C.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", C), T;
  }
  function S(C) {
    const T = C.target;
    T.removeEventListener("dispose", S);
    const E = c.indexOf(T.__bindingPointIndex);
    c.splice(E, 1), n.deleteBuffer(r[T.id]), delete r[T.id], delete l[T.id];
  }
  function y() {
    for (const C in r)
      n.deleteBuffer(r[C]);
    c = [], r = {}, l = {};
  }
  return {
    bind: d,
    update: h,
    dispose: y
  };
}
class DN {
  constructor(t = {}) {
    const {
      canvas: e = l2(),
      context: s = null,
      depth: r = !0,
      stencil: l = !1,
      alpha: c = !1,
      antialias: f = !1,
      premultipliedAlpha: d = !0,
      preserveDrawingBuffer: h = !1,
      powerPreference: m = "default",
      failIfMajorPerformanceCaveat: p = !1,
      reverseDepthBuffer: _ = !1
    } = t;
    this.isWebGLRenderer = !0;
    let x;
    if (s !== null) {
      if (typeof WebGLRenderingContext < "u" && s instanceof WebGLRenderingContext)
        throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");
      x = s.getContextAttributes().alpha;
    } else
      x = c;
    const b = new Uint32Array(4), M = new Int32Array(4);
    let S = null, y = null;
    const C = [], T = [];
    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 = Pi, this.toneMapping = Ra, this.toneMappingExposure = 1;
    const E = this;
    let O = !1, N = 0, D = 0, z = null, A = -1, R = null;
    const L = new on(), H = new on();
    let k = null;
    const P = new we(0);
    let Y = 0, U = e.width, X = e.height, V = 1, W = null, J = null;
    const I = new on(0, 0, U, X), q = new on(0, 0, U, X);
    let lt = !1;
    const $ = new Jg();
    let ot = !1, gt = !1;
    this.transmissionResolutionScale = 1;
    const ht = new qe(), _t = new qe(), Et = new at(), Lt = new on(), Gt = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 };
    let Nt = !1;
    function Bt() {
      return z === null ? V : 1;
    }
    let K = s;
    function pe(G, it) {
      return e.getContext(G, it);
    }
    try {
      const G = {
        alpha: !0,
        depth: r,
        stencil: l,
        antialias: f,
        premultipliedAlpha: d,
        preserveDrawingBuffer: h,
        powerPreference: m,
        failIfMajorPerformanceCaveat: p
      };
      if ("setAttribute" in e && e.setAttribute("data-engine", `three.js r${kg}`), e.addEventListener("webglcontextlost", At, !1), e.addEventListener("webglcontextrestored", Pt, !1), e.addEventListener("webglcontextcreationerror", zt, !1), K === null) {
        const it = "webgl2";
        if (K = pe(it, G), K === null)
          throw pe(it) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context.");
      }
    } catch (G) {
      throw console.error("THREE.WebGLRenderer: " + G.message), G;
    }
    let Xt, se, qt, xe, jt, j, B, ft, St, wt, bt, Zt, Ut, Wt, ve, Dt, Yt, Jt, $t, Vt, re, de, Fe, nt;
    function Ot() {
      Xt = new F3(K), Xt.init(), de = new SN(K, Xt), se = new U3(K, Xt, t, de), qt = new yN(K, Xt), se.reverseDepthBuffer && _ && qt.buffers.depth.setReversed(!0), xe = new G3(K), jt = new rN(), j = new xN(K, Xt, qt, jt, se, de, xe), B = new P3(E), ft = new B3(E), St = new Z2(K), Fe = new N3(K, St), wt = new H3(K, St, xe, Fe), bt = new X3(K, wt, St, xe), $t = new k3(K, se, j), Dt = new O3(jt), Zt = new aN(E, B, ft, Xt, se, Fe, Dt), Ut = new CN(E, jt), Wt = new lN(), ve = new pN(Xt), Jt = new D3(E, B, ft, qt, bt, x, d), Yt = new _N(E, bt, se), nt = new RN(K, xe, se, qt), Vt = new L3(K, Xt, xe), re = new V3(K, Xt, xe), xe.programs = Zt.programs, E.capabilities = se, E.extensions = Xt, E.properties = jt, E.renderLists = Wt, E.shadowMap = Yt, E.state = qt, E.info = xe;
    }
    Ot();
    const yt = new AN(E, K);
    this.xr = yt, this.getContext = function() {
      return K;
    }, this.getContextAttributes = function() {
      return K.getContextAttributes();
    }, this.forceContextLoss = function() {
      const G = Xt.get("WEBGL_lose_context");
      G && G.loseContext();
    }, this.forceContextRestore = function() {
      const G = Xt.get("WEBGL_lose_context");
      G && G.restoreContext();
    }, this.getPixelRatio = function() {
      return V;
    }, this.setPixelRatio = function(G) {
      G !== void 0 && (V = G, this.setSize(U, X, !1));
    }, this.getSize = function(G) {
      return G.set(U, X);
    }, this.setSize = function(G, it, dt = !0) {
      if (yt.isPresenting) {
        console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
        return;
      }
      U = G, X = it, e.width = Math.floor(G * V), e.height = Math.floor(it * V), dt === !0 && (e.style.width = G + "px", e.style.height = it + "px"), this.setViewport(0, 0, G, it);
    }, this.getDrawingBufferSize = function(G) {
      return G.set(U * V, X * V).floor();
    }, this.setDrawingBufferSize = function(G, it, dt) {
      U = G, X = it, V = dt, e.width = Math.floor(G * dt), e.height = Math.floor(it * dt), this.setViewport(0, 0, G, it);
    }, this.getCurrentViewport = function(G) {
      return G.copy(L);
    }, this.getViewport = function(G) {
      return G.copy(I);
    }, this.setViewport = function(G, it, dt, mt) {
      G.isVector4 ? I.set(G.x, G.y, G.z, G.w) : I.set(G, it, dt, mt), qt.viewport(L.copy(I).multiplyScalar(V).round());
    }, this.getScissor = function(G) {
      return G.copy(q);
    }, this.setScissor = function(G, it, dt, mt) {
      G.isVector4 ? q.set(G.x, G.y, G.z, G.w) : q.set(G, it, dt, mt), qt.scissor(H.copy(q).multiplyScalar(V).round());
    }, this.getScissorTest = function() {
      return lt;
    }, this.setScissorTest = function(G) {
      qt.setScissorTest(lt = G);
    }, this.setOpaqueSort = function(G) {
      W = G;
    }, this.setTransparentSort = function(G) {
      J = G;
    }, this.getClearColor = function(G) {
      return G.copy(Jt.getClearColor());
    }, this.setClearColor = function() {
      Jt.setClearColor.apply(Jt, arguments);
    }, this.getClearAlpha = function() {
      return Jt.getClearAlpha();
    }, this.setClearAlpha = function() {
      Jt.setClearAlpha.apply(Jt, arguments);
    }, this.clear = function(G = !0, it = !0, dt = !0) {
      let mt = 0;
      if (G) {
        let et = !1;
        if (z !== null) {
          const Rt = z.texture.format;
          et = Rt === $g || Rt === Kg || Rt === Zg;
        }
        if (et) {
          const Rt = z.texture.type, It = Rt === Hs || Rt === _r || Rt === pc || Rt === Xo || Rt === Yg || Rt === jg, Ft = Jt.getClearColor(), kt = Jt.getClearAlpha(), ue = Ft.r, oe = Ft.g, te = Ft.b;
          It ? (b[0] = ue, b[1] = oe, b[2] = te, b[3] = kt, K.clearBufferuiv(K.COLOR, 0, b)) : (M[0] = ue, M[1] = oe, M[2] = te, M[3] = kt, K.clearBufferiv(K.COLOR, 0, M));
        } else
          mt |= K.COLOR_BUFFER_BIT;
      }
      it && (mt |= K.DEPTH_BUFFER_BIT), dt && (mt |= K.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), K.clear(mt);
    }, 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", At, !1), e.removeEventListener("webglcontextrestored", Pt, !1), e.removeEventListener("webglcontextcreationerror", zt, !1), Jt.dispose(), Wt.dispose(), ve.dispose(), jt.dispose(), B.dispose(), ft.dispose(), bt.dispose(), Fe.dispose(), nt.dispose(), Zt.dispose(), yt.dispose(), yt.removeEventListener("sessionstart", Oa), yt.removeEventListener("sessionend", Pa), Ei.stop();
    };
    function At(G) {
      G.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), O = !0;
    }
    function Pt() {
      console.log("THREE.WebGLRenderer: Context Restored."), O = !1;
      const G = xe.autoReset, it = Yt.enabled, dt = Yt.autoUpdate, mt = Yt.needsUpdate, et = Yt.type;
      Ot(), xe.autoReset = G, Yt.enabled = it, Yt.autoUpdate = dt, Yt.needsUpdate = mt, Yt.type = et;
    }
    function zt(G) {
      console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", G.statusMessage);
    }
    function ce(G) {
      const it = G.target;
      it.removeEventListener("dispose", ce), $e(it);
    }
    function $e(G) {
      fn(G), jt.remove(G);
    }
    function fn(G) {
      const it = jt.get(G).programs;
      it !== void 0 && (it.forEach(function(dt) {
        Zt.releaseProgram(dt);
      }), G.isShaderMaterial && Zt.releaseShaderCache(G));
    }
    this.renderBufferDirect = function(G, it, dt, mt, et, Rt) {
      it === null && (it = Gt);
      const It = et.isMesh && et.matrixWorld.determinant() < 0, Ft = Ws(G, it, dt, mt, et);
      qt.setMaterial(mt, It);
      let kt = dt.index, ue = 1;
      if (mt.wireframe === !0) {
        if (kt = wt.getWireframeAttribute(dt), kt === void 0) return;
        ue = 2;
      }
      const oe = dt.drawRange, te = dt.attributes.position;
      let be = oe.start * ue, Me = (oe.start + oe.count) * ue;
      Rt !== null && (be = Math.max(be, Rt.start * ue), Me = Math.min(Me, (Rt.start + Rt.count) * ue)), kt !== null ? (be = Math.max(be, 0), Me = Math.min(Me, kt.count)) : te != null && (be = Math.max(be, 0), Me = Math.min(Me, te.count));
      const Ze = Me - be;
      if (Ze < 0 || Ze === 1 / 0) return;
      Fe.setup(et, mt, Ft, dt, kt);
      let Le, fe = Vt;
      if (kt !== null && (Le = St.get(kt), fe = re, fe.setIndex(Le)), et.isMesh)
        mt.wireframe === !0 ? (qt.setLineWidth(mt.wireframeLinewidth * Bt()), fe.setMode(K.LINES)) : fe.setMode(K.TRIANGLES);
      else if (et.isLine) {
        let ee = mt.linewidth;
        ee === void 0 && (ee = 1), qt.setLineWidth(ee * Bt()), et.isLineSegments ? fe.setMode(K.LINES) : et.isLineLoop ? fe.setMode(K.LINE_LOOP) : fe.setMode(K.LINE_STRIP);
      } else et.isPoints ? fe.setMode(K.POINTS) : et.isSprite && fe.setMode(K.TRIANGLES);
      if (et.isBatchedMesh)
        if (et._multiDrawInstances !== null)
          fe.renderMultiDrawInstances(et._multiDrawStarts, et._multiDrawCounts, et._multiDrawCount, et._multiDrawInstances);
        else if (Xt.get("WEBGL_multi_draw"))
          fe.renderMultiDraw(et._multiDrawStarts, et._multiDrawCounts, et._multiDrawCount);
        else {
          const ee = et._multiDrawStarts, dn = et._multiDrawCounts, Se = et._multiDrawCount, kn = kt ? St.get(kt).bytesPerElement : 1, Qn = jt.get(mt).currentProgram.getUniforms();
          for (let On = 0; On < Se; On++)
            Qn.setValue(K, "_gl_DrawID", On), fe.render(ee[On] / kn, dn[On]);
        }
      else if (et.isInstancedMesh)
        fe.renderInstances(be, Ze, et.count);
      else if (dt.isInstancedBufferGeometry) {
        const ee = dt._maxInstanceCount !== void 0 ? dt._maxInstanceCount : 1 / 0, dn = Math.min(dt.instanceCount, ee);
        fe.renderInstances(be, Ze, dn);
      } else
        fe.render(be, Ze);
    };
    function De(G, it, dt) {
      G.transparent === !0 && G.side === es && G.forceSinglePass === !1 ? (G.side = li, G.needsUpdate = !0, nn(G, it, dt), G.side = Na, G.needsUpdate = !0, nn(G, it, dt), G.side = es) : nn(G, it, dt);
    }
    this.compile = function(G, it, dt = null) {
      dt === null && (dt = G), y = ve.get(dt), y.init(it), T.push(y), dt.traverseVisible(function(et) {
        et.isLight && et.layers.test(it.layers) && (y.pushLight(et), et.castShadow && y.pushShadow(et));
      }), G !== dt && G.traverseVisible(function(et) {
        et.isLight && et.layers.test(it.layers) && (y.pushLight(et), et.castShadow && y.pushShadow(et));
      }), y.setupLights();
      const mt = /* @__PURE__ */ new Set();
      return G.traverse(function(et) {
        if (!(et.isMesh || et.isPoints || et.isLine || et.isSprite))
          return;
        const Rt = et.material;
        if (Rt)
          if (Array.isArray(Rt))
            for (let It = 0; It < Rt.length; It++) {
              const Ft = Rt[It];
              De(Ft, dt, et), mt.add(Ft);
            }
          else
            De(Rt, dt, et), mt.add(Rt);
      }), T.pop(), y = null, mt;
    }, this.compileAsync = function(G, it, dt = null) {
      const mt = this.compile(G, it, dt);
      return new Promise((et) => {
        function Rt() {
          if (mt.forEach(function(It) {
            jt.get(It).currentProgram.isReady() && mt.delete(It);
          }), mt.size === 0) {
            et(G);
            return;
          }
          setTimeout(Rt, 10);
        }
        Xt.get("KHR_parallel_shader_compile") !== null ? Rt() : setTimeout(Rt, 10);
      });
    };
    let Mn = null;
    function ci(G) {
      Mn && Mn(G);
    }
    function Oa() {
      Ei.stop();
    }
    function Pa() {
      Ei.start();
    }
    const Ei = new XM();
    Ei.setAnimationLoop(ci), typeof self < "u" && Ei.setContext(self), this.setAnimationLoop = function(G) {
      Mn = G, yt.setAnimationLoop(G), G === null ? Ei.stop() : Ei.start();
    }, yt.addEventListener("sessionstart", Oa), yt.addEventListener("sessionend", Pa), this.render = function(G, it) {
      if (it !== void 0 && it.isCamera !== !0) {
        console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
        return;
      }
      if (O === !0) return;
      if (G.matrixWorldAutoUpdate === !0 && G.updateMatrixWorld(), it.parent === null && it.matrixWorldAutoUpdate === !0 && it.updateMatrixWorld(), yt.enabled === !0 && yt.isPresenting === !0 && (yt.cameraAutoUpdate === !0 && yt.updateCamera(it), it = yt.getCamera()), G.isScene === !0 && G.onBeforeRender(E, G, it, z), y = ve.get(G, T.length), y.init(it), T.push(y), _t.multiplyMatrices(it.projectionMatrix, it.matrixWorldInverse), $.setFromProjectionMatrix(_t), gt = this.localClippingEnabled, ot = Dt.init(this.clippingPlanes, gt), S = Wt.get(G, C.length), S.init(), C.push(S), yt.enabled === !0 && yt.isPresenting === !0) {
        const Rt = E.xr.getDepthSensingMesh();
        Rt !== null && ls(Rt, it, -1 / 0, E.sortObjects);
      }
      ls(G, it, 0, E.sortObjects), S.finish(), E.sortObjects === !0 && S.sort(W, J), Nt = yt.enabled === !1 || yt.isPresenting === !1 || yt.hasDepthSensing() === !1, Nt && Jt.addToRenderList(S, G), this.info.render.frame++, ot === !0 && Dt.beginShadows();
      const dt = y.state.shadowsArray;
      Yt.render(dt, G, it), ot === !0 && Dt.endShadows(), this.info.autoReset === !0 && this.info.reset();
      const mt = S.opaque, et = S.transmissive;
      if (y.setupLights(), it.isArrayCamera) {
        const Rt = it.cameras;
        if (et.length > 0)
          for (let It = 0, Ft = Rt.length; It < Ft; It++) {
            const kt = Rt[It];
            za(mt, et, G, kt);
          }
        Nt && Jt.render(G);
        for (let It = 0, Ft = Rt.length; It < Ft; It++) {
          const kt = Rt[It];
          Xs(S, G, kt, kt.viewport);
        }
      } else
        et.length > 0 && za(mt, et, G, it), Nt && Jt.render(G), Xs(S, G, it);
      z !== null && D === 0 && (j.updateMultisampleRenderTarget(z), j.updateRenderTargetMipmap(z)), G.isScene === !0 && G.onAfterRender(E, G, it), Fe.resetDefaultState(), A = -1, R = null, T.pop(), T.length > 0 ? (y = T[T.length - 1], ot === !0 && Dt.setGlobalState(E.clippingPlanes, y.state.camera)) : y = null, C.pop(), C.length > 0 ? S = C[C.length - 1] : S = null;
    };
    function ls(G, it, dt, mt) {
      if (G.visible === !1) return;
      if (G.layers.test(it.layers)) {
        if (G.isGroup)
          dt = G.renderOrder;
        else if (G.isLOD)
          G.autoUpdate === !0 && G.update(it);
        else if (G.isLight)
          y.pushLight(G), G.castShadow && y.pushShadow(G);
        else if (G.isSprite) {
          if (!G.frustumCulled || $.intersectsSprite(G)) {
            mt && Lt.setFromMatrixPosition(G.matrixWorld).applyMatrix4(_t);
            const It = bt.update(G), Ft = G.material;
            Ft.visible && S.push(G, It, Ft, dt, Lt.z, null);
          }
        } else if ((G.isMesh || G.isLine || G.isPoints) && (!G.frustumCulled || $.intersectsObject(G))) {
          const It = bt.update(G), Ft = G.material;
          if (mt && (G.boundingSphere !== void 0 ? (G.boundingSphere === null && G.computeBoundingSphere(), Lt.copy(G.boundingSphere.center)) : (It.boundingSphere === null && It.computeBoundingSphere(), Lt.copy(It.boundingSphere.center)), Lt.applyMatrix4(G.matrixWorld).applyMatrix4(_t)), Array.isArray(Ft)) {
            const kt = It.groups;
            for (let ue = 0, oe = kt.length; ue < oe; ue++) {
              const te = kt[ue], be = Ft[te.materialIndex];
              be && be.visible && S.push(G, It, be, dt, Lt.z, te);
            }
          } else Ft.visible && S.push(G, It, Ft, dt, Lt.z, null);
        }
      }
      const Rt = G.children;
      for (let It = 0, Ft = Rt.length; It < Ft; It++)
        ls(Rt[It], it, dt, mt);
    }
    function Xs(G, it, dt, mt) {
      const et = G.opaque, Rt = G.transmissive, It = G.transparent;
      y.setupLightsView(dt), ot === !0 && Dt.setGlobalState(E.clippingPlanes, dt), mt && qt.viewport(L.copy(mt)), et.length > 0 && cs(et, it, dt), Rt.length > 0 && cs(Rt, it, dt), It.length > 0 && cs(It, it, dt), qt.buffers.depth.setTest(!0), qt.buffers.depth.setMask(!0), qt.buffers.color.setMask(!0), qt.setPolygonOffset(!1);
    }
    function za(G, it, dt, mt) {
      if ((dt.isScene === !0 ? dt.overrideMaterial : null) !== null)
        return;
      y.state.transmissionRenderTarget[mt.id] === void 0 && (y.state.transmissionRenderTarget[mt.id] = new vr(1, 1, {
        generateMipmaps: !0,
        type: Xt.has("EXT_color_buffer_half_float") || Xt.has("EXT_color_buffer_float") ? Cc : Hs,
        minFilter: dr,
        samples: 4,
        stencilBuffer: l,
        resolveDepthBuffer: !1,
        resolveStencilBuffer: !1,
        colorSpace: Ie.workingColorSpace
      }));
      const Rt = y.state.transmissionRenderTarget[mt.id], It = mt.viewport || L;
      Rt.setSize(It.z * E.transmissionResolutionScale, It.w * E.transmissionResolutionScale);
      const Ft = E.getRenderTarget();
      E.setRenderTarget(Rt), E.getClearColor(P), Y = E.getClearAlpha(), Y < 1 && E.setClearColor(16777215, 0.5), E.clear(), Nt && Jt.render(dt);
      const kt = E.toneMapping;
      E.toneMapping = Ra;
      const ue = mt.viewport;
      if (mt.viewport !== void 0 && (mt.viewport = void 0), y.setupLightsView(mt), ot === !0 && Dt.setGlobalState(E.clippingPlanes, mt), cs(G, dt, mt), j.updateMultisampleRenderTarget(Rt), j.updateRenderTargetMipmap(Rt), Xt.has("WEBGL_multisampled_render_to_texture") === !1) {
        let oe = !1;
        for (let te = 0, be = it.length; te < be; te++) {
          const Me = it[te], Ze = Me.object, Le = Me.geometry, fe = Me.material, ee = Me.group;
          if (fe.side === es && Ze.layers.test(mt.layers)) {
            const dn = fe.side;
            fe.side = li, fe.needsUpdate = !0, ui(Ze, dt, mt, Le, fe, ee), fe.side = dn, fe.needsUpdate = !0, oe = !0;
          }
        }
        oe === !0 && (j.updateMultisampleRenderTarget(Rt), j.updateRenderTargetMipmap(Rt));
      }
      E.setRenderTarget(Ft), E.setClearColor(P, Y), ue !== void 0 && (mt.viewport = ue), E.toneMapping = kt;
    }
    function cs(G, it, dt) {
      const mt = it.isScene === !0 ? it.overrideMaterial : null;
      for (let et = 0, Rt = G.length; et < Rt; et++) {
        const It = G[et], Ft = It.object, kt = It.geometry, ue = mt === null ? It.material : mt, oe = It.group;
        Ft.layers.test(dt.layers) && ui(Ft, it, dt, kt, ue, oe);
      }
    }
    function ui(G, it, dt, mt, et, Rt) {
      G.onBeforeRender(E, it, dt, mt, et, Rt), G.modelViewMatrix.multiplyMatrices(dt.matrixWorldInverse, G.matrixWorld), G.normalMatrix.getNormalMatrix(G.modelViewMatrix), et.onBeforeRender(E, it, dt, mt, G, Rt), et.transparent === !0 && et.side === es && et.forceSinglePass === !1 ? (et.side = li, et.needsUpdate = !0, E.renderBufferDirect(dt, it, mt, et, G, Rt), et.side = Na, et.needsUpdate = !0, E.renderBufferDirect(dt, it, mt, et, G, Rt), et.side = es) : E.renderBufferDirect(dt, it, mt, et, G, Rt), G.onAfterRender(E, it, dt, mt, et, Rt);
    }
    function nn(G, it, dt) {
      it.isScene !== !0 && (it = Gt);
      const mt = jt.get(G), et = y.state.lights, Rt = y.state.shadowsArray, It = et.state.version, Ft = Zt.getParameters(G, et.state, Rt, it, dt), kt = Zt.getProgramCacheKey(Ft);
      let ue = mt.programs;
      mt.environment = G.isMeshStandardMaterial ? it.environment : null, mt.fog = it.fog, mt.envMap = (G.isMeshStandardMaterial ? ft : B).get(G.envMap || mt.environment), mt.envMapRotation = mt.environment !== null && G.envMap === null ? it.environmentRotation : G.envMapRotation, ue === void 0 && (G.addEventListener("dispose", ce), ue = /* @__PURE__ */ new Map(), mt.programs = ue);
      let oe = ue.get(kt);
      if (oe !== void 0) {
        if (mt.currentProgram === oe && mt.lightsStateVersion === It)
          return Ti(G, Ft), oe;
      } else
        Ft.uniforms = Zt.getUniforms(G), G.onBeforeCompile(Ft, E), oe = Zt.acquireProgram(Ft, kt), ue.set(kt, oe), mt.uniforms = Ft.uniforms;
      const te = mt.uniforms;
      return (!G.isShaderMaterial && !G.isRawShaderMaterial || G.clipping === !0) && (te.clippingPlanes = Dt.uniform), Ti(G, Ft), mt.needsLights = sl(G), mt.lightsStateVersion = It, mt.needsLights && (te.ambientLightColor.value = et.state.ambient, te.lightProbe.value = et.state.probe, te.directionalLights.value = et.state.directional, te.directionalLightShadows.value = et.state.directionalShadow, te.spotLights.value = et.state.spot, te.spotLightShadows.value = et.state.spotShadow, te.rectAreaLights.value = et.state.rectArea, te.ltc_1.value = et.state.rectAreaLTC1, te.ltc_2.value = et.state.rectAreaLTC2, te.pointLights.value = et.state.point, te.pointLightShadows.value = et.state.pointShadow, te.hemisphereLights.value = et.state.hemi, te.directionalShadowMap.value = et.state.directionalShadowMap, te.directionalShadowMatrix.value = et.state.directionalShadowMatrix, te.spotShadowMap.value = et.state.spotShadowMap, te.spotLightMatrix.value = et.state.spotLightMatrix, te.spotLightMap.value = et.state.spotLightMap, te.pointShadowMap.value = et.state.pointShadowMap, te.pointShadowMatrix.value = et.state.pointShadowMatrix), mt.currentProgram = oe, mt.uniformsList = null, oe;
    }
    function En(G) {
      if (G.uniformsList === null) {
        const it = G.currentProgram.getUniforms();
        G.uniformsList = Gf.seqWithValue(it.seq, G.uniforms);
      }
      return G.uniformsList;
    }
    function Ti(G, it) {
      const dt = jt.get(G);
      dt.outputColorSpace = it.outputColorSpace, dt.batching = it.batching, dt.batchingColor = it.batchingColor, dt.instancing = it.instancing, dt.instancingColor = it.instancingColor, dt.instancingMorph = it.instancingMorph, dt.skinning = it.skinning, dt.morphTargets = it.morphTargets, dt.morphNormals = it.morphNormals, dt.morphColors = it.morphColors, dt.morphTargetsCount = it.morphTargetsCount, dt.numClippingPlanes = it.numClippingPlanes, dt.numIntersection = it.numClipIntersection, dt.vertexAlphas = it.vertexAlphas, dt.vertexTangents = it.vertexTangents, dt.toneMapping = it.toneMapping;
    }
    function Ws(G, it, dt, mt, et) {
      it.isScene !== !0 && (it = Gt), j.resetTextureUnits();
      const Rt = it.fog, It = mt.isMeshStandardMaterial ? it.environment : null, Ft = z === null ? E.outputColorSpace : z.isXRRenderTarget === !0 ? z.texture.colorSpace : Yo, kt = (mt.isMeshStandardMaterial ? ft : B).get(mt.envMap || It), ue = mt.vertexColors === !0 && !!dt.attributes.color && dt.attributes.color.itemSize === 4, oe = !!dt.attributes.tangent && (!!mt.normalMap || mt.anisotropy > 0), te = !!dt.morphAttributes.position, be = !!dt.morphAttributes.normal, Me = !!dt.morphAttributes.color;
      let Ze = Ra;
      mt.toneMapped && (z === null || z.isXRRenderTarget === !0) && (Ze = E.toneMapping);
      const Le = dt.morphAttributes.position || dt.morphAttributes.normal || dt.morphAttributes.color, fe = Le !== void 0 ? Le.length : 0, ee = jt.get(mt), dn = y.state.lights;
      if (ot === !0 && (gt === !0 || G !== R)) {
        const Qe = G === R && mt.id === A;
        Dt.setState(mt, G, Qe);
      }
      let Se = !1;
      mt.version === ee.__version ? (ee.needsLights && ee.lightsStateVersion !== dn.state.version || ee.outputColorSpace !== Ft || et.isBatchedMesh && ee.batching === !1 || !et.isBatchedMesh && ee.batching === !0 || et.isBatchedMesh && ee.batchingColor === !0 && et.colorTexture === null || et.isBatchedMesh && ee.batchingColor === !1 && et.colorTexture !== null || et.isInstancedMesh && ee.instancing === !1 || !et.isInstancedMesh && ee.instancing === !0 || et.isSkinnedMesh && ee.skinning === !1 || !et.isSkinnedMesh && ee.skinning === !0 || et.isInstancedMesh && ee.instancingColor === !0 && et.instanceColor === null || et.isInstancedMesh && ee.instancingColor === !1 && et.instanceColor !== null || et.isInstancedMesh && ee.instancingMorph === !0 && et.morphTexture === null || et.isInstancedMesh && ee.instancingMorph === !1 && et.morphTexture !== null || ee.envMap !== kt || mt.fog === !0 && ee.fog !== Rt || ee.numClippingPlanes !== void 0 && (ee.numClippingPlanes !== Dt.numPlanes || ee.numIntersection !== Dt.numIntersection) || ee.vertexAlphas !== ue || ee.vertexTangents !== oe || ee.morphTargets !== te || ee.morphNormals !== be || ee.morphColors !== Me || ee.toneMapping !== Ze || ee.morphTargetsCount !== fe) && (Se = !0) : (Se = !0, ee.__version = mt.version);
      let kn = ee.currentProgram;
      Se === !0 && (kn = nn(mt, it, et));
      let Qn = !1, On = !1, mn = !1;
      const Oe = kn.getUniforms(), Pn = ee.uniforms;
      if (qt.useProgram(kn.program) && (Qn = !0, On = !0, mn = !0), mt.id !== A && (A = mt.id, On = !0), Qn || R !== G) {
        qt.buffers.depth.getReversed() ? (ht.copy(G.projectionMatrix), u2(ht), f2(ht), Oe.setValue(K, "projectionMatrix", ht)) : Oe.setValue(K, "projectionMatrix", G.projectionMatrix), Oe.setValue(K, "viewMatrix", G.matrixWorldInverse);
        const zn = Oe.map.cameraPosition;
        zn !== void 0 && zn.setValue(K, Et.setFromMatrixPosition(G.matrixWorld)), se.logarithmicDepthBuffer && Oe.setValue(
          K,
          "logDepthBufFC",
          2 / (Math.log(G.far + 1) / Math.LN2)
        ), (mt.isMeshPhongMaterial || mt.isMeshToonMaterial || mt.isMeshLambertMaterial || mt.isMeshBasicMaterial || mt.isMeshStandardMaterial || mt.isShaderMaterial) && Oe.setValue(K, "isOrthographic", G.isOrthographicCamera === !0), R !== G && (R = G, On = !0, mn = !0);
      }
      if (et.isSkinnedMesh) {
        Oe.setOptional(K, et, "bindMatrix"), Oe.setOptional(K, et, "bindMatrixInverse");
        const Qe = et.skeleton;
        Qe && (Qe.boneTexture === null && Qe.computeBoneTexture(), Oe.setValue(K, "boneTexture", Qe.boneTexture, j));
      }
      et.isBatchedMesh && (Oe.setOptional(K, et, "batchingTexture"), Oe.setValue(K, "batchingTexture", et._matricesTexture, j), Oe.setOptional(K, et, "batchingIdTexture"), Oe.setValue(K, "batchingIdTexture", et._indirectTexture, j), Oe.setOptional(K, et, "batchingColorTexture"), et._colorsTexture !== null && Oe.setValue(K, "batchingColorTexture", et._colorsTexture, j));
      const Dn = dt.morphAttributes;
      if ((Dn.position !== void 0 || Dn.normal !== void 0 || Dn.color !== void 0) && $t.update(et, dt, kn), (On || ee.receiveShadow !== et.receiveShadow) && (ee.receiveShadow = et.receiveShadow, Oe.setValue(K, "receiveShadow", et.receiveShadow)), mt.isMeshGouraudMaterial && mt.envMap !== null && (Pn.envMap.value = kt, Pn.flipEnvMap.value = kt.isCubeTexture && kt.isRenderTargetTexture === !1 ? -1 : 1), mt.isMeshStandardMaterial && mt.envMap === null && it.environment !== null && (Pn.envMapIntensity.value = it.environmentIntensity), On && (Oe.setValue(K, "toneMappingExposure", E.toneMappingExposure), ee.needsLights && Ar(Pn, mn), Rt && mt.fog === !0 && Ut.refreshFogUniforms(Pn, Rt), Ut.refreshMaterialUniforms(Pn, mt, V, X, y.state.transmissionRenderTarget[G.id]), Gf.upload(K, En(ee), Pn, j)), mt.isShaderMaterial && mt.uniformsNeedUpdate === !0 && (Gf.upload(K, En(ee), Pn, j), mt.uniformsNeedUpdate = !1), mt.isSpriteMaterial && Oe.setValue(K, "center", et.center), Oe.setValue(K, "modelViewMatrix", et.modelViewMatrix), Oe.setValue(K, "normalMatrix", et.normalMatrix), Oe.setValue(K, "modelMatrix", et.matrixWorld), mt.isShaderMaterial || mt.isRawShaderMaterial) {
        const Qe = mt.uniformsGroups;
        for (let zn = 0, Cr = Qe.length; zn < Cr; zn++) {
          const Jn = Qe[zn];
          nt.update(Jn, kn), nt.bind(Jn, kn);
        }
      }
      return kn;
    }
    function Ar(G, it) {
      G.ambientLightColor.needsUpdate = it, G.lightProbe.needsUpdate = it, G.directionalLights.needsUpdate = it, G.directionalLightShadows.needsUpdate = it, G.pointLights.needsUpdate = it, G.pointLightShadows.needsUpdate = it, G.spotLights.needsUpdate = it, G.spotLightShadows.needsUpdate = it, G.rectAreaLights.needsUpdate = it, G.hemisphereLights.needsUpdate = it;
    }
    function sl(G) {
      return G.isMeshLambertMaterial || G.isMeshToonMaterial || G.isMeshPhongMaterial || G.isMeshStandardMaterial || G.isShadowMaterial || G.isShaderMaterial && G.lights === !0;
    }
    this.getActiveCubeFace = function() {
      return N;
    }, this.getActiveMipmapLevel = function() {
      return D;
    }, this.getRenderTarget = function() {
      return z;
    }, this.setRenderTargetTextures = function(G, it, dt) {
      jt.get(G.texture).__webglTexture = it, jt.get(G.depthTexture).__webglTexture = dt;
      const mt = jt.get(G);
      mt.__hasExternalTextures = !0, mt.__autoAllocateDepthBuffer = dt === void 0, mt.__autoAllocateDepthBuffer || Xt.has("WEBGL_multisampled_render_to_texture") === !0 && (console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"), mt.__useRenderToTexture = !1);
    }, this.setRenderTargetFramebuffer = function(G, it) {
      const dt = jt.get(G);
      dt.__webglFramebuffer = it, dt.__useDefaultFramebuffer = it === void 0;
    };
    const wr = K.createFramebuffer();
    this.setRenderTarget = function(G, it = 0, dt = 0) {
      z = G, N = it, D = dt;
      let mt = !0, et = null, Rt = !1, It = !1;
      if (G) {
        const kt = jt.get(G);
        if (kt.__useDefaultFramebuffer !== void 0)
          qt.bindFramebuffer(K.FRAMEBUFFER, null), mt = !1;
        else if (kt.__webglFramebuffer === void 0)
          j.setupRenderTarget(G);
        else if (kt.__hasExternalTextures)
          j.rebindTextures(G, jt.get(G.texture).__webglTexture, jt.get(G.depthTexture).__webglTexture);
        else if (G.depthBuffer) {
          const te = G.depthTexture;
          if (kt.__boundDepthTexture !== te) {
            if (te !== null && jt.has(te) && (G.width !== te.image.width || G.height !== te.image.height))
              throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");
            j.setupDepthRenderbuffer(G);
          }
        }
        const ue = G.texture;
        (ue.isData3DTexture || ue.isDataArrayTexture || ue.isCompressedArrayTexture) && (It = !0);
        const oe = jt.get(G).__webglFramebuffer;
        G.isWebGLCubeRenderTarget ? (Array.isArray(oe[it]) ? et = oe[it][dt] : et = oe[it], Rt = !0) : G.samples > 0 && j.useMultisampledRTT(G) === !1 ? et = jt.get(G).__webglMultisampledFramebuffer : Array.isArray(oe) ? et = oe[dt] : et = oe, L.copy(G.viewport), H.copy(G.scissor), k = G.scissorTest;
      } else
        L.copy(I).multiplyScalar(V).floor(), H.copy(q).multiplyScalar(V).floor(), k = lt;
      if (dt !== 0 && (et = wr), qt.bindFramebuffer(K.FRAMEBUFFER, et) && mt && qt.drawBuffers(G, et), qt.viewport(L), qt.scissor(H), qt.setScissorTest(k), Rt) {
        const kt = jt.get(G.texture);
        K.framebufferTexture2D(K.FRAMEBUFFER, K.COLOR_ATTACHMENT0, K.TEXTURE_CUBE_MAP_POSITIVE_X + it, kt.__webglTexture, dt);
      } else if (It) {
        const kt = jt.get(G.texture), ue = it;
        K.framebufferTextureLayer(K.FRAMEBUFFER, K.COLOR_ATTACHMENT0, kt.__webglTexture, dt, ue);
      } else if (G !== null && dt !== 0) {
        const kt = jt.get(G.texture);
        K.framebufferTexture2D(K.FRAMEBUFFER, K.COLOR_ATTACHMENT0, K.TEXTURE_2D, kt.__webglTexture, dt);
      }
      A = -1;
    }, this.readRenderTargetPixels = function(G, it, dt, mt, et, Rt, It) {
      if (!(G && G.isWebGLRenderTarget)) {
        console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
        return;
      }
      let Ft = jt.get(G).__webglFramebuffer;
      if (G.isWebGLCubeRenderTarget && It !== void 0 && (Ft = Ft[It]), Ft) {
        qt.bindFramebuffer(K.FRAMEBUFFER, Ft);
        try {
          const kt = G.texture, ue = kt.format, oe = kt.type;
          if (!se.textureFormatReadable(ue)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
            return;
          }
          if (!se.textureTypeReadable(oe)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
            return;
          }
          it >= 0 && it <= G.width - mt && dt >= 0 && dt <= G.height - et && K.readPixels(it, dt, mt, et, de.convert(ue), de.convert(oe), Rt);
        } finally {
          const kt = z !== null ? jt.get(z).__webglFramebuffer : null;
          qt.bindFramebuffer(K.FRAMEBUFFER, kt);
        }
      }
    }, this.readRenderTargetPixelsAsync = async function(G, it, dt, mt, et, Rt, It) {
      if (!(G && G.isWebGLRenderTarget))
        throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
      let Ft = jt.get(G).__webglFramebuffer;
      if (G.isWebGLCubeRenderTarget && It !== void 0 && (Ft = Ft[It]), Ft) {
        const kt = G.texture, ue = kt.format, oe = kt.type;
        if (!se.textureFormatReadable(ue))
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");
        if (!se.textureTypeReadable(oe))
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");
        if (it >= 0 && it <= G.width - mt && dt >= 0 && dt <= G.height - et) {
          qt.bindFramebuffer(K.FRAMEBUFFER, Ft);
          const te = K.createBuffer();
          K.bindBuffer(K.PIXEL_PACK_BUFFER, te), K.bufferData(K.PIXEL_PACK_BUFFER, Rt.byteLength, K.STREAM_READ), K.readPixels(it, dt, mt, et, de.convert(ue), de.convert(oe), 0);
          const be = z !== null ? jt.get(z).__webglFramebuffer : null;
          qt.bindFramebuffer(K.FRAMEBUFFER, be);
          const Me = K.fenceSync(K.SYNC_GPU_COMMANDS_COMPLETE, 0);
          return K.flush(), await c2(K, Me, 4), K.bindBuffer(K.PIXEL_PACK_BUFFER, te), K.getBufferSubData(K.PIXEL_PACK_BUFFER, 0, Rt), K.deleteBuffer(te), K.deleteSync(Me), Rt;
        } else
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");
      }
    }, this.copyFramebufferToTexture = function(G, it = null, dt = 0) {
      G.isTexture !== !0 && (Ro("WebGLRenderer: copyFramebufferToTexture function signature has changed."), it = arguments[0] || null, G = arguments[1]);
      const mt = Math.pow(2, -dt), et = Math.floor(G.image.width * mt), Rt = Math.floor(G.image.height * mt), It = it !== null ? it.x : 0, Ft = it !== null ? it.y : 0;
      j.setTexture2D(G, 0), K.copyTexSubImage2D(K.TEXTURE_2D, dt, 0, 0, It, Ft, et, Rt), qt.unbindTexture();
    };
    const us = K.createFramebuffer(), Ia = K.createFramebuffer();
    this.copyTextureToTexture = function(G, it, dt = null, mt = null, et = 0, Rt = null) {
      G.isTexture !== !0 && (Ro("WebGLRenderer: copyTextureToTexture function signature has changed."), mt = arguments[0] || null, G = arguments[1], it = arguments[2], Rt = arguments[3] || 0, dt = null), Rt === null && (et !== 0 ? (Ro("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."), Rt = et, et = 0) : Rt = 0);
      let It, Ft, kt, ue, oe, te, be, Me, Ze;
      const Le = G.isCompressedTexture ? G.mipmaps[Rt] : G.image;
      if (dt !== null)
        It = dt.max.x - dt.min.x, Ft = dt.max.y - dt.min.y, kt = dt.isBox3 ? dt.max.z - dt.min.z : 1, ue = dt.min.x, oe = dt.min.y, te = dt.isBox3 ? dt.min.z : 0;
      else {
        const Dn = Math.pow(2, -et);
        It = Math.floor(Le.width * Dn), Ft = Math.floor(Le.height * Dn), G.isDataArrayTexture ? kt = Le.depth : G.isData3DTexture ? kt = Math.floor(Le.depth * Dn) : kt = 1, ue = 0, oe = 0, te = 0;
      }
      mt !== null ? (be = mt.x, Me = mt.y, Ze = mt.z) : (be = 0, Me = 0, Ze = 0);
      const fe = de.convert(it.format), ee = de.convert(it.type);
      let dn;
      it.isData3DTexture ? (j.setTexture3D(it, 0), dn = K.TEXTURE_3D) : it.isDataArrayTexture || it.isCompressedArrayTexture ? (j.setTexture2DArray(it, 0), dn = K.TEXTURE_2D_ARRAY) : (j.setTexture2D(it, 0), dn = K.TEXTURE_2D), K.pixelStorei(K.UNPACK_FLIP_Y_WEBGL, it.flipY), K.pixelStorei(K.UNPACK_PREMULTIPLY_ALPHA_WEBGL, it.premultiplyAlpha), K.pixelStorei(K.UNPACK_ALIGNMENT, it.unpackAlignment);
      const Se = K.getParameter(K.UNPACK_ROW_LENGTH), kn = K.getParameter(K.UNPACK_IMAGE_HEIGHT), Qn = K.getParameter(K.UNPACK_SKIP_PIXELS), On = K.getParameter(K.UNPACK_SKIP_ROWS), mn = K.getParameter(K.UNPACK_SKIP_IMAGES);
      K.pixelStorei(K.UNPACK_ROW_LENGTH, Le.width), K.pixelStorei(K.UNPACK_IMAGE_HEIGHT, Le.height), K.pixelStorei(K.UNPACK_SKIP_PIXELS, ue), K.pixelStorei(K.UNPACK_SKIP_ROWS, oe), K.pixelStorei(K.UNPACK_SKIP_IMAGES, te);
      const Oe = G.isDataArrayTexture || G.isData3DTexture, Pn = it.isDataArrayTexture || it.isData3DTexture;
      if (G.isDepthTexture) {
        const Dn = jt.get(G), Qe = jt.get(it), zn = jt.get(Dn.__renderTarget), Cr = jt.get(Qe.__renderTarget);
        qt.bindFramebuffer(K.READ_FRAMEBUFFER, zn.__webglFramebuffer), qt.bindFramebuffer(K.DRAW_FRAMEBUFFER, Cr.__webglFramebuffer);
        for (let Jn = 0; Jn < kt; Jn++)
          Oe && (K.framebufferTextureLayer(K.READ_FRAMEBUFFER, K.COLOR_ATTACHMENT0, jt.get(G).__webglTexture, et, te + Jn), K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER, K.COLOR_ATTACHMENT0, jt.get(it).__webglTexture, Rt, Ze + Jn)), K.blitFramebuffer(ue, oe, It, Ft, be, Me, It, Ft, K.DEPTH_BUFFER_BIT, K.NEAREST);
        qt.bindFramebuffer(K.READ_FRAMEBUFFER, null), qt.bindFramebuffer(K.DRAW_FRAMEBUFFER, null);
      } else if (et !== 0 || G.isRenderTargetTexture || jt.has(G)) {
        const Dn = jt.get(G), Qe = jt.get(it);
        qt.bindFramebuffer(K.READ_FRAMEBUFFER, us), qt.bindFramebuffer(K.DRAW_FRAMEBUFFER, Ia);
        for (let zn = 0; zn < kt; zn++)
          Oe ? K.framebufferTextureLayer(K.READ_FRAMEBUFFER, K.COLOR_ATTACHMENT0, Dn.__webglTexture, et, te + zn) : K.framebufferTexture2D(K.READ_FRAMEBUFFER, K.COLOR_ATTACHMENT0, K.TEXTURE_2D, Dn.__webglTexture, et), Pn ? K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER, K.COLOR_ATTACHMENT0, Qe.__webglTexture, Rt, Ze + zn) : K.framebufferTexture2D(K.DRAW_FRAMEBUFFER, K.COLOR_ATTACHMENT0, K.TEXTURE_2D, Qe.__webglTexture, Rt), et !== 0 ? K.blitFramebuffer(ue, oe, It, Ft, be, Me, It, Ft, K.COLOR_BUFFER_BIT, K.NEAREST) : Pn ? K.copyTexSubImage3D(dn, Rt, be, Me, Ze + zn, ue, oe, It, Ft) : K.copyTexSubImage2D(dn, Rt, be, Me, ue, oe, It, Ft);
        qt.bindFramebuffer(K.READ_FRAMEBUFFER, null), qt.bindFramebuffer(K.DRAW_FRAMEBUFFER, null);
      } else
        Pn ? G.isDataTexture || G.isData3DTexture ? K.texSubImage3D(dn, Rt, be, Me, Ze, It, Ft, kt, fe, ee, Le.data) : it.isCompressedArrayTexture ? K.compressedTexSubImage3D(dn, Rt, be, Me, Ze, It, Ft, kt, fe, Le.data) : K.texSubImage3D(dn, Rt, be, Me, Ze, It, Ft, kt, fe, ee, Le) : G.isDataTexture ? K.texSubImage2D(K.TEXTURE_2D, Rt, be, Me, It, Ft, fe, ee, Le.data) : G.isCompressedTexture ? K.compressedTexSubImage2D(K.TEXTURE_2D, Rt, be, Me, Le.width, Le.height, fe, Le.data) : K.texSubImage2D(K.TEXTURE_2D, Rt, be, Me, It, Ft, fe, ee, Le);
      K.pixelStorei(K.UNPACK_ROW_LENGTH, Se), K.pixelStorei(K.UNPACK_IMAGE_HEIGHT, kn), K.pixelStorei(K.UNPACK_SKIP_PIXELS, Qn), K.pixelStorei(K.UNPACK_SKIP_ROWS, On), K.pixelStorei(K.UNPACK_SKIP_IMAGES, mn), Rt === 0 && it.generateMipmaps && K.generateMipmap(dn), qt.unbindTexture();
    }, this.copyTextureToTexture3D = function(G, it, dt = null, mt = null, et = 0) {
      return G.isTexture !== !0 && (Ro("WebGLRenderer: copyTextureToTexture3D function signature has changed."), dt = arguments[0] || null, mt = arguments[1] || null, G = arguments[2], it = arguments[3], et = arguments[4] || 0), Ro('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'), this.copyTextureToTexture(G, it, dt, mt, et);
    }, this.initRenderTarget = function(G) {
      jt.get(G).__webglFramebuffer === void 0 && j.setupRenderTarget(G);
    }, this.initTexture = function(G) {
      G.isCubeTexture ? j.setTextureCube(G, 0) : G.isData3DTexture ? j.setTexture3D(G, 0) : G.isDataArrayTexture || G.isCompressedArrayTexture ? j.setTexture2DArray(G, 0) : j.setTexture2D(G, 0), qt.unbindTexture();
    }, this.resetState = function() {
      N = 0, D = 0, z = null, qt.reset(), Fe.reset();
    }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  get coordinateSystem() {
    return Ps;
  }
  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 bS = { type: "change" }, s0 = { type: "start" }, ZM = { type: "end" }, bf = new Qg(), MS = new Ea(), NN = Math.cos(70 * o2.DEG2RAD), An = new at(), ri = 2 * Math.PI, je = {
  NONE: -1,
  ROTATE: 0,
  DOLLY: 1,
  PAN: 2,
  TOUCH_ROTATE: 3,
  TOUCH_PAN: 4,
  TOUCH_DOLLY_PAN: 5,
  TOUCH_DOLLY_ROTATE: 6
}, ym = 1e-6;
class ES extends j2 {
  constructor(t, e = null) {
    super(t, e), this.state = je.NONE, this.enabled = !0, this.target = new at(), this.cursor = new at(), 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: Po.ROTATE, MIDDLE: Po.DOLLY, RIGHT: Po.PAN }, this.touches = { ONE: No.ROTATE, TWO: No.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new at(), this._lastQuaternion = new La(), this._lastTargetPosition = new at(), this._quat = new La().setFromUnitVectors(t.up, new at(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new Zx(), this._sphericalDelta = new Zx(), this._scale = 1, this._panOffset = new at(), this._rotateStart = new le(), this._rotateEnd = new le(), this._rotateDelta = new le(), this._panStart = new le(), this._panEnd = new le(), this._panDelta = new le(), this._dollyStart = new le(), this._dollyEnd = new le(), this._dollyDelta = new le(), this._dollyDirection = new at(), this._mouse = new le(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = UN.bind(this), this._onPointerDown = LN.bind(this), this._onPointerUp = ON.bind(this), this._onContextMenu = VN.bind(this), this._onMouseWheel = IN.bind(this), this._onKeyDown = BN.bind(this), this._onTouchStart = FN.bind(this), this._onTouchMove = HN.bind(this), this._onMouseDown = PN.bind(this), this._onMouseMove = zN.bind(this), this._interceptControlDown = GN.bind(this), this._interceptControlUp = kN.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(bS), this.update(), this.state = je.NONE;
  }
  update(t = null) {
    const e = this.object.position;
    An.copy(e).sub(this.target), An.applyQuaternion(this._quat), this._spherical.setFromVector3(An), this.autoRotate && this.state === je.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 s = this.minAzimuthAngle, r = this.maxAzimuthAngle;
    isFinite(s) && isFinite(r) && (s < -Math.PI ? s += ri : s > Math.PI && (s -= ri), r < -Math.PI ? r += ri : r > Math.PI && (r -= ri), s <= r ? this._spherical.theta = Math.max(s, Math.min(r, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (s + r) / 2 ? Math.max(s, this._spherical.theta) : Math.min(r, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
    let l = !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), l = c != this._spherical.radius;
    }
    if (An.setFromSpherical(this._spherical), An.applyQuaternion(this._quatInverse), e.copy(this.target).add(An), 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 f = An.length();
        c = this._clampDistance(f * this._scale);
        const d = f - c;
        this.object.position.addScaledVector(this._dollyDirection, d), this.object.updateMatrixWorld(), l = !!d;
      } else if (this.object.isOrthographicCamera) {
        const f = new at(this._mouse.x, this._mouse.y, 0);
        f.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(), l = d !== this.object.zoom;
        const h = new at(this._mouse.x, this._mouse.y, 0);
        h.unproject(this.object), this.object.position.sub(h).add(f), this.object.updateMatrixWorld(), c = An.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)) < NN ? this.object.lookAt(this.target) : (MS.setFromNormalAndCoplanarPoint(this.object.up, this.target), bf.intersectPlane(MS, 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(), l = !0);
    }
    return this._scale = 1, this._performCursorZoom = !1, l || this._lastPosition.distanceToSquared(this.object.position) > ym || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > ym || this._lastTargetPosition.distanceToSquared(this.target) > ym ? (this.dispatchEvent(bS), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
  }
  _getAutoRotationAngle(t) {
    return t !== null ? ri / 60 * this.autoRotateSpeed * t : ri / 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) {
    An.setFromMatrixColumn(e, 0), An.multiplyScalar(-t), this._panOffset.add(An);
  }
  _panUp(t, e) {
    this.screenSpacePanning === !0 ? An.setFromMatrixColumn(e, 1) : (An.setFromMatrixColumn(e, 0), An.crossVectors(this.object.up, An)), An.multiplyScalar(t), this._panOffset.add(An);
  }
  // deltaX and deltaY are in pixels; right and down are positive
  _pan(t, e) {
    const s = this.domElement;
    if (this.object.isPerspectiveCamera) {
      const r = this.object.position;
      An.copy(r).sub(this.target);
      let l = An.length();
      l *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * t * l / s.clientHeight, this.object.matrix), this._panUp(2 * e * l / s.clientHeight, this.object.matrix);
    } else this.object.isOrthographicCamera ? (this._panLeft(t * (this.object.right - this.object.left) / this.object.zoom / s.clientWidth, this.object.matrix), this._panUp(e * (this.object.top - this.object.bottom) / this.object.zoom / s.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 s = this.domElement.getBoundingClientRect(), r = t - s.left, l = e - s.top, c = s.width, f = s.height;
    this._mouse.x = r / c * 2 - 1, this._mouse.y = -(l / f) * 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(ri * this._rotateDelta.x / e.clientHeight), this._rotateUp(ri * 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(ri * 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(-ri * 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(ri * 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(-ri * 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), s = 0.5 * (t.pageX + e.x), r = 0.5 * (t.pageY + e.y);
      this._rotateStart.set(s, r);
    }
  }
  _handleTouchStartPan(t) {
    if (this._pointers.length === 1)
      this._panStart.set(t.pageX, t.pageY);
    else {
      const e = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + e.x), r = 0.5 * (t.pageY + e.y);
      this._panStart.set(s, r);
    }
  }
  _handleTouchStartDolly(t) {
    const e = this._getSecondPointerPosition(t), s = t.pageX - e.x, r = t.pageY - e.y, l = Math.sqrt(s * s + r * r);
    this._dollyStart.set(0, l);
  }
  _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 s = this._getSecondPointerPosition(t), r = 0.5 * (t.pageX + s.x), l = 0.5 * (t.pageY + s.y);
      this._rotateEnd.set(r, l);
    }
    this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
    const e = this.domElement;
    this._rotateLeft(ri * this._rotateDelta.x / e.clientHeight), this._rotateUp(ri * 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), s = 0.5 * (t.pageX + e.x), r = 0.5 * (t.pageY + e.y);
      this._panEnd.set(s, r);
    }
    this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
  }
  _handleTouchMoveDolly(t) {
    const e = this._getSecondPointerPosition(t), s = t.pageX - e.x, r = t.pageY - e.y, l = Math.sqrt(s * s + r * r);
    this._dollyEnd.set(0, l), 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, f = (t.pageY + e.y) * 0.5;
    this._updateZoomParameters(c, f);
  }
  _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 le(), 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, s = {
      clientX: t.clientX,
      clientY: t.clientY,
      deltaY: t.deltaY
    };
    switch (e) {
      case 1:
        s.deltaY *= 16;
        break;
      case 2:
        s.deltaY *= 100;
        break;
    }
    return t.ctrlKey && !this._controlActive && (s.deltaY *= 10), s;
  }
}
function LN(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 UN(n) {
  this.enabled !== !1 && (n.pointerType === "touch" ? this._onTouchMove(n) : this._onMouseMove(n));
}
function ON(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 = je.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 PN(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 Po.DOLLY:
      if (this.enableZoom === !1) return;
      this._handleMouseDownDolly(n), this.state = je.DOLLY;
      break;
    case Po.ROTATE:
      if (n.ctrlKey || n.metaKey || n.shiftKey) {
        if (this.enablePan === !1) return;
        this._handleMouseDownPan(n), this.state = je.PAN;
      } else {
        if (this.enableRotate === !1) return;
        this._handleMouseDownRotate(n), this.state = je.ROTATE;
      }
      break;
    case Po.PAN:
      if (n.ctrlKey || n.metaKey || n.shiftKey) {
        if (this.enableRotate === !1) return;
        this._handleMouseDownRotate(n), this.state = je.ROTATE;
      } else {
        if (this.enablePan === !1) return;
        this._handleMouseDownPan(n), this.state = je.PAN;
      }
      break;
    default:
      this.state = je.NONE;
  }
  this.state !== je.NONE && this.dispatchEvent(s0);
}
function zN(n) {
  switch (this.state) {
    case je.ROTATE:
      if (this.enableRotate === !1) return;
      this._handleMouseMoveRotate(n);
      break;
    case je.DOLLY:
      if (this.enableZoom === !1) return;
      this._handleMouseMoveDolly(n);
      break;
    case je.PAN:
      if (this.enablePan === !1) return;
      this._handleMouseMovePan(n);
      break;
  }
}
function IN(n) {
  this.enabled === !1 || this.enableZoom === !1 || this.state !== je.NONE || (n.preventDefault(), this.dispatchEvent(s0), this._handleMouseWheel(this._customWheelEvent(n)), this.dispatchEvent(ZM));
}
function BN(n) {
  this.enabled !== !1 && this._handleKeyDown(n);
}
function FN(n) {
  switch (this._trackPointer(n), this._pointers.length) {
    case 1:
      switch (this.touches.ONE) {
        case No.ROTATE:
          if (this.enableRotate === !1) return;
          this._handleTouchStartRotate(n), this.state = je.TOUCH_ROTATE;
          break;
        case No.PAN:
          if (this.enablePan === !1) return;
          this._handleTouchStartPan(n), this.state = je.TOUCH_PAN;
          break;
        default:
          this.state = je.NONE;
      }
      break;
    case 2:
      switch (this.touches.TWO) {
        case No.DOLLY_PAN:
          if (this.enableZoom === !1 && this.enablePan === !1) return;
          this._handleTouchStartDollyPan(n), this.state = je.TOUCH_DOLLY_PAN;
          break;
        case No.DOLLY_ROTATE:
          if (this.enableZoom === !1 && this.enableRotate === !1) return;
          this._handleTouchStartDollyRotate(n), this.state = je.TOUCH_DOLLY_ROTATE;
          break;
        default:
          this.state = je.NONE;
      }
      break;
    default:
      this.state = je.NONE;
  }
  this.state !== je.NONE && this.dispatchEvent(s0);
}
function HN(n) {
  switch (this._trackPointer(n), this.state) {
    case je.TOUCH_ROTATE:
      if (this.enableRotate === !1) return;
      this._handleTouchMoveRotate(n), this.update();
      break;
    case je.TOUCH_PAN:
      if (this.enablePan === !1) return;
      this._handleTouchMovePan(n), this.update();
      break;
    case je.TOUCH_DOLLY_PAN:
      if (this.enableZoom === !1 && this.enablePan === !1) return;
      this._handleTouchMoveDollyPan(n), this.update();
      break;
    case je.TOUCH_DOLLY_ROTATE:
      if (this.enableZoom === !1 && this.enableRotate === !1) return;
      this._handleTouchMoveDollyRotate(n), this.update();
      break;
    default:
      this.state = je.NONE;
  }
}
function VN(n) {
  this.enabled !== !1 && n.preventDefault();
}
function GN(n) {
  n.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
function kN(n) {
  n.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
const XN = {
  1: [1, 1, 1],
  // H  - white
  2: [0.851, 1, 1],
  // He - light cyan
  5: [1, 0.71, 0.71],
  // B  - pink
  6: [0.565, 0.565, 0.565],
  // C  - gray
  7: [0.188, 0.314, 0.973],
  // N  - blue
  8: [1, 0.051, 0.051],
  // O  - red
  9: [0.565, 0.878, 0.314],
  // F  - green
  11: [0.671, 0.361, 0.949],
  // Na - purple
  12: [0.541, 1, 0],
  // Mg - green
  13: [0.749, 0.651, 0.651],
  // Al - gray-pink
  14: [0.941, 0.784, 0.627],
  // Si - tan
  15: [1, 0.502, 0],
  // P  - orange
  16: [1, 1, 0.188],
  // S  - yellow
  17: [0.122, 0.941, 0.122],
  // Cl - green
  18: [0.502, 0.82, 0.89],
  // Ar - light blue
  19: [0.561, 0.251, 0.831],
  // K  - purple
  20: [0.239, 1, 0],
  // Ca - green
  26: [0.878, 0.4, 0.2],
  // Fe - orange
  29: [0.784, 0.502, 0.2],
  // Cu - copper
  30: [0.49, 0.502, 0.69],
  // Zn - slate
  34: [1, 0.631, 0],
  // Se - orange
  35: [0.651, 0.161, 0.161],
  // Br - dark red
  53: [0.58, 0, 0.58]
  // I  - purple
}, WN = [0.75, 0.4, 0.75], wg = {
  1: 1.2,
  6: 1.7,
  7: 1.55,
  8: 1.52,
  9: 1.47,
  11: 2.27,
  12: 1.73,
  15: 1.8,
  16: 1.8,
  17: 1.75,
  19: 2.75,
  20: 2.31,
  26: 2.04,
  29: 1.4,
  30: 1.39
}, Cg = 1.5, a0 = 0.3, YN = 0.15, TS = 1, AS = 2, wS = 3, CS = 4, RS = 0.18, jN = 0.1, DS = 0.2, qN = 0.08, ZN = 0.1, KN = 0.06, $N = {
  1: "H",
  6: "C",
  7: "N",
  8: "O",
  9: "F",
  11: "Na",
  12: "Mg",
  15: "P",
  16: "S",
  17: "Cl",
  19: "K",
  20: "Ca",
  26: "Fe",
  29: "Cu",
  30: "Zn"
};
function gc(n) {
  return XN[n] ?? WN;
}
function r0(n) {
  return wg[n] ?? Cg;
}
const QN = {
  1: 1.008,
  2: 4.003,
  5: 10.81,
  6: 12.011,
  7: 14.007,
  8: 15.999,
  9: 18.998,
  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,
  26: 55.845,
  29: 63.546,
  30: 65.38,
  34: 78.96,
  35: 79.904,
  53: 126.904
};
function o0(n) {
  return $N[n] ?? `#${n}`;
}
function JN(n) {
  return QN[n] ?? 0;
}
const tL = (
  /* 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);
  }
`
), eL = (
  /* 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);
  }
`
), nL = (
  /* 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);
  }
`
), iL = (
  /* 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 sL {
  constructor(t = 1e6) {
    Ct(this, "mesh");
    Ct(this, "geo");
    Ct(this, "material");
    Ct(this, "centerAttr");
    Ct(this, "radiusAttr");
    Ct(this, "colorAttr");
    Ct(this, "scaleOverrideAttr");
    Ct(this, "opacityOverrideAttr");
    Ct(this, "centerBuf");
    Ct(this, "radiusBuf");
    Ct(this, "colorBuf");
    Ct(this, "scaleOverrideBuf");
    Ct(this, "opacityOverrideBuf");
    Ct(this, "nAtoms", 0);
    Ct(this, "capacity");
    this.capacity = t, this.geo = new kM();
    const e = new Float32Array([
      -1,
      -1,
      0,
      1,
      -1,
      0,
      1,
      1,
      0,
      -1,
      1,
      0
    ]), s = new Uint16Array([0, 1, 2, 0, 2, 3]);
    this.geo.setAttribute("position", new ln(e, 3)), this.geo.setIndex(new ln(s, 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 wn(this.centerBuf, 3), this.radiusAttr = new wn(this.radiusBuf, 1), this.colorAttr = new wn(this.colorBuf, 3), this.scaleOverrideAttr = new wn(this.scaleOverrideBuf, 1), this.opacityOverrideAttr = new wn(this.opacityOverrideBuf, 1), this.centerAttr.setUsage(oo), this.radiusAttr.setUsage(hr), this.colorAttr.setUsage(hr), this.scaleOverrideAttr.setUsage(oo), this.opacityOverrideAttr.setUsage(oo), 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 GM({
      glslVersion: Kf,
      vertexShader: tL,
      fragmentShader: eL,
      uniforms: {
        uScaleMultiplier: { value: 1 },
        uOpacity: { value: 1 },
        uUsePerAtomOverrides: { value: 0 }
      },
      depthWrite: !0,
      depthTest: !0
    }), this.mesh = new Un(this.geo, this.material), this.mesh.frustumCulled = !1;
  }
  loadSnapshot(t) {
    const { nAtoms: e, positions: s, elements: r } = t;
    this.nAtoms = e, e > this.capacity && this.grow(e);
    for (let l = 0; l < e; l++) {
      const c = l * 3;
      this.centerBuf[c] = s[c], this.centerBuf[c + 1] = s[c + 1], this.centerBuf[c + 2] = s[c + 2], this.radiusBuf[l] = r0(r[l]) * a0;
      const [f, d, h] = gc(r[l]);
      this.colorBuf[c] = f, 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 s = 0; s < this.nAtoms; s++)
      if (this.opacityOverrideBuf[s] < 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), s = new Float32Array(this.capacity), r = new Float32Array(this.capacity * 3), l = new Float32Array(this.capacity).fill(1), c = new Float32Array(this.capacity).fill(1);
    e.set(this.centerBuf), s.set(this.radiusBuf), r.set(this.colorBuf), l.set(this.scaleOverrideBuf), c.set(this.opacityOverrideBuf), this.centerBuf = e, this.radiusBuf = s, this.colorBuf = r, this.scaleOverrideBuf = l, this.opacityOverrideBuf = c, this.centerAttr = new wn(this.centerBuf, 3), this.radiusAttr = new wn(this.radiusBuf, 1), this.colorAttr = new wn(this.colorBuf, 3), this.scaleOverrideAttr = new wn(this.scaleOverrideBuf, 1), this.opacityOverrideAttr = new wn(this.opacityOverrideBuf, 1), this.centerAttr.setUsage(oo), this.radiusAttr.setUsage(hr), this.colorAttr.setUsage(hr), this.scaleOverrideAttr.setUsage(oo), this.opacityOverrideAttr.setUsage(oo), 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 aL = 4096;
class rL {
  constructor(t = 3e6) {
    Ct(this, "mesh");
    Ct(this, "geo");
    Ct(this, "bondMaterial");
    // Topology buffers (set at loadSnapshot, static per snapshot)
    Ct(this, "atomABuf");
    Ct(this, "atomBBuf");
    Ct(this, "offsetXBuf");
    Ct(this, "offsetYBuf");
    Ct(this, "colorBuf");
    Ct(this, "radiusBuf");
    Ct(this, "dashedBuf");
    // Position DataTexture (updated per frame)
    Ct(this, "positionTex");
    Ct(this, "positionTexData");
    Ct(this, "positionTexWidth", 1);
    Ct(this, "positionTexHeight", 1);
    Ct(this, "nAtoms", 0);
    Ct(this, "capacity");
    this.capacity = t, this.geo = new kM();
    const e = new Float32Array([
      -1,
      -1,
      0,
      1,
      -1,
      0,
      1,
      1,
      0,
      -1,
      1,
      0
    ]), s = new Float32Array([
      -1,
      -1,
      1,
      -1,
      1,
      1,
      -1,
      1
    ]), r = new Uint16Array([0, 1, 2, 0, 2, 3]);
    this.geo.setAttribute("position", new ln(e, 3)), this.geo.setAttribute("uv", new ln(s, 2)), this.geo.setIndex(new ln(r, 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 Eg(
      this.positionTexData,
      1,
      1,
      bi,
      Ii
    ), this.positionTex.minFilter = Vn, this.positionTex.magFilter = Vn, this.positionTex.generateMipmaps = !1, this.positionTex.needsUpdate = !0, this.registerAttributes(), this.bondMaterial = new GM({
      glslVersion: Kf,
      vertexShader: nL,
      fragmentShader: iL,
      uniforms: {
        uOpacity: { value: 1 },
        uBondScaleMultiplier: { value: 1 },
        uPositionTex: { value: this.positionTex },
        uPositionTexWidth: { value: 1 }
      },
      depthWrite: !0,
      depthTest: !0
    }), this.mesh = new Un(this.geo, this.bondMaterial), this.mesh.frustumCulled = !1;
  }
  loadSnapshot(t) {
    const { nAtoms: e, nBonds: s, positions: r, elements: l, bonds: c, bondOrders: f } = t;
    this.nAtoms = e, this.positionTexWidth = Math.min(e, aL), this.positionTexHeight = Math.max(1, Math.ceil(e / this.positionTexWidth)), this.positionTexData = new Float32Array(this.positionTexWidth * this.positionTexHeight * 4), this.copyPositionsToTexData(r), this.positionTex.dispose(), this.positionTex = new Eg(
      this.positionTexData,
      this.positionTexWidth,
      this.positionTexHeight,
      bi,
      Ii
    ), this.positionTex.minFilter = Vn, this.positionTex.magFilter = Vn, 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 m = 0; m < s; m++) {
      const p = f ? f[m] : TS;
      p === AS ? d += 2 : p === wS ? d += 3 : p === CS ? d += 2 : d += 1;
    }
    d > this.capacity && this.grow(d);
    let h = 0;
    for (let m = 0; m < s; m++) {
      const p = c[m * 2], _ = c[m * 2 + 1], x = f ? f[m] : TS, [b, M, S] = gc(l[p]), [y, C, T] = gc(l[_]), E = (b + y) * 0.5, O = (M + C) * 0.5, N = (S + T) * 0.5;
      if (x === AS)
        for (const D of [-1, 1])
          this.setTopology(
            h,
            p,
            _,
            D * RS,
            0,
            jN,
            E,
            O,
            N,
            0
          ), h++;
      else if (x === wS) {
        const D = [0, 2 * Math.PI / 3, 4 * Math.PI / 3];
        for (const z of D) {
          const A = Math.cos(z) * DS, R = Math.sin(z) * DS;
          this.setTopology(
            h,
            p,
            _,
            A,
            R,
            qN,
            E,
            O,
            N,
            0
          ), h++;
        }
      } else x === CS ? (this.setTopology(
        h,
        p,
        _,
        0,
        0,
        ZN,
        E,
        O,
        N,
        0
      ), h++, this.setTopology(
        h,
        p,
        _,
        RS,
        0,
        KN,
        E,
        O,
        N,
        1
      ), h++) : (this.setTopology(
        h,
        p,
        _,
        0,
        0,
        YN,
        E,
        O,
        N,
        0
      ), h++);
    }
    this.registerAttributes(), this.geo.instanceCount = h;
  }
  updatePositions(t, e, s) {
    this.copyPositionsToTexData(t), this.positionTex.needsUpdate = !0;
  }
  setTopology(t, e, s, r, l, c, f, d, h, m) {
    this.atomABuf[t] = e, this.atomBBuf[t] = s, this.offsetXBuf[t] = r, this.offsetYBuf[t] = l;
    const p = t * 3;
    this.colorBuf[p] = f, this.colorBuf[p + 1] = d, this.colorBuf[p + 2] = h, this.radiusBuf[t] = c, this.dashedBuf[t] = m;
  }
  copyPositionsToTexData(t) {
    const e = this.positionTexData, s = this.nAtoms;
    for (let r = 0; r < s; r++) {
      const l = r * 3, c = r * 4;
      e[c] = t[l], e[c + 1] = t[l + 1], e[c + 2] = t[l + 2];
    }
  }
  /** Recreate all instance attributes and re-register with geometry. */
  registerAttributes() {
    const t = new wn(this.atomABuf, 1), e = new wn(this.atomBBuf, 1), s = new wn(this.offsetXBuf, 1), r = new wn(this.offsetYBuf, 1), l = new wn(this.colorBuf, 3), c = new wn(this.radiusBuf, 1), f = new wn(this.dashedBuf, 1);
    this.geo.setAttribute("instanceAtomA", t), this.geo.setAttribute("instanceAtomB", e), this.geo.setAttribute("instanceOffsetX", s), this.geo.setAttribute("instanceOffsetY", r), this.geo.setAttribute("instanceColor", l), this.geo.setAttribute("instanceRadius", c), this.geo.setAttribute("instanceDashed", f);
  }
  grow(t) {
    this.capacity = Math.max(t, this.capacity * 2);
    const e = new Float32Array(this.capacity), s = new Float32Array(this.capacity), r = new Float32Array(this.capacity), l = new Float32Array(this.capacity), c = new Float32Array(this.capacity * 3), f = new Float32Array(this.capacity), d = new Float32Array(this.capacity);
    e.set(this.atomABuf), s.set(this.atomBBuf), r.set(this.offsetXBuf), l.set(this.offsetYBuf), c.set(this.colorBuf), f.set(this.radiusBuf), d.set(this.dashedBuf), this.atomABuf = e, this.atomBBuf = s, this.offsetXBuf = r, this.offsetYBuf = l, this.colorBuf = c, this.radiusBuf = f, 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 oL {
  constructor() {
    Ct(this, "mesh");
    Ct(this, "geometry");
    this.geometry = new Gn();
    const t = new Float32Array(72);
    this.geometry.setAttribute(
      "position",
      new ln(t, 3)
    );
    const e = new Dc({
      color: 6710886,
      transparent: !0,
      opacity: 0.5
    });
    this.mesh = new HM(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 at(t[0], t[1], t[2]), s = new at(t[3], t[4], t[5]), r = new at(t[6], t[7], t[8]), l = new at(0, 0, 0), c = e.clone(), f = s.clone(), d = r.clone(), h = e.clone().add(s), m = e.clone().add(r), p = s.clone().add(r), _ = e.clone().add(s).add(r), x = [
      // Bottom face
      [l, c],
      [l, f],
      [c, h],
      [f, h],
      // Top face
      [d, m],
      [d, p],
      [m, _],
      [p, _],
      // Vertical edges
      [l, d],
      [c, m],
      [f, p],
      [h, _]
    ], b = this.geometry.getAttribute(
      "position"
    ), M = b.array;
    for (let S = 0; S < 12; S++) {
      const [y, C] = x[S];
      M[S * 6] = y.x, M[S * 6 + 1] = y.y, M[S * 6 + 2] = y.z, M[S * 6 + 3] = C.x, M[S * 6 + 4] = C.y, M[S * 6 + 5] = C.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 NS = 8, LS = [14496563, 3385907, 3368669], xm = 1e-4;
class lL {
  constructor() {
    Ct(this, "axesScene");
    Ct(this, "axesCamera");
    Ct(this, "arrowGroup");
    Ct(this, "visible", !0);
    /** Inset position in CSS pixels (bottom-left corner of the inset). */
    Ct(this, "posX", NS);
    Ct(this, "posY", NS);
    /** Last computed inset size (CSS pixels), cached for hit-testing. */
    Ct(this, "lastInsetSize", 60);
    this.axesScene = new BM(), this.axesCamera = new xi(50, 1, 0.1, 100), this.axesCamera.position.set(0, 0, 3);
    const t = new X2(16777215, 0.6);
    this.axesScene.add(t);
    const e = new Vf(16777215, 0.8);
    e.position.set(2, 2, 2), this.axesScene.add(e), this.arrowGroup = new wa(), this.axesScene.add(this.arrowGroup);
  }
  /**
   * Update from the 3x3 cell matrix (row-major Float32Array of length 9).
   */
  loadBox(t) {
    const e = new at(t[0], t[1], t[2]), s = new at(t[3], t[4], t[5]), r = new at(t[6], t[7], t[8]), l = e.length(), c = s.length(), f = r.length(), h = Math.abs(e.dot(s)) < xm * l * c && Math.abs(e.dot(r)) < xm * l * f && Math.abs(s.dot(r)) < xm * c * f ? ["x", "y", "z"] : ["a", "b", "c"], m = [e.normalize(), s.normalize(), r.normalize()];
    this.buildArrows(m, h);
  }
  buildArrows(t, e) {
    for (; this.arrowGroup.children.length > 0; ) {
      const s = this.arrowGroup.children[0];
      this.arrowGroup.remove(s), this.disposeObject(s);
    }
    for (let s = 0; s < 3; s++) {
      const r = new Y2(
        t[s],
        new at(0, 0, 0),
        1,
        LS[s],
        0.25,
        0.1
      );
      this.arrowGroup.add(r);
      const l = this.makeTextSprite(e[s], LS[s]);
      l.position.copy(t[s]).multiplyScalar(1.25), l.scale.set(0.3, 0.3, 1), this.arrowGroup.add(l);
    }
  }
  makeTextSprite(t, e) {
    const r = document.createElement("canvas");
    r.width = 64, r.height = 64;
    const l = r.getContext("2d");
    if (!l)
      return new om(new Mg({ transparent: !0 }));
    l.clearRect(0, 0, 64, 64);
    const c = new we(e);
    l.fillStyle = `rgb(${c.r * 255 | 0},${c.g * 255 | 0},${c.b * 255 | 0})`, l.font = "bold 48px Arial, sans-serif", l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, 64 / 2, 64 / 2);
    const f = new B2(r), d = new Mg({
      map: f,
      depthTest: !1,
      transparent: !0
    });
    return new om(d);
  }
  // ── Hit-testing & drag ──────────────────────────────────────
  /**
   * Test whether a CSS-pixel coordinate (origin = top-left of container)
   * lies inside the axes inset.
   */
  hitTest(t, e, s) {
    if (!this.visible || this.arrowGroup.children.length === 0) return !1;
    const r = s - e;
    return t >= this.posX && t <= this.posX + this.lastInsetSize && r >= this.posY && r <= this.posY + this.lastInsetSize;
  }
  /**
   * Move the inset by a delta (CSS pixels), clamped to container bounds.
   */
  moveBy(t, e, s, r) {
    this.posX += t, this.posY -= e, this.clampPosition(s, r);
  }
  clampPosition(t, e) {
    const s = this.lastInsetSize, r = 4;
    this.posX = Math.max(r, Math.min(t - s - r, this.posX)), this.posY = Math.max(r, Math.min(e - s - r, this.posY));
  }
  // ── Rendering ───────────────────────────────────────────────
  /**
   * Render the axes inset.
   * Must be called AFTER the main scene render.
   */
  render(t, e, s, r) {
    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 l = Math.min(s, r), c = Math.max(60, Math.min(140, Math.round(l * 0.12)));
    this.lastInsetSize = c, this.clampPosition(s, r);
    const f = 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 = f, t.setViewport(0, 0, s, r), t.setScissorTest(!1);
  }
  setVisible(t) {
    this.visible = t;
  }
  isVisible() {
    return this.visible;
  }
  disposeObject(t) {
    t.traverse((e) => {
      var s, r, l;
      (e instanceof Un || e instanceof mc) && ((s = e.geometry) == null || s.dispose(), Array.isArray(e.material) ? e.material.forEach((c) => c.dispose()) : (r = e.material) == null || r.dispose()), e instanceof om && ((l = e.material.map) == null || l.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 cL = 500, uL = "bold 11px sans-serif", US = -8;
class fL {
  constructor() {
    Ct(this, "canvas");
    Ct(this, "ctx");
    Ct(this, "labels", null);
    Ct(this, "elements", null);
    Ct(this, "nAtoms", 0);
    Ct(this, "positions", null);
    Ct(this, "tmpVec", new at());
    Ct(this, "lastWidth", 0);
    Ct(this, "lastHeight", 0);
    Ct(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, s) {
    this.lastWidth = t, this.lastHeight = e, this.lastPixelRatio = s, this.canvas.width = Math.round(t * s), this.canvas.height = Math.round(e * s), this.ctx.setTransform(s, 0, 0, s, 0, 0);
  }
  render(t, e, s, r = 1) {
    if ((this.lastWidth !== e || this.lastHeight !== s || this.lastPixelRatio !== r) && this.resize(e, s, r), this.ctx.clearRect(0, 0, e, s), !this.labels || !this.positions || !this.elements || this.nAtoms === 0)
      return;
    const l = e / 2, c = s / 2, f = [];
    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 p = this.tmpVec.x * l + l, _ = -(this.tmpVec.y * c) + c;
      p < -50 || p > e + 50 || _ < -20 || _ > s + 20 || f.push({ sx: p, sy: _, z: this.tmpVec.z, idx: h });
    }
    f.sort((h, m) => h.z - m.z);
    const d = Math.min(f.length, cL);
    this.ctx.font = uL, this.ctx.textAlign = "center", this.ctx.textBaseline = "bottom";
    for (let h = 0; h < d; h++) {
      const { sx: m, sy: p, idx: _ } = f[h], x = this.labels[_], b = this.elements[_], [M, S, y] = gc(b), C = 0.299 * M + 0.587 * S + 0.114 * y, T = C > 0.5 ? "#000000" : "#ffffff", E = C > 0.5 ? "#ffffff" : "#000000";
      this.ctx.strokeStyle = E, this.ctx.lineWidth = 2.5, this.ctx.lineJoin = "round", this.ctx.strokeText(x, m, p + US), this.ctx.fillStyle = T, this.ctx.fillText(x, m, p + US);
    }
  }
  dispose() {
    this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
  }
}
const OS = 15158332, PS = 0.04, dL = 0.1, Sm = 0.2, hL = 6, pL = 8, mL = 1e-6, sc = new at(), gL = new at(0, 1, 0), bm = new La(), Mf = new at(), Ef = new at(), rr = new qe();
class _L {
  constructor(t = 1e5) {
    Ct(this, "mesh");
    Ct(this, "shaftMesh");
    Ct(this, "headMesh");
    Ct(this, "nAtoms", 0);
    Ct(this, "positions", null);
    Ct(this, "vectors", null);
    Ct(this, "arrowScale", 1);
    Ct(this, "capacity");
    this.capacity = t, this.mesh = new wa(), this.mesh.visible = !1;
    const e = new Nc(
      PS,
      PS,
      1,
      hL
    );
    e.translate(0, 0.5, 0);
    const s = new t0(dL, Sm, pL);
    s.translate(0, Sm / 2, 0);
    const r = new Tg({
      color: OS,
      transparent: !0,
      opacity: 0.85
    }), l = new Tg({
      color: OS,
      transparent: !0,
      opacity: 0.85
    });
    this.shaftMesh = new Gx(e, r, t), this.headMesh = new Gx(s, l, 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 s = this.positions[e * 3], r = this.positions[e * 3 + 1], l = this.positions[e * 3 + 2], c = this.vectors[e * 3], f = this.vectors[e * 3 + 1], d = this.vectors[e * 3 + 2], h = Math.sqrt(c * c + f * f + d * d);
      if (h < mL) {
        rr.makeScale(0, 0, 0), this.shaftMesh.setMatrixAt(e, rr), this.headMesh.setMatrixAt(e, rr);
        continue;
      }
      sc.set(c / h, f / h, d / h), bm.setFromUnitVectors(gL, sc);
      const m = h * this.arrowScale, p = Math.max(m - Sm, m * 0.7);
      Mf.set(s, r, l), Ef.set(1, p, 1), rr.compose(Mf, bm, Ef), this.shaftMesh.setMatrixAt(e, rr), Mf.set(
        s + sc.x * p,
        r + sc.y * p,
        l + sc.z * p
      ), Ef.set(1, 1, 1), rr.compose(Mf, bm, Ef), this.headMesh.setMatrixAt(e, rr);
    }
    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);
  }
}
class vL {
  constructor() {
    Ct(this, "group");
    Ct(this, "faceMesh", null);
    Ct(this, "edgeLines", null);
    this.group = new wa(), this.group.frustumCulled = !1;
  }
  loadMeshData(t) {
    this.clear();
    const e = t.positions.length / 3;
    if (e === 0 || t.indices.length === 0) return;
    const s = new Gn();
    s.setAttribute("position", new ln(t.positions, 3)), s.setAttribute("normal", new ln(t.normals, 3));
    const r = new Float32Array(e * 3);
    for (let c = 0; c < e; c++)
      r[c * 3] = t.colors[c * 4], r[c * 3 + 1] = t.colors[c * 4 + 1], r[c * 3 + 2] = t.colors[c * 4 + 2];
    s.setAttribute("color", new ln(r, 3)), s.setIndex(new ln(t.indices, 1));
    const l = new Tg({
      vertexColors: !0,
      transparent: !0,
      opacity: t.opacity,
      side: es,
      depthWrite: !1,
      shininess: 30
    });
    if (this.faceMesh = new Un(s, l), this.faceMesh.renderOrder = 1, this.group.add(this.faceMesh), t.showEdges && t.edgePositions && t.edgePositions.length > 0) {
      const c = new Gn();
      c.setAttribute("position", new ln(t.edgePositions, 3));
      const f = new Dc({
        color: 3355443,
        opacity: 0.7,
        transparent: !0
      });
      this.edgeLines = new HM(c, f), this.edgeLines.renderOrder = 2, this.group.add(this.edgeLines);
    }
  }
  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);
  }
  setVisible(t) {
    this.group.visible = t;
  }
  dispose() {
    this.clear();
  }
}
const Sa = new on();
function zS(n, t, e, s, r, l) {
  Sa.set(t, e, s, 1), Sa.applyMatrix4(n.matrixWorldInverse);
  const c = -Sa.z;
  Sa.applyMatrix4(n.projectionMatrix);
  const f = (Sa.x / Sa.w * 0.5 + 0.5) * r, d = (-Sa.y / Sa.w * 0.5 + 0.5) * l;
  return { sx: f, sy: d, depth: c };
}
function yL(n, t, e, s) {
  if (n instanceof zs) {
    const c = (n.top - n.bottom) / n.zoom, f = s / c;
    return t * f;
  }
  const r = n.fov * Math.PI / 180, l = s / (2 * e * Math.tan(r / 2));
  return t * l;
}
function xL(n, t, e, s, r, l, c) {
  const f = t.getBoundingClientRect(), d = l - f.left, h = c - f.top, m = f.width, p = f.height, _ = s, x = e.elements, b = e.nAtoms;
  let M = -1, S = 1 / 0;
  for (let D = 0; D < b; D++) {
    const { sx: z, sy: A, depth: R } = zS(
      n,
      _[D * 3],
      _[D * 3 + 1],
      _[D * 3 + 2],
      m,
      p
    );
    if (R <= 0) continue;
    const L = r0(x[D]) * a0 * r, H = yL(n, L, R, p), k = d - z, P = h - A;
    k * k + P * P <= H * H && R < S && (M = D, S = R);
  }
  if (M >= 0) {
    const D = M, z = x[D];
    return {
      kind: "atom",
      atomIndex: D,
      elementSymbol: o0(z),
      atomicNumber: z,
      position: [_[D * 3], _[D * 3 + 1], _[D * 3 + 2]],
      screenX: l,
      screenY: c
    };
  }
  const y = 8, C = e.bonds, T = e.nBonds, E = e.bondOrders;
  let O = -1, N = 1 / 0;
  for (let D = 0; D < T; D++) {
    const z = C[D * 2], A = C[D * 2 + 1], R = (_[z * 3] + _[A * 3]) * 0.5, L = (_[z * 3 + 1] + _[A * 3 + 1]) * 0.5, H = (_[z * 3 + 2] + _[A * 3 + 2]) * 0.5, { sx: k, sy: P, depth: Y } = zS(n, R, L, H, m, p);
    if (Y <= 0) continue;
    const U = d - k, X = h - P;
    U * U + X * X <= y * y && Y < N && (O = D, N = Y);
  }
  if (O >= 0) {
    const D = C[O * 2], z = C[O * 2 + 1], A = _[z * 3] - _[D * 3], R = _[z * 3 + 1] - _[D * 3 + 1], L = _[z * 3 + 2] - _[D * 3 + 2], H = Math.sqrt(A * A + R * R + L * L), k = E ? E[O] : 1;
    return {
      kind: "bond",
      atomA: D,
      atomB: z,
      bondOrder: k,
      bondLength: H,
      screenX: l,
      screenY: c
    };
  }
  return null;
}
function SL(n, t, e) {
  const s = n[e * 3] - n[t * 3], r = n[e * 3 + 1] - n[t * 3 + 1], l = n[e * 3 + 2] - n[t * 3 + 2];
  return Math.sqrt(s * s + r * r + l * l);
}
function bL(n, t, e, s) {
  const r = n[t * 3] - n[e * 3], l = n[t * 3 + 1] - n[e * 3 + 1], c = n[t * 3 + 2] - n[e * 3 + 2], f = n[s * 3] - n[e * 3], d = n[s * 3 + 1] - n[e * 3 + 1], h = n[s * 3 + 2] - n[e * 3 + 2], m = r * f + l * d + c * h, p = Math.sqrt(r * r + l * l + c * c), _ = Math.sqrt(f * f + d * d + h * h);
  return Math.acos(Math.max(-1, Math.min(1, m / (p * _)))) * (180 / Math.PI);
}
function ML(n, t, e, s, r) {
  const l = n[e * 3] - n[t * 3], c = n[e * 3 + 1] - n[t * 3 + 1], f = n[e * 3 + 2] - n[t * 3 + 2], d = n[s * 3] - n[e * 3], h = n[s * 3 + 1] - n[e * 3 + 1], m = n[s * 3 + 2] - n[e * 3 + 2], p = n[r * 3] - n[s * 3], _ = n[r * 3 + 1] - n[s * 3 + 1], x = n[r * 3 + 2] - n[s * 3 + 2], b = c * m - f * h, M = f * d - l * m, S = l * h - c * d, y = h * x - m * _, C = m * p - d * x, T = d * _ - h * p, E = Math.sqrt(d * d + h * h + m * m), O = d / E, N = h / E, D = m / E, z = M * D - S * N, A = S * O - b * D, R = b * N - M * O, L = b * y + M * C + S * T, H = z * y + A * C + R * T;
  return Math.atan2(H, L) * (180 / Math.PI);
}
function EL(n, t) {
  if (t.length < 2) return null;
  if (t.length === 2) {
    const e = SL(n, t[0], t[1]);
    return { atoms: [...t], type: "distance", value: e, label: `${e.toFixed(3)} Å` };
  }
  if (t.length === 3) {
    const e = bL(n, t[0], t[1], t[2]);
    return { atoms: [...t], type: "angle", value: e, label: `${e.toFixed(1)}°` };
  }
  if (t.length === 4) {
    const e = ML(n, t[0], t[1], t[2], t[3]);
    return { atoms: [...t], type: "dihedral", value: e, label: `${e.toFixed(1)}°` };
  }
  return null;
}
function TL(n) {
  const { positions: t, nAtoms: e } = n;
  let s = 0, r = 0, l = 0;
  for (let E = 0; E < e; E++)
    s += t[E * 3], r += t[E * 3 + 1], l += t[E * 3 + 2];
  let c, f, d, h = 1 / 0, m = 1 / 0, p = 1 / 0, _ = -1 / 0, x = -1 / 0, b = -1 / 0;
  if (n.box && n.box.some((E) => E !== 0)) {
    const E = n.box;
    c = (E[0] + E[3] + E[6]) / 2, f = (E[1] + E[4] + E[7]) / 2, d = (E[2] + E[5] + E[8]) / 2;
    const O = [E[0], E[1], E[2]], N = [E[3], E[4], E[5]], D = [E[6], E[7], E[8]];
    for (let z = 0; z <= 1; z++)
      for (let A = 0; A <= 1; A++)
        for (let R = 0; R <= 1; R++) {
          const L = z * O[0] + A * N[0] + R * D[0], H = z * O[1] + A * N[1] + R * D[1], k = z * O[2] + A * N[2] + R * D[2];
          h = Math.min(h, L), m = Math.min(m, H), p = Math.min(p, k), _ = Math.max(_, L), x = Math.max(x, H), b = Math.max(b, k);
        }
  } else {
    c = e > 0 ? s / e : 0, f = e > 0 ? r / e : 0, d = e > 0 ? l / e : 0;
    for (let E = 0; E < e; E++) {
      const O = t[E * 3], N = t[E * 3 + 1], D = t[E * 3 + 2];
      h = Math.min(h, O), m = Math.min(m, N), p = Math.min(p, D), _ = Math.max(_, O), x = Math.max(x, N), b = Math.max(b, D);
    }
  }
  const S = _ - h, y = x - m, C = b - p, T = Math.max(S, y, C);
  return {
    center: [c, f, d],
    extent: { maxExtent: T, extentX: S, extentY: y }
  };
}
function AL(n, t, e) {
  const { center: s, extent: r } = TL(e), [l, c, f] = s;
  t.target.set(l, c, f);
  const d = Math.max(r.maxExtent * 1.2, 0.1);
  return n.position.set(l, c - d, f), n instanceof zs ? (n.near = -d * 10, n.far = d * 10, n.zoom = 1) : (n.near = d * 0.01, n.far = d * 10, n.updateProjectionMatrix()), t.update(), r;
}
function wL(n, t, e, s, r, l) {
  if (t === 0 || e === 0) return;
  const c = Math.max(t * 0.3, 100), d = Math.max(t - s - r, c) / e, m = Math.max(l.extentY / 2, l.extentX / (2 * d)) * 1.2, p = Math.max(m * 2, 0.1), _ = t / e, x = p * _ / 2;
  n.left = -x, n.right = x, n.top = p / 2, n.bottom = -p / 2;
  const b = 2 * x, M = (s - r) / (2 * t) * b;
  n.left -= M, n.right -= M, n.updateProjectionMatrix();
}
function CL(n, t, e, s) {
  const r = n.position.clone(), l = n.up.clone(), c = e / s;
  let f;
  return t ? f = new xi(50, c, 0.1, 1e4) : f = new zs(
    -50 * c / 2,
    50 * c / 2,
    50 / 2,
    -50 / 2,
    0.1,
    1e4
  ), f.position.copy(r), f.up.copy(l), f;
}
class RL {
  constructor() {
    Ct(this, "container", null);
    Ct(this, "renderer");
    Ct(this, "scene");
    Ct(this, "camera");
    Ct(this, "controls");
    Ct(this, "perspectiveMode", !1);
    Ct(this, "atomRenderer", null);
    Ct(this, "bondRenderer", null);
    Ct(this, "cellRenderer", null);
    Ct(this, "cellAxesRenderer", null);
    Ct(this, "labelOverlay", null);
    Ct(this, "arrowRenderer", null);
    Ct(this, "polyhedronRenderer", null);
    Ct(this, "useImpostor", !1);
    Ct(this, "animationId", null);
    Ct(this, "snapshot", null);
    Ct(this, "lastExtent", { maxExtent: 1, extentX: 1, extentY: 1 });
    Ct(this, "currentPositions", null);
    /** Axes-inset drag state */
    Ct(this, "axesDragging", !1);
    Ct(this, "axesDragLastX", 0);
    Ct(this, "axesDragLastY", 0);
    Ct(this, "atomScale", 1);
    Ct(this, "atomOpacity", 1);
    Ct(this, "bondScale", 1);
    Ct(this, "bondOpacity", 1);
    Ct(this, "viewInsetLeft", 0);
    Ct(this, "viewInsetRight", 0);
    Ct(this, "dprMediaQuery", null);
    Ct(this, "dprChangeHandler", null);
    // Cached dimensions for frame-synchronous resize detection
    Ct(this, "lastContainerW", 0);
    Ct(this, "lastContainerH", 0);
    Ct(this, "lastDpr", 1);
    // (screen-space picking replaces Three.js raycasting)
    // Atom selection & measurement
    Ct(this, "selectedAtoms", []);
    Ct(this, "selectionGroup", new wa());
    Ct(this, "animate", () => {
      if (this.animationId = requestAnimationFrame(this.animate), this.container) {
        const s = this.container.clientWidth, r = this.container.clientHeight, l = Math.min(window.devicePixelRatio, 2);
        (s !== this.lastContainerW || r !== this.lastContainerH || l !== this.lastDpr) && (this.lastContainerW = s, this.lastContainerH = r, this.lastDpr = l, this.onResize());
      }
      this.controls.update(), this.renderer.render(this.scene, this.camera);
      const t = new le();
      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 (s) {
          console.warn("CellAxesRenderer render error:", s), 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 DN({
      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 fL(), t.appendChild(this.labelOverlay.getCanvas()), this.labelOverlay.resize(
      t.clientWidth,
      t.clientHeight,
      Math.min(window.devicePixelRatio, 2)
    ), this.scene = new BM(), this.scene.background = new we(16777215);
    const s = t.clientWidth / t.clientHeight, r = 50;
    this.camera = new zs(
      -r * s / 2,
      r * s / 2,
      r / 2,
      -r / 2,
      0.1,
      1e4
    ), this.camera.position.set(0, -50, 0), this.camera.up.set(0, 0, 1), this.controls = new ES(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 l = new V2(14544639, 10057540, 0.4);
    this.scene.add(l);
    const c = new Vf(16777215, 0.8);
    c.position.set(50, 50, 50), this.scene.add(c);
    const f = new Vf(16777215, 0.4);
    f.position.set(-30, 20, -20), this.scene.add(f);
    const d = new Vf(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.bondRenderer.loadSnapshot(t), this.atomScale !== 1 && this.atomRenderer.setScale && this.atomRenderer.setScale(this.atomScale, t), this.bondScale !== 1 && this.bondRenderer.setScale && this.bondRenderer.setScale(this.bondScale, t), this.labelOverlay && (this.labelOverlay.setAtomData(t.elements, t.nAtoms), this.labelOverlay.setPositions(t.positions)), this.arrowRenderer || (this.arrowRenderer = new _L(t.nAtoms), this.scene.add(this.arrowRenderer.mesh)), this.arrowRenderer.setAtomPositions(t.positions, t.nAtoms), t.box) {
      const e = t.box.some((s) => s !== 0);
      if (e && (this.cellRenderer || (this.cellRenderer = new oL(), this.scene.add(this.cellRenderer.mesh)), this.cellRenderer.loadBox(t.box)), e)
        try {
          this.cellAxesRenderer || (this.cellAxesRenderer = new lL()), this.cellAxesRenderer.loadBox(t.box);
        } catch (s) {
          console.warn("CellAxesRenderer init error:", s), this.cellAxesRenderer = null;
        }
    }
    this.fitToView(t);
  }
  /** Update positions from a trajectory frame. */
  updateFrame(t) {
    var e, s;
    !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), (s = this.arrowRenderer) == null || s.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 s = this.currentPositions ?? this.snapshot.positions, r = {
      ...this.snapshot,
      nBonds: t.length / 2,
      bonds: t,
      bondOrders: e
    };
    this.snapshot = r, this.bondRenderer.loadSnapshot({
      ...r,
      positions: s
    }), this.bondScale !== 1 && this.bondRenderer.setScale && this.bondRenderer.setScale(this.bondScale, r);
  }
  /** 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 vL(), 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, s;
    this.atomOpacity = t, (s = (e = this.atomRenderer) == null ? void 0 : e.setOpacity) == null || s.call(e, t);
  }
  /** Set per-atom scale overrides from selection pipeline. */
  setAtomScaleOverrides(t) {
    var e, s;
    (s = (e = this.atomRenderer) == null ? void 0 : e.setScaleOverrides) == null || s.call(e, t);
  }
  /** Set per-atom opacity overrides from selection pipeline. */
  setAtomOpacityOverrides(t) {
    var e, s;
    (s = (e = this.atomRenderer) == null ? void 0 : e.setOpacityOverrides) == null || s.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, s;
    this.bondOpacity = t, (s = (e = this.bondRenderer) == null ? void 0 : e.setOpacity) == null || s.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 s = t - this.axesDragLastX, r = e - this.axesDragLastY;
    return this.axesDragLastX = t, this.axesDragLastY = e, this.cellAxesRenderer.moveBy(
      s,
      r,
      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 r, l, c, f;
    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 sL(), s = new rL();
    this.atomRenderer = e, this.bondRenderer = s, this.scene.add(this.atomRenderer.mesh), this.scene.add(this.bondRenderer.mesh), this.atomOpacity !== 1 && ((l = (r = this.atomRenderer).setOpacity) == null || l.call(r, this.atomOpacity)), this.bondOpacity !== 1 && ((f = (c = this.bondRenderer).setOpacity) == null || f.call(c, this.bondOpacity));
  }
  /** Fit camera to show all atoms (or simulation cell if present). */
  fitToView(t) {
    this.lastExtent = AL(this.camera, this.controls, t), this.camera instanceof zs && 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, s) {
    this.controls.target.set(t, e, s), 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 zs && this.container && wL(
      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(), s = CL(
      this.camera,
      t,
      this.container.clientWidth,
      this.container.clientHeight
    ), r = this.controls.enableDamping, l = this.controls.dampingFactor, c = this.controls.rotateSpeed, f = this.controls.zoomSpeed;
    this.controls.dispose(), this.camera = s, this.controls = new ES(this.camera, this.renderer.domElement), this.controls.enableDamping = r, this.controls.dampingFactor = l, this.controls.rotateSpeed = c, this.controls.zoomSpeed = f, 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 : xL(
      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 : EL(this.getCurrentPositions(), this.selectedAtoms);
  }
  updateSelectionVisuals() {
    for (; this.selectionGroup.children.length > 0; ) {
      const s = this.selectionGroup.children[0];
      this.selectionGroup.remove(s), (s instanceof Un || s instanceof mc) && (s.geometry.dispose(), Array.isArray(s.material) ? s.material.forEach((r) => r.dispose()) : s.material.dispose());
    }
    if (!this.snapshot || this.selectedAtoms.length === 0) return;
    const t = this.getCurrentPositions(), e = this.snapshot.elements;
    for (const s of this.selectedAtoms) {
      const r = r0(e[s]) * a0 * 1.6, l = new e0(r, 16, 16), c = new pd({
        color: 4359668,
        transparent: !0,
        opacity: 0.35,
        depthWrite: !1
      }), f = new Un(l, c);
      f.position.set(
        t[s * 3],
        t[s * 3 + 1],
        t[s * 3 + 2]
      ), this.selectionGroup.add(f);
    }
    if (this.selectedAtoms.length >= 2) {
      const s = this.selectedAtoms.map(
        (f) => new at(t[f * 3], t[f * 3 + 1], t[f * 3 + 2])
      ), r = new Gn().setFromPoints(s), l = new Dc({
        color: 4359668,
        depthTest: !1
      }), c = new mc(r, l);
      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 r;
    if (!this.container) return;
    const t = this.container.clientWidth, e = this.container.clientHeight;
    if (t === 0 || e === 0) return;
    const s = Math.min(window.devicePixelRatio, 2);
    this.lastContainerW = t, this.lastContainerH = e, this.lastDpr = s, this.renderer.setPixelRatio(s), this.camera instanceof zs ? this.doApplyFrustumInsets() : (this.camera.aspect = t / e, this.camera.updateProjectionMatrix()), this.renderer.setSize(t, e, !1), (r = this.labelOverlay) == null || r.resize(t, e, s);
  }
  /** 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 KM({
  snapshot: n,
  frame: t,
  atomLabels: e,
  atomVectors: s,
  onRendererReady: r,
  onHover: l,
  onAtomRightClick: c,
  onFrameUpdated: f
}) {
  const d = st.useRef(null), h = st.useRef(null), m = st.useRef(l), p = st.useRef(c), _ = st.useRef(f);
  return m.current = l, p.current = c, _.current = f, st.useEffect(() => {
    if (!d.current) return;
    const x = new RL();
    return x.mount(d.current), h.current = x, r == null || r(x), () => {
      x.dispose(), h.current = null;
    };
  }, []), st.useEffect(() => {
    const x = h.current, b = x == null ? void 0 : x.getCanvas();
    if (!b || !x) return;
    let M = null;
    const S = (A) => {
      M === null && (M = requestAnimationFrame(() => {
        var L;
        const R = x.raycastAtPixel(A.clientX, A.clientY);
        (L = m.current) == null || L.call(m, R), M = null;
      }));
    }, y = (A) => {
      var L;
      A.preventDefault();
      const R = x.raycastAtPixel(A.clientX, A.clientY);
      R && R.kind === "atom" && ((L = p.current) == null || L.call(p, R.atomIndex));
    }, C = () => {
      var A;
      (A = m.current) == null || A.call(m, null);
    }, T = (A) => {
      const R = x.raycastAtPixel(A.clientX, A.clientY);
      if (R && R.kind === "atom") {
        const L = x.getCurrentPositionsCopy();
        if (L) {
          const H = R.atomIndex;
          x.setRotationCenter(
            L[H * 3],
            L[H * 3 + 1],
            L[H * 3 + 2]
          );
        }
      }
    }, E = d.current, O = (A) => {
      const R = E.getBoundingClientRect();
      return { x: A.clientX - R.left, y: A.clientY - R.top };
    }, N = (A) => {
      var H, k;
      const { x: R, y: L } = O(A);
      x.hitTestAxesInset(R, L) && (A.preventDefault(), x.startAxesDrag(R, L), (k = (H = A.target) == null ? void 0 : H.setPointerCapture) == null || k.call(H, A.pointerId));
    }, D = (A) => {
      if (x.isAxesDragging()) {
        const { x: R, y: L } = O(A);
        x.moveAxesDrag(R, L);
      }
    }, z = (A) => {
      x.endAxesDrag();
    };
    return b.addEventListener("mousemove", S), b.addEventListener("contextmenu", y), b.addEventListener("mouseleave", C), b.addEventListener("dblclick", T), b.addEventListener("pointerdown", N), b.addEventListener("pointermove", D), b.addEventListener("pointerup", z), b.addEventListener("pointercancel", z), () => {
      b.removeEventListener("mousemove", S), b.removeEventListener("contextmenu", y), b.removeEventListener("mouseleave", C), b.removeEventListener("dblclick", T), b.removeEventListener("pointerdown", N), b.removeEventListener("pointermove", D), b.removeEventListener("pointerup", z), b.removeEventListener("pointercancel", z), M !== null && cancelAnimationFrame(M);
    };
  }, []), st.useEffect(() => {
    n && h.current && h.current.loadSnapshot(n);
  }, [n]), st.useEffect(() => {
    var x;
    t && h.current && (h.current.updateFrame(t), (x = _.current) == null || x.call(_));
  }, [t]), st.useEffect(() => {
    var x;
    (x = h.current) == null || x.setLabels(e ?? null);
  }, [e]), st.useEffect(() => {
    var x;
    (x = h.current) == null || x.setVectors(s ?? null);
  }, [s]), /* @__PURE__ */ Z.jsx(
    "div",
    {
      ref: d,
      style: {
        width: "100%",
        height: "100%",
        position: "relative",
        background: "#ffffff"
      }
    }
  );
}
function bn(n) {
  if (typeof n == "string" || typeof n == "number") return "" + n;
  let t = "";
  if (Array.isArray(n))
    for (let e = 0, s; e < n.length; e++)
      (s = bn(n[e])) !== "" && (t += (t && " ") + s);
  else
    for (let e in n)
      n[e] && (t += (t && " ") + e);
  return t;
}
var DL = { value: () => {
} };
function _d() {
  for (var n = 0, t = arguments.length, e = {}, s; n < t; ++n) {
    if (!(s = arguments[n] + "") || s in e || /[\s.]/.test(s)) throw new Error("illegal type: " + s);
    e[s] = [];
  }
  return new kf(e);
}
function kf(n) {
  this._ = n;
}
function NL(n, t) {
  return n.trim().split(/^|\s+/).map(function(e) {
    var s = "", r = e.indexOf(".");
    if (r >= 0 && (s = e.slice(r + 1), e = e.slice(0, r)), e && !t.hasOwnProperty(e)) throw new Error("unknown type: " + e);
    return { type: e, name: s };
  });
}
kf.prototype = _d.prototype = {
  constructor: kf,
  on: function(n, t) {
    var e = this._, s = NL(n + "", e), r, l = -1, c = s.length;
    if (arguments.length < 2) {
      for (; ++l < c; ) if ((r = (n = s[l]).type) && (r = LL(e[r], n.name))) return r;
      return;
    }
    if (t != null && typeof t != "function") throw new Error("invalid callback: " + t);
    for (; ++l < c; )
      if (r = (n = s[l]).type) e[r] = IS(e[r], n.name, t);
      else if (t == null) for (r in e) e[r] = IS(e[r], n.name, null);
    return this;
  },
  copy: function() {
    var n = {}, t = this._;
    for (var e in t) n[e] = t[e].slice();
    return new kf(n);
  },
  call: function(n, t) {
    if ((r = arguments.length - 2) > 0) for (var e = new Array(r), s = 0, r, l; s < r; ++s) e[s] = arguments[s + 2];
    if (!this._.hasOwnProperty(n)) throw new Error("unknown type: " + n);
    for (l = this._[n], s = 0, r = l.length; s < r; ++s) l[s].value.apply(t, e);
  },
  apply: function(n, t, e) {
    if (!this._.hasOwnProperty(n)) throw new Error("unknown type: " + n);
    for (var s = this._[n], r = 0, l = s.length; r < l; ++r) s[r].value.apply(t, e);
  }
};
function LL(n, t) {
  for (var e = 0, s = n.length, r; e < s; ++e)
    if ((r = n[e]).name === t)
      return r.value;
}
function IS(n, t, e) {
  for (var s = 0, r = n.length; s < r; ++s)
    if (n[s].name === t) {
      n[s] = DL, n = n.slice(0, s).concat(n.slice(s + 1));
      break;
    }
  return e != null && n.push({ name: t, value: e }), n;
}
var Rg = "http://www.w3.org/1999/xhtml";
const BS = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: Rg,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function vd(n) {
  var t = n += "", e = t.indexOf(":");
  return e >= 0 && (t = n.slice(0, e)) !== "xmlns" && (n = n.slice(e + 1)), BS.hasOwnProperty(t) ? { space: BS[t], local: n } : n;
}
function UL(n) {
  return function() {
    var t = this.ownerDocument, e = this.namespaceURI;
    return e === Rg && t.documentElement.namespaceURI === Rg ? t.createElement(n) : t.createElementNS(e, n);
  };
}
function OL(n) {
  return function() {
    return this.ownerDocument.createElementNS(n.space, n.local);
  };
}
function $M(n) {
  var t = vd(n);
  return (t.local ? OL : UL)(t);
}
function PL() {
}
function l0(n) {
  return n == null ? PL : function() {
    return this.querySelector(n);
  };
}
function zL(n) {
  typeof n != "function" && (n = l0(n));
  for (var t = this._groups, e = t.length, s = new Array(e), r = 0; r < e; ++r)
    for (var l = t[r], c = l.length, f = s[r] = new Array(c), d, h, m = 0; m < c; ++m)
      (d = l[m]) && (h = n.call(d, d.__data__, m, l)) && ("__data__" in d && (h.__data__ = d.__data__), f[m] = h);
  return new Mi(s, this._parents);
}
function IL(n) {
  return n == null ? [] : Array.isArray(n) ? n : Array.from(n);
}
function BL() {
  return [];
}
function QM(n) {
  return n == null ? BL : function() {
    return this.querySelectorAll(n);
  };
}
function FL(n) {
  return function() {
    return IL(n.apply(this, arguments));
  };
}
function HL(n) {
  typeof n == "function" ? n = FL(n) : n = QM(n);
  for (var t = this._groups, e = t.length, s = [], r = [], l = 0; l < e; ++l)
    for (var c = t[l], f = c.length, d, h = 0; h < f; ++h)
      (d = c[h]) && (s.push(n.call(d, d.__data__, h, c)), r.push(d));
  return new Mi(s, r);
}
function JM(n) {
  return function() {
    return this.matches(n);
  };
}
function t1(n) {
  return function(t) {
    return t.matches(n);
  };
}
var VL = Array.prototype.find;
function GL(n) {
  return function() {
    return VL.call(this.children, n);
  };
}
function kL() {
  return this.firstElementChild;
}
function XL(n) {
  return this.select(n == null ? kL : GL(typeof n == "function" ? n : t1(n)));
}
var WL = Array.prototype.filter;
function YL() {
  return Array.from(this.children);
}
function jL(n) {
  return function() {
    return WL.call(this.children, n);
  };
}
function qL(n) {
  return this.selectAll(n == null ? YL : jL(typeof n == "function" ? n : t1(n)));
}
function ZL(n) {
  typeof n != "function" && (n = JM(n));
  for (var t = this._groups, e = t.length, s = new Array(e), r = 0; r < e; ++r)
    for (var l = t[r], c = l.length, f = s[r] = [], d, h = 0; h < c; ++h)
      (d = l[h]) && n.call(d, d.__data__, h, l) && f.push(d);
  return new Mi(s, this._parents);
}
function e1(n) {
  return new Array(n.length);
}
function KL() {
  return new Mi(this._enter || this._groups.map(e1), this._parents);
}
function nd(n, t) {
  this.ownerDocument = n.ownerDocument, this.namespaceURI = n.namespaceURI, this._next = null, this._parent = n, this.__data__ = t;
}
nd.prototype = {
  constructor: nd,
  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 $L(n) {
  return function() {
    return n;
  };
}
function QL(n, t, e, s, r, l) {
  for (var c = 0, f, d = t.length, h = l.length; c < h; ++c)
    (f = t[c]) ? (f.__data__ = l[c], s[c] = f) : e[c] = new nd(n, l[c]);
  for (; c < d; ++c)
    (f = t[c]) && (r[c] = f);
}
function JL(n, t, e, s, r, l, c) {
  var f, d, h = /* @__PURE__ */ new Map(), m = t.length, p = l.length, _ = new Array(m), x;
  for (f = 0; f < m; ++f)
    (d = t[f]) && (_[f] = x = c.call(d, d.__data__, f, t) + "", h.has(x) ? r[f] = d : h.set(x, d));
  for (f = 0; f < p; ++f)
    x = c.call(n, l[f], f, l) + "", (d = h.get(x)) ? (s[f] = d, d.__data__ = l[f], h.delete(x)) : e[f] = new nd(n, l[f]);
  for (f = 0; f < m; ++f)
    (d = t[f]) && h.get(_[f]) === d && (r[f] = d);
}
function tU(n) {
  return n.__data__;
}
function eU(n, t) {
  if (!arguments.length) return Array.from(this, tU);
  var e = t ? JL : QL, s = this._parents, r = this._groups;
  typeof n != "function" && (n = $L(n));
  for (var l = r.length, c = new Array(l), f = new Array(l), d = new Array(l), h = 0; h < l; ++h) {
    var m = s[h], p = r[h], _ = p.length, x = nU(n.call(m, m && m.__data__, h, s)), b = x.length, M = f[h] = new Array(b), S = c[h] = new Array(b), y = d[h] = new Array(_);
    e(m, p, M, S, y, x, t);
    for (var C = 0, T = 0, E, O; C < b; ++C)
      if (E = M[C]) {
        for (C >= T && (T = C + 1); !(O = S[T]) && ++T < b; ) ;
        E._next = O || null;
      }
  }
  return c = new Mi(c, s), c._enter = f, c._exit = d, c;
}
function nU(n) {
  return typeof n == "object" && "length" in n ? n : Array.from(n);
}
function iU() {
  return new Mi(this._exit || this._groups.map(e1), this._parents);
}
function sU(n, t, e) {
  var s = this.enter(), r = this, l = this.exit();
  return typeof n == "function" ? (s = n(s), s && (s = s.selection())) : s = s.append(n + ""), t != null && (r = t(r), r && (r = r.selection())), e == null ? l.remove() : e(l), s && r ? s.merge(r).order() : r;
}
function aU(n) {
  for (var t = n.selection ? n.selection() : n, e = this._groups, s = t._groups, r = e.length, l = s.length, c = Math.min(r, l), f = new Array(r), d = 0; d < c; ++d)
    for (var h = e[d], m = s[d], p = h.length, _ = f[d] = new Array(p), x, b = 0; b < p; ++b)
      (x = h[b] || m[b]) && (_[b] = x);
  for (; d < r; ++d)
    f[d] = e[d];
  return new Mi(f, this._parents);
}
function rU() {
  for (var n = this._groups, t = -1, e = n.length; ++t < e; )
    for (var s = n[t], r = s.length - 1, l = s[r], c; --r >= 0; )
      (c = s[r]) && (l && c.compareDocumentPosition(l) ^ 4 && l.parentNode.insertBefore(c, l), l = c);
  return this;
}
function oU(n) {
  n || (n = lU);
  function t(p, _) {
    return p && _ ? n(p.__data__, _.__data__) : !p - !_;
  }
  for (var e = this._groups, s = e.length, r = new Array(s), l = 0; l < s; ++l) {
    for (var c = e[l], f = c.length, d = r[l] = new Array(f), h, m = 0; m < f; ++m)
      (h = c[m]) && (d[m] = h);
    d.sort(t);
  }
  return new Mi(r, this._parents).order();
}
function lU(n, t) {
  return n < t ? -1 : n > t ? 1 : n >= t ? 0 : NaN;
}
function cU() {
  var n = arguments[0];
  return arguments[0] = this, n.apply(null, arguments), this;
}
function uU() {
  return Array.from(this);
}
function fU() {
  for (var n = this._groups, t = 0, e = n.length; t < e; ++t)
    for (var s = n[t], r = 0, l = s.length; r < l; ++r) {
      var c = s[r];
      if (c) return c;
    }
  return null;
}
function dU() {
  let n = 0;
  for (const t of this) ++n;
  return n;
}
function hU() {
  return !this.node();
}
function pU(n) {
  for (var t = this._groups, e = 0, s = t.length; e < s; ++e)
    for (var r = t[e], l = 0, c = r.length, f; l < c; ++l)
      (f = r[l]) && n.call(f, f.__data__, l, r);
  return this;
}
function mU(n) {
  return function() {
    this.removeAttribute(n);
  };
}
function gU(n) {
  return function() {
    this.removeAttributeNS(n.space, n.local);
  };
}
function _U(n, t) {
  return function() {
    this.setAttribute(n, t);
  };
}
function vU(n, t) {
  return function() {
    this.setAttributeNS(n.space, n.local, t);
  };
}
function yU(n, t) {
  return function() {
    var e = t.apply(this, arguments);
    e == null ? this.removeAttribute(n) : this.setAttribute(n, e);
  };
}
function xU(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 SU(n, t) {
  var e = vd(n);
  if (arguments.length < 2) {
    var s = this.node();
    return e.local ? s.getAttributeNS(e.space, e.local) : s.getAttribute(e);
  }
  return this.each((t == null ? e.local ? gU : mU : typeof t == "function" ? e.local ? xU : yU : e.local ? vU : _U)(e, t));
}
function n1(n) {
  return n.ownerDocument && n.ownerDocument.defaultView || n.document && n || n.defaultView;
}
function bU(n) {
  return function() {
    this.style.removeProperty(n);
  };
}
function MU(n, t, e) {
  return function() {
    this.style.setProperty(n, t, e);
  };
}
function EU(n, t, e) {
  return function() {
    var s = t.apply(this, arguments);
    s == null ? this.style.removeProperty(n) : this.style.setProperty(n, s, e);
  };
}
function TU(n, t, e) {
  return arguments.length > 1 ? this.each((t == null ? bU : typeof t == "function" ? EU : MU)(n, t, e ?? "")) : qo(this.node(), n);
}
function qo(n, t) {
  return n.style.getPropertyValue(t) || n1(n).getComputedStyle(n, null).getPropertyValue(t);
}
function AU(n) {
  return function() {
    delete this[n];
  };
}
function wU(n, t) {
  return function() {
    this[n] = t;
  };
}
function CU(n, t) {
  return function() {
    var e = t.apply(this, arguments);
    e == null ? delete this[n] : this[n] = e;
  };
}
function RU(n, t) {
  return arguments.length > 1 ? this.each((t == null ? AU : typeof t == "function" ? CU : wU)(n, t)) : this.node()[n];
}
function i1(n) {
  return n.trim().split(/^|\s+/);
}
function c0(n) {
  return n.classList || new s1(n);
}
function s1(n) {
  this._node = n, this._names = i1(n.getAttribute("class") || "");
}
s1.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 a1(n, t) {
  for (var e = c0(n), s = -1, r = t.length; ++s < r; ) e.add(t[s]);
}
function r1(n, t) {
  for (var e = c0(n), s = -1, r = t.length; ++s < r; ) e.remove(t[s]);
}
function DU(n) {
  return function() {
    a1(this, n);
  };
}
function NU(n) {
  return function() {
    r1(this, n);
  };
}
function LU(n, t) {
  return function() {
    (t.apply(this, arguments) ? a1 : r1)(this, n);
  };
}
function UU(n, t) {
  var e = i1(n + "");
  if (arguments.length < 2) {
    for (var s = c0(this.node()), r = -1, l = e.length; ++r < l; ) if (!s.contains(e[r])) return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? LU : t ? DU : NU)(e, t));
}
function OU() {
  this.textContent = "";
}
function PU(n) {
  return function() {
    this.textContent = n;
  };
}
function zU(n) {
  return function() {
    var t = n.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function IU(n) {
  return arguments.length ? this.each(n == null ? OU : (typeof n == "function" ? zU : PU)(n)) : this.node().textContent;
}
function BU() {
  this.innerHTML = "";
}
function FU(n) {
  return function() {
    this.innerHTML = n;
  };
}
function HU(n) {
  return function() {
    var t = n.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function VU(n) {
  return arguments.length ? this.each(n == null ? BU : (typeof n == "function" ? HU : FU)(n)) : this.node().innerHTML;
}
function GU() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function kU() {
  return this.each(GU);
}
function XU() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function WU() {
  return this.each(XU);
}
function YU(n) {
  var t = typeof n == "function" ? n : $M(n);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function jU() {
  return null;
}
function qU(n, t) {
  var e = typeof n == "function" ? n : $M(n), s = t == null ? jU : typeof t == "function" ? t : l0(t);
  return this.select(function() {
    return this.insertBefore(e.apply(this, arguments), s.apply(this, arguments) || null);
  });
}
function ZU() {
  var n = this.parentNode;
  n && n.removeChild(this);
}
function KU() {
  return this.each(ZU);
}
function $U() {
  var n = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(n, this.nextSibling) : n;
}
function QU() {
  var n = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(n, this.nextSibling) : n;
}
function JU(n) {
  return this.select(n ? QU : $U);
}
function tO(n) {
  return arguments.length ? this.property("__data__", n) : this.node().__data__;
}
function eO(n) {
  return function(t) {
    n.call(this, t, this.__data__);
  };
}
function nO(n) {
  return n.trim().split(/^|\s+/).map(function(t) {
    var e = "", s = t.indexOf(".");
    return s >= 0 && (e = t.slice(s + 1), t = t.slice(0, s)), { type: t, name: e };
  });
}
function iO(n) {
  return function() {
    var t = this.__on;
    if (t) {
      for (var e = 0, s = -1, r = t.length, l; e < r; ++e)
        l = t[e], (!n.type || l.type === n.type) && l.name === n.name ? this.removeEventListener(l.type, l.listener, l.options) : t[++s] = l;
      ++s ? t.length = s : delete this.__on;
    }
  };
}
function sO(n, t, e) {
  return function() {
    var s = this.__on, r, l = eO(t);
    if (s) {
      for (var c = 0, f = s.length; c < f; ++c)
        if ((r = s[c]).type === n.type && r.name === n.name) {
          this.removeEventListener(r.type, r.listener, r.options), this.addEventListener(r.type, r.listener = l, r.options = e), r.value = t;
          return;
        }
    }
    this.addEventListener(n.type, l, e), r = { type: n.type, name: n.name, value: t, listener: l, options: e }, s ? s.push(r) : this.__on = [r];
  };
}
function aO(n, t, e) {
  var s = nO(n + ""), r, l = s.length, c;
  if (arguments.length < 2) {
    var f = this.node().__on;
    if (f) {
      for (var d = 0, h = f.length, m; d < h; ++d)
        for (r = 0, m = f[d]; r < l; ++r)
          if ((c = s[r]).type === m.type && c.name === m.name)
            return m.value;
    }
    return;
  }
  for (f = t ? sO : iO, r = 0; r < l; ++r) this.each(f(s[r], t, e));
  return this;
}
function o1(n, t, e) {
  var s = n1(n), r = s.CustomEvent;
  typeof r == "function" ? r = new r(t, e) : (r = s.document.createEvent("Event"), e ? (r.initEvent(t, e.bubbles, e.cancelable), r.detail = e.detail) : r.initEvent(t, !1, !1)), n.dispatchEvent(r);
}
function rO(n, t) {
  return function() {
    return o1(this, n, t);
  };
}
function oO(n, t) {
  return function() {
    return o1(this, n, t.apply(this, arguments));
  };
}
function lO(n, t) {
  return this.each((typeof t == "function" ? oO : rO)(n, t));
}
function* cO() {
  for (var n = this._groups, t = 0, e = n.length; t < e; ++t)
    for (var s = n[t], r = 0, l = s.length, c; r < l; ++r)
      (c = s[r]) && (yield c);
}
var l1 = [null];
function Mi(n, t) {
  this._groups = n, this._parents = t;
}
function Lc() {
  return new Mi([[document.documentElement]], l1);
}
function uO() {
  return this;
}
Mi.prototype = Lc.prototype = {
  constructor: Mi,
  select: zL,
  selectAll: HL,
  selectChild: XL,
  selectChildren: qL,
  filter: ZL,
  data: eU,
  enter: KL,
  exit: iU,
  join: sU,
  merge: aU,
  selection: uO,
  order: rU,
  sort: oU,
  call: cU,
  nodes: uU,
  node: fU,
  size: dU,
  empty: hU,
  each: pU,
  attr: SU,
  style: TU,
  property: RU,
  classed: UU,
  text: IU,
  html: VU,
  raise: kU,
  lower: WU,
  append: YU,
  insert: qU,
  remove: KU,
  clone: JU,
  datum: tO,
  on: aO,
  dispatch: lO,
  [Symbol.iterator]: cO
};
function Si(n) {
  return typeof n == "string" ? new Mi([[document.querySelector(n)]], [document.documentElement]) : new Mi([[n]], l1);
}
function fO(n) {
  let t;
  for (; t = n.sourceEvent; ) n = t;
  return n;
}
function Xi(n, t) {
  if (n = fO(n), t === void 0 && (t = n.currentTarget), t) {
    var e = t.ownerSVGElement || t;
    if (e.createSVGPoint) {
      var s = e.createSVGPoint();
      return s.x = n.clientX, s.y = n.clientY, s = s.matrixTransform(t.getScreenCTM().inverse()), [s.x, s.y];
    }
    if (t.getBoundingClientRect) {
      var r = t.getBoundingClientRect();
      return [n.clientX - r.left - t.clientLeft, n.clientY - r.top - t.clientTop];
    }
  }
  return [n.pageX, n.pageY];
}
const dO = { passive: !1 }, _c = { capture: !0, passive: !1 };
function Mm(n) {
  n.stopImmediatePropagation();
}
function Fo(n) {
  n.preventDefault(), n.stopImmediatePropagation();
}
function c1(n) {
  var t = n.document.documentElement, e = Si(n).on("dragstart.drag", Fo, _c);
  "onselectstart" in t ? e.on("selectstart.drag", Fo, _c) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function u1(n, t) {
  var e = n.document.documentElement, s = Si(n).on("dragstart.drag", null);
  t && (s.on("click.drag", Fo, _c), setTimeout(function() {
    s.on("click.drag", null);
  }, 0)), "onselectstart" in e ? s.on("selectstart.drag", null) : (e.style.MozUserSelect = e.__noselect, delete e.__noselect);
}
const Tf = (n) => () => n;
function Dg(n, {
  sourceEvent: t,
  subject: e,
  target: s,
  identifier: r,
  active: l,
  x: c,
  y: f,
  dx: d,
  dy: h,
  dispatch: m
}) {
  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: s, enumerable: !0, configurable: !0 },
    identifier: { value: r, enumerable: !0, configurable: !0 },
    active: { value: l, enumerable: !0, configurable: !0 },
    x: { value: c, enumerable: !0, configurable: !0 },
    y: { value: f, enumerable: !0, configurable: !0 },
    dx: { value: d, enumerable: !0, configurable: !0 },
    dy: { value: h, enumerable: !0, configurable: !0 },
    _: { value: m }
  });
}
Dg.prototype.on = function() {
  var n = this._.on.apply(this._, arguments);
  return n === this._ ? this : n;
};
function hO(n) {
  return !n.ctrlKey && !n.button;
}
function pO() {
  return this.parentNode;
}
function mO(n, t) {
  return t ?? { x: n.x, y: n.y };
}
function gO() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function f1() {
  var n = hO, t = pO, e = mO, s = gO, r = {}, l = _d("start", "drag", "end"), c = 0, f, d, h, m, p = 0;
  function _(E) {
    E.on("mousedown.drag", x).filter(s).on("touchstart.drag", S).on("touchmove.drag", y, dO).on("touchend.drag touchcancel.drag", C).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  function x(E, O) {
    if (!(m || !n.call(this, E, O))) {
      var N = T(this, t.call(this, E, O), E, O, "mouse");
      N && (Si(E.view).on("mousemove.drag", b, _c).on("mouseup.drag", M, _c), c1(E.view), Mm(E), h = !1, f = E.clientX, d = E.clientY, N("start", E));
    }
  }
  function b(E) {
    if (Fo(E), !h) {
      var O = E.clientX - f, N = E.clientY - d;
      h = O * O + N * N > p;
    }
    r.mouse("drag", E);
  }
  function M(E) {
    Si(E.view).on("mousemove.drag mouseup.drag", null), u1(E.view, h), Fo(E), r.mouse("end", E);
  }
  function S(E, O) {
    if (n.call(this, E, O)) {
      var N = E.changedTouches, D = t.call(this, E, O), z = N.length, A, R;
      for (A = 0; A < z; ++A)
        (R = T(this, D, E, O, N[A].identifier, N[A])) && (Mm(E), R("start", E, N[A]));
    }
  }
  function y(E) {
    var O = E.changedTouches, N = O.length, D, z;
    for (D = 0; D < N; ++D)
      (z = r[O[D].identifier]) && (Fo(E), z("drag", E, O[D]));
  }
  function C(E) {
    var O = E.changedTouches, N = O.length, D, z;
    for (m && clearTimeout(m), m = setTimeout(function() {
      m = null;
    }, 500), D = 0; D < N; ++D)
      (z = r[O[D].identifier]) && (Mm(E), z("end", E, O[D]));
  }
  function T(E, O, N, D, z, A) {
    var R = l.copy(), L = Xi(A || N, O), H, k, P;
    if ((P = e.call(E, new Dg("beforestart", {
      sourceEvent: N,
      target: _,
      identifier: z,
      active: c,
      x: L[0],
      y: L[1],
      dx: 0,
      dy: 0,
      dispatch: R
    }), D)) != null)
      return H = P.x - L[0] || 0, k = P.y - L[1] || 0, function Y(U, X, V) {
        var W = L, J;
        switch (U) {
          case "start":
            r[z] = Y, J = c++;
            break;
          case "end":
            delete r[z], --c;
          // falls through
          case "drag":
            L = Xi(V || X, O), J = c;
            break;
        }
        R.call(
          U,
          E,
          new Dg(U, {
            sourceEvent: X,
            subject: P,
            target: _,
            identifier: z,
            active: J,
            x: L[0] + H,
            y: L[1] + k,
            dx: L[0] - W[0],
            dy: L[1] - W[1],
            dispatch: R
          }),
          D
        );
      };
  }
  return _.filter = function(E) {
    return arguments.length ? (n = typeof E == "function" ? E : Tf(!!E), _) : n;
  }, _.container = function(E) {
    return arguments.length ? (t = typeof E == "function" ? E : Tf(E), _) : t;
  }, _.subject = function(E) {
    return arguments.length ? (e = typeof E == "function" ? E : Tf(E), _) : e;
  }, _.touchable = function(E) {
    return arguments.length ? (s = typeof E == "function" ? E : Tf(!!E), _) : s;
  }, _.on = function() {
    var E = l.on.apply(l, arguments);
    return E === l ? _ : E;
  }, _.clickDistance = function(E) {
    return arguments.length ? (p = (E = +E) * E, _) : Math.sqrt(p);
  }, _;
}
function u0(n, t, e) {
  n.prototype = t.prototype = e, e.constructor = n;
}
function d1(n, t) {
  var e = Object.create(n.prototype);
  for (var s in t) e[s] = t[s];
  return e;
}
function Uc() {
}
var vc = 0.7, id = 1 / vc, Ho = "\\s*([+-]?\\d+)\\s*", yc = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", ss = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", _O = /^#([0-9a-f]{3,8})$/, vO = new RegExp(`^rgb\\(${Ho},${Ho},${Ho}\\)$`), yO = new RegExp(`^rgb\\(${ss},${ss},${ss}\\)$`), xO = new RegExp(`^rgba\\(${Ho},${Ho},${Ho},${yc}\\)$`), SO = new RegExp(`^rgba\\(${ss},${ss},${ss},${yc}\\)$`), bO = new RegExp(`^hsl\\(${yc},${ss},${ss}\\)$`), MO = new RegExp(`^hsla\\(${yc},${ss},${ss},${yc}\\)$`), FS = {
  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
};
u0(Uc, yr, {
  copy(n) {
    return Object.assign(new this.constructor(), this, n);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: HS,
  // Deprecated! Use color.formatHex.
  formatHex: HS,
  formatHex8: EO,
  formatHsl: TO,
  formatRgb: VS,
  toString: VS
});
function HS() {
  return this.rgb().formatHex();
}
function EO() {
  return this.rgb().formatHex8();
}
function TO() {
  return h1(this).formatHsl();
}
function VS() {
  return this.rgb().formatRgb();
}
function yr(n) {
  var t, e;
  return n = (n + "").trim().toLowerCase(), (t = _O.exec(n)) ? (e = t[1].length, t = parseInt(t[1], 16), e === 6 ? GS(t) : e === 3 ? new oi(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : e === 8 ? Af(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : e === 4 ? Af(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 = vO.exec(n)) ? new oi(t[1], t[2], t[3], 1) : (t = yO.exec(n)) ? new oi(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = xO.exec(n)) ? Af(t[1], t[2], t[3], t[4]) : (t = SO.exec(n)) ? Af(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = bO.exec(n)) ? WS(t[1], t[2] / 100, t[3] / 100, 1) : (t = MO.exec(n)) ? WS(t[1], t[2] / 100, t[3] / 100, t[4]) : FS.hasOwnProperty(n) ? GS(FS[n]) : n === "transparent" ? new oi(NaN, NaN, NaN, 0) : null;
}
function GS(n) {
  return new oi(n >> 16 & 255, n >> 8 & 255, n & 255, 1);
}
function Af(n, t, e, s) {
  return s <= 0 && (n = t = e = NaN), new oi(n, t, e, s);
}
function AO(n) {
  return n instanceof Uc || (n = yr(n)), n ? (n = n.rgb(), new oi(n.r, n.g, n.b, n.opacity)) : new oi();
}
function Ng(n, t, e, s) {
  return arguments.length === 1 ? AO(n) : new oi(n, t, e, s ?? 1);
}
function oi(n, t, e, s) {
  this.r = +n, this.g = +t, this.b = +e, this.opacity = +s;
}
u0(oi, Ng, d1(Uc, {
  brighter(n) {
    return n = n == null ? id : Math.pow(id, n), new oi(this.r * n, this.g * n, this.b * n, this.opacity);
  },
  darker(n) {
    return n = n == null ? vc : Math.pow(vc, n), new oi(this.r * n, this.g * n, this.b * n, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new oi(mr(this.r), mr(this.g), mr(this.b), sd(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: kS,
  // Deprecated! Use color.formatHex.
  formatHex: kS,
  formatHex8: wO,
  formatRgb: XS,
  toString: XS
}));
function kS() {
  return `#${pr(this.r)}${pr(this.g)}${pr(this.b)}`;
}
function wO() {
  return `#${pr(this.r)}${pr(this.g)}${pr(this.b)}${pr((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function XS() {
  const n = sd(this.opacity);
  return `${n === 1 ? "rgb(" : "rgba("}${mr(this.r)}, ${mr(this.g)}, ${mr(this.b)}${n === 1 ? ")" : `, ${n})`}`;
}
function sd(n) {
  return isNaN(n) ? 1 : Math.max(0, Math.min(1, n));
}
function mr(n) {
  return Math.max(0, Math.min(255, Math.round(n) || 0));
}
function pr(n) {
  return n = mr(n), (n < 16 ? "0" : "") + n.toString(16);
}
function WS(n, t, e, s) {
  return s <= 0 ? n = t = e = NaN : e <= 0 || e >= 1 ? n = t = NaN : t <= 0 && (n = NaN), new Wi(n, t, e, s);
}
function h1(n) {
  if (n instanceof Wi) return new Wi(n.h, n.s, n.l, n.opacity);
  if (n instanceof Uc || (n = yr(n)), !n) return new Wi();
  if (n instanceof Wi) return n;
  n = n.rgb();
  var t = n.r / 255, e = n.g / 255, s = n.b / 255, r = Math.min(t, e, s), l = Math.max(t, e, s), c = NaN, f = l - r, d = (l + r) / 2;
  return f ? (t === l ? c = (e - s) / f + (e < s) * 6 : e === l ? c = (s - t) / f + 2 : c = (t - e) / f + 4, f /= d < 0.5 ? l + r : 2 - l - r, c *= 60) : f = d > 0 && d < 1 ? 0 : c, new Wi(c, f, d, n.opacity);
}
function CO(n, t, e, s) {
  return arguments.length === 1 ? h1(n) : new Wi(n, t, e, s ?? 1);
}
function Wi(n, t, e, s) {
  this.h = +n, this.s = +t, this.l = +e, this.opacity = +s;
}
u0(Wi, CO, d1(Uc, {
  brighter(n) {
    return n = n == null ? id : Math.pow(id, n), new Wi(this.h, this.s, this.l * n, this.opacity);
  },
  darker(n) {
    return n = n == null ? vc : Math.pow(vc, n), new Wi(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, s = e + (e < 0.5 ? e : 1 - e) * t, r = 2 * e - s;
    return new oi(
      Em(n >= 240 ? n - 240 : n + 120, r, s),
      Em(n, r, s),
      Em(n < 120 ? n + 240 : n - 120, r, s),
      this.opacity
    );
  },
  clamp() {
    return new Wi(YS(this.h), wf(this.s), wf(this.l), sd(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 = sd(this.opacity);
    return `${n === 1 ? "hsl(" : "hsla("}${YS(this.h)}, ${wf(this.s) * 100}%, ${wf(this.l) * 100}%${n === 1 ? ")" : `, ${n})`}`;
  }
}));
function YS(n) {
  return n = (n || 0) % 360, n < 0 ? n + 360 : n;
}
function wf(n) {
  return Math.max(0, Math.min(1, n || 0));
}
function Em(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 RO(n, t) {
  return function(e) {
    return n + e * t;
  };
}
function DO(n, t, e) {
  return n = Math.pow(n, e), t = Math.pow(t, e) - n, e = 1 / e, function(s) {
    return Math.pow(n + s * t, e);
  };
}
function NO(n) {
  return (n = +n) == 1 ? p1 : function(t, e) {
    return e - t ? DO(t, e, n) : f0(isNaN(t) ? e : t);
  };
}
function p1(n, t) {
  var e = t - n;
  return e ? RO(n, e) : f0(isNaN(n) ? t : n);
}
const ad = (function n(t) {
  var e = NO(t);
  function s(r, l) {
    var c = e((r = Ng(r)).r, (l = Ng(l)).r), f = e(r.g, l.g), d = e(r.b, l.b), h = p1(r.opacity, l.opacity);
    return function(m) {
      return r.r = c(m), r.g = f(m), r.b = d(m), r.opacity = h(m), r + "";
    };
  }
  return s.gamma = n, s;
})(1);
function LO(n, t) {
  t || (t = []);
  var e = n ? Math.min(t.length, n.length) : 0, s = t.slice(), r;
  return function(l) {
    for (r = 0; r < e; ++r) s[r] = n[r] * (1 - l) + t[r] * l;
    return s;
  };
}
function UO(n) {
  return ArrayBuffer.isView(n) && !(n instanceof DataView);
}
function OO(n, t) {
  var e = t ? t.length : 0, s = n ? Math.min(e, n.length) : 0, r = new Array(s), l = new Array(e), c;
  for (c = 0; c < s; ++c) r[c] = dc(n[c], t[c]);
  for (; c < e; ++c) l[c] = t[c];
  return function(f) {
    for (c = 0; c < s; ++c) l[c] = r[c](f);
    return l;
  };
}
function PO(n, t) {
  var e = /* @__PURE__ */ new Date();
  return n = +n, t = +t, function(s) {
    return e.setTime(n * (1 - s) + t * s), e;
  };
}
function ts(n, t) {
  return n = +n, t = +t, function(e) {
    return n * (1 - e) + t * e;
  };
}
function zO(n, t) {
  var e = {}, s = {}, r;
  (n === null || typeof n != "object") && (n = {}), (t === null || typeof t != "object") && (t = {});
  for (r in t)
    r in n ? e[r] = dc(n[r], t[r]) : s[r] = t[r];
  return function(l) {
    for (r in e) s[r] = e[r](l);
    return s;
  };
}
var Lg = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Tm = new RegExp(Lg.source, "g");
function IO(n) {
  return function() {
    return n;
  };
}
function BO(n) {
  return function(t) {
    return n(t) + "";
  };
}
function m1(n, t) {
  var e = Lg.lastIndex = Tm.lastIndex = 0, s, r, l, c = -1, f = [], d = [];
  for (n = n + "", t = t + ""; (s = Lg.exec(n)) && (r = Tm.exec(t)); )
    (l = r.index) > e && (l = t.slice(e, l), f[c] ? f[c] += l : f[++c] = l), (s = s[0]) === (r = r[0]) ? f[c] ? f[c] += r : f[++c] = r : (f[++c] = null, d.push({ i: c, x: ts(s, r) })), e = Tm.lastIndex;
  return e < t.length && (l = t.slice(e), f[c] ? f[c] += l : f[++c] = l), f.length < 2 ? d[0] ? BO(d[0].x) : IO(t) : (t = d.length, function(h) {
    for (var m = 0, p; m < t; ++m) f[(p = d[m]).i] = p.x(h);
    return f.join("");
  });
}
function dc(n, t) {
  var e = typeof t, s;
  return t == null || e === "boolean" ? f0(t) : (e === "number" ? ts : e === "string" ? (s = yr(t)) ? (t = s, ad) : m1 : t instanceof yr ? ad : t instanceof Date ? PO : UO(t) ? LO : Array.isArray(t) ? OO : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? zO : ts)(n, t);
}
var jS = 180 / Math.PI, Ug = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function g1(n, t, e, s, r, l) {
  var c, f, d;
  return (c = Math.sqrt(n * n + t * t)) && (n /= c, t /= c), (d = n * e + t * s) && (e -= n * d, s -= t * d), (f = Math.sqrt(e * e + s * s)) && (e /= f, s /= f, d /= f), n * s < t * e && (n = -n, t = -t, d = -d, c = -c), {
    translateX: r,
    translateY: l,
    rotate: Math.atan2(t, n) * jS,
    skewX: Math.atan(d) * jS,
    scaleX: c,
    scaleY: f
  };
}
var Cf;
function FO(n) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(n + "");
  return t.isIdentity ? Ug : g1(t.a, t.b, t.c, t.d, t.e, t.f);
}
function HO(n) {
  return n == null || (Cf || (Cf = document.createElementNS("http://www.w3.org/2000/svg", "g")), Cf.setAttribute("transform", n), !(n = Cf.transform.baseVal.consolidate())) ? Ug : (n = n.matrix, g1(n.a, n.b, n.c, n.d, n.e, n.f));
}
function _1(n, t, e, s) {
  function r(h) {
    return h.length ? h.pop() + " " : "";
  }
  function l(h, m, p, _, x, b) {
    if (h !== p || m !== _) {
      var M = x.push("translate(", null, t, null, e);
      b.push({ i: M - 4, x: ts(h, p) }, { i: M - 2, x: ts(m, _) });
    } else (p || _) && x.push("translate(" + p + t + _ + e);
  }
  function c(h, m, p, _) {
    h !== m ? (h - m > 180 ? m += 360 : m - h > 180 && (h += 360), _.push({ i: p.push(r(p) + "rotate(", null, s) - 2, x: ts(h, m) })) : m && p.push(r(p) + "rotate(" + m + s);
  }
  function f(h, m, p, _) {
    h !== m ? _.push({ i: p.push(r(p) + "skewX(", null, s) - 2, x: ts(h, m) }) : m && p.push(r(p) + "skewX(" + m + s);
  }
  function d(h, m, p, _, x, b) {
    if (h !== p || m !== _) {
      var M = x.push(r(x) + "scale(", null, ",", null, ")");
      b.push({ i: M - 4, x: ts(h, p) }, { i: M - 2, x: ts(m, _) });
    } else (p !== 1 || _ !== 1) && x.push(r(x) + "scale(" + p + "," + _ + ")");
  }
  return function(h, m) {
    var p = [], _ = [];
    return h = n(h), m = n(m), l(h.translateX, h.translateY, m.translateX, m.translateY, p, _), c(h.rotate, m.rotate, p, _), f(h.skewX, m.skewX, p, _), d(h.scaleX, h.scaleY, m.scaleX, m.scaleY, p, _), h = m = null, function(x) {
      for (var b = -1, M = _.length, S; ++b < M; ) p[(S = _[b]).i] = S.x(x);
      return p.join("");
    };
  };
}
var VO = _1(FO, "px, ", "px)", "deg)"), GO = _1(HO, ", ", ")", ")"), kO = 1e-12;
function qS(n) {
  return ((n = Math.exp(n)) + 1 / n) / 2;
}
function XO(n) {
  return ((n = Math.exp(n)) - 1 / n) / 2;
}
function WO(n) {
  return ((n = Math.exp(2 * n)) - 1) / (n + 1);
}
const Xf = (function n(t, e, s) {
  function r(l, c) {
    var f = l[0], d = l[1], h = l[2], m = c[0], p = c[1], _ = c[2], x = m - f, b = p - d, M = x * x + b * b, S, y;
    if (M < kO)
      y = Math.log(_ / h) / t, S = function(D) {
        return [
          f + D * x,
          d + D * b,
          h * Math.exp(t * D * y)
        ];
      };
    else {
      var C = Math.sqrt(M), T = (_ * _ - h * h + s * M) / (2 * h * e * C), E = (_ * _ - h * h - s * M) / (2 * _ * e * C), O = Math.log(Math.sqrt(T * T + 1) - T), N = Math.log(Math.sqrt(E * E + 1) - E);
      y = (N - O) / t, S = function(D) {
        var z = D * y, A = qS(O), R = h / (e * C) * (A * WO(t * z + O) - XO(O));
        return [
          f + R * x,
          d + R * b,
          h * A / qS(t * z + O)
        ];
      };
    }
    return S.duration = y * 1e3 * t / Math.SQRT2, S;
  }
  return r.rho = function(l) {
    var c = Math.max(1e-3, +l), f = c * c, d = f * f;
    return n(c, f, d);
  }, r;
})(Math.SQRT2, 2, 4);
var Zo = 0, uc = 0, ac = 0, v1 = 1e3, rd, fc, od = 0, xr = 0, yd = 0, xc = typeof performance == "object" && performance.now ? performance : Date, y1 = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(n) {
  setTimeout(n, 17);
};
function d0() {
  return xr || (y1(YO), xr = xc.now() + yd);
}
function YO() {
  xr = 0;
}
function ld() {
  this._call = this._time = this._next = null;
}
ld.prototype = x1.prototype = {
  constructor: ld,
  restart: function(n, t, e) {
    if (typeof n != "function") throw new TypeError("callback is not a function");
    e = (e == null ? d0() : +e) + (t == null ? 0 : +t), !this._next && fc !== this && (fc ? fc._next = this : rd = this, fc = this), this._call = n, this._time = e, Og();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, Og());
  }
};
function x1(n, t, e) {
  var s = new ld();
  return s.restart(n, t, e), s;
}
function jO() {
  d0(), ++Zo;
  for (var n = rd, t; n; )
    (t = xr - n._time) >= 0 && n._call.call(void 0, t), n = n._next;
  --Zo;
}
function ZS() {
  xr = (od = xc.now()) + yd, Zo = uc = 0;
  try {
    jO();
  } finally {
    Zo = 0, ZO(), xr = 0;
  }
}
function qO() {
  var n = xc.now(), t = n - od;
  t > v1 && (yd -= t, od = n);
}
function ZO() {
  for (var n, t = rd, e, s = 1 / 0; t; )
    t._call ? (s > t._time && (s = t._time), n = t, t = t._next) : (e = t._next, t._next = null, t = n ? n._next = e : rd = e);
  fc = n, Og(s);
}
function Og(n) {
  if (!Zo) {
    uc && (uc = clearTimeout(uc));
    var t = n - xr;
    t > 24 ? (n < 1 / 0 && (uc = setTimeout(ZS, n - xc.now() - yd)), ac && (ac = clearInterval(ac))) : (ac || (od = xc.now(), ac = setInterval(qO, v1)), Zo = 1, y1(ZS));
  }
}
function KS(n, t, e) {
  var s = new ld();
  return t = t == null ? 0 : +t, s.restart((r) => {
    s.stop(), n(r + t);
  }, t, e), s;
}
var KO = _d("start", "end", "cancel", "interrupt"), $O = [], S1 = 0, $S = 1, Pg = 2, Wf = 3, QS = 4, zg = 5, Yf = 6;
function xd(n, t, e, s, r, l) {
  var c = n.__transition;
  if (!c) n.__transition = {};
  else if (e in c) return;
  QO(n, e, {
    name: t,
    index: s,
    // For context during callback.
    group: r,
    // For context during callback.
    on: KO,
    tween: $O,
    time: l.time,
    delay: l.delay,
    duration: l.duration,
    ease: l.ease,
    timer: null,
    state: S1
  });
}
function h0(n, t) {
  var e = qi(n, t);
  if (e.state > S1) throw new Error("too late; already scheduled");
  return e;
}
function os(n, t) {
  var e = qi(n, t);
  if (e.state > Wf) throw new Error("too late; already running");
  return e;
}
function qi(n, t) {
  var e = n.__transition;
  if (!e || !(e = e[t])) throw new Error("transition not found");
  return e;
}
function QO(n, t, e) {
  var s = n.__transition, r;
  s[t] = e, e.timer = x1(l, 0, e.time);
  function l(h) {
    e.state = $S, e.timer.restart(c, e.delay, e.time), e.delay <= h && c(h - e.delay);
  }
  function c(h) {
    var m, p, _, x;
    if (e.state !== $S) return d();
    for (m in s)
      if (x = s[m], x.name === e.name) {
        if (x.state === Wf) return KS(c);
        x.state === QS ? (x.state = Yf, x.timer.stop(), x.on.call("interrupt", n, n.__data__, x.index, x.group), delete s[m]) : +m < t && (x.state = Yf, x.timer.stop(), x.on.call("cancel", n, n.__data__, x.index, x.group), delete s[m]);
      }
    if (KS(function() {
      e.state === Wf && (e.state = QS, e.timer.restart(f, e.delay, e.time), f(h));
    }), e.state = Pg, e.on.call("start", n, n.__data__, e.index, e.group), e.state === Pg) {
      for (e.state = Wf, r = new Array(_ = e.tween.length), m = 0, p = -1; m < _; ++m)
        (x = e.tween[m].value.call(n, n.__data__, e.index, e.group)) && (r[++p] = x);
      r.length = p + 1;
    }
  }
  function f(h) {
    for (var m = h < e.duration ? e.ease.call(null, h / e.duration) : (e.timer.restart(d), e.state = zg, 1), p = -1, _ = r.length; ++p < _; )
      r[p].call(n, m);
    e.state === zg && (e.on.call("end", n, n.__data__, e.index, e.group), d());
  }
  function d() {
    e.state = Yf, e.timer.stop(), delete s[t];
    for (var h in s) return;
    delete n.__transition;
  }
}
function jf(n, t) {
  var e = n.__transition, s, r, l = !0, c;
  if (e) {
    t = t == null ? null : t + "";
    for (c in e) {
      if ((s = e[c]).name !== t) {
        l = !1;
        continue;
      }
      r = s.state > Pg && s.state < zg, s.state = Yf, s.timer.stop(), s.on.call(r ? "interrupt" : "cancel", n, n.__data__, s.index, s.group), delete e[c];
    }
    l && delete n.__transition;
  }
}
function JO(n) {
  return this.each(function() {
    jf(this, n);
  });
}
function tP(n, t) {
  var e, s;
  return function() {
    var r = os(this, n), l = r.tween;
    if (l !== e) {
      s = e = l;
      for (var c = 0, f = s.length; c < f; ++c)
        if (s[c].name === t) {
          s = s.slice(), s.splice(c, 1);
          break;
        }
    }
    r.tween = s;
  };
}
function eP(n, t, e) {
  var s, r;
  if (typeof e != "function") throw new Error();
  return function() {
    var l = os(this, n), c = l.tween;
    if (c !== s) {
      r = (s = c).slice();
      for (var f = { name: t, value: e }, d = 0, h = r.length; d < h; ++d)
        if (r[d].name === t) {
          r[d] = f;
          break;
        }
      d === h && r.push(f);
    }
    l.tween = r;
  };
}
function nP(n, t) {
  var e = this._id;
  if (n += "", arguments.length < 2) {
    for (var s = qi(this.node(), e).tween, r = 0, l = s.length, c; r < l; ++r)
      if ((c = s[r]).name === n)
        return c.value;
    return null;
  }
  return this.each((t == null ? tP : eP)(e, n, t));
}
function p0(n, t, e) {
  var s = n._id;
  return n.each(function() {
    var r = os(this, s);
    (r.value || (r.value = {}))[t] = e.apply(this, arguments);
  }), function(r) {
    return qi(r, s).value[t];
  };
}
function b1(n, t) {
  var e;
  return (typeof t == "number" ? ts : t instanceof yr ? ad : (e = yr(t)) ? (t = e, ad) : m1)(n, t);
}
function iP(n) {
  return function() {
    this.removeAttribute(n);
  };
}
function sP(n) {
  return function() {
    this.removeAttributeNS(n.space, n.local);
  };
}
function aP(n, t, e) {
  var s, r = e + "", l;
  return function() {
    var c = this.getAttribute(n);
    return c === r ? null : c === s ? l : l = t(s = c, e);
  };
}
function rP(n, t, e) {
  var s, r = e + "", l;
  return function() {
    var c = this.getAttributeNS(n.space, n.local);
    return c === r ? null : c === s ? l : l = t(s = c, e);
  };
}
function oP(n, t, e) {
  var s, r, l;
  return function() {
    var c, f = e(this), d;
    return f == null ? void this.removeAttribute(n) : (c = this.getAttribute(n), d = f + "", c === d ? null : c === s && d === r ? l : (r = d, l = t(s = c, f)));
  };
}
function lP(n, t, e) {
  var s, r, l;
  return function() {
    var c, f = e(this), d;
    return f == null ? void this.removeAttributeNS(n.space, n.local) : (c = this.getAttributeNS(n.space, n.local), d = f + "", c === d ? null : c === s && d === r ? l : (r = d, l = t(s = c, f)));
  };
}
function cP(n, t) {
  var e = vd(n), s = e === "transform" ? GO : b1;
  return this.attrTween(n, typeof t == "function" ? (e.local ? lP : oP)(e, s, p0(this, "attr." + n, t)) : t == null ? (e.local ? sP : iP)(e) : (e.local ? rP : aP)(e, s, t));
}
function uP(n, t) {
  return function(e) {
    this.setAttribute(n, t.call(this, e));
  };
}
function fP(n, t) {
  return function(e) {
    this.setAttributeNS(n.space, n.local, t.call(this, e));
  };
}
function dP(n, t) {
  var e, s;
  function r() {
    var l = t.apply(this, arguments);
    return l !== s && (e = (s = l) && fP(n, l)), e;
  }
  return r._value = t, r;
}
function hP(n, t) {
  var e, s;
  function r() {
    var l = t.apply(this, arguments);
    return l !== s && (e = (s = l) && uP(n, l)), e;
  }
  return r._value = t, r;
}
function pP(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 s = vd(n);
  return this.tween(e, (s.local ? dP : hP)(s, t));
}
function mP(n, t) {
  return function() {
    h0(this, n).delay = +t.apply(this, arguments);
  };
}
function gP(n, t) {
  return t = +t, function() {
    h0(this, n).delay = t;
  };
}
function _P(n) {
  var t = this._id;
  return arguments.length ? this.each((typeof n == "function" ? mP : gP)(t, n)) : qi(this.node(), t).delay;
}
function vP(n, t) {
  return function() {
    os(this, n).duration = +t.apply(this, arguments);
  };
}
function yP(n, t) {
  return t = +t, function() {
    os(this, n).duration = t;
  };
}
function xP(n) {
  var t = this._id;
  return arguments.length ? this.each((typeof n == "function" ? vP : yP)(t, n)) : qi(this.node(), t).duration;
}
function SP(n, t) {
  if (typeof t != "function") throw new Error();
  return function() {
    os(this, n).ease = t;
  };
}
function bP(n) {
  var t = this._id;
  return arguments.length ? this.each(SP(t, n)) : qi(this.node(), t).ease;
}
function MP(n, t) {
  return function() {
    var e = t.apply(this, arguments);
    if (typeof e != "function") throw new Error();
    os(this, n).ease = e;
  };
}
function EP(n) {
  if (typeof n != "function") throw new Error();
  return this.each(MP(this._id, n));
}
function TP(n) {
  typeof n != "function" && (n = JM(n));
  for (var t = this._groups, e = t.length, s = new Array(e), r = 0; r < e; ++r)
    for (var l = t[r], c = l.length, f = s[r] = [], d, h = 0; h < c; ++h)
      (d = l[h]) && n.call(d, d.__data__, h, l) && f.push(d);
  return new Gs(s, this._parents, this._name, this._id);
}
function AP(n) {
  if (n._id !== this._id) throw new Error();
  for (var t = this._groups, e = n._groups, s = t.length, r = e.length, l = Math.min(s, r), c = new Array(s), f = 0; f < l; ++f)
    for (var d = t[f], h = e[f], m = d.length, p = c[f] = new Array(m), _, x = 0; x < m; ++x)
      (_ = d[x] || h[x]) && (p[x] = _);
  for (; f < s; ++f)
    c[f] = t[f];
  return new Gs(c, this._parents, this._name, this._id);
}
function wP(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 CP(n, t, e) {
  var s, r, l = wP(t) ? h0 : os;
  return function() {
    var c = l(this, n), f = c.on;
    f !== s && (r = (s = f).copy()).on(t, e), c.on = r;
  };
}
function RP(n, t) {
  var e = this._id;
  return arguments.length < 2 ? qi(this.node(), e).on.on(n) : this.each(CP(e, n, t));
}
function DP(n) {
  return function() {
    var t = this.parentNode;
    for (var e in this.__transition) if (+e !== n) return;
    t && t.removeChild(this);
  };
}
function NP() {
  return this.on("end.remove", DP(this._id));
}
function LP(n) {
  var t = this._name, e = this._id;
  typeof n != "function" && (n = l0(n));
  for (var s = this._groups, r = s.length, l = new Array(r), c = 0; c < r; ++c)
    for (var f = s[c], d = f.length, h = l[c] = new Array(d), m, p, _ = 0; _ < d; ++_)
      (m = f[_]) && (p = n.call(m, m.__data__, _, f)) && ("__data__" in m && (p.__data__ = m.__data__), h[_] = p, xd(h[_], t, e, _, h, qi(m, e)));
  return new Gs(l, this._parents, t, e);
}
function UP(n) {
  var t = this._name, e = this._id;
  typeof n != "function" && (n = QM(n));
  for (var s = this._groups, r = s.length, l = [], c = [], f = 0; f < r; ++f)
    for (var d = s[f], h = d.length, m, p = 0; p < h; ++p)
      if (m = d[p]) {
        for (var _ = n.call(m, m.__data__, p, d), x, b = qi(m, e), M = 0, S = _.length; M < S; ++M)
          (x = _[M]) && xd(x, t, e, M, _, b);
        l.push(_), c.push(m);
      }
  return new Gs(l, c, t, e);
}
var OP = Lc.prototype.constructor;
function PP() {
  return new OP(this._groups, this._parents);
}
function zP(n, t) {
  var e, s, r;
  return function() {
    var l = qo(this, n), c = (this.style.removeProperty(n), qo(this, n));
    return l === c ? null : l === e && c === s ? r : r = t(e = l, s = c);
  };
}
function M1(n) {
  return function() {
    this.style.removeProperty(n);
  };
}
function IP(n, t, e) {
  var s, r = e + "", l;
  return function() {
    var c = qo(this, n);
    return c === r ? null : c === s ? l : l = t(s = c, e);
  };
}
function BP(n, t, e) {
  var s, r, l;
  return function() {
    var c = qo(this, n), f = e(this), d = f + "";
    return f == null && (d = f = (this.style.removeProperty(n), qo(this, n))), c === d ? null : c === s && d === r ? l : (r = d, l = t(s = c, f));
  };
}
function FP(n, t) {
  var e, s, r, l = "style." + t, c = "end." + l, f;
  return function() {
    var d = os(this, n), h = d.on, m = d.value[l] == null ? f || (f = M1(t)) : void 0;
    (h !== e || r !== m) && (s = (e = h).copy()).on(c, r = m), d.on = s;
  };
}
function HP(n, t, e) {
  var s = (n += "") == "transform" ? VO : b1;
  return t == null ? this.styleTween(n, zP(n, s)).on("end.style." + n, M1(n)) : typeof t == "function" ? this.styleTween(n, BP(n, s, p0(this, "style." + n, t))).each(FP(this._id, n)) : this.styleTween(n, IP(n, s, t), e).on("end.style." + n, null);
}
function VP(n, t, e) {
  return function(s) {
    this.style.setProperty(n, t.call(this, s), e);
  };
}
function GP(n, t, e) {
  var s, r;
  function l() {
    var c = t.apply(this, arguments);
    return c !== r && (s = (r = c) && VP(n, c, e)), s;
  }
  return l._value = t, l;
}
function kP(n, t, e) {
  var s = "style." + (n += "");
  if (arguments.length < 2) return (s = this.tween(s)) && s._value;
  if (t == null) return this.tween(s, null);
  if (typeof t != "function") throw new Error();
  return this.tween(s, GP(n, t, e ?? ""));
}
function XP(n) {
  return function() {
    this.textContent = n;
  };
}
function WP(n) {
  return function() {
    var t = n(this);
    this.textContent = t ?? "";
  };
}
function YP(n) {
  return this.tween("text", typeof n == "function" ? WP(p0(this, "text", n)) : XP(n == null ? "" : n + ""));
}
function jP(n) {
  return function(t) {
    this.textContent = n.call(this, t);
  };
}
function qP(n) {
  var t, e;
  function s() {
    var r = n.apply(this, arguments);
    return r !== e && (t = (e = r) && jP(r)), t;
  }
  return s._value = n, s;
}
function ZP(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, qP(n));
}
function KP() {
  for (var n = this._name, t = this._id, e = E1(), s = this._groups, r = s.length, l = 0; l < r; ++l)
    for (var c = s[l], f = c.length, d, h = 0; h < f; ++h)
      if (d = c[h]) {
        var m = qi(d, t);
        xd(d, n, e, h, c, {
          time: m.time + m.delay + m.duration,
          delay: 0,
          duration: m.duration,
          ease: m.ease
        });
      }
  return new Gs(s, this._parents, n, e);
}
function $P() {
  var n, t, e = this, s = e._id, r = e.size();
  return new Promise(function(l, c) {
    var f = { value: c }, d = { value: function() {
      --r === 0 && l();
    } };
    e.each(function() {
      var h = os(this, s), m = h.on;
      m !== n && (t = (n = m).copy(), t._.cancel.push(f), t._.interrupt.push(f), t._.end.push(d)), h.on = t;
    }), r === 0 && l();
  });
}
var QP = 0;
function Gs(n, t, e, s) {
  this._groups = n, this._parents = t, this._name = e, this._id = s;
}
function E1() {
  return ++QP;
}
var Us = Lc.prototype;
Gs.prototype = {
  constructor: Gs,
  select: LP,
  selectAll: UP,
  selectChild: Us.selectChild,
  selectChildren: Us.selectChildren,
  filter: TP,
  merge: AP,
  selection: PP,
  transition: KP,
  call: Us.call,
  nodes: Us.nodes,
  node: Us.node,
  size: Us.size,
  empty: Us.empty,
  each: Us.each,
  on: RP,
  attr: cP,
  attrTween: pP,
  style: HP,
  styleTween: kP,
  text: YP,
  textTween: ZP,
  remove: NP,
  tween: nP,
  delay: _P,
  duration: xP,
  ease: bP,
  easeVarying: EP,
  end: $P,
  [Symbol.iterator]: Us[Symbol.iterator]
};
function JP(n) {
  return ((n *= 2) <= 1 ? n * n * n : (n -= 2) * n * n + 2) / 2;
}
var tz = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: JP
};
function ez(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 nz(n) {
  var t, e;
  n instanceof Gs ? (t = n._id, n = n._name) : (t = E1(), (e = tz).time = d0(), n = n == null ? null : n + "");
  for (var s = this._groups, r = s.length, l = 0; l < r; ++l)
    for (var c = s[l], f = c.length, d, h = 0; h < f; ++h)
      (d = c[h]) && xd(d, n, t, h, c, e || ez(d, t));
  return new Gs(s, this._parents, n, t);
}
Lc.prototype.interrupt = JO;
Lc.prototype.transition = nz;
const Rf = (n) => () => n;
function iz(n, {
  sourceEvent: t,
  target: e,
  transform: s,
  dispatch: r
}) {
  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: s, enumerable: !0, configurable: !0 },
    _: { value: r }
  });
}
function Is(n, t, e) {
  this.k = n, this.x = t, this.y = e;
}
Is.prototype = {
  constructor: Is,
  scale: function(n) {
    return n === 1 ? this : new Is(this.k * n, this.x, this.y);
  },
  translate: function(n, t) {
    return n === 0 & t === 0 ? this : new Is(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 Sd = new Is(1, 0, 0);
T1.prototype = Is.prototype;
function T1(n) {
  for (; !n.__zoom; ) if (!(n = n.parentNode)) return Sd;
  return n.__zoom;
}
function Am(n) {
  n.stopImmediatePropagation();
}
function rc(n) {
  n.preventDefault(), n.stopImmediatePropagation();
}
function sz(n) {
  return (!n.ctrlKey || n.type === "wheel") && !n.button;
}
function az() {
  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 JS() {
  return this.__zoom || Sd;
}
function rz(n) {
  return -n.deltaY * (n.deltaMode === 1 ? 0.05 : n.deltaMode ? 1 : 2e-3) * (n.ctrlKey ? 10 : 1);
}
function oz() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function lz(n, t, e) {
  var s = n.invertX(t[0][0]) - e[0][0], r = n.invertX(t[1][0]) - e[1][0], l = n.invertY(t[0][1]) - e[0][1], c = n.invertY(t[1][1]) - e[1][1];
  return n.translate(
    r > s ? (s + r) / 2 : Math.min(0, s) || Math.max(0, r),
    c > l ? (l + c) / 2 : Math.min(0, l) || Math.max(0, c)
  );
}
function A1() {
  var n = sz, t = az, e = lz, s = rz, r = oz, l = [0, 1 / 0], c = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], f = 250, d = Xf, h = _d("start", "zoom", "end"), m, p, _, x = 500, b = 150, M = 0, S = 10;
  function y(P) {
    P.property("__zoom", JS).on("wheel.zoom", z, { passive: !1 }).on("mousedown.zoom", A).on("dblclick.zoom", R).filter(r).on("touchstart.zoom", L).on("touchmove.zoom", H).on("touchend.zoom touchcancel.zoom", k).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  y.transform = function(P, Y, U, X) {
    var V = P.selection ? P.selection() : P;
    V.property("__zoom", JS), P !== V ? O(P, Y, U, X) : V.interrupt().each(function() {
      N(this, arguments).event(X).start().zoom(null, typeof Y == "function" ? Y.apply(this, arguments) : Y).end();
    });
  }, y.scaleBy = function(P, Y, U, X) {
    y.scaleTo(P, function() {
      var V = this.__zoom.k, W = typeof Y == "function" ? Y.apply(this, arguments) : Y;
      return V * W;
    }, U, X);
  }, y.scaleTo = function(P, Y, U, X) {
    y.transform(P, function() {
      var V = t.apply(this, arguments), W = this.__zoom, J = U == null ? E(V) : typeof U == "function" ? U.apply(this, arguments) : U, I = W.invert(J), q = typeof Y == "function" ? Y.apply(this, arguments) : Y;
      return e(T(C(W, q), J, I), V, c);
    }, U, X);
  }, y.translateBy = function(P, Y, U, X) {
    y.transform(P, function() {
      return e(this.__zoom.translate(
        typeof Y == "function" ? Y.apply(this, arguments) : Y,
        typeof U == "function" ? U.apply(this, arguments) : U
      ), t.apply(this, arguments), c);
    }, null, X);
  }, y.translateTo = function(P, Y, U, X, V) {
    y.transform(P, function() {
      var W = t.apply(this, arguments), J = this.__zoom, I = X == null ? E(W) : typeof X == "function" ? X.apply(this, arguments) : X;
      return e(Sd.translate(I[0], I[1]).scale(J.k).translate(
        typeof Y == "function" ? -Y.apply(this, arguments) : -Y,
        typeof U == "function" ? -U.apply(this, arguments) : -U
      ), W, c);
    }, X, V);
  };
  function C(P, Y) {
    return Y = Math.max(l[0], Math.min(l[1], Y)), Y === P.k ? P : new Is(Y, P.x, P.y);
  }
  function T(P, Y, U) {
    var X = Y[0] - U[0] * P.k, V = Y[1] - U[1] * P.k;
    return X === P.x && V === P.y ? P : new Is(P.k, X, V);
  }
  function E(P) {
    return [(+P[0][0] + +P[1][0]) / 2, (+P[0][1] + +P[1][1]) / 2];
  }
  function O(P, Y, U, X) {
    P.on("start.zoom", function() {
      N(this, arguments).event(X).start();
    }).on("interrupt.zoom end.zoom", function() {
      N(this, arguments).event(X).end();
    }).tween("zoom", function() {
      var V = this, W = arguments, J = N(V, W).event(X), I = t.apply(V, W), q = U == null ? E(I) : typeof U == "function" ? U.apply(V, W) : U, lt = Math.max(I[1][0] - I[0][0], I[1][1] - I[0][1]), $ = V.__zoom, ot = typeof Y == "function" ? Y.apply(V, W) : Y, gt = d($.invert(q).concat(lt / $.k), ot.invert(q).concat(lt / ot.k));
      return function(ht) {
        if (ht === 1) ht = ot;
        else {
          var _t = gt(ht), Et = lt / _t[2];
          ht = new Is(Et, q[0] - _t[0] * Et, q[1] - _t[1] * Et);
        }
        J.zoom(null, ht);
      };
    });
  }
  function N(P, Y, U) {
    return !U && P.__zooming || new D(P, Y);
  }
  function D(P, Y) {
    this.that = P, this.args = Y, this.active = 0, this.sourceEvent = null, this.extent = t.apply(P, Y), this.taps = 0;
  }
  D.prototype = {
    event: function(P) {
      return P && (this.sourceEvent = P), this;
    },
    start: function() {
      return ++this.active === 1 && (this.that.__zooming = this, this.emit("start")), this;
    },
    zoom: function(P, Y) {
      return this.mouse && P !== "mouse" && (this.mouse[1] = Y.invert(this.mouse[0])), this.touch0 && P !== "touch" && (this.touch0[1] = Y.invert(this.touch0[0])), this.touch1 && P !== "touch" && (this.touch1[1] = Y.invert(this.touch1[0])), this.that.__zoom = Y, this.emit("zoom"), this;
    },
    end: function() {
      return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
    },
    emit: function(P) {
      var Y = Si(this.that).datum();
      h.call(
        P,
        this.that,
        new iz(P, {
          sourceEvent: this.sourceEvent,
          target: y,
          transform: this.that.__zoom,
          dispatch: h
        }),
        Y
      );
    }
  };
  function z(P, ...Y) {
    if (!n.apply(this, arguments)) return;
    var U = N(this, Y).event(P), X = this.__zoom, V = Math.max(l[0], Math.min(l[1], X.k * Math.pow(2, s.apply(this, arguments)))), W = Xi(P);
    if (U.wheel)
      (U.mouse[0][0] !== W[0] || U.mouse[0][1] !== W[1]) && (U.mouse[1] = X.invert(U.mouse[0] = W)), clearTimeout(U.wheel);
    else {
      if (X.k === V) return;
      U.mouse = [W, X.invert(W)], jf(this), U.start();
    }
    rc(P), U.wheel = setTimeout(J, b), U.zoom("mouse", e(T(C(X, V), U.mouse[0], U.mouse[1]), U.extent, c));
    function J() {
      U.wheel = null, U.end();
    }
  }
  function A(P, ...Y) {
    if (_ || !n.apply(this, arguments)) return;
    var U = P.currentTarget, X = N(this, Y, !0).event(P), V = Si(P.view).on("mousemove.zoom", q, !0).on("mouseup.zoom", lt, !0), W = Xi(P, U), J = P.clientX, I = P.clientY;
    c1(P.view), Am(P), X.mouse = [W, this.__zoom.invert(W)], jf(this), X.start();
    function q($) {
      if (rc($), !X.moved) {
        var ot = $.clientX - J, gt = $.clientY - I;
        X.moved = ot * ot + gt * gt > M;
      }
      X.event($).zoom("mouse", e(T(X.that.__zoom, X.mouse[0] = Xi($, U), X.mouse[1]), X.extent, c));
    }
    function lt($) {
      V.on("mousemove.zoom mouseup.zoom", null), u1($.view, X.moved), rc($), X.event($).end();
    }
  }
  function R(P, ...Y) {
    if (n.apply(this, arguments)) {
      var U = this.__zoom, X = Xi(P.changedTouches ? P.changedTouches[0] : P, this), V = U.invert(X), W = U.k * (P.shiftKey ? 0.5 : 2), J = e(T(C(U, W), X, V), t.apply(this, Y), c);
      rc(P), f > 0 ? Si(this).transition().duration(f).call(O, J, X, P) : Si(this).call(y.transform, J, X, P);
    }
  }
  function L(P, ...Y) {
    if (n.apply(this, arguments)) {
      var U = P.touches, X = U.length, V = N(this, Y, P.changedTouches.length === X).event(P), W, J, I, q;
      for (Am(P), J = 0; J < X; ++J)
        I = U[J], q = Xi(I, this), q = [q, this.__zoom.invert(q), I.identifier], V.touch0 ? !V.touch1 && V.touch0[2] !== q[2] && (V.touch1 = q, V.taps = 0) : (V.touch0 = q, W = !0, V.taps = 1 + !!m);
      m && (m = clearTimeout(m)), W && (V.taps < 2 && (p = q[0], m = setTimeout(function() {
        m = null;
      }, x)), jf(this), V.start());
    }
  }
  function H(P, ...Y) {
    if (this.__zooming) {
      var U = N(this, Y).event(P), X = P.changedTouches, V = X.length, W, J, I, q;
      for (rc(P), W = 0; W < V; ++W)
        J = X[W], I = Xi(J, this), U.touch0 && U.touch0[2] === J.identifier ? U.touch0[0] = I : U.touch1 && U.touch1[2] === J.identifier && (U.touch1[0] = I);
      if (J = U.that.__zoom, U.touch1) {
        var lt = U.touch0[0], $ = U.touch0[1], ot = U.touch1[0], gt = U.touch1[1], ht = (ht = ot[0] - lt[0]) * ht + (ht = ot[1] - lt[1]) * ht, _t = (_t = gt[0] - $[0]) * _t + (_t = gt[1] - $[1]) * _t;
        J = C(J, Math.sqrt(ht / _t)), I = [(lt[0] + ot[0]) / 2, (lt[1] + ot[1]) / 2], q = [($[0] + gt[0]) / 2, ($[1] + gt[1]) / 2];
      } else if (U.touch0) I = U.touch0[0], q = U.touch0[1];
      else return;
      U.zoom("touch", e(T(J, I, q), U.extent, c));
    }
  }
  function k(P, ...Y) {
    if (this.__zooming) {
      var U = N(this, Y).event(P), X = P.changedTouches, V = X.length, W, J;
      for (Am(P), _ && clearTimeout(_), _ = setTimeout(function() {
        _ = null;
      }, x), W = 0; W < V; ++W)
        J = X[W], U.touch0 && U.touch0[2] === J.identifier ? delete U.touch0 : U.touch1 && U.touch1[2] === J.identifier && delete U.touch1;
      if (U.touch1 && !U.touch0 && (U.touch0 = U.touch1, delete U.touch1), U.touch0) U.touch0[1] = this.__zoom.invert(U.touch0[0]);
      else if (U.end(), U.taps === 2 && (J = Xi(J, this), Math.hypot(p[0] - J[0], p[1] - J[1]) < S)) {
        var I = Si(this).on("dblclick.zoom");
        I && I.apply(this, arguments);
      }
    }
  }
  return y.wheelDelta = function(P) {
    return arguments.length ? (s = typeof P == "function" ? P : Rf(+P), y) : s;
  }, y.filter = function(P) {
    return arguments.length ? (n = typeof P == "function" ? P : Rf(!!P), y) : n;
  }, y.touchable = function(P) {
    return arguments.length ? (r = typeof P == "function" ? P : Rf(!!P), y) : r;
  }, y.extent = function(P) {
    return arguments.length ? (t = typeof P == "function" ? P : Rf([[+P[0][0], +P[0][1]], [+P[1][0], +P[1][1]]]), y) : t;
  }, y.scaleExtent = function(P) {
    return arguments.length ? (l[0] = +P[0], l[1] = +P[1], y) : [l[0], l[1]];
  }, y.translateExtent = function(P) {
    return arguments.length ? (c[0][0] = +P[0][0], c[1][0] = +P[1][0], c[0][1] = +P[0][1], c[1][1] = +P[1][1], y) : [[c[0][0], c[0][1]], [c[1][0], c[1][1]]];
  }, y.constrain = function(P) {
    return arguments.length ? (e = P, y) : e;
  }, y.duration = function(P) {
    return arguments.length ? (f = +P, y) : f;
  }, y.interpolate = function(P) {
    return arguments.length ? (d = P, y) : d;
  }, y.on = function() {
    var P = h.on.apply(h, arguments);
    return P === h ? y : P;
  }, y.clickDistance = function(P) {
    return arguments.length ? (M = (P = +P) * P, y) : Math.sqrt(M);
  }, y.tapDistance = function(P) {
    return arguments.length ? (S = +P, y) : S;
  }, y;
}
const rs = {
  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: s }) => `Couldn't create edge for ${n} handle id: "${n === "source" ? e : s}", 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."
}, Sc = [
  [Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
  [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]
], w1 = ["Enter", " ", "Escape"], C1 = {
  "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 Ko;
(function(n) {
  n.Strict = "strict", n.Loose = "loose";
})(Ko || (Ko = {}));
var gr;
(function(n) {
  n.Free = "free", n.Vertical = "vertical", n.Horizontal = "horizontal";
})(gr || (gr = {}));
var bc;
(function(n) {
  n.Partial = "partial", n.Full = "full";
})(bc || (bc = {}));
const R1 = {
  inProgress: !1,
  isValid: null,
  from: null,
  fromHandle: null,
  fromPosition: null,
  fromNode: null,
  to: null,
  toHandle: null,
  toPosition: null,
  toNode: null,
  pointer: null
};
var Aa;
(function(n) {
  n.Bezier = "default", n.Straight = "straight", n.Step = "step", n.SmoothStep = "smoothstep", n.SimpleBezier = "simplebezier";
})(Aa || (Aa = {}));
var cd;
(function(n) {
  n.Arrow = "arrow", n.ArrowClosed = "arrowclosed";
})(cd || (cd = {}));
var ne;
(function(n) {
  n.Left = "left", n.Top = "top", n.Right = "right", n.Bottom = "bottom";
})(ne || (ne = {}));
const tb = {
  [ne.Left]: ne.Right,
  [ne.Right]: ne.Left,
  [ne.Top]: ne.Bottom,
  [ne.Bottom]: ne.Top
};
function D1(n) {
  return n === null ? null : n ? "valid" : "invalid";
}
const N1 = (n) => "id" in n && "source" in n && "target" in n, cz = (n) => "id" in n && "position" in n && !("source" in n) && !("target" in n), m0 = (n) => "id" in n && "internals" in n && !("source" in n) && !("target" in n), Oc = (n, t = [0, 0]) => {
  const { width: e, height: s } = ks(n), r = n.origin ?? t, l = e * r[0], c = s * r[1];
  return {
    x: n.position.x - l,
    y: n.position.y - c
  };
}, uz = (n, t = { nodeOrigin: [0, 0] }) => {
  if (n.length === 0)
    return { x: 0, y: 0, width: 0, height: 0 };
  const e = n.reduce((s, r) => {
    const l = typeof r == "string";
    let c = !t.nodeLookup && !l ? r : void 0;
    t.nodeLookup && (c = l ? t.nodeLookup.get(r) : m0(r) ? r : t.nodeLookup.get(r.id));
    const f = c ? ud(c, t.nodeOrigin) : { x: 0, y: 0, x2: 0, y2: 0 };
    return bd(s, f);
  }, { x: 1 / 0, y: 1 / 0, x2: -1 / 0, y2: -1 / 0 });
  return Md(e);
}, Pc = (n, t = {}) => {
  let e = { x: 1 / 0, y: 1 / 0, x2: -1 / 0, y2: -1 / 0 }, s = !1;
  return n.forEach((r) => {
    (t.filter === void 0 || t.filter(r)) && (e = bd(e, ud(r)), s = !0);
  }), s ? Md(e) : { x: 0, y: 0, width: 0, height: 0 };
}, g0 = (n, t, [e, s, r] = [0, 0, 1], l = !1, c = !1) => {
  const f = {
    ...Ic(t, [e, s, r]),
    width: t.width / r,
    height: t.height / r
  }, d = [];
  for (const h of n.values()) {
    const { measured: m, selectable: p = !0, hidden: _ = !1 } = h;
    if (c && !p || _)
      continue;
    const x = m.width ?? h.width ?? h.initialWidth ?? null, b = m.height ?? h.height ?? h.initialHeight ?? null, M = Mc(f, Qo(h)), S = (x ?? 0) * (b ?? 0), y = l && M > 0;
    (!h.internals.handleBounds || y || M >= S || h.dragging) && d.push(h);
  }
  return d;
}, fz = (n, t) => {
  const e = /* @__PURE__ */ new Set();
  return n.forEach((s) => {
    e.add(s.id);
  }), t.filter((s) => e.has(s.source) || e.has(s.target));
};
function dz(n, t) {
  const e = /* @__PURE__ */ new Map(), s = t != null && t.nodes ? new Set(t.nodes.map((r) => r.id)) : null;
  return n.forEach((r) => {
    r.measured.width && r.measured.height && ((t == null ? void 0 : t.includeHiddenNodes) || !r.hidden) && (!s || s.has(r.id)) && e.set(r.id, r);
  }), e;
}
async function hz({ nodes: n, width: t, height: e, panZoom: s, minZoom: r, maxZoom: l }, c) {
  if (n.size === 0)
    return Promise.resolve(!0);
  const f = dz(n, c), d = Pc(f), h = _0(d, t, e, (c == null ? void 0 : c.minZoom) ?? r, (c == null ? void 0 : c.maxZoom) ?? l, (c == null ? void 0 : c.padding) ?? 0.1);
  return await s.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 L1({ nodeId: n, nextPosition: t, nodeLookup: e, nodeOrigin: s = [0, 0], nodeExtent: r, onError: l }) {
  const c = e.get(n), f = c.parentId ? e.get(c.parentId) : void 0, { x: d, y: h } = f ? f.internals.positionAbsolute : { x: 0, y: 0 }, m = c.origin ?? s;
  let p = c.extent || r;
  if (c.extent === "parent" && !c.expandParent)
    if (!f)
      l == null || l("005", rs.error005());
    else {
      const x = f.measured.width, b = f.measured.height;
      x && b && (p = [
        [d, h],
        [d + x, h + b]
      ]);
    }
  else f && Jo(c.extent) && (p = [
    [c.extent[0][0] + d, c.extent[0][1] + h],
    [c.extent[1][0] + d, c.extent[1][1] + h]
  ]);
  const _ = Jo(p) ? Sr(t, p, c.measured) : t;
  return (c.measured.width === void 0 || c.measured.height === void 0) && (l == null || l("015", rs.error015())), {
    position: {
      x: _.x - d + (c.measured.width ?? 0) * m[0],
      y: _.y - h + (c.measured.height ?? 0) * m[1]
    },
    positionAbsolute: _
  };
}
async function pz({ nodesToRemove: n = [], edgesToRemove: t = [], nodes: e, edges: s, onBeforeDelete: r }) {
  const l = new Set(n.map((_) => _.id)), c = [];
  for (const _ of e) {
    if (_.deletable === !1)
      continue;
    const x = l.has(_.id), b = !x && _.parentId && c.find((M) => M.id === _.parentId);
    (x || b) && c.push(_);
  }
  const f = new Set(t.map((_) => _.id)), d = s.filter((_) => _.deletable !== !1), m = fz(c, d);
  for (const _ of d)
    f.has(_.id) && !m.find((b) => b.id === _.id) && m.push(_);
  if (!r)
    return {
      edges: m,
      nodes: c
    };
  const p = await r({
    nodes: c,
    edges: m
  });
  return typeof p == "boolean" ? p ? { edges: m, nodes: c } : { edges: [], nodes: [] } : p;
}
const $o = (n, t = 0, e = 1) => Math.min(Math.max(n, t), e), Sr = (n = { x: 0, y: 0 }, t, e) => ({
  x: $o(n.x, t[0][0], t[1][0] - ((e == null ? void 0 : e.width) ?? 0)),
  y: $o(n.y, t[0][1], t[1][1] - ((e == null ? void 0 : e.height) ?? 0))
});
function U1(n, t, e) {
  const { width: s, height: r } = ks(e), { x: l, y: c } = e.internals.positionAbsolute;
  return Sr(n, [
    [l, c],
    [l + s, c + r]
  ], t);
}
const eb = (n, t, e) => n < t ? $o(Math.abs(n - t), 1, t) / t : n > e ? -$o(Math.abs(n - e), 1, t) / t : 0, O1 = (n, t, e = 15, s = 40) => {
  const r = eb(n.x, s, t.width - s) * e, l = eb(n.y, s, t.height - s) * e;
  return [r, l];
}, bd = (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)
}), Ig = ({ x: n, y: t, width: e, height: s }) => ({
  x: n,
  y: t,
  x2: n + e,
  y2: t + s
}), Md = ({ x: n, y: t, x2: e, y2: s }) => ({
  x: n,
  y: t,
  width: e - n,
  height: s - t
}), Qo = (n, t = [0, 0]) => {
  var r, l;
  const { x: e, y: s } = m0(n) ? n.internals.positionAbsolute : Oc(n, t);
  return {
    x: e,
    y: s,
    width: ((r = n.measured) == null ? void 0 : r.width) ?? n.width ?? n.initialWidth ?? 0,
    height: ((l = n.measured) == null ? void 0 : l.height) ?? n.height ?? n.initialHeight ?? 0
  };
}, ud = (n, t = [0, 0]) => {
  var r, l;
  const { x: e, y: s } = m0(n) ? n.internals.positionAbsolute : Oc(n, t);
  return {
    x: e,
    y: s,
    x2: e + (((r = n.measured) == null ? void 0 : r.width) ?? n.width ?? n.initialWidth ?? 0),
    y2: s + (((l = n.measured) == null ? void 0 : l.height) ?? n.height ?? n.initialHeight ?? 0)
  };
}, P1 = (n, t) => Md(bd(Ig(n), Ig(t))), Mc = (n, t) => {
  const e = Math.max(0, Math.min(n.x + n.width, t.x + t.width) - Math.max(n.x, t.x)), s = Math.max(0, Math.min(n.y + n.height, t.y + t.height) - Math.max(n.y, t.y));
  return Math.ceil(e * s);
}, nb = (n) => Yi(n.width) && Yi(n.height) && Yi(n.x) && Yi(n.y), Yi = (n) => !isNaN(n) && isFinite(n), mz = (n, t) => {
}, zc = (n, t = [1, 1]) => ({
  x: t[0] * Math.round(n.x / t[0]),
  y: t[1] * Math.round(n.y / t[1])
}), Ic = ({ x: n, y: t }, [e, s, r], l = !1, c = [1, 1]) => {
  const f = {
    x: (n - e) / r,
    y: (t - s) / r
  };
  return l ? zc(f, c) : f;
}, fd = ({ x: n, y: t }, [e, s, r]) => ({
  x: n * r + e,
  y: t * r + s
});
function wo(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 gz(n, t, e) {
  if (typeof n == "string" || typeof n == "number") {
    const s = wo(n, e), r = wo(n, t);
    return {
      top: s,
      right: r,
      bottom: s,
      left: r,
      x: r * 2,
      y: s * 2
    };
  }
  if (typeof n == "object") {
    const s = wo(n.top ?? n.y ?? 0, e), r = wo(n.bottom ?? n.y ?? 0, e), l = wo(n.left ?? n.x ?? 0, t), c = wo(n.right ?? n.x ?? 0, t);
    return { top: s, right: c, bottom: r, left: l, x: l + c, y: s + r };
  }
  return { top: 0, right: 0, bottom: 0, left: 0, x: 0, y: 0 };
}
function _z(n, t, e, s, r, l) {
  const { x: c, y: f } = fd(n, [t, e, s]), { x: d, y: h } = fd({ x: n.x + n.width, y: n.y + n.height }, [t, e, s]), m = r - d, p = l - h;
  return {
    left: Math.floor(c),
    top: Math.floor(f),
    right: Math.floor(m),
    bottom: Math.floor(p)
  };
}
const _0 = (n, t, e, s, r, l) => {
  const c = gz(l, t, e), f = (t - c.x) / n.width, d = (e - c.y) / n.height, h = Math.min(f, d), m = $o(h, s, r), p = n.x + n.width / 2, _ = n.y + n.height / 2, x = t / 2 - p * m, b = e / 2 - _ * m, M = _z(n, x, b, m, t, e), S = {
    left: Math.min(M.left - c.left, 0),
    top: Math.min(M.top - c.top, 0),
    right: Math.min(M.right - c.right, 0),
    bottom: Math.min(M.bottom - c.bottom, 0)
  };
  return {
    x: x - S.left + S.right,
    y: b - S.top + S.bottom,
    zoom: m
  };
}, Ec = () => {
  var n;
  return typeof navigator < "u" && ((n = navigator == null ? void 0 : navigator.userAgent) == null ? void 0 : n.indexOf("Mac")) >= 0;
};
function Jo(n) {
  return n != null && n !== "parent";
}
function ks(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 z1(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 I1(n, t = { width: 0, height: 0 }, e, s, r) {
  const l = { ...n }, c = s.get(e);
  if (c) {
    const f = c.origin || r;
    l.x += c.internals.positionAbsolute.x - (t.width ?? 0) * f[0], l.y += c.internals.positionAbsolute.y - (t.height ?? 0) * f[1];
  }
  return l;
}
function ib(n, t) {
  if (n.size !== t.size)
    return !1;
  for (const e of n)
    if (!t.has(e))
      return !1;
  return !0;
}
function vz() {
  let n, t;
  return { promise: new Promise((s, r) => {
    n = s, t = r;
  }), resolve: n, reject: t };
}
function yz(n) {
  return { ...C1, ...n || {} };
}
function hc(n, { snapGrid: t = [0, 0], snapToGrid: e = !1, transform: s, containerBounds: r }) {
  const { x: l, y: c } = ji(n), f = Ic({ x: l - ((r == null ? void 0 : r.left) ?? 0), y: c - ((r == null ? void 0 : r.top) ?? 0) }, s), { x: d, y: h } = e ? zc(f, t) : f;
  return {
    xSnapped: d,
    ySnapped: h,
    ...f
  };
}
const v0 = (n) => ({
  width: n.offsetWidth,
  height: n.offsetHeight
}), B1 = (n) => {
  var t;
  return ((t = n == null ? void 0 : n.getRootNode) == null ? void 0 : t.call(n)) || (window == null ? void 0 : window.document);
}, xz = ["INPUT", "SELECT", "TEXTAREA"];
function F1(n) {
  var s, r;
  const t = ((r = (s = n.composedPath) == null ? void 0 : s.call(n)) == null ? void 0 : r[0]) || n.target;
  return (t == null ? void 0 : t.nodeType) !== 1 ? !1 : xz.includes(t.nodeName) || t.hasAttribute("contenteditable") || !!t.closest(".nokey");
}
const H1 = (n) => "clientX" in n, ji = (n, t) => {
  var l, c;
  const e = H1(n), s = e ? n.clientX : (l = n.touches) == null ? void 0 : l[0].clientX, r = e ? n.clientY : (c = n.touches) == null ? void 0 : c[0].clientY;
  return {
    x: s - ((t == null ? void 0 : t.left) ?? 0),
    y: r - ((t == null ? void 0 : t.top) ?? 0)
  };
}, sb = (n, t, e, s, r) => {
  const l = t.querySelectorAll(`.${n}`);
  return !l || !l.length ? null : Array.from(l).map((c) => {
    const f = c.getBoundingClientRect();
    return {
      id: c.getAttribute("data-handleid"),
      type: n,
      nodeId: r,
      position: c.getAttribute("data-handlepos"),
      x: (f.left - e.left) / s,
      y: (f.top - e.top) / s,
      ...v0(c)
    };
  });
};
function V1({ sourceX: n, sourceY: t, targetX: e, targetY: s, sourceControlX: r, sourceControlY: l, targetControlX: c, targetControlY: f }) {
  const d = n * 0.125 + r * 0.375 + c * 0.375 + e * 0.125, h = t * 0.125 + l * 0.375 + f * 0.375 + s * 0.125, m = Math.abs(d - n), p = Math.abs(h - t);
  return [d, h, m, p];
}
function Df(n, t) {
  return n >= 0 ? 0.5 * n : t * 25 * Math.sqrt(-n);
}
function ab({ pos: n, x1: t, y1: e, x2: s, y2: r, c: l }) {
  switch (n) {
    case ne.Left:
      return [t - Df(t - s, l), e];
    case ne.Right:
      return [t + Df(s - t, l), e];
    case ne.Top:
      return [t, e - Df(e - r, l)];
    case ne.Bottom:
      return [t, e + Df(r - e, l)];
  }
}
function G1({ sourceX: n, sourceY: t, sourcePosition: e = ne.Bottom, targetX: s, targetY: r, targetPosition: l = ne.Top, curvature: c = 0.25 }) {
  const [f, d] = ab({
    pos: e,
    x1: n,
    y1: t,
    x2: s,
    y2: r,
    c
  }), [h, m] = ab({
    pos: l,
    x1: s,
    y1: r,
    x2: n,
    y2: t,
    c
  }), [p, _, x, b] = V1({
    sourceX: n,
    sourceY: t,
    targetX: s,
    targetY: r,
    sourceControlX: f,
    sourceControlY: d,
    targetControlX: h,
    targetControlY: m
  });
  return [
    `M${n},${t} C${f},${d} ${h},${m} ${s},${r}`,
    p,
    _,
    x,
    b
  ];
}
function k1({ sourceX: n, sourceY: t, targetX: e, targetY: s }) {
  const r = Math.abs(e - n) / 2, l = e < n ? e + r : e - r, c = Math.abs(s - t) / 2, f = s < t ? s + c : s - c;
  return [l, f, r, c];
}
function Sz({ sourceNode: n, targetNode: t, selected: e = !1, zIndex: s = 0, elevateOnSelect: r = !1, zIndexMode: l = "basic" }) {
  if (l === "manual")
    return s;
  const c = r && e ? s + 1e3 : s, f = Math.max(n.parentId || r && n.selected ? n.internals.z : 0, t.parentId || r && t.selected ? t.internals.z : 0);
  return c + f;
}
function bz({ sourceNode: n, targetNode: t, width: e, height: s, transform: r }) {
  const l = bd(ud(n), ud(t));
  l.x === l.x2 && (l.x2 += 1), l.y === l.y2 && (l.y2 += 1);
  const c = {
    x: -r[0] / r[2],
    y: -r[1] / r[2],
    width: e / r[2],
    height: s / r[2]
  };
  return Mc(c, Md(l)) > 0;
}
const Mz = ({ source: n, sourceHandle: t, target: e, targetHandle: s }) => `xy-edge__${n}${t || ""}-${e}${s || ""}`, Ez = (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)), X1 = (n, t, e = {}) => {
  if (!n.source || !n.target)
    return t;
  const s = e.getEdgeId || Mz;
  let r;
  return N1(n) ? r = { ...n } : r = {
    ...n,
    id: s(n)
  }, Ez(r, t) ? t : (r.sourceHandle === null && delete r.sourceHandle, r.targetHandle === null && delete r.targetHandle, t.concat(r));
};
function W1({ sourceX: n, sourceY: t, targetX: e, targetY: s }) {
  const [r, l, c, f] = k1({
    sourceX: n,
    sourceY: t,
    targetX: e,
    targetY: s
  });
  return [`M ${n},${t}L ${e},${s}`, r, l, c, f];
}
const rb = {
  [ne.Left]: { x: -1, y: 0 },
  [ne.Right]: { x: 1, y: 0 },
  [ne.Top]: { x: 0, y: -1 },
  [ne.Bottom]: { x: 0, y: 1 }
}, Tz = ({ source: n, sourcePosition: t = ne.Bottom, target: e }) => t === ne.Left || t === ne.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 }, ob = (n, t) => Math.sqrt(Math.pow(t.x - n.x, 2) + Math.pow(t.y - n.y, 2));
function Az({ source: n, sourcePosition: t = ne.Bottom, target: e, targetPosition: s = ne.Top, center: r, offset: l, stepPosition: c }) {
  const f = rb[t], d = rb[s], h = { x: n.x + f.x * l, y: n.y + f.y * l }, m = { x: e.x + d.x * l, y: e.y + d.y * l }, p = Tz({
    source: h,
    sourcePosition: t,
    target: m
  }), _ = p.x !== 0 ? "x" : "y", x = p[_];
  let b = [], M, S;
  const y = { x: 0, y: 0 }, C = { x: 0, y: 0 }, [, , T, E] = k1({
    sourceX: n.x,
    sourceY: n.y,
    targetX: e.x,
    targetY: e.y
  });
  if (f[_] * d[_] === -1) {
    _ === "x" ? (M = r.x ?? h.x + (m.x - h.x) * c, S = r.y ?? (h.y + m.y) / 2) : (M = r.x ?? (h.x + m.x) / 2, S = r.y ?? h.y + (m.y - h.y) * c);
    const N = [
      { x: M, y: h.y },
      { x: M, y: m.y }
    ], D = [
      { x: h.x, y: S },
      { x: m.x, y: S }
    ];
    f[_] === x ? b = _ === "x" ? N : D : b = _ === "x" ? D : N;
  } else {
    const N = [{ x: h.x, y: m.y }], D = [{ x: m.x, y: h.y }];
    if (_ === "x" ? b = f.x === x ? D : N : b = f.y === x ? N : D, t === s) {
      const H = Math.abs(n[_] - e[_]);
      if (H <= l) {
        const k = Math.min(l - 1, l - H);
        f[_] === x ? y[_] = (h[_] > n[_] ? -1 : 1) * k : C[_] = (m[_] > e[_] ? -1 : 1) * k;
      }
    }
    if (t !== s) {
      const H = _ === "x" ? "y" : "x", k = f[_] === d[H], P = h[H] > m[H], Y = h[H] < m[H];
      (f[_] === 1 && (!k && P || k && Y) || f[_] !== 1 && (!k && Y || k && P)) && (b = _ === "x" ? N : D);
    }
    const z = { x: h.x + y.x, y: h.y + y.y }, A = { x: m.x + C.x, y: m.y + C.y }, R = Math.max(Math.abs(z.x - b[0].x), Math.abs(A.x - b[0].x)), L = Math.max(Math.abs(z.y - b[0].y), Math.abs(A.y - b[0].y));
    R >= L ? (M = (z.x + A.x) / 2, S = b[0].y) : (M = b[0].x, S = (z.y + A.y) / 2);
  }
  return [[
    n,
    { x: h.x + y.x, y: h.y + y.y },
    ...b,
    { x: m.x + C.x, y: m.y + C.y },
    e
  ], M, S, T, E];
}
function wz(n, t, e, s) {
  const r = Math.min(ob(n, t) / 2, ob(t, e) / 2, s), { x: l, y: c } = t;
  if (n.x === l && l === e.x || n.y === c && c === e.y)
    return `L${l} ${c}`;
  if (n.y === c) {
    const h = n.x < e.x ? -1 : 1, m = n.y < e.y ? 1 : -1;
    return `L ${l + r * h},${c}Q ${l},${c} ${l},${c + r * m}`;
  }
  const f = n.x < e.x ? 1 : -1, d = n.y < e.y ? -1 : 1;
  return `L ${l},${c + r * d}Q ${l},${c} ${l + r * f},${c}`;
}
function Bg({ sourceX: n, sourceY: t, sourcePosition: e = ne.Bottom, targetX: s, targetY: r, targetPosition: l = ne.Top, borderRadius: c = 5, centerX: f, centerY: d, offset: h = 20, stepPosition: m = 0.5 }) {
  const [p, _, x, b, M] = Az({
    source: { x: n, y: t },
    sourcePosition: e,
    target: { x: s, y: r },
    targetPosition: l,
    center: { x: f, y: d },
    offset: h,
    stepPosition: m
  });
  return [p.reduce((y, C, T) => {
    let E = "";
    return T > 0 && T < p.length - 1 ? E = wz(p[T - 1], C, p[T + 1], c) : E = `${T === 0 ? "M" : "L"}${C.x} ${C.y}`, y += E, y;
  }, ""), _, x, b, M];
}
function lb(n) {
  var t;
  return n && !!(n.internals.handleBounds || (t = n.handles) != null && t.length) && !!(n.measured.width || n.width || n.initialWidth);
}
function Cz(n) {
  var p;
  const { sourceNode: t, targetNode: e } = n;
  if (!lb(t) || !lb(e))
    return null;
  const s = t.internals.handleBounds || cb(t.handles), r = e.internals.handleBounds || cb(e.handles), l = ub((s == null ? void 0 : s.source) ?? [], n.sourceHandle), c = ub(
    // when connection type is loose we can define all handles as sources and connect source -> source
    n.connectionMode === Ko.Strict ? (r == null ? void 0 : r.target) ?? [] : ((r == null ? void 0 : r.target) ?? []).concat((r == null ? void 0 : r.source) ?? []),
    n.targetHandle
  );
  if (!l || !c)
    return (p = n.onError) == null || p.call(n, "008", rs.error008(l ? "target" : "source", {
      id: n.id,
      sourceHandle: n.sourceHandle,
      targetHandle: n.targetHandle
    })), null;
  const f = (l == null ? void 0 : l.position) || ne.Bottom, d = (c == null ? void 0 : c.position) || ne.Top, h = br(t, l, f), m = br(e, c, d);
  return {
    sourceX: h.x,
    sourceY: h.y,
    targetX: m.x,
    targetY: m.y,
    sourcePosition: f,
    targetPosition: d
  };
}
function cb(n) {
  if (!n)
    return null;
  const t = [], e = [];
  for (const s of n)
    s.width = s.width ?? 1, s.height = s.height ?? 1, s.type === "source" ? t.push(s) : s.type === "target" && e.push(s);
  return {
    source: t,
    target: e
  };
}
function br(n, t, e = ne.Left, s = !1) {
  const r = ((t == null ? void 0 : t.x) ?? 0) + n.internals.positionAbsolute.x, l = ((t == null ? void 0 : t.y) ?? 0) + n.internals.positionAbsolute.y, { width: c, height: f } = t ?? ks(n);
  if (s)
    return { x: r + c / 2, y: l + f / 2 };
  switch ((t == null ? void 0 : t.position) ?? e) {
    case ne.Top:
      return { x: r + c / 2, y: l };
    case ne.Right:
      return { x: r + c, y: l + f / 2 };
    case ne.Bottom:
      return { x: r + c / 2, y: l + f };
    case ne.Left:
      return { x: r, y: l + f / 2 };
  }
}
function ub(n, t) {
  return n && (t ? n.find((e) => e.id === t) : n[0]) || null;
}
function Fg(n, t) {
  return n ? typeof n == "string" ? n : `${t ? `${t}__` : ""}${Object.keys(n).sort().map((s) => `${s}=${n[s]}`).join("&")}` : "";
}
function Rz(n, { id: t, defaultColor: e, defaultMarkerStart: s, defaultMarkerEnd: r }) {
  const l = /* @__PURE__ */ new Set();
  return n.reduce((c, f) => ([f.markerStart || s, f.markerEnd || r].forEach((d) => {
    if (d && typeof d == "object") {
      const h = Fg(d, t);
      l.has(h) || (c.push({ id: h, color: d.color || e, ...d }), l.add(h));
    }
  }), c), []).sort((c, f) => c.id.localeCompare(f.id));
}
const Y1 = 1e3, Dz = 10, y0 = {
  nodeOrigin: [0, 0],
  nodeExtent: Sc,
  elevateNodesOnSelect: !0,
  zIndexMode: "basic",
  defaults: {}
}, Nz = {
  ...y0,
  checkEquality: !0
};
function x0(n, t) {
  const e = { ...n };
  for (const s in t)
    t[s] !== void 0 && (e[s] = t[s]);
  return e;
}
function Lz(n, t, e) {
  const s = x0(y0, e);
  for (const r of n.values())
    if (r.parentId)
      b0(r, n, t, s);
    else {
      const l = Oc(r, s.nodeOrigin), c = Jo(r.extent) ? r.extent : s.nodeExtent, f = Sr(l, c, ks(r));
      r.internals.positionAbsolute = f;
    }
}
function Uz(n, t) {
  if (!n.handles)
    return n.measured ? t == null ? void 0 : t.internals.handleBounds : void 0;
  const e = [], s = [];
  for (const r of n.handles) {
    const l = {
      id: r.id,
      width: r.width ?? 1,
      height: r.height ?? 1,
      nodeId: n.id,
      x: r.x,
      y: r.y,
      position: r.position,
      type: r.type
    };
    r.type === "source" ? e.push(l) : r.type === "target" && s.push(l);
  }
  return {
    source: e,
    target: s
  };
}
function S0(n) {
  return n === "manual";
}
function Hg(n, t, e, s = {}) {
  var h, m;
  const r = x0(Nz, s), l = { i: 0 }, c = new Map(t), f = r != null && r.elevateNodesOnSelect && !S0(r.zIndexMode) ? Y1 : 0;
  let d = n.length > 0;
  t.clear(), e.clear();
  for (const p of n) {
    let _ = c.get(p.id);
    if (r.checkEquality && p === (_ == null ? void 0 : _.internals.userNode))
      t.set(p.id, _);
    else {
      const x = Oc(p, r.nodeOrigin), b = Jo(p.extent) ? p.extent : r.nodeExtent, M = Sr(x, b, ks(p));
      _ = {
        ...r.defaults,
        ...p,
        measured: {
          width: (h = p.measured) == null ? void 0 : h.width,
          height: (m = p.measured) == null ? void 0 : m.height
        },
        internals: {
          positionAbsolute: M,
          // if user re-initializes the node or removes `measured` for whatever reason, we reset the handleBounds so that the node gets re-measured
          handleBounds: Uz(p, _),
          z: j1(p, f, r.zIndexMode),
          userNode: p
        }
      }, t.set(p.id, _);
    }
    (_.measured === void 0 || _.measured.width === void 0 || _.measured.height === void 0) && !_.hidden && (d = !1), p.parentId && b0(_, t, e, s, l);
  }
  return d;
}
function Oz(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 b0(n, t, e, s, r) {
  const { elevateNodesOnSelect: l, nodeOrigin: c, nodeExtent: f, zIndexMode: d } = x0(y0, s), h = n.parentId, m = t.get(h);
  if (!m) {
    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;
  }
  Oz(n, e), r && !m.parentId && m.internals.rootParentIndex === void 0 && d === "auto" && (m.internals.rootParentIndex = ++r.i, m.internals.z = m.internals.z + r.i * Dz), r && m.internals.rootParentIndex !== void 0 && (r.i = m.internals.rootParentIndex);
  const p = l && !S0(d) ? Y1 : 0, { x: _, y: x, z: b } = Pz(n, m, c, f, p, d), { positionAbsolute: M } = n.internals, S = _ !== M.x || x !== M.y;
  (S || b !== n.internals.z) && t.set(n.id, {
    ...n,
    internals: {
      ...n.internals,
      positionAbsolute: S ? { x: _, y: x } : M,
      z: b
    }
  });
}
function j1(n, t, e) {
  const s = Yi(n.zIndex) ? n.zIndex : 0;
  return S0(e) ? s : s + (n.selected ? t : 0);
}
function Pz(n, t, e, s, r, l) {
  const { x: c, y: f } = t.internals.positionAbsolute, d = ks(n), h = Oc(n, e), m = Jo(n.extent) ? Sr(h, n.extent, d) : h;
  let p = Sr({ x: c + m.x, y: f + m.y }, s, d);
  n.extent === "parent" && (p = U1(p, d, t));
  const _ = j1(n, r, l), x = t.internals.z ?? 0;
  return {
    x: p.x,
    y: p.y,
    z: x >= _ ? x + 1 : _
  };
}
function M0(n, t, e, s = [0, 0]) {
  var c;
  const r = [], l = /* @__PURE__ */ new Map();
  for (const f of n) {
    const d = t.get(f.parentId);
    if (!d)
      continue;
    const h = ((c = l.get(f.parentId)) == null ? void 0 : c.expandedRect) ?? Qo(d), m = P1(h, f.rect);
    l.set(f.parentId, { expandedRect: m, parent: d });
  }
  return l.size > 0 && l.forEach(({ expandedRect: f, parent: d }, h) => {
    var T;
    const m = d.internals.positionAbsolute, p = ks(d), _ = d.origin ?? s, x = f.x < m.x ? Math.round(Math.abs(m.x - f.x)) : 0, b = f.y < m.y ? Math.round(Math.abs(m.y - f.y)) : 0, M = Math.max(p.width, Math.round(f.width)), S = Math.max(p.height, Math.round(f.height)), y = (M - p.width) * _[0], C = (S - p.height) * _[1];
    (x > 0 || b > 0 || y || C) && (r.push({
      id: h,
      type: "position",
      position: {
        x: d.position.x - x + y,
        y: d.position.y - b + C
      }
    }), (T = e.get(h)) == null || T.forEach((E) => {
      n.some((O) => O.id === E.id) || r.push({
        id: E.id,
        type: "position",
        position: {
          x: E.position.x + x,
          y: E.position.y + b
        }
      });
    })), (p.width < f.width || p.height < f.height || x || b) && r.push({
      id: h,
      type: "dimensions",
      setAttributes: !0,
      dimensions: {
        width: M + (x ? _[0] * x - y : 0),
        height: S + (b ? _[1] * b - C : 0)
      }
    });
  }), r;
}
function zz(n, t, e, s, r, l, c) {
  const f = s == null ? void 0 : s.querySelector(".xyflow__viewport");
  let d = !1;
  if (!f)
    return { changes: [], updatedInternals: d };
  const h = [], m = window.getComputedStyle(f), { m22: p } = new window.DOMMatrixReadOnly(m.transform), _ = [];
  for (const x of n.values()) {
    const b = t.get(x.id);
    if (!b)
      continue;
    if (b.hidden) {
      t.set(b.id, {
        ...b,
        internals: {
          ...b.internals,
          handleBounds: void 0
        }
      }), d = !0;
      continue;
    }
    const M = v0(x.nodeElement), S = b.measured.width !== M.width || b.measured.height !== M.height;
    if (!!(M.width && M.height && (S || !b.internals.handleBounds || x.force))) {
      const C = x.nodeElement.getBoundingClientRect(), T = Jo(b.extent) ? b.extent : l;
      let { positionAbsolute: E } = b.internals;
      b.parentId && b.extent === "parent" ? E = U1(E, M, t.get(b.parentId)) : T && (E = Sr(E, T, M));
      const O = {
        ...b,
        measured: M,
        internals: {
          ...b.internals,
          positionAbsolute: E,
          handleBounds: {
            source: sb("source", x.nodeElement, C, p, b.id),
            target: sb("target", x.nodeElement, C, p, b.id)
          }
        }
      };
      t.set(b.id, O), b.parentId && b0(O, t, e, { nodeOrigin: r, zIndexMode: c }), d = !0, S && (h.push({
        id: b.id,
        type: "dimensions",
        dimensions: M
      }), b.expandParent && b.parentId && _.push({
        id: b.id,
        parentId: b.parentId,
        rect: Qo(O, r)
      }));
    }
  }
  if (_.length > 0) {
    const x = M0(_, t, e, r);
    h.push(...x);
  }
  return { changes: h, updatedInternals: d };
}
async function Iz({ delta: n, panZoom: t, transform: e, translateExtent: s, width: r, height: l }) {
  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],
    [r, l]
  ], s), f = !!c && (c.x !== e[0] || c.y !== e[1] || c.k !== e[2]);
  return Promise.resolve(f);
}
function fb(n, t, e, s, r, l) {
  let c = r;
  const f = s.get(c) || /* @__PURE__ */ new Map();
  s.set(c, f.set(e, t)), c = `${r}-${n}`;
  const d = s.get(c) || /* @__PURE__ */ new Map();
  if (s.set(c, d.set(e, t)), l) {
    c = `${r}-${n}-${l}`;
    const h = s.get(c) || /* @__PURE__ */ new Map();
    s.set(c, h.set(e, t));
  }
}
function q1(n, t, e) {
  n.clear(), t.clear();
  for (const s of e) {
    const { source: r, target: l, sourceHandle: c = null, targetHandle: f = null } = s, d = { edgeId: s.id, source: r, target: l, sourceHandle: c, targetHandle: f }, h = `${r}-${c}--${l}-${f}`, m = `${l}-${f}--${r}-${c}`;
    fb("source", d, m, n, r, c), fb("target", d, h, n, l, f), t.set(s.id, s);
  }
}
function Z1(n, t) {
  if (!n.parentId)
    return !1;
  const e = t.get(n.parentId);
  return e ? e.selected ? !0 : Z1(e, t) : !1;
}
function db(n, t, e) {
  var r;
  let s = n;
  do {
    if ((r = s == null ? void 0 : s.matches) != null && r.call(s, t))
      return !0;
    if (s === e)
      return !1;
    s = s == null ? void 0 : s.parentElement;
  } while (s);
  return !1;
}
function Bz(n, t, e, s) {
  const r = /* @__PURE__ */ new Map();
  for (const [l, c] of n)
    if ((c.selected || c.id === s) && (!c.parentId || !Z1(c, n)) && (c.draggable || t && typeof c.draggable > "u")) {
      const f = n.get(l);
      f && r.set(l, {
        id: l,
        position: f.position || { x: 0, y: 0 },
        distance: {
          x: e.x - f.internals.positionAbsolute.x,
          y: e.y - f.internals.positionAbsolute.y
        },
        extent: f.extent,
        parentId: f.parentId,
        origin: f.origin,
        expandParent: f.expandParent,
        internals: {
          positionAbsolute: f.internals.positionAbsolute || { x: 0, y: 0 }
        },
        measured: {
          width: f.measured.width ?? 0,
          height: f.measured.height ?? 0
        }
      });
    }
  return r;
}
function wm({ nodeId: n, dragItems: t, nodeLookup: e, dragging: s = !0 }) {
  var c, f, d;
  const r = [];
  for (const [h, m] of t) {
    const p = (c = e.get(h)) == null ? void 0 : c.internals.userNode;
    p && r.push({
      ...p,
      position: m.position,
      dragging: s
    });
  }
  if (!n)
    return [r[0], r];
  const l = (f = e.get(n)) == null ? void 0 : f.internals.userNode;
  return [
    l ? {
      ...l,
      position: ((d = t.get(n)) == null ? void 0 : d.position) || l.position,
      dragging: s
    } : r[0],
    r
  ];
}
function Fz({ dragItems: n, snapGrid: t, x: e, y: s }) {
  const r = n.values().next().value;
  if (!r)
    return null;
  const l = {
    x: e - r.distance.x,
    y: s - r.distance.y
  }, c = zc(l, t);
  return {
    x: c.x - l.x,
    y: c.y - l.y
  };
}
function Hz({ onNodeMouseDown: n, getStoreItems: t, onDragStart: e, onDrag: s, onDragStop: r }) {
  let l = { x: null, y: null }, c = 0, f = /* @__PURE__ */ new Map(), d = !1, h = { x: 0, y: 0 }, m = null, p = !1, _ = null, x = !1, b = !1, M = null;
  function S({ noDragClassName: C, handleSelector: T, domNode: E, isSelectable: O, nodeId: N, nodeClickDistance: D = 0 }) {
    _ = Si(E);
    function z({ x: H, y: k }) {
      const { nodeLookup: P, nodeExtent: Y, snapGrid: U, snapToGrid: X, nodeOrigin: V, onNodeDrag: W, onSelectionDrag: J, onError: I, updateNodePositions: q } = t();
      l = { x: H, y: k };
      let lt = !1;
      const $ = f.size > 1, ot = $ && Y ? Ig(Pc(f)) : null, gt = $ && X ? Fz({
        dragItems: f,
        snapGrid: U,
        x: H,
        y: k
      }) : null;
      for (const [ht, _t] of f) {
        if (!P.has(ht))
          continue;
        let Et = { x: H - _t.distance.x, y: k - _t.distance.y };
        X && (Et = gt ? {
          x: Math.round(Et.x + gt.x),
          y: Math.round(Et.y + gt.y)
        } : zc(Et, U));
        let Lt = null;
        if ($ && Y && !_t.extent && ot) {
          const { positionAbsolute: Bt } = _t.internals, K = Bt.x - ot.x + Y[0][0], pe = Bt.x + _t.measured.width - ot.x2 + Y[1][0], Xt = Bt.y - ot.y + Y[0][1], se = Bt.y + _t.measured.height - ot.y2 + Y[1][1];
          Lt = [
            [K, Xt],
            [pe, se]
          ];
        }
        const { position: Gt, positionAbsolute: Nt } = L1({
          nodeId: ht,
          nextPosition: Et,
          nodeLookup: P,
          nodeExtent: Lt || Y,
          nodeOrigin: V,
          onError: I
        });
        lt = lt || _t.position.x !== Gt.x || _t.position.y !== Gt.y, _t.position = Gt, _t.internals.positionAbsolute = Nt;
      }
      if (b = b || lt, !!lt && (q(f, !0), M && (s || W || !N && J))) {
        const [ht, _t] = wm({
          nodeId: N,
          dragItems: f,
          nodeLookup: P
        });
        s == null || s(M, f, ht, _t), W == null || W(M, ht, _t), N || J == null || J(M, _t);
      }
    }
    async function A() {
      if (!m)
        return;
      const { transform: H, panBy: k, autoPanSpeed: P, autoPanOnNodeDrag: Y } = t();
      if (!Y) {
        d = !1, cancelAnimationFrame(c);
        return;
      }
      const [U, X] = O1(h, m, P);
      (U !== 0 || X !== 0) && (l.x = (l.x ?? 0) - U / H[2], l.y = (l.y ?? 0) - X / H[2], await k({ x: U, y: X }) && z(l)), c = requestAnimationFrame(A);
    }
    function R(H) {
      var $;
      const { nodeLookup: k, multiSelectionActive: P, nodesDraggable: Y, transform: U, snapGrid: X, snapToGrid: V, selectNodesOnDrag: W, onNodeDragStart: J, onSelectionDragStart: I, unselectNodesAndEdges: q } = t();
      p = !0, (!W || !O) && !P && N && (($ = k.get(N)) != null && $.selected || q()), O && W && N && (n == null || n(N));
      const lt = hc(H.sourceEvent, { transform: U, snapGrid: X, snapToGrid: V, containerBounds: m });
      if (l = lt, f = Bz(k, Y, lt, N), f.size > 0 && (e || J || !N && I)) {
        const [ot, gt] = wm({
          nodeId: N,
          dragItems: f,
          nodeLookup: k
        });
        e == null || e(H.sourceEvent, f, ot, gt), J == null || J(H.sourceEvent, ot, gt), N || I == null || I(H.sourceEvent, gt);
      }
    }
    const L = f1().clickDistance(D).on("start", (H) => {
      const { domNode: k, nodeDragThreshold: P, transform: Y, snapGrid: U, snapToGrid: X } = t();
      m = (k == null ? void 0 : k.getBoundingClientRect()) || null, x = !1, b = !1, M = H.sourceEvent, P === 0 && R(H), l = hc(H.sourceEvent, { transform: Y, snapGrid: U, snapToGrid: X, containerBounds: m }), h = ji(H.sourceEvent, m);
    }).on("drag", (H) => {
      const { autoPanOnNodeDrag: k, transform: P, snapGrid: Y, snapToGrid: U, nodeDragThreshold: X, nodeLookup: V } = t(), W = hc(H.sourceEvent, { transform: P, snapGrid: Y, snapToGrid: U, containerBounds: m });
      if (M = H.sourceEvent, (H.sourceEvent.type === "touchmove" && H.sourceEvent.touches.length > 1 || // if user deletes a node while dragging, we need to abort the drag to prevent errors
      N && !V.has(N)) && (x = !0), !x) {
        if (!d && k && p && (d = !0, A()), !p) {
          const J = ji(H.sourceEvent, m), I = J.x - h.x, q = J.y - h.y;
          Math.sqrt(I * I + q * q) > X && R(H);
        }
        (l.x !== W.xSnapped || l.y !== W.ySnapped) && f && p && (h = ji(H.sourceEvent, m), z(W));
      }
    }).on("end", (H) => {
      if (!(!p || x) && (d = !1, p = !1, cancelAnimationFrame(c), f.size > 0)) {
        const { nodeLookup: k, updateNodePositions: P, onNodeDragStop: Y, onSelectionDragStop: U } = t();
        if (b && (P(f, !1), b = !1), r || Y || !N && U) {
          const [X, V] = wm({
            nodeId: N,
            dragItems: f,
            nodeLookup: k,
            dragging: !1
          });
          r == null || r(H.sourceEvent, f, X, V), Y == null || Y(H.sourceEvent, X, V), N || U == null || U(H.sourceEvent, V);
        }
      }
    }).filter((H) => {
      const k = H.target;
      return !H.button && (!C || !db(k, `.${C}`, E)) && (!T || db(k, T, E));
    });
    _.call(L);
  }
  function y() {
    _ == null || _.on(".drag", null);
  }
  return {
    update: S,
    destroy: y
  };
}
function Vz(n, t, e) {
  const s = [], r = {
    x: n.x - e,
    y: n.y - e,
    width: e * 2,
    height: e * 2
  };
  for (const l of t.values())
    Mc(r, Qo(l)) > 0 && s.push(l);
  return s;
}
const Gz = 250;
function kz(n, t, e, s) {
  var f, d;
  let r = [], l = 1 / 0;
  const c = Vz(n, e, t + Gz);
  for (const h of c) {
    const m = [...((f = h.internals.handleBounds) == null ? void 0 : f.source) ?? [], ...((d = h.internals.handleBounds) == null ? void 0 : d.target) ?? []];
    for (const p of m) {
      if (s.nodeId === p.nodeId && s.type === p.type && s.id === p.id)
        continue;
      const { x: _, y: x } = br(h, p, p.position, !0), b = Math.sqrt(Math.pow(_ - n.x, 2) + Math.pow(x - n.y, 2));
      b > t || (b < l ? (r = [{ ...p, x: _, y: x }], l = b) : b === l && r.push({ ...p, x: _, y: x }));
    }
  }
  if (!r.length)
    return null;
  if (r.length > 1) {
    const h = s.type === "source" ? "target" : "source";
    return r.find((m) => m.type === h) ?? r[0];
  }
  return r[0];
}
function K1(n, t, e, s, r, l = !1) {
  var h, m, p;
  const c = s.get(n);
  if (!c)
    return null;
  const f = r === "strict" ? (h = c.internals.handleBounds) == null ? void 0 : h[t] : [...((m = c.internals.handleBounds) == null ? void 0 : m.source) ?? [], ...((p = c.internals.handleBounds) == null ? void 0 : p.target) ?? []], d = (e ? f == null ? void 0 : f.find((_) => _.id === e) : f == null ? void 0 : f[0]) ?? null;
  return d && l ? { ...d, ...br(c, d, d.position, !0) } : d;
}
function $1(n, t) {
  return n || (t != null && t.classList.contains("target") ? "target" : t != null && t.classList.contains("source") ? "source" : null);
}
function Xz(n, t) {
  let e = null;
  return t ? e = !0 : n && !t && (e = !1), e;
}
const Q1 = () => !0;
function Wz(n, { connectionMode: t, connectionRadius: e, handleId: s, nodeId: r, edgeUpdaterType: l, isTarget: c, domNode: f, nodeLookup: d, lib: h, autoPanOnConnect: m, flowId: p, panBy: _, cancelConnection: x, onConnectStart: b, onConnect: M, onConnectEnd: S, isValidConnection: y = Q1, onReconnectEnd: C, updateConnection: T, getTransform: E, getFromHandle: O, autoPanSpeed: N, dragThreshold: D = 1, handleDomNode: z }) {
  const A = B1(n.target);
  let R = 0, L;
  const { x: H, y: k } = ji(n), P = $1(l, z), Y = f == null ? void 0 : f.getBoundingClientRect();
  let U = !1;
  if (!Y || !P)
    return;
  const X = K1(r, P, s, d, t);
  if (!X)
    return;
  let V = ji(n, Y), W = !1, J = null, I = !1, q = null;
  function lt() {
    if (!m || !Y)
      return;
    const [Gt, Nt] = O1(V, Y, N);
    _({ x: Gt, y: Nt }), R = requestAnimationFrame(lt);
  }
  const $ = {
    ...X,
    nodeId: r,
    type: P,
    position: X.position
  }, ot = d.get(r);
  let ht = {
    inProgress: !0,
    isValid: null,
    from: br(ot, $, ne.Left, !0),
    fromHandle: $,
    fromPosition: $.position,
    fromNode: ot,
    to: V,
    toHandle: null,
    toPosition: tb[$.position],
    toNode: null,
    pointer: V
  };
  function _t() {
    U = !0, T(ht), b == null || b(n, { nodeId: r, handleId: s, handleType: P });
  }
  D === 0 && _t();
  function Et(Gt) {
    if (!U) {
      const { x: se, y: qt } = ji(Gt), xe = se - H, jt = qt - k;
      if (!(xe * xe + jt * jt > D * D))
        return;
      _t();
    }
    if (!O() || !$) {
      Lt(Gt);
      return;
    }
    const Nt = E();
    V = ji(Gt, Y), L = kz(Ic(V, Nt, !1, [1, 1]), e, d, $), W || (lt(), W = !0);
    const Bt = J1(Gt, {
      handle: L,
      connectionMode: t,
      fromNodeId: r,
      fromHandleId: s,
      fromType: c ? "target" : "source",
      isValidConnection: y,
      doc: A,
      lib: h,
      flowId: p,
      nodeLookup: d
    });
    q = Bt.handleDomNode, J = Bt.connection, I = Xz(!!L, Bt.isValid);
    const K = d.get(r), pe = K ? br(K, $, ne.Left, !0) : ht.from, Xt = {
      ...ht,
      from: pe,
      isValid: I,
      to: Bt.toHandle && I ? fd({ x: Bt.toHandle.x, y: Bt.toHandle.y }, Nt) : V,
      toHandle: Bt.toHandle,
      toPosition: I && Bt.toHandle ? Bt.toHandle.position : tb[$.position],
      toNode: Bt.toHandle ? d.get(Bt.toHandle.nodeId) : null,
      pointer: V
    };
    T(Xt), ht = Xt;
  }
  function Lt(Gt) {
    if (!("touches" in Gt && Gt.touches.length > 0)) {
      if (U) {
        (L || q) && J && I && (M == null || M(J));
        const { inProgress: Nt, ...Bt } = ht, K = {
          ...Bt,
          toPosition: ht.toHandle ? ht.toPosition : null
        };
        S == null || S(Gt, K), l && (C == null || C(Gt, K));
      }
      x(), cancelAnimationFrame(R), W = !1, I = !1, J = null, q = null, A.removeEventListener("mousemove", Et), A.removeEventListener("mouseup", Lt), A.removeEventListener("touchmove", Et), A.removeEventListener("touchend", Lt);
    }
  }
  A.addEventListener("mousemove", Et), A.addEventListener("mouseup", Lt), A.addEventListener("touchmove", Et), A.addEventListener("touchend", Lt);
}
function J1(n, { handle: t, connectionMode: e, fromNodeId: s, fromHandleId: r, fromType: l, doc: c, lib: f, flowId: d, isValidConnection: h = Q1, nodeLookup: m }) {
  const p = l === "target", _ = t ? c.querySelector(`.${f}-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 } = ji(n), M = c.elementFromPoint(x, b), S = M != null && M.classList.contains(`${f}-flow__handle`) ? M : _, y = {
    handleDomNode: S,
    isValid: !1,
    connection: null,
    toHandle: null
  };
  if (S) {
    const C = $1(void 0, S), T = S.getAttribute("data-nodeid"), E = S.getAttribute("data-handleid"), O = S.classList.contains("connectable"), N = S.classList.contains("connectableend");
    if (!T || !C)
      return y;
    const D = {
      source: p ? T : s,
      sourceHandle: p ? E : r,
      target: p ? s : T,
      targetHandle: p ? r : E
    };
    y.connection = D;
    const A = O && N && (e === Ko.Strict ? p && C === "source" || !p && C === "target" : T !== s || E !== r);
    y.isValid = A && h(D), y.toHandle = K1(T, C, E, m, e, !0);
  }
  return y;
}
const Vg = {
  onPointerDown: Wz,
  isValid: J1
};
function Yz({ domNode: n, panZoom: t, getTransform: e, getViewScale: s }) {
  const r = Si(n);
  function l({ translateExtent: f, width: d, height: h, zoomStep: m = 1, pannable: p = !0, zoomable: _ = !0, inversePan: x = !1 }) {
    const b = (T) => {
      if (T.sourceEvent.type !== "wheel" || !t)
        return;
      const E = e(), O = T.sourceEvent.ctrlKey && Ec() ? 10 : 1, N = -T.sourceEvent.deltaY * (T.sourceEvent.deltaMode === 1 ? 0.05 : T.sourceEvent.deltaMode ? 1 : 2e-3) * m, D = E[2] * Math.pow(2, N * O);
      t.scaleTo(D);
    };
    let M = [0, 0];
    const S = (T) => {
      (T.sourceEvent.type === "mousedown" || T.sourceEvent.type === "touchstart") && (M = [
        T.sourceEvent.clientX ?? T.sourceEvent.touches[0].clientX,
        T.sourceEvent.clientY ?? T.sourceEvent.touches[0].clientY
      ]);
    }, y = (T) => {
      const E = e();
      if (T.sourceEvent.type !== "mousemove" && T.sourceEvent.type !== "touchmove" || !t)
        return;
      const O = [
        T.sourceEvent.clientX ?? T.sourceEvent.touches[0].clientX,
        T.sourceEvent.clientY ?? T.sourceEvent.touches[0].clientY
      ], N = [O[0] - M[0], O[1] - M[1]];
      M = O;
      const D = s() * Math.max(E[2], Math.log(E[2])) * (x ? -1 : 1), z = {
        x: E[0] - N[0] * D,
        y: E[1] - N[1] * D
      }, A = [
        [0, 0],
        [d, h]
      ];
      t.setViewportConstrained({
        x: z.x,
        y: z.y,
        zoom: E[2]
      }, A, f);
    }, C = A1().on("start", S).on("zoom", p ? y : null).on("zoom.wheel", _ ? b : null);
    r.call(C, {});
  }
  function c() {
    r.on("zoom", null);
  }
  return {
    update: l,
    destroy: c,
    pointer: Xi
  };
}
const Ed = (n) => ({
  x: n.x,
  y: n.y,
  zoom: n.k
}), Cm = ({ x: n, y: t, zoom: e }) => Sd.translate(n, t).scale(e), Uo = (n, t) => n.target.closest(`.${t}`), tE = (n, t) => t === 2 && Array.isArray(n) && n.includes(2), jz = (n) => ((n *= 2) <= 1 ? n * n * n : (n -= 2) * n * n + 2) / 2, Rm = (n, t = 0, e = jz, s = () => {
}) => {
  const r = typeof t == "number" && t > 0;
  return r || s(), r ? n.transition().duration(t).ease(e).on("end", s) : n;
}, eE = (n) => {
  const t = n.ctrlKey && Ec() ? 10 : 1;
  return -n.deltaY * (n.deltaMode === 1 ? 0.05 : n.deltaMode ? 1 : 2e-3) * t;
};
function qz({ zoomPanValues: n, noWheelClassName: t, d3Selection: e, d3Zoom: s, panOnScrollMode: r, panOnScrollSpeed: l, zoomOnPinch: c, onPanZoomStart: f, onPanZoom: d, onPanZoomEnd: h }) {
  return (m) => {
    if (Uo(m, t))
      return m.ctrlKey && m.preventDefault(), !1;
    m.preventDefault(), m.stopImmediatePropagation();
    const p = e.property("__zoom").k || 1;
    if (m.ctrlKey && c) {
      const S = Xi(m), y = eE(m), C = p * Math.pow(2, y);
      s.scaleTo(e, C, S, m);
      return;
    }
    const _ = m.deltaMode === 1 ? 20 : 1;
    let x = r === gr.Vertical ? 0 : m.deltaX * _, b = r === gr.Horizontal ? 0 : m.deltaY * _;
    !Ec() && m.shiftKey && r !== gr.Vertical && (x = m.deltaY * _, b = 0), s.translateBy(
      e,
      -(x / p) * l,
      -(b / p) * l,
      // @ts-ignore
      { internal: !0 }
    );
    const M = Ed(e.property("__zoom"));
    clearTimeout(n.panScrollTimeout), n.isPanScrolling ? (d == null || d(m, M), n.panScrollTimeout = setTimeout(() => {
      h == null || h(m, M), n.isPanScrolling = !1;
    }, 150)) : (n.isPanScrolling = !0, f == null || f(m, M));
  };
}
function Zz({ noWheelClassName: n, preventScrolling: t, d3ZoomHandler: e }) {
  return function(s, r) {
    const l = s.type === "wheel", c = !t && l && !s.ctrlKey, f = Uo(s, n);
    if (s.ctrlKey && l && f && s.preventDefault(), c || f)
      return null;
    s.preventDefault(), e.call(this, s, r);
  };
}
function Kz({ zoomPanValues: n, onDraggingChange: t, onPanZoomStart: e }) {
  return (s) => {
    var l, c, f;
    if ((l = s.sourceEvent) != null && l.internal)
      return;
    const r = Ed(s.transform);
    n.mouseButton = ((c = s.sourceEvent) == null ? void 0 : c.button) || 0, n.isZoomingOrPanning = !0, n.prevViewport = r, ((f = s.sourceEvent) == null ? void 0 : f.type) === "mousedown" && t(!0), e && (e == null || e(s.sourceEvent, r));
  };
}
function $z({ zoomPanValues: n, panOnDrag: t, onPaneContextMenu: e, onTransformChange: s, onPanZoom: r }) {
  return (l) => {
    var c, f;
    n.usedRightMouseButton = !!(e && tE(t, n.mouseButton ?? 0)), (c = l.sourceEvent) != null && c.sync || s([l.transform.x, l.transform.y, l.transform.k]), r && !((f = l.sourceEvent) != null && f.internal) && (r == null || r(l.sourceEvent, Ed(l.transform)));
  };
}
function Qz({ zoomPanValues: n, panOnDrag: t, panOnScroll: e, onDraggingChange: s, onPanZoomEnd: r, onPaneContextMenu: l }) {
  return (c) => {
    var f;
    if (!((f = c.sourceEvent) != null && f.internal) && (n.isZoomingOrPanning = !1, l && tE(t, n.mouseButton ?? 0) && !n.usedRightMouseButton && c.sourceEvent && l(c.sourceEvent), n.usedRightMouseButton = !1, s(!1), r)) {
      const d = Ed(c.transform);
      n.prevViewport = d, clearTimeout(n.timerId), n.timerId = setTimeout(
        () => {
          r == null || r(c.sourceEvent, d);
        },
        // we need a setTimeout for panOnScroll to supress multiple end events fired during scroll
        e ? 150 : 0
      );
    }
  };
}
function Jz({ zoomActivationKeyPressed: n, zoomOnScroll: t, zoomOnPinch: e, panOnDrag: s, panOnScroll: r, zoomOnDoubleClick: l, userSelectionActive: c, noWheelClassName: f, noPanClassName: d, lib: h, connectionInProgress: m }) {
  return (p) => {
    var S;
    const _ = n || t, x = e && p.ctrlKey, b = p.type === "wheel";
    if (p.button === 1 && p.type === "mousedown" && (Uo(p, `${h}-flow__node`) || Uo(p, `${h}-flow__edge`)))
      return !0;
    if (!s && !_ && !r && !l && !e || c || m && !b || Uo(p, f) && b || Uo(p, d) && (!b || r && b && !n) || !e && p.ctrlKey && b)
      return !1;
    if (!e && p.type === "touchstart" && ((S = p.touches) == null ? void 0 : S.length) > 1)
      return p.preventDefault(), !1;
    if (!_ && !r && !x && b || !s && (p.type === "mousedown" || p.type === "touchstart") || Array.isArray(s) && !s.includes(p.button) && p.type === "mousedown")
      return !1;
    const M = Array.isArray(s) && s.includes(p.button) || !p.button || p.button <= 1;
    return (!p.ctrlKey || b) && M;
  };
}
function tI({ domNode: n, minZoom: t, maxZoom: e, translateExtent: s, viewport: r, onPanZoom: l, onPanZoomStart: c, onPanZoomEnd: f, onDraggingChange: d }) {
  const h = {
    isZoomingOrPanning: !1,
    usedRightMouseButton: !1,
    prevViewport: {},
    mouseButton: 0,
    timerId: void 0,
    panScrollTimeout: void 0,
    isPanScrolling: !1
  }, m = n.getBoundingClientRect(), p = A1().scaleExtent([t, e]).translateExtent(s), _ = Si(n).call(p);
  C({
    x: r.x,
    y: r.y,
    zoom: $o(r.zoom, t, e)
  }, [
    [0, 0],
    [m.width, m.height]
  ], s);
  const x = _.on("wheel.zoom"), b = _.on("dblclick.zoom");
  p.wheelDelta(eE);
  function M(L, H) {
    return _ ? new Promise((k) => {
      p == null || p.interpolate((H == null ? void 0 : H.interpolate) === "linear" ? dc : Xf).transform(Rm(_, H == null ? void 0 : H.duration, H == null ? void 0 : H.ease, () => k(!0)), L);
    }) : Promise.resolve(!1);
  }
  function S({ noWheelClassName: L, noPanClassName: H, onPaneContextMenu: k, userSelectionActive: P, panOnScroll: Y, panOnDrag: U, panOnScrollMode: X, panOnScrollSpeed: V, preventScrolling: W, zoomOnPinch: J, zoomOnScroll: I, zoomOnDoubleClick: q, zoomActivationKeyPressed: lt, lib: $, onTransformChange: ot, connectionInProgress: gt, paneClickDistance: ht, selectionOnDrag: _t }) {
    P && !h.isZoomingOrPanning && y();
    const Et = Y && !lt && !P;
    p.clickDistance(_t ? 1 / 0 : !Yi(ht) || ht < 0 ? 0 : ht);
    const Lt = Et ? qz({
      zoomPanValues: h,
      noWheelClassName: L,
      d3Selection: _,
      d3Zoom: p,
      panOnScrollMode: X,
      panOnScrollSpeed: V,
      zoomOnPinch: J,
      onPanZoomStart: c,
      onPanZoom: l,
      onPanZoomEnd: f
    }) : Zz({
      noWheelClassName: L,
      preventScrolling: W,
      d3ZoomHandler: x
    });
    if (_.on("wheel.zoom", Lt, { passive: !1 }), !P) {
      const Nt = Kz({
        zoomPanValues: h,
        onDraggingChange: d,
        onPanZoomStart: c
      });
      p.on("start", Nt);
      const Bt = $z({
        zoomPanValues: h,
        panOnDrag: U,
        onPaneContextMenu: !!k,
        onPanZoom: l,
        onTransformChange: ot
      });
      p.on("zoom", Bt);
      const K = Qz({
        zoomPanValues: h,
        panOnDrag: U,
        panOnScroll: Y,
        onPaneContextMenu: k,
        onPanZoomEnd: f,
        onDraggingChange: d
      });
      p.on("end", K);
    }
    const Gt = Jz({
      zoomActivationKeyPressed: lt,
      panOnDrag: U,
      zoomOnScroll: I,
      panOnScroll: Y,
      zoomOnDoubleClick: q,
      zoomOnPinch: J,
      userSelectionActive: P,
      noPanClassName: H,
      noWheelClassName: L,
      lib: $,
      connectionInProgress: gt
    });
    p.filter(Gt), q ? _.on("dblclick.zoom", b) : _.on("dblclick.zoom", null);
  }
  function y() {
    p.on("zoom", null);
  }
  async function C(L, H, k) {
    const P = Cm(L), Y = p == null ? void 0 : p.constrain()(P, H, k);
    return Y && await M(Y), new Promise((U) => U(Y));
  }
  async function T(L, H) {
    const k = Cm(L);
    return await M(k, H), new Promise((P) => P(k));
  }
  function E(L) {
    if (_) {
      const H = Cm(L), k = _.property("__zoom");
      (k.k !== L.zoom || k.x !== L.x || k.y !== L.y) && (p == null || p.transform(_, H, null, { sync: !0 }));
    }
  }
  function O() {
    const L = _ ? T1(_.node()) : { x: 0, y: 0, k: 1 };
    return { x: L.x, y: L.y, zoom: L.k };
  }
  function N(L, H) {
    return _ ? new Promise((k) => {
      p == null || p.interpolate((H == null ? void 0 : H.interpolate) === "linear" ? dc : Xf).scaleTo(Rm(_, H == null ? void 0 : H.duration, H == null ? void 0 : H.ease, () => k(!0)), L);
    }) : Promise.resolve(!1);
  }
  function D(L, H) {
    return _ ? new Promise((k) => {
      p == null || p.interpolate((H == null ? void 0 : H.interpolate) === "linear" ? dc : Xf).scaleBy(Rm(_, H == null ? void 0 : H.duration, H == null ? void 0 : H.ease, () => k(!0)), L);
    }) : Promise.resolve(!1);
  }
  function z(L) {
    p == null || p.scaleExtent(L);
  }
  function A(L) {
    p == null || p.translateExtent(L);
  }
  function R(L) {
    const H = !Yi(L) || L < 0 ? 0 : L;
    p == null || p.clickDistance(H);
  }
  return {
    update: S,
    destroy: y,
    setViewport: T,
    setViewportConstrained: C,
    getViewport: O,
    scaleTo: N,
    scaleBy: D,
    setScaleExtent: z,
    setTranslateExtent: A,
    syncViewport: E,
    setClickDistance: R
  };
}
var tl;
(function(n) {
  n.Line = "line", n.Handle = "handle";
})(tl || (tl = {}));
function eI({ width: n, prevWidth: t, height: e, prevHeight: s, affectsX: r, affectsY: l }) {
  const c = n - t, f = e - s, d = [c > 0 ? 1 : c < 0 ? -1 : 0, f > 0 ? 1 : f < 0 ? -1 : 0];
  return c && r && (d[0] = d[0] * -1), f && l && (d[1] = d[1] * -1), d;
}
function hb(n) {
  const t = n.includes("right") || n.includes("left"), e = n.includes("bottom") || n.includes("top"), s = n.includes("left"), r = n.includes("top");
  return {
    isHorizontal: t,
    isVertical: e,
    affectsX: s,
    affectsY: r
  };
}
function ba(n, t) {
  return Math.max(0, t - n);
}
function Ma(n, t) {
  return Math.max(0, n - t);
}
function Nf(n, t, e) {
  return Math.max(0, t - n, n - e);
}
function pb(n, t) {
  return n ? !t : t;
}
function nI(n, t, e, s, r, l, c, f) {
  let { affectsX: d, affectsY: h } = t;
  const { isHorizontal: m, isVertical: p } = t, _ = m && p, { xSnapped: x, ySnapped: b } = e, { minWidth: M, maxWidth: S, minHeight: y, maxHeight: C } = s, { x: T, y: E, width: O, height: N, aspectRatio: D } = n;
  let z = Math.floor(m ? x - n.pointerX : 0), A = Math.floor(p ? b - n.pointerY : 0);
  const R = O + (d ? -z : z), L = N + (h ? -A : A), H = -l[0] * O, k = -l[1] * N;
  let P = Nf(R, M, S), Y = Nf(L, y, C);
  if (c) {
    let V = 0, W = 0;
    d && z < 0 ? V = ba(T + z + H, c[0][0]) : !d && z > 0 && (V = Ma(T + R + H, c[1][0])), h && A < 0 ? W = ba(E + A + k, c[0][1]) : !h && A > 0 && (W = Ma(E + L + k, c[1][1])), P = Math.max(P, V), Y = Math.max(Y, W);
  }
  if (f) {
    let V = 0, W = 0;
    d && z > 0 ? V = Ma(T + z, f[0][0]) : !d && z < 0 && (V = ba(T + R, f[1][0])), h && A > 0 ? W = Ma(E + A, f[0][1]) : !h && A < 0 && (W = ba(E + L, f[1][1])), P = Math.max(P, V), Y = Math.max(Y, W);
  }
  if (r) {
    if (m) {
      const V = Nf(R / D, y, C) * D;
      if (P = Math.max(P, V), c) {
        let W = 0;
        !d && !h || d && !h && _ ? W = Ma(E + k + R / D, c[1][1]) * D : W = ba(E + k + (d ? z : -z) / D, c[0][1]) * D, P = Math.max(P, W);
      }
      if (f) {
        let W = 0;
        !d && !h || d && !h && _ ? W = ba(E + R / D, f[1][1]) * D : W = Ma(E + (d ? z : -z) / D, f[0][1]) * D, P = Math.max(P, W);
      }
    }
    if (p) {
      const V = Nf(L * D, M, S) / D;
      if (Y = Math.max(Y, V), c) {
        let W = 0;
        !d && !h || h && !d && _ ? W = Ma(T + L * D + H, c[1][0]) / D : W = ba(T + (h ? A : -A) * D + H, c[0][0]) / D, Y = Math.max(Y, W);
      }
      if (f) {
        let W = 0;
        !d && !h || h && !d && _ ? W = ba(T + L * D, f[1][0]) / D : W = Ma(T + (h ? A : -A) * D, f[0][0]) / D, Y = Math.max(Y, W);
      }
    }
  }
  A = A + (A < 0 ? Y : -Y), z = z + (z < 0 ? P : -P), r && (_ ? R > L * D ? A = (pb(d, h) ? -z : z) / D : z = (pb(d, h) ? -A : A) * D : m ? (A = z / D, h = d) : (z = A * D, d = h));
  const U = d ? T + z : T, X = h ? E + A : E;
  return {
    width: O + (d ? -z : z),
    height: N + (h ? -A : A),
    x: l[0] * z * (d ? -1 : 1) + U,
    y: l[1] * A * (h ? -1 : 1) + X
  };
}
const nE = { width: 0, height: 0, x: 0, y: 0 }, iI = {
  ...nE,
  pointerX: 0,
  pointerY: 0,
  aspectRatio: 1
};
function sI(n) {
  return [
    [0, 0],
    [n.measured.width, n.measured.height]
  ];
}
function aI(n, t, e) {
  const s = t.position.x + n.position.x, r = t.position.y + n.position.y, l = n.measured.width ?? 0, c = n.measured.height ?? 0, f = e[0] * l, d = e[1] * c;
  return [
    [s - f, r - d],
    [s + l - f, r + c - d]
  ];
}
function rI({ domNode: n, nodeId: t, getStoreItems: e, onChange: s, onEnd: r }) {
  const l = Si(n);
  let c = {
    controlDirection: hb("bottom-right"),
    boundaries: {
      minWidth: 0,
      minHeight: 0,
      maxWidth: Number.MAX_VALUE,
      maxHeight: Number.MAX_VALUE
    },
    resizeDirection: void 0,
    keepAspectRatio: !1
  };
  function f({ controlPosition: h, boundaries: m, keepAspectRatio: p, resizeDirection: _, onResizeStart: x, onResize: b, onResizeEnd: M, shouldResize: S }) {
    let y = { ...nE }, C = { ...iI };
    c = {
      boundaries: m,
      resizeDirection: _,
      keepAspectRatio: p,
      controlDirection: hb(h)
    };
    let T, E = null, O = [], N, D, z, A = !1;
    const R = f1().on("start", (L) => {
      const { nodeLookup: H, transform: k, snapGrid: P, snapToGrid: Y, nodeOrigin: U, paneDomNode: X } = e();
      if (T = H.get(t), !T)
        return;
      E = (X == null ? void 0 : X.getBoundingClientRect()) ?? null;
      const { xSnapped: V, ySnapped: W } = hc(L.sourceEvent, {
        transform: k,
        snapGrid: P,
        snapToGrid: Y,
        containerBounds: E
      });
      y = {
        width: T.measured.width ?? 0,
        height: T.measured.height ?? 0,
        x: T.position.x ?? 0,
        y: T.position.y ?? 0
      }, C = {
        ...y,
        pointerX: V,
        pointerY: W,
        aspectRatio: y.width / y.height
      }, N = void 0, T.parentId && (T.extent === "parent" || T.expandParent) && (N = H.get(T.parentId), D = N && T.extent === "parent" ? sI(N) : void 0), O = [], z = void 0;
      for (const [J, I] of H)
        if (I.parentId === t && (O.push({
          id: J,
          position: { ...I.position },
          extent: I.extent
        }), I.extent === "parent" || I.expandParent)) {
          const q = aI(I, T, I.origin ?? U);
          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;
        }
      x == null || x(L, { ...y });
    }).on("drag", (L) => {
      const { transform: H, snapGrid: k, snapToGrid: P, nodeOrigin: Y } = e(), U = hc(L.sourceEvent, {
        transform: H,
        snapGrid: k,
        snapToGrid: P,
        containerBounds: E
      }), X = [];
      if (!T)
        return;
      const { x: V, y: W, width: J, height: I } = y, q = {}, lt = T.origin ?? Y, { width: $, height: ot, x: gt, y: ht } = nI(C, c.controlDirection, U, c.boundaries, c.keepAspectRatio, lt, D, z), _t = $ !== J, Et = ot !== I, Lt = gt !== V && _t, Gt = ht !== W && Et;
      if (!Lt && !Gt && !_t && !Et)
        return;
      if ((Lt || Gt || lt[0] === 1 || lt[1] === 1) && (q.x = Lt ? gt : y.x, q.y = Gt ? ht : y.y, y.x = q.x, y.y = q.y, O.length > 0)) {
        const pe = gt - V, Xt = ht - W;
        for (const se of O)
          se.position = {
            x: se.position.x - pe + lt[0] * ($ - J),
            y: se.position.y - Xt + lt[1] * (ot - I)
          }, X.push(se);
      }
      if ((_t || Et) && (q.width = _t && (!c.resizeDirection || c.resizeDirection === "horizontal") ? $ : y.width, q.height = Et && (!c.resizeDirection || c.resizeDirection === "vertical") ? ot : y.height, y.width = q.width, y.height = q.height), N && T.expandParent) {
        const pe = lt[0] * (q.width ?? 0);
        q.x && q.x < pe && (y.x = pe, C.x = C.x - (q.x - pe));
        const Xt = lt[1] * (q.height ?? 0);
        q.y && q.y < Xt && (y.y = Xt, C.y = C.y - (q.y - Xt));
      }
      const Nt = eI({
        width: y.width,
        prevWidth: J,
        height: y.height,
        prevHeight: I,
        affectsX: c.controlDirection.affectsX,
        affectsY: c.controlDirection.affectsY
      }), Bt = { ...y, direction: Nt };
      (S == null ? void 0 : S(L, Bt)) !== !1 && (A = !0, b == null || b(L, Bt), s(q, X));
    }).on("end", (L) => {
      A && (M == null || M(L, { ...y }), r == null || r({ ...y }), A = !1);
    });
    l.call(R);
  }
  function d() {
    l.on(".drag", null);
  }
  return {
    update: f,
    destroy: d
  };
}
var Dm = { exports: {} }, Nm = {}, Lm = { exports: {} }, Um = {};
/**
 * @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 mb;
function oI() {
  if (mb) return Um;
  mb = 1;
  var n = wc();
  function t(p, _) {
    return p === _ && (p !== 0 || 1 / p === 1 / _) || p !== p && _ !== _;
  }
  var e = typeof Object.is == "function" ? Object.is : t, s = n.useState, r = n.useEffect, l = n.useLayoutEffect, c = n.useDebugValue;
  function f(p, _) {
    var x = _(), b = s({ inst: { value: x, getSnapshot: _ } }), M = b[0].inst, S = b[1];
    return l(
      function() {
        M.value = x, M.getSnapshot = _, d(M) && S({ inst: M });
      },
      [p, x, _]
    ), r(
      function() {
        return d(M) && S({ inst: M }), p(function() {
          d(M) && S({ inst: M });
        });
      },
      [p]
    ), c(x), x;
  }
  function d(p) {
    var _ = p.getSnapshot;
    p = p.value;
    try {
      var x = _();
      return !e(p, x);
    } catch {
      return !0;
    }
  }
  function h(p, _) {
    return _();
  }
  var m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? h : f;
  return Um.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : m, Um;
}
var gb;
function lI() {
  return gb || (gb = 1, Lm.exports = oI()), Lm.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 _b;
function cI() {
  if (_b) return Nm;
  _b = 1;
  var n = wc(), t = lI();
  function e(h, m) {
    return h === m && (h !== 0 || 1 / h === 1 / m) || h !== h && m !== m;
  }
  var s = typeof Object.is == "function" ? Object.is : e, r = t.useSyncExternalStore, l = n.useRef, c = n.useEffect, f = n.useMemo, d = n.useDebugValue;
  return Nm.useSyncExternalStoreWithSelector = function(h, m, p, _, x) {
    var b = l(null);
    if (b.current === null) {
      var M = { hasValue: !1, value: null };
      b.current = M;
    } else M = b.current;
    b = f(
      function() {
        function y(N) {
          if (!C) {
            if (C = !0, T = N, N = _(N), x !== void 0 && M.hasValue) {
              var D = M.value;
              if (x(D, N))
                return E = D;
            }
            return E = N;
          }
          if (D = E, s(T, N)) return D;
          var z = _(N);
          return x !== void 0 && x(D, z) ? (T = N, D) : (T = N, E = z);
        }
        var C = !1, T, E, O = p === void 0 ? null : p;
        return [
          function() {
            return y(m());
          },
          O === null ? void 0 : function() {
            return y(O());
          }
        ];
      },
      [m, p, _, x]
    );
    var S = r(h, b[0], b[1]);
    return c(
      function() {
        M.hasValue = !0, M.value = S;
      },
      [S]
    ), d(S), S;
  }, Nm;
}
var vb;
function uI() {
  return vb || (vb = 1, Dm.exports = cI()), Dm.exports;
}
var fI = uI();
const dI = /* @__PURE__ */ hM(fI), hI = {}, yb = (n) => {
  let t;
  const e = /* @__PURE__ */ new Set(), s = (m, p) => {
    const _ = typeof m == "function" ? m(t) : m;
    if (!Object.is(_, t)) {
      const x = t;
      t = p ?? (typeof _ != "object" || _ === null) ? _ : Object.assign({}, t, _), e.forEach((b) => b(t, x));
    }
  }, r = () => t, d = { setState: s, getState: r, getInitialState: () => h, subscribe: (m) => (e.add(m), () => e.delete(m)), destroy: () => {
    (hI ? "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(s, r, d);
  return d;
}, pI = (n) => n ? yb(n) : yb, { useDebugValue: mI } = lc, { useSyncExternalStoreWithSelector: gI } = dI, _I = (n) => n;
function iE(n, t = _I, e) {
  const s = gI(
    n.subscribe,
    n.getState,
    n.getServerState || n.getInitialState,
    t,
    e
  );
  return mI(s), s;
}
const xb = (n, t) => {
  const e = pI(n), s = (r, l = t) => iE(e, r, l);
  return Object.assign(s, e), s;
}, vI = (n, t) => n ? xb(n, t) : xb;
function an(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 [s, r] of n)
      if (!Object.is(r, t.get(s)))
        return !1;
    return !0;
  }
  if (n instanceof Set && t instanceof Set) {
    if (n.size !== t.size) return !1;
    for (const s of n)
      if (!t.has(s))
        return !1;
    return !0;
  }
  const e = Object.keys(n);
  if (e.length !== Object.keys(t).length)
    return !1;
  for (const s of e)
    if (!Object.prototype.hasOwnProperty.call(t, s) || !Object.is(n[s], t[s]))
      return !1;
  return !0;
}
pM();
const Td = st.createContext(null), yI = Td.Provider, sE = rs.error001();
function Ue(n, t) {
  const e = st.useContext(Td);
  if (e === null)
    throw new Error(sE);
  return iE(e, n, t);
}
function rn() {
  const n = st.useContext(Td);
  if (n === null)
    throw new Error(sE);
  return st.useMemo(() => ({
    getState: n.getState,
    setState: n.setState,
    subscribe: n.subscribe
  }), [n]);
}
const Sb = { display: "none" }, xI = {
  position: "absolute",
  width: 1,
  height: 1,
  margin: -1,
  border: 0,
  padding: 0,
  overflow: "hidden",
  clip: "rect(0px, 0px, 0px, 0px)",
  clipPath: "inset(100%)"
}, aE = "react-flow__node-desc", rE = "react-flow__edge-desc", SI = "react-flow__aria-live", bI = (n) => n.ariaLiveMessage, MI = (n) => n.ariaLabelConfig;
function EI({ rfId: n }) {
  const t = Ue(bI);
  return Z.jsx("div", { id: `${SI}-${n}`, "aria-live": "assertive", "aria-atomic": "true", style: xI, children: t });
}
function TI({ rfId: n, disableKeyboardA11y: t }) {
  const e = Ue(MI);
  return Z.jsxs(Z.Fragment, { children: [Z.jsx("div", { id: `${aE}-${n}`, style: Sb, children: t ? e["node.a11yDescription.default"] : e["node.a11yDescription.keyboardDisabled"] }), Z.jsx("div", { id: `${rE}-${n}`, style: Sb, children: e["edge.a11yDescription.default"] }), !t && Z.jsx(EI, { rfId: n })] });
}
const Ad = st.forwardRef(({ position: n = "top-left", children: t, className: e, style: s, ...r }, l) => {
  const c = `${n}`.split("-");
  return Z.jsx("div", { className: bn(["react-flow__panel", e, ...c]), style: s, ref: l, ...r, children: t });
});
Ad.displayName = "Panel";
function AI({ proOptions: n, position: t = "bottom-right" }) {
  return n != null && n.hideAttribution ? null : Z.jsx(Ad, { 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: Z.jsx("a", { href: "https://reactflow.dev", target: "_blank", rel: "noopener noreferrer", "aria-label": "React Flow attribution", children: "React Flow" }) });
}
const wI = (n) => {
  const t = [], e = [];
  for (const [, s] of n.nodeLookup)
    s.selected && t.push(s.internals.userNode);
  for (const [, s] of n.edgeLookup)
    s.selected && e.push(s);
  return { selectedNodes: t, selectedEdges: e };
}, Lf = (n) => n.id;
function CI(n, t) {
  return an(n.selectedNodes.map(Lf), t.selectedNodes.map(Lf)) && an(n.selectedEdges.map(Lf), t.selectedEdges.map(Lf));
}
function RI({ onSelectionChange: n }) {
  const t = rn(), { selectedNodes: e, selectedEdges: s } = Ue(wI, CI);
  return st.useEffect(() => {
    const r = { nodes: e, edges: s };
    n == null || n(r), t.getState().onSelectionChangeHandlers.forEach((l) => l(r));
  }, [e, s, n]), null;
}
const DI = (n) => !!n.onSelectionChangeHandlers;
function NI({ onSelectionChange: n }) {
  const t = Ue(DI);
  return n || t ? Z.jsx(RI, { onSelectionChange: n }) : null;
}
const oE = [0, 0], LI = { x: 0, y: 0, zoom: 1 }, UI = [
  "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"
], bb = [...UI, "rfId"], OI = (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
}), Mb = {
  /*
   * 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: Sc,
  nodeOrigin: oE,
  minZoom: 0.5,
  maxZoom: 2,
  elementsSelectable: !0,
  noPanClassName: "nopan",
  rfId: "1"
};
function PI(n) {
  const { setNodes: t, setEdges: e, setMinZoom: s, setMaxZoom: r, setTranslateExtent: l, setNodeExtent: c, reset: f, setDefaultNodesAndEdges: d } = Ue(OI, an), h = rn();
  st.useEffect(() => (d(n.defaultNodes, n.defaultEdges), () => {
    m.current = Mb, f();
  }), []);
  const m = st.useRef(Mb);
  return st.useEffect(
    () => {
      for (const p of bb) {
        const _ = n[p], x = m.current[p];
        _ !== x && (typeof n[p] > "u" || (p === "nodes" ? t(_) : p === "edges" ? e(_) : p === "minZoom" ? s(_) : p === "maxZoom" ? r(_) : p === "translateExtent" ? l(_) : p === "nodeExtent" ? c(_) : p === "ariaLabelConfig" ? h.setState({ ariaLabelConfig: yz(_) }) : p === "fitView" ? h.setState({ fitViewQueued: _ }) : p === "fitViewOptions" ? h.setState({ fitViewOptions: _ }) : h.setState({ [p]: _ })));
      }
      m.current = n;
    },
    // Only re-run the effect if one of the fields we track changes
    bb.map((p) => n[p])
  ), null;
}
function Eb() {
  return typeof window > "u" || !window.matchMedia ? null : window.matchMedia("(prefers-color-scheme: dark)");
}
function zI(n) {
  var s;
  const [t, e] = st.useState(n === "system" ? null : n);
  return st.useEffect(() => {
    if (n !== "system") {
      e(n);
      return;
    }
    const r = Eb(), l = () => e(r != null && r.matches ? "dark" : "light");
    return l(), r == null || r.addEventListener("change", l), () => {
      r == null || r.removeEventListener("change", l);
    };
  }, [n]), t !== null ? t : (s = Eb()) != null && s.matches ? "dark" : "light";
}
const Tb = typeof document < "u" ? document : null;
function Tc(n = null, t = { target: Tb, actInsideInputWithModifier: !0 }) {
  const [e, s] = st.useState(!1), r = st.useRef(!1), l = st.useRef(/* @__PURE__ */ new Set([])), [c, f] = st.useMemo(() => {
    if (n !== null) {
      const h = (Array.isArray(n) ? n : [n]).filter((p) => typeof p == "string").map((p) => p.replace("+", `
`).replace(`

`, `
+`).split(`
`)), m = h.reduce((p, _) => p.concat(..._), []);
      return [h, m];
    }
    return [[], []];
  }, [n]);
  return st.useEffect(() => {
    const d = (t == null ? void 0 : t.target) ?? Tb, h = (t == null ? void 0 : t.actInsideInputWithModifier) ?? !0;
    if (n !== null) {
      const m = (x) => {
        var S, y;
        if (r.current = x.ctrlKey || x.metaKey || x.shiftKey || x.altKey, (!r.current || r.current && !h) && F1(x))
          return !1;
        const M = wb(x.code, f);
        if (l.current.add(x[M]), Ab(c, l.current, !1)) {
          const C = ((y = (S = x.composedPath) == null ? void 0 : S.call(x)) == null ? void 0 : y[0]) || x.target, T = (C == null ? void 0 : C.nodeName) === "BUTTON" || (C == null ? void 0 : C.nodeName) === "A";
          t.preventDefault !== !1 && (r.current || !T) && x.preventDefault(), s(!0);
        }
      }, p = (x) => {
        const b = wb(x.code, f);
        Ab(c, l.current, !0) ? (s(!1), l.current.clear()) : l.current.delete(x[b]), x.key === "Meta" && l.current.clear(), r.current = !1;
      }, _ = () => {
        l.current.clear(), s(!1);
      };
      return d == null || d.addEventListener("keydown", m), d == null || d.addEventListener("keyup", p), window.addEventListener("blur", _), window.addEventListener("contextmenu", _), () => {
        d == null || d.removeEventListener("keydown", m), d == null || d.removeEventListener("keyup", p), window.removeEventListener("blur", _), window.removeEventListener("contextmenu", _);
      };
    }
  }, [n, s]), e;
}
function Ab(n, t, e) {
  return n.filter((s) => e || s.length === t.size).some((s) => s.every((r) => t.has(r)));
}
function wb(n, t) {
  return t.includes(n) ? "code" : "key";
}
const II = () => {
  const n = rn();
  return st.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: s } = n.getState();
      return s ? s.scaleTo(t, { duration: e == null ? void 0 : e.duration }) : Promise.resolve(!1);
    },
    getZoom: () => n.getState().transform[2],
    setViewport: async (t, e) => {
      const { transform: [s, r, l], panZoom: c } = n.getState();
      return c ? (await c.setViewport({
        x: t.x ?? s,
        y: t.y ?? r,
        zoom: t.zoom ?? l
      }, e), Promise.resolve(!0)) : Promise.resolve(!1);
    },
    getViewport: () => {
      const [t, e, s] = n.getState().transform;
      return { x: t, y: e, zoom: s };
    },
    setCenter: async (t, e, s) => n.getState().setCenter(t, e, s),
    fitBounds: async (t, e) => {
      const { width: s, height: r, minZoom: l, maxZoom: c, panZoom: f } = n.getState(), d = _0(t, s, r, l, c, (e == null ? void 0 : e.padding) ?? 0.1);
      return f ? (await f.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: s, snapGrid: r, snapToGrid: l, domNode: c } = n.getState();
      if (!c)
        return t;
      const { x: f, y: d } = c.getBoundingClientRect(), h = {
        x: t.x - f,
        y: t.y - d
      }, m = e.snapGrid ?? r, p = e.snapToGrid ?? l;
      return Ic(h, s, p, m);
    },
    flowToScreenPosition: (t) => {
      const { transform: e, domNode: s } = n.getState();
      if (!s)
        return t;
      const { x: r, y: l } = s.getBoundingClientRect(), c = fd(t, e);
      return {
        x: c.x + r,
        y: c.y + l
      };
    }
  }), []);
};
function lE(n, t) {
  const e = [], s = /* @__PURE__ */ new Map(), r = [];
  for (const l of n)
    if (l.type === "add") {
      r.push(l);
      continue;
    } else if (l.type === "remove" || l.type === "replace")
      s.set(l.id, [l]);
    else {
      const c = s.get(l.id);
      c ? c.push(l) : s.set(l.id, [l]);
    }
  for (const l of t) {
    const c = s.get(l.id);
    if (!c) {
      e.push(l);
      continue;
    }
    if (c[0].type === "remove")
      continue;
    if (c[0].type === "replace") {
      e.push({ ...c[0].item });
      continue;
    }
    const f = { ...l };
    for (const d of c)
      BI(d, f);
    e.push(f);
  }
  return r.length && r.forEach((l) => {
    l.index !== void 0 ? e.splice(l.index, 0, { ...l.item }) : e.push({ ...l.item });
  }), e;
}
function BI(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 cE(n, t) {
  return lE(n, t);
}
function uE(n, t) {
  return lE(n, t);
}
function lr(n, t) {
  return {
    id: n,
    type: "select",
    selected: t
  };
}
function Oo(n, t = /* @__PURE__ */ new Set(), e = !1) {
  const s = [];
  for (const [r, l] of n) {
    const c = t.has(r);
    !(l.selected === void 0 && !c) && l.selected !== c && (e && (l.selected = c), s.push(lr(l.id, c)));
  }
  return s;
}
function Cb({ items: n = [], lookup: t }) {
  var r;
  const e = [], s = new Map(n.map((l) => [l.id, l]));
  for (const [l, c] of n.entries()) {
    const f = t.get(c.id), d = ((r = f == null ? void 0 : f.internals) == null ? void 0 : r.userNode) ?? f;
    d !== void 0 && d !== c && e.push({ id: c.id, item: c, type: "replace" }), d === void 0 && e.push({ item: c, type: "add", index: l });
  }
  for (const [l] of t)
    s.get(l) === void 0 && e.push({ id: l, type: "remove" });
  return e;
}
function Rb(n) {
  return {
    id: n.id,
    type: "remove"
  };
}
const Db = (n) => cz(n), FI = (n) => N1(n);
function fE(n) {
  return st.forwardRef(n);
}
const HI = typeof window < "u" ? st.useLayoutEffect : st.useEffect;
function Nb(n) {
  const [t, e] = st.useState(BigInt(0)), [s] = st.useState(() => VI(() => e((r) => r + BigInt(1))));
  return HI(() => {
    const r = s.get();
    r.length && (n(r), s.reset());
  }, [t]), s;
}
function VI(n) {
  let t = [];
  return {
    get: () => t,
    reset: () => {
      t = [];
    },
    push: (e) => {
      t.push(e), n();
    }
  };
}
const dE = st.createContext(null);
function GI({ children: n }) {
  const t = rn(), e = st.useCallback((f) => {
    const { nodes: d = [], setNodes: h, hasDefaultNodes: m, onNodesChange: p, nodeLookup: _, fitViewQueued: x, onNodesChangeMiddlewareMap: b } = t.getState();
    let M = d;
    for (const y of f)
      M = typeof y == "function" ? y(M) : y;
    let S = Cb({
      items: M,
      lookup: _
    });
    for (const y of b.values())
      S = y(S);
    m && h(M), S.length > 0 ? p == null || p(S) : x && window.requestAnimationFrame(() => {
      const { fitViewQueued: y, nodes: C, setNodes: T } = t.getState();
      y && T(C);
    });
  }, []), s = Nb(e), r = st.useCallback((f) => {
    const { edges: d = [], setEdges: h, hasDefaultEdges: m, onEdgesChange: p, edgeLookup: _ } = t.getState();
    let x = d;
    for (const b of f)
      x = typeof b == "function" ? b(x) : b;
    m ? h(x) : p && p(Cb({
      items: x,
      lookup: _
    }));
  }, []), l = Nb(r), c = st.useMemo(() => ({ nodeQueue: s, edgeQueue: l }), []);
  return Z.jsx(dE.Provider, { value: c, children: n });
}
function kI() {
  const n = st.useContext(dE);
  if (!n)
    throw new Error("useBatchContext must be used within a BatchProvider");
  return n;
}
const XI = (n) => !!n.panZoom;
function E0() {
  const n = II(), t = rn(), e = kI(), s = Ue(XI), r = st.useMemo(() => {
    const l = (p) => t.getState().nodeLookup.get(p), c = (p) => {
      e.nodeQueue.push(p);
    }, f = (p) => {
      e.edgeQueue.push(p);
    }, d = (p) => {
      var y, C;
      const { nodeLookup: _, nodeOrigin: x } = t.getState(), b = Db(p) ? p : _.get(p.id), M = b.parentId ? I1(b.position, b.measured, b.parentId, _, x) : b.position, S = {
        ...b,
        position: M,
        width: ((y = b.measured) == null ? void 0 : y.width) ?? b.width,
        height: ((C = b.measured) == null ? void 0 : C.height) ?? b.height
      };
      return Qo(S);
    }, h = (p, _, x = { replace: !1 }) => {
      c((b) => b.map((M) => {
        if (M.id === p) {
          const S = typeof _ == "function" ? _(M) : _;
          return x.replace && Db(S) ? S : { ...M, ...S };
        }
        return M;
      }));
    }, m = (p, _, x = { replace: !1 }) => {
      f((b) => b.map((M) => {
        if (M.id === p) {
          const S = typeof _ == "function" ? _(M) : _;
          return x.replace && FI(S) ? S : { ...M, ...S };
        }
        return M;
      }));
    };
    return {
      getNodes: () => t.getState().nodes.map((p) => ({ ...p })),
      getNode: (p) => {
        var _;
        return (_ = l(p)) == null ? void 0 : _.internals.userNode;
      },
      getInternalNode: l,
      getEdges: () => {
        const { edges: p = [] } = t.getState();
        return p.map((_) => ({ ..._ }));
      },
      getEdge: (p) => t.getState().edgeLookup.get(p),
      setNodes: c,
      setEdges: f,
      addNodes: (p) => {
        const _ = Array.isArray(p) ? p : [p];
        e.nodeQueue.push((x) => [...x, ..._]);
      },
      addEdges: (p) => {
        const _ = Array.isArray(p) ? p : [p];
        e.edgeQueue.push((x) => [...x, ..._]);
      },
      toObject: () => {
        const { nodes: p = [], edges: _ = [], transform: x } = t.getState(), [b, M, S] = x;
        return {
          nodes: p.map((y) => ({ ...y })),
          edges: _.map((y) => ({ ...y })),
          viewport: {
            x: b,
            y: M,
            zoom: S
          }
        };
      },
      deleteElements: async ({ nodes: p = [], edges: _ = [] }) => {
        const { nodes: x, edges: b, onNodesDelete: M, onEdgesDelete: S, triggerNodeChanges: y, triggerEdgeChanges: C, onDelete: T, onBeforeDelete: E } = t.getState(), { nodes: O, edges: N } = await pz({
          nodesToRemove: p,
          edgesToRemove: _,
          nodes: x,
          edges: b,
          onBeforeDelete: E
        }), D = N.length > 0, z = O.length > 0;
        if (D) {
          const A = N.map(Rb);
          S == null || S(N), C(A);
        }
        if (z) {
          const A = O.map(Rb);
          M == null || M(O), y(A);
        }
        return (z || D) && (T == null || T({ nodes: O, edges: N })), { deletedNodes: O, deletedEdges: N };
      },
      /**
       * 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: (p, _ = !0, x) => {
        const b = nb(p), M = b ? p : d(p), S = x !== void 0;
        return M ? (x || t.getState().nodes).filter((y) => {
          const C = t.getState().nodeLookup.get(y.id);
          if (C && !b && (y.id === p.id || !C.internals.positionAbsolute))
            return !1;
          const T = Qo(S ? y : C), E = Mc(T, M);
          return _ && E > 0 || E >= T.width * T.height || E >= M.width * M.height;
        }) : [];
      },
      isNodeIntersecting: (p, _, x = !0) => {
        const M = nb(p) ? p : d(p);
        if (!M)
          return !1;
        const S = Mc(M, _);
        return x && S > 0 || S >= _.width * _.height || S >= M.width * M.height;
      },
      updateNode: h,
      updateNodeData: (p, _, x = { replace: !1 }) => {
        h(p, (b) => {
          const M = typeof _ == "function" ? _(b) : _;
          return x.replace ? { ...b, data: M } : { ...b, data: { ...b.data, ...M } };
        }, x);
      },
      updateEdge: m,
      updateEdgeData: (p, _, x = { replace: !1 }) => {
        m(p, (b) => {
          const M = typeof _ == "function" ? _(b) : _;
          return x.replace ? { ...b, data: M } : { ...b, data: { ...b.data, ...M } };
        }, x);
      },
      getNodesBounds: (p) => {
        const { nodeLookup: _, nodeOrigin: x } = t.getState();
        return uz(p, { nodeLookup: _, nodeOrigin: x });
      },
      getHandleConnections: ({ type: p, id: _, nodeId: x }) => {
        var b;
        return Array.from(((b = t.getState().connectionLookup.get(`${x}-${p}${_ ? `-${_}` : ""}`)) == null ? void 0 : b.values()) ?? []);
      },
      getNodeConnections: ({ type: p, handleId: _, nodeId: x }) => {
        var b;
        return Array.from(((b = t.getState().connectionLookup.get(`${x}${p ? _ ? `-${p}-${_}` : `-${p}` : ""}`)) == null ? void 0 : b.values()) ?? []);
      },
      fitView: async (p) => {
        const _ = t.getState().fitViewResolver ?? vz();
        return t.setState({ fitViewQueued: !0, fitViewOptions: p, fitViewResolver: _ }), e.nodeQueue.push((x) => [...x]), _.promise;
      }
    };
  }, []);
  return st.useMemo(() => ({
    ...r,
    ...n,
    viewportInitialized: s
  }), [s]);
}
const Lb = (n) => n.selected, WI = typeof window < "u" ? window : void 0;
function YI({ deleteKeyCode: n, multiSelectionKeyCode: t }) {
  const e = rn(), { deleteElements: s } = E0(), r = Tc(n, { actInsideInputWithModifier: !1 }), l = Tc(t, { target: WI });
  st.useEffect(() => {
    if (r) {
      const { edges: c, nodes: f } = e.getState();
      s({ nodes: f.filter(Lb), edges: c.filter(Lb) }), e.setState({ nodesSelectionActive: !1 });
    }
  }, [r]), st.useEffect(() => {
    e.setState({ multiSelectionActive: l });
  }, [l]);
}
function jI(n) {
  const t = rn();
  st.useEffect(() => {
    const e = () => {
      var r, l, c, f;
      if (!n.current || !(((l = (r = n.current).checkVisibility) == null ? void 0 : l.call(r)) ?? !0))
        return !1;
      const s = v0(n.current);
      (s.height === 0 || s.width === 0) && ((f = (c = t.getState()).onError) == null || f.call(c, "004", rs.error004())), t.setState({ width: s.width || 500, height: s.height || 500 });
    };
    if (n.current) {
      e(), window.addEventListener("resize", e);
      const s = new ResizeObserver(() => e());
      return s.observe(n.current), () => {
        window.removeEventListener("resize", e), s && n.current && s.unobserve(n.current);
      };
    }
  }, []);
}
const wd = {
  position: "absolute",
  width: "100%",
  height: "100%",
  top: 0,
  left: 0
}, qI = (n) => ({
  userSelectionActive: n.userSelectionActive,
  lib: n.lib,
  connectionInProgress: n.connection.inProgress
});
function ZI({ onPaneContextMenu: n, zoomOnScroll: t = !0, zoomOnPinch: e = !0, panOnScroll: s = !1, panOnScrollSpeed: r = 0.5, panOnScrollMode: l = gr.Free, zoomOnDoubleClick: c = !0, panOnDrag: f = !0, defaultViewport: d, translateExtent: h, minZoom: m, maxZoom: p, zoomActivationKeyCode: _, preventScrolling: x = !0, children: b, noWheelClassName: M, noPanClassName: S, onViewportChange: y, isControlledViewport: C, paneClickDistance: T, selectionOnDrag: E }) {
  const O = rn(), N = st.useRef(null), { userSelectionActive: D, lib: z, connectionInProgress: A } = Ue(qI, an), R = Tc(_), L = st.useRef();
  jI(N);
  const H = st.useCallback((k) => {
    y == null || y({ x: k[0], y: k[1], zoom: k[2] }), C || O.setState({ transform: k });
  }, [y, C]);
  return st.useEffect(() => {
    if (N.current) {
      L.current = tI({
        domNode: N.current,
        minZoom: m,
        maxZoom: p,
        translateExtent: h,
        viewport: d,
        onDraggingChange: (U) => O.setState((X) => X.paneDragging === U ? X : { paneDragging: U }),
        onPanZoomStart: (U, X) => {
          const { onViewportChangeStart: V, onMoveStart: W } = O.getState();
          W == null || W(U, X), V == null || V(X);
        },
        onPanZoom: (U, X) => {
          const { onViewportChange: V, onMove: W } = O.getState();
          W == null || W(U, X), V == null || V(X);
        },
        onPanZoomEnd: (U, X) => {
          const { onViewportChangeEnd: V, onMoveEnd: W } = O.getState();
          W == null || W(U, X), V == null || V(X);
        }
      });
      const { x: k, y: P, zoom: Y } = L.current.getViewport();
      return O.setState({
        panZoom: L.current,
        transform: [k, P, Y],
        domNode: N.current.closest(".react-flow")
      }), () => {
        var U;
        (U = L.current) == null || U.destroy();
      };
    }
  }, []), st.useEffect(() => {
    var k;
    (k = L.current) == null || k.update({
      onPaneContextMenu: n,
      zoomOnScroll: t,
      zoomOnPinch: e,
      panOnScroll: s,
      panOnScrollSpeed: r,
      panOnScrollMode: l,
      zoomOnDoubleClick: c,
      panOnDrag: f,
      zoomActivationKeyPressed: R,
      preventScrolling: x,
      noPanClassName: S,
      userSelectionActive: D,
      noWheelClassName: M,
      lib: z,
      onTransformChange: H,
      connectionInProgress: A,
      selectionOnDrag: E,
      paneClickDistance: T
    });
  }, [
    n,
    t,
    e,
    s,
    r,
    l,
    c,
    f,
    R,
    x,
    S,
    D,
    M,
    z,
    H,
    A,
    E,
    T
  ]), Z.jsx("div", { className: "react-flow__renderer", ref: N, style: wd, children: b });
}
const KI = (n) => ({
  userSelectionActive: n.userSelectionActive,
  userSelectionRect: n.userSelectionRect
});
function $I() {
  const { userSelectionActive: n, userSelectionRect: t } = Ue(KI, an);
  return n && t ? Z.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 Om = (n, t) => (e) => {
  e.target === t.current && (n == null || n(e));
}, QI = (n) => ({
  userSelectionActive: n.userSelectionActive,
  elementsSelectable: n.elementsSelectable,
  connectionInProgress: n.connection.inProgress,
  dragging: n.paneDragging
});
function JI({ isSelecting: n, selectionKeyPressed: t, selectionMode: e = bc.Full, panOnDrag: s, paneClickDistance: r, selectionOnDrag: l, onSelectionStart: c, onSelectionEnd: f, onPaneClick: d, onPaneContextMenu: h, onPaneScroll: m, onPaneMouseEnter: p, onPaneMouseMove: _, onPaneMouseLeave: x, children: b }) {
  const M = rn(), { userSelectionActive: S, elementsSelectable: y, dragging: C, connectionInProgress: T } = Ue(QI, an), E = y && (n || S), O = st.useRef(null), N = st.useRef(), D = st.useRef(/* @__PURE__ */ new Set()), z = st.useRef(/* @__PURE__ */ new Set()), A = st.useRef(!1), R = (V) => {
    if (A.current || T) {
      A.current = !1;
      return;
    }
    d == null || d(V), M.getState().resetSelectedElements(), M.setState({ nodesSelectionActive: !1 });
  }, L = (V) => {
    if (Array.isArray(s) && (s != null && s.includes(2))) {
      V.preventDefault();
      return;
    }
    h == null || h(V);
  }, H = m ? (V) => m(V) : void 0, k = (V) => {
    A.current && (V.stopPropagation(), A.current = !1);
  }, P = (V) => {
    var ot, gt;
    const { domNode: W } = M.getState();
    if (N.current = W == null ? void 0 : W.getBoundingClientRect(), !N.current)
      return;
    const J = V.target === O.current;
    if (!J && !!V.target.closest(".nokey") || !n || !(l && J || t) || V.button !== 0 || !V.isPrimary)
      return;
    (gt = (ot = V.target) == null ? void 0 : ot.setPointerCapture) == null || gt.call(ot, V.pointerId), A.current = !1;
    const { x: lt, y: $ } = ji(V.nativeEvent, N.current);
    M.setState({
      userSelectionRect: {
        width: 0,
        height: 0,
        startX: lt,
        startY: $,
        x: lt,
        y: $
      }
    }), J || (V.stopPropagation(), V.preventDefault());
  }, Y = (V) => {
    const { userSelectionRect: W, transform: J, nodeLookup: I, edgeLookup: q, connectionLookup: lt, triggerNodeChanges: $, triggerEdgeChanges: ot, defaultEdgeOptions: gt, resetSelectedElements: ht } = M.getState();
    if (!N.current || !W)
      return;
    const { x: _t, y: Et } = ji(V.nativeEvent, N.current), { startX: Lt, startY: Gt } = W;
    if (!A.current) {
      const Xt = t ? 0 : r;
      if (Math.hypot(_t - Lt, Et - Gt) <= Xt)
        return;
      ht(), c == null || c(V);
    }
    A.current = !0;
    const Nt = {
      startX: Lt,
      startY: Gt,
      x: _t < Lt ? _t : Lt,
      y: Et < Gt ? Et : Gt,
      width: Math.abs(_t - Lt),
      height: Math.abs(Et - Gt)
    }, Bt = D.current, K = z.current;
    D.current = new Set(g0(I, Nt, J, e === bc.Partial, !0).map((Xt) => Xt.id)), z.current = /* @__PURE__ */ new Set();
    const pe = (gt == null ? void 0 : gt.selectable) ?? !0;
    for (const Xt of D.current) {
      const se = lt.get(Xt);
      if (se)
        for (const { edgeId: qt } of se.values()) {
          const xe = q.get(qt);
          xe && (xe.selectable ?? pe) && z.current.add(qt);
        }
    }
    if (!ib(Bt, D.current)) {
      const Xt = Oo(I, D.current, !0);
      $(Xt);
    }
    if (!ib(K, z.current)) {
      const Xt = Oo(q, z.current);
      ot(Xt);
    }
    M.setState({
      userSelectionRect: Nt,
      userSelectionActive: !0,
      nodesSelectionActive: !1
    });
  }, U = (V) => {
    var W, J;
    V.button === 0 && ((J = (W = V.target) == null ? void 0 : W.releasePointerCapture) == null || J.call(W, V.pointerId), !S && V.target === O.current && M.getState().userSelectionRect && (R == null || R(V)), M.setState({
      userSelectionActive: !1,
      userSelectionRect: null
    }), A.current && (f == null || f(V), M.setState({
      nodesSelectionActive: D.current.size > 0
    })));
  }, X = s === !0 || Array.isArray(s) && s.includes(0);
  return Z.jsxs("div", { className: bn(["react-flow__pane", { draggable: X, dragging: C, selection: n }]), onClick: E ? void 0 : Om(R, O), onContextMenu: Om(L, O), onWheel: Om(H, O), onPointerEnter: E ? void 0 : p, onPointerMove: E ? Y : _, onPointerUp: E ? U : void 0, onPointerDownCapture: E ? P : void 0, onClickCapture: E ? k : void 0, onPointerLeave: x, ref: O, style: wd, children: [b, Z.jsx($I, {})] });
}
function Gg({ id: n, store: t, unselect: e = !1, nodeRef: s }) {
  const { addSelectedNodes: r, unselectNodesAndEdges: l, multiSelectionActive: c, nodeLookup: f, onError: d } = t.getState(), h = f.get(n);
  if (!h) {
    d == null || d("012", rs.error012(n));
    return;
  }
  t.setState({ nodesSelectionActive: !1 }), h.selected ? (e || h.selected && c) && (l({ nodes: [h], edges: [] }), requestAnimationFrame(() => {
    var m;
    return (m = s == null ? void 0 : s.current) == null ? void 0 : m.blur();
  })) : r([n]);
}
function hE({ nodeRef: n, disabled: t = !1, noDragClassName: e, handleSelector: s, nodeId: r, isSelectable: l, nodeClickDistance: c }) {
  const f = rn(), [d, h] = st.useState(!1), m = st.useRef();
  return st.useEffect(() => {
    m.current = Hz({
      getStoreItems: () => f.getState(),
      onNodeMouseDown: (p) => {
        Gg({
          id: p,
          store: f,
          nodeRef: n
        });
      },
      onDragStart: () => {
        h(!0);
      },
      onDragStop: () => {
        h(!1);
      }
    });
  }, []), st.useEffect(() => {
    if (!(t || !n.current || !m.current))
      return m.current.update({
        noDragClassName: e,
        handleSelector: s,
        domNode: n.current,
        isSelectable: l,
        nodeId: r,
        nodeClickDistance: c
      }), () => {
        var p;
        (p = m.current) == null || p.destroy();
      };
  }, [e, s, t, l, n, r, c]), d;
}
const tB = (n) => (t) => t.selected && (t.draggable || n && typeof t.draggable > "u");
function pE() {
  const n = rn();
  return st.useCallback((e) => {
    const { nodeExtent: s, snapToGrid: r, snapGrid: l, nodesDraggable: c, onError: f, updateNodePositions: d, nodeLookup: h, nodeOrigin: m } = n.getState(), p = /* @__PURE__ */ new Map(), _ = tB(c), x = r ? l[0] : 5, b = r ? l[1] : 5, M = e.direction.x * x * e.factor, S = e.direction.y * b * e.factor;
    for (const [, y] of h) {
      if (!_(y))
        continue;
      let C = {
        x: y.internals.positionAbsolute.x + M,
        y: y.internals.positionAbsolute.y + S
      };
      r && (C = zc(C, l));
      const { position: T, positionAbsolute: E } = L1({
        nodeId: y.id,
        nextPosition: C,
        nodeLookup: h,
        nodeExtent: s,
        nodeOrigin: m,
        onError: f
      });
      y.position = T, y.internals.positionAbsolute = E, p.set(y.id, y);
    }
    d(p);
  }, []);
}
const T0 = st.createContext(null), eB = T0.Provider;
T0.Consumer;
const mE = () => st.useContext(T0), nB = (n) => ({
  connectOnClick: n.connectOnClick,
  noPanClassName: n.noPanClassName,
  rfId: n.rfId
}), iB = (n, t, e) => (s) => {
  const { connectionClickStartHandle: r, connectionMode: l, connection: c } = s, { fromHandle: f, toHandle: d, isValid: h } = c, m = (d == null ? void 0 : d.nodeId) === n && (d == null ? void 0 : d.id) === t && (d == null ? void 0 : d.type) === e;
  return {
    connectingFrom: (f == null ? void 0 : f.nodeId) === n && (f == null ? void 0 : f.id) === t && (f == null ? void 0 : f.type) === e,
    connectingTo: m,
    clickConnecting: (r == null ? void 0 : r.nodeId) === n && (r == null ? void 0 : r.id) === t && (r == null ? void 0 : r.type) === e,
    isPossibleEndHandle: l === Ko.Strict ? (f == null ? void 0 : f.type) !== e : n !== (f == null ? void 0 : f.nodeId) || t !== (f == null ? void 0 : f.id),
    connectionInProcess: !!f,
    clickConnectionInProcess: !!r,
    valid: m && h
  };
};
function sB({ type: n = "source", position: t = ne.Top, isValidConnection: e, isConnectable: s = !0, isConnectableStart: r = !0, isConnectableEnd: l = !0, id: c, onConnect: f, children: d, className: h, onMouseDown: m, onTouchStart: p, ..._ }, x) {
  var Y, U;
  const b = c || null, M = n === "target", S = rn(), y = mE(), { connectOnClick: C, noPanClassName: T, rfId: E } = Ue(nB, an), { connectingFrom: O, connectingTo: N, clickConnecting: D, isPossibleEndHandle: z, connectionInProcess: A, clickConnectionInProcess: R, valid: L } = Ue(iB(y, b, n), an);
  y || (U = (Y = S.getState()).onError) == null || U.call(Y, "010", rs.error010());
  const H = (X) => {
    const { defaultEdgeOptions: V, onConnect: W, hasDefaultEdges: J } = S.getState(), I = {
      ...V,
      ...X
    };
    if (J) {
      const { edges: q, setEdges: lt } = S.getState();
      lt(X1(I, q));
    }
    W == null || W(I), f == null || f(I);
  }, k = (X) => {
    if (!y)
      return;
    const V = H1(X.nativeEvent);
    if (r && (V && X.button === 0 || !V)) {
      const W = S.getState();
      Vg.onPointerDown(X.nativeEvent, {
        handleDomNode: X.currentTarget,
        autoPanOnConnect: W.autoPanOnConnect,
        connectionMode: W.connectionMode,
        connectionRadius: W.connectionRadius,
        domNode: W.domNode,
        nodeLookup: W.nodeLookup,
        lib: W.lib,
        isTarget: M,
        handleId: b,
        nodeId: y,
        flowId: W.rfId,
        panBy: W.panBy,
        cancelConnection: W.cancelConnection,
        onConnectStart: W.onConnectStart,
        onConnectEnd: (...J) => {
          var I, q;
          return (q = (I = S.getState()).onConnectEnd) == null ? void 0 : q.call(I, ...J);
        },
        updateConnection: W.updateConnection,
        onConnect: H,
        isValidConnection: e || ((...J) => {
          var I, q;
          return ((q = (I = S.getState()).isValidConnection) == null ? void 0 : q.call(I, ...J)) ?? !0;
        }),
        getTransform: () => S.getState().transform,
        getFromHandle: () => S.getState().connection.fromHandle,
        autoPanSpeed: W.autoPanSpeed,
        dragThreshold: W.connectionDragThreshold
      });
    }
    V ? m == null || m(X) : p == null || p(X);
  }, P = (X) => {
    const { onClickConnectStart: V, onClickConnectEnd: W, connectionClickStartHandle: J, connectionMode: I, isValidConnection: q, lib: lt, rfId: $, nodeLookup: ot, connection: gt } = S.getState();
    if (!y || !J && !r)
      return;
    if (!J) {
      V == null || V(X.nativeEvent, { nodeId: y, handleId: b, handleType: n }), S.setState({ connectionClickStartHandle: { nodeId: y, type: n, id: b } });
      return;
    }
    const ht = B1(X.target), _t = e || q, { connection: Et, isValid: Lt } = Vg.isValid(X.nativeEvent, {
      handle: {
        nodeId: y,
        id: b,
        type: n
      },
      connectionMode: I,
      fromNodeId: J.nodeId,
      fromHandleId: J.id || null,
      fromType: J.type,
      isValidConnection: _t,
      flowId: $,
      doc: ht,
      lib: lt,
      nodeLookup: ot
    });
    Lt && Et && H(Et);
    const Gt = structuredClone(gt);
    delete Gt.inProgress, Gt.toPosition = Gt.toHandle ? Gt.toHandle.position : null, W == null || W(X, Gt), S.setState({ connectionClickStartHandle: null });
  };
  return Z.jsx("div", { "data-handleid": b, "data-nodeid": y, "data-handlepos": t, "data-id": `${E}-${y}-${b}-${n}`, className: bn([
    "react-flow__handle",
    `react-flow__handle-${t}`,
    "nodrag",
    T,
    h,
    {
      source: !M,
      target: M,
      connectable: s,
      connectablestart: r,
      connectableend: l,
      clickconnecting: D,
      connectingfrom: O,
      connectingto: N,
      valid: L,
      /*
       * shows where you can start a connection from
       * and where you can end it while connecting
       */
      connectionindicator: s && (!A || z) && (A || R ? l : r)
    }
  ]), onMouseDown: k, onTouchStart: k, onClick: C ? P : void 0, ref: x, ..._, children: d });
}
const el = st.memo(fE(sB));
function aB({ data: n, isConnectable: t, sourcePosition: e = ne.Bottom }) {
  return Z.jsxs(Z.Fragment, { children: [n == null ? void 0 : n.label, Z.jsx(el, { type: "source", position: e, isConnectable: t })] });
}
function rB({ data: n, isConnectable: t, targetPosition: e = ne.Top, sourcePosition: s = ne.Bottom }) {
  return Z.jsxs(Z.Fragment, { children: [Z.jsx(el, { type: "target", position: e, isConnectable: t }), n == null ? void 0 : n.label, Z.jsx(el, { type: "source", position: s, isConnectable: t })] });
}
function oB() {
  return null;
}
function lB({ data: n, isConnectable: t, targetPosition: e = ne.Top }) {
  return Z.jsxs(Z.Fragment, { children: [Z.jsx(el, { type: "target", position: e, isConnectable: t }), n == null ? void 0 : n.label] });
}
const dd = {
  ArrowUp: { x: 0, y: -1 },
  ArrowDown: { x: 0, y: 1 },
  ArrowLeft: { x: -1, y: 0 },
  ArrowRight: { x: 1, y: 0 }
}, Ub = {
  input: aB,
  default: rB,
  output: lB,
  group: oB
};
function cB(n) {
  var t, e, s, r;
  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 ?? ((s = n.style) == null ? void 0 : s.width),
    height: n.height ?? ((r = n.style) == null ? void 0 : r.height)
  };
}
const uB = (n) => {
  const { width: t, height: e, x: s, y: r } = Pc(n.nodeLookup, {
    filter: (l) => !!l.selected
  });
  return {
    width: Yi(t) ? t : null,
    height: Yi(e) ? e : null,
    userSelectionActive: n.userSelectionActive,
    transformString: `translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]}) translate(${s}px,${r}px)`
  };
};
function fB({ onSelectionContextMenu: n, noPanClassName: t, disableKeyboardA11y: e }) {
  const s = rn(), { width: r, height: l, transformString: c, userSelectionActive: f } = Ue(uB, an), d = pE(), h = st.useRef(null);
  st.useEffect(() => {
    var x;
    e || (x = h.current) == null || x.focus({
      preventScroll: !0
    });
  }, [e]);
  const m = !f && r !== null && l !== null;
  if (hE({
    nodeRef: h,
    disabled: !m
  }), !m)
    return null;
  const p = n ? (x) => {
    const b = s.getState().nodes.filter((M) => M.selected);
    n(x, b);
  } : void 0, _ = (x) => {
    Object.prototype.hasOwnProperty.call(dd, x.key) && (x.preventDefault(), d({
      direction: dd[x.key],
      factor: x.shiftKey ? 4 : 1
    }));
  };
  return Z.jsx("div", { className: bn(["react-flow__nodesselection", "react-flow__container", t]), style: {
    transform: c
  }, children: Z.jsx("div", { ref: h, className: "react-flow__nodesselection-rect", onContextMenu: p, tabIndex: e ? void 0 : -1, onKeyDown: e ? void 0 : _, style: {
    width: r,
    height: l
  } }) });
}
const Ob = typeof window < "u" ? window : void 0, dB = (n) => ({ nodesSelectionActive: n.nodesSelectionActive, userSelectionActive: n.userSelectionActive });
function gE({ children: n, onPaneClick: t, onPaneMouseEnter: e, onPaneMouseMove: s, onPaneMouseLeave: r, onPaneContextMenu: l, onPaneScroll: c, paneClickDistance: f, deleteKeyCode: d, selectionKeyCode: h, selectionOnDrag: m, selectionMode: p, onSelectionStart: _, onSelectionEnd: x, multiSelectionKeyCode: b, panActivationKeyCode: M, zoomActivationKeyCode: S, elementsSelectable: y, zoomOnScroll: C, zoomOnPinch: T, panOnScroll: E, panOnScrollSpeed: O, panOnScrollMode: N, zoomOnDoubleClick: D, panOnDrag: z, defaultViewport: A, translateExtent: R, minZoom: L, maxZoom: H, preventScrolling: k, onSelectionContextMenu: P, noWheelClassName: Y, noPanClassName: U, disableKeyboardA11y: X, onViewportChange: V, isControlledViewport: W }) {
  const { nodesSelectionActive: J, userSelectionActive: I } = Ue(dB, an), q = Tc(h, { target: Ob }), lt = Tc(M, { target: Ob }), $ = lt || z, ot = lt || E, gt = m && $ !== !0, ht = q || I || gt;
  return YI({ deleteKeyCode: d, multiSelectionKeyCode: b }), Z.jsx(ZI, { onPaneContextMenu: l, elementsSelectable: y, zoomOnScroll: C, zoomOnPinch: T, panOnScroll: ot, panOnScrollSpeed: O, panOnScrollMode: N, zoomOnDoubleClick: D, panOnDrag: !q && $, defaultViewport: A, translateExtent: R, minZoom: L, maxZoom: H, zoomActivationKeyCode: S, preventScrolling: k, noWheelClassName: Y, noPanClassName: U, onViewportChange: V, isControlledViewport: W, paneClickDistance: f, selectionOnDrag: gt, children: Z.jsxs(JI, { onSelectionStart: _, onSelectionEnd: x, onPaneClick: t, onPaneMouseEnter: e, onPaneMouseMove: s, onPaneMouseLeave: r, onPaneContextMenu: l, onPaneScroll: c, panOnDrag: $, isSelecting: !!ht, selectionMode: p, selectionKeyPressed: q, paneClickDistance: f, selectionOnDrag: gt, children: [n, J && Z.jsx(fB, { onSelectionContextMenu: P, noPanClassName: U, disableKeyboardA11y: X })] }) });
}
gE.displayName = "FlowRenderer";
const hB = st.memo(gE), pB = (n) => (t) => n ? g0(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 mB(n) {
  return Ue(st.useCallback(pB(n), [n]), an);
}
const gB = (n) => n.updateNodeInternals;
function _B() {
  const n = Ue(gB), [t] = st.useState(() => typeof ResizeObserver > "u" ? null : new ResizeObserver((e) => {
    const s = /* @__PURE__ */ new Map();
    e.forEach((r) => {
      const l = r.target.getAttribute("data-id");
      s.set(l, {
        id: l,
        nodeElement: r.target,
        force: !0
      });
    }), n(s);
  }));
  return st.useEffect(() => () => {
    t == null || t.disconnect();
  }, [t]), t;
}
function vB({ node: n, nodeType: t, hasDimensions: e, resizeObserver: s }) {
  const r = rn(), l = st.useRef(null), c = st.useRef(null), f = st.useRef(n.sourcePosition), d = st.useRef(n.targetPosition), h = st.useRef(t), m = e && !!n.internals.handleBounds;
  return st.useEffect(() => {
    l.current && !n.hidden && (!m || c.current !== l.current) && (c.current && (s == null || s.unobserve(c.current)), s == null || s.observe(l.current), c.current = l.current);
  }, [m, n.hidden]), st.useEffect(() => () => {
    c.current && (s == null || s.unobserve(c.current), c.current = null);
  }, []), st.useEffect(() => {
    if (l.current) {
      const p = h.current !== t, _ = f.current !== n.sourcePosition, x = d.current !== n.targetPosition;
      (p || _ || x) && (h.current = t, f.current = n.sourcePosition, d.current = n.targetPosition, r.getState().updateNodeInternals(/* @__PURE__ */ new Map([[n.id, { id: n.id, nodeElement: l.current, force: !0 }]])));
    }
  }, [n.id, t, n.sourcePosition, n.targetPosition]), l;
}
function yB({ id: n, onClick: t, onMouseEnter: e, onMouseMove: s, onMouseLeave: r, onContextMenu: l, onDoubleClick: c, nodesDraggable: f, elementsSelectable: d, nodesConnectable: h, nodesFocusable: m, resizeObserver: p, noDragClassName: _, noPanClassName: x, disableKeyboardA11y: b, rfId: M, nodeTypes: S, nodeClickDistance: y, onError: C }) {
  const { node: T, internals: E, isParent: O } = Ue((_t) => {
    const Et = _t.nodeLookup.get(n), Lt = _t.parentLookup.has(n);
    return {
      node: Et,
      internals: Et.internals,
      isParent: Lt
    };
  }, an);
  let N = T.type || "default", D = (S == null ? void 0 : S[N]) || Ub[N];
  D === void 0 && (C == null || C("003", rs.error003(N)), N = "default", D = (S == null ? void 0 : S.default) || Ub.default);
  const z = !!(T.draggable || f && typeof T.draggable > "u"), A = !!(T.selectable || d && typeof T.selectable > "u"), R = !!(T.connectable || h && typeof T.connectable > "u"), L = !!(T.focusable || m && typeof T.focusable > "u"), H = rn(), k = z1(T), P = vB({ node: T, nodeType: N, hasDimensions: k, resizeObserver: p }), Y = hE({
    nodeRef: P,
    disabled: T.hidden || !z,
    noDragClassName: _,
    handleSelector: T.dragHandle,
    nodeId: n,
    isSelectable: A,
    nodeClickDistance: y
  }), U = pE();
  if (T.hidden)
    return null;
  const X = ks(T), V = cB(T), W = A || z || t || e || s || r, J = e ? (_t) => e(_t, { ...E.userNode }) : void 0, I = s ? (_t) => s(_t, { ...E.userNode }) : void 0, q = r ? (_t) => r(_t, { ...E.userNode }) : void 0, lt = l ? (_t) => l(_t, { ...E.userNode }) : void 0, $ = c ? (_t) => c(_t, { ...E.userNode }) : void 0, ot = (_t) => {
    const { selectNodesOnDrag: Et, nodeDragThreshold: Lt } = H.getState();
    A && (!Et || !z || Lt > 0) && Gg({
      id: n,
      store: H,
      nodeRef: P
    }), t && t(_t, { ...E.userNode });
  }, gt = (_t) => {
    if (!(F1(_t.nativeEvent) || b)) {
      if (w1.includes(_t.key) && A) {
        const Et = _t.key === "Escape";
        Gg({
          id: n,
          store: H,
          unselect: Et,
          nodeRef: P
        });
      } else if (z && T.selected && Object.prototype.hasOwnProperty.call(dd, _t.key)) {
        _t.preventDefault();
        const { ariaLabelConfig: Et } = H.getState();
        H.setState({
          ariaLiveMessage: Et["node.a11yDescription.ariaLiveMessage"]({
            direction: _t.key.replace("Arrow", "").toLowerCase(),
            x: ~~E.positionAbsolute.x,
            y: ~~E.positionAbsolute.y
          })
        }), U({
          direction: dd[_t.key],
          factor: _t.shiftKey ? 4 : 1
        });
      }
    }
  }, ht = () => {
    var K;
    if (b || !((K = P.current) != null && K.matches(":focus-visible")))
      return;
    const { transform: _t, width: Et, height: Lt, autoPanOnNodeFocus: Gt, setCenter: Nt } = H.getState();
    if (!Gt)
      return;
    g0(/* @__PURE__ */ new Map([[n, T]]), { x: 0, y: 0, width: Et, height: Lt }, _t, !0).length > 0 || Nt(T.position.x + X.width / 2, T.position.y + X.height / 2, {
      zoom: _t[2]
    });
  };
  return Z.jsx("div", { className: bn([
    "react-flow__node",
    `react-flow__node-${N}`,
    {
      // this is overwritable by passing `nopan` as a class name
      [x]: z
    },
    T.className,
    {
      selected: T.selected,
      selectable: A,
      parent: O,
      draggable: z,
      dragging: Y
    }
  ]), ref: P, style: {
    zIndex: E.z,
    transform: `translate(${E.positionAbsolute.x}px,${E.positionAbsolute.y}px)`,
    pointerEvents: W ? "all" : "none",
    visibility: k ? "visible" : "hidden",
    ...T.style,
    ...V
  }, "data-id": n, "data-testid": `rf__node-${n}`, onMouseEnter: J, onMouseMove: I, onMouseLeave: q, onContextMenu: lt, onClick: ot, onDoubleClick: $, onKeyDown: L ? gt : void 0, tabIndex: L ? 0 : void 0, onFocus: L ? ht : void 0, role: T.ariaRole ?? (L ? "group" : void 0), "aria-roledescription": "node", "aria-describedby": b ? void 0 : `${aE}-${M}`, "aria-label": T.ariaLabel, ...T.domAttributes, children: Z.jsx(eB, { value: n, children: Z.jsx(D, { id: n, data: T.data, type: N, positionAbsoluteX: E.positionAbsolute.x, positionAbsoluteY: E.positionAbsolute.y, selected: T.selected ?? !1, selectable: A, draggable: z, deletable: T.deletable ?? !0, isConnectable: R, sourcePosition: T.sourcePosition, targetPosition: T.targetPosition, dragging: Y, dragHandle: T.dragHandle, zIndex: E.z, parentId: T.parentId, ...X }) }) });
}
var xB = st.memo(yB);
const SB = (n) => ({
  nodesDraggable: n.nodesDraggable,
  nodesConnectable: n.nodesConnectable,
  nodesFocusable: n.nodesFocusable,
  elementsSelectable: n.elementsSelectable,
  onError: n.onError
});
function _E(n) {
  const { nodesDraggable: t, nodesConnectable: e, nodesFocusable: s, elementsSelectable: r, onError: l } = Ue(SB, an), c = mB(n.onlyRenderVisibleElements), f = _B();
  return Z.jsx("div", { className: "react-flow__nodes", style: wd, 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.
     */
    Z.jsx(xB, { 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: f, nodesDraggable: t, nodesConnectable: e, nodesFocusable: s, elementsSelectable: r, nodeClickDistance: n.nodeClickDistance, onError: l }, d)
  )) });
}
_E.displayName = "NodeRenderer";
const bB = st.memo(_E);
function MB(n) {
  return Ue(st.useCallback((e) => {
    if (!n)
      return e.edges.map((r) => r.id);
    const s = [];
    if (e.width && e.height)
      for (const r of e.edges) {
        const l = e.nodeLookup.get(r.source), c = e.nodeLookup.get(r.target);
        l && c && bz({
          sourceNode: l,
          targetNode: c,
          width: e.width,
          height: e.height,
          transform: e.transform
        }) && s.push(r.id);
      }
    return s;
  }, [n]), an);
}
const EB = ({ color: n = "none", strokeWidth: t = 1 }) => {
  const e = {
    strokeWidth: t,
    ...n && { stroke: n }
  };
  return Z.jsx("polyline", { className: "arrow", style: e, strokeLinecap: "round", fill: "none", strokeLinejoin: "round", points: "-5,-4 0,0 -5,4" });
}, TB = ({ color: n = "none", strokeWidth: t = 1 }) => {
  const e = {
    strokeWidth: t,
    ...n && { stroke: n, fill: n }
  };
  return Z.jsx("polyline", { className: "arrowclosed", style: e, strokeLinecap: "round", strokeLinejoin: "round", points: "-5,-4 0,0 -5,4 -5,-4" });
}, Pb = {
  [cd.Arrow]: EB,
  [cd.ArrowClosed]: TB
};
function AB(n) {
  const t = rn();
  return st.useMemo(() => {
    var r, l;
    return Object.prototype.hasOwnProperty.call(Pb, n) ? Pb[n] : ((l = (r = t.getState()).onError) == null || l.call(r, "009", rs.error009(n)), null);
  }, [n]);
}
const wB = ({ id: n, type: t, color: e, width: s = 12.5, height: r = 12.5, markerUnits: l = "strokeWidth", strokeWidth: c, orient: f = "auto-start-reverse" }) => {
  const d = AB(t);
  return d ? Z.jsx("marker", { className: "react-flow__arrowhead", id: n, markerWidth: `${s}`, markerHeight: `${r}`, viewBox: "-10 -10 20 20", markerUnits: l, orient: f, refX: "0", refY: "0", children: Z.jsx(d, { color: e, strokeWidth: c }) }) : null;
}, vE = ({ defaultColor: n, rfId: t }) => {
  const e = Ue((l) => l.edges), s = Ue((l) => l.defaultEdgeOptions), r = st.useMemo(() => Rz(e, {
    id: t,
    defaultColor: n,
    defaultMarkerStart: s == null ? void 0 : s.markerStart,
    defaultMarkerEnd: s == null ? void 0 : s.markerEnd
  }), [e, s, t, n]);
  return r.length ? Z.jsx("svg", { className: "react-flow__marker", "aria-hidden": "true", children: Z.jsx("defs", { children: r.map((l) => Z.jsx(wB, { id: l.id, type: l.type, color: l.color, width: l.width, height: l.height, markerUnits: l.markerUnits, strokeWidth: l.strokeWidth, orient: l.orient }, l.id)) }) }) : null;
};
vE.displayName = "MarkerDefinitions";
var CB = st.memo(vE);
function yE({ x: n, y: t, label: e, labelStyle: s, labelShowBg: r = !0, labelBgStyle: l, labelBgPadding: c = [2, 4], labelBgBorderRadius: f = 2, children: d, className: h, ...m }) {
  const [p, _] = st.useState({ x: 1, y: 0, width: 0, height: 0 }), x = bn(["react-flow__edge-textwrapper", h]), b = st.useRef(null);
  return st.useEffect(() => {
    if (b.current) {
      const M = b.current.getBBox();
      _({
        x: M.x,
        y: M.y,
        width: M.width,
        height: M.height
      });
    }
  }, [e]), e ? Z.jsxs("g", { transform: `translate(${n - p.width / 2} ${t - p.height / 2})`, className: x, visibility: p.width ? "visible" : "hidden", ...m, children: [r && Z.jsx("rect", { width: p.width + 2 * c[0], x: -c[0], y: -c[1], height: p.height + 2 * c[1], className: "react-flow__edge-textbg", style: l, rx: f, ry: f }), Z.jsx("text", { className: "react-flow__edge-text", y: p.height / 2, dy: "0.3em", ref: b, style: s, children: e }), d] }) : null;
}
yE.displayName = "EdgeText";
const RB = st.memo(yE);
function Cd({ path: n, labelX: t, labelY: e, label: s, labelStyle: r, labelShowBg: l, labelBgStyle: c, labelBgPadding: f, labelBgBorderRadius: d, interactionWidth: h = 20, ...m }) {
  return Z.jsxs(Z.Fragment, { children: [Z.jsx("path", { ...m, d: n, fill: "none", className: bn(["react-flow__edge-path", m.className]) }), h ? Z.jsx("path", { d: n, fill: "none", strokeOpacity: 0, strokeWidth: h, className: "react-flow__edge-interaction" }) : null, s && Yi(t) && Yi(e) ? Z.jsx(RB, { x: t, y: e, label: s, labelStyle: r, labelShowBg: l, labelBgStyle: c, labelBgPadding: f, labelBgBorderRadius: d }) : null] });
}
function zb({ pos: n, x1: t, y1: e, x2: s, y2: r }) {
  return n === ne.Left || n === ne.Right ? [0.5 * (t + s), e] : [t, 0.5 * (e + r)];
}
function xE({ sourceX: n, sourceY: t, sourcePosition: e = ne.Bottom, targetX: s, targetY: r, targetPosition: l = ne.Top }) {
  const [c, f] = zb({
    pos: e,
    x1: n,
    y1: t,
    x2: s,
    y2: r
  }), [d, h] = zb({
    pos: l,
    x1: s,
    y1: r,
    x2: n,
    y2: t
  }), [m, p, _, x] = V1({
    sourceX: n,
    sourceY: t,
    targetX: s,
    targetY: r,
    sourceControlX: c,
    sourceControlY: f,
    targetControlX: d,
    targetControlY: h
  });
  return [
    `M${n},${t} C${c},${f} ${d},${h} ${s},${r}`,
    m,
    p,
    _,
    x
  ];
}
function SE(n) {
  return st.memo(({ id: t, sourceX: e, sourceY: s, targetX: r, targetY: l, sourcePosition: c, targetPosition: f, label: d, labelStyle: h, labelShowBg: m, labelBgStyle: p, labelBgPadding: _, labelBgBorderRadius: x, style: b, markerEnd: M, markerStart: S, interactionWidth: y }) => {
    const [C, T, E] = xE({
      sourceX: e,
      sourceY: s,
      sourcePosition: c,
      targetX: r,
      targetY: l,
      targetPosition: f
    }), O = n.isInternal ? void 0 : t;
    return Z.jsx(Cd, { id: O, path: C, labelX: T, labelY: E, label: d, labelStyle: h, labelShowBg: m, labelBgStyle: p, labelBgPadding: _, labelBgBorderRadius: x, style: b, markerEnd: M, markerStart: S, interactionWidth: y });
  });
}
const DB = SE({ isInternal: !1 }), bE = SE({ isInternal: !0 });
DB.displayName = "SimpleBezierEdge";
bE.displayName = "SimpleBezierEdgeInternal";
function ME(n) {
  return st.memo(({ id: t, sourceX: e, sourceY: s, targetX: r, targetY: l, label: c, labelStyle: f, labelShowBg: d, labelBgStyle: h, labelBgPadding: m, labelBgBorderRadius: p, style: _, sourcePosition: x = ne.Bottom, targetPosition: b = ne.Top, markerEnd: M, markerStart: S, pathOptions: y, interactionWidth: C }) => {
    const [T, E, O] = Bg({
      sourceX: e,
      sourceY: s,
      sourcePosition: x,
      targetX: r,
      targetY: l,
      targetPosition: b,
      borderRadius: y == null ? void 0 : y.borderRadius,
      offset: y == null ? void 0 : y.offset,
      stepPosition: y == null ? void 0 : y.stepPosition
    }), N = n.isInternal ? void 0 : t;
    return Z.jsx(Cd, { id: N, path: T, labelX: E, labelY: O, label: c, labelStyle: f, labelShowBg: d, labelBgStyle: h, labelBgPadding: m, labelBgBorderRadius: p, style: _, markerEnd: M, markerStart: S, interactionWidth: C });
  });
}
const EE = ME({ isInternal: !1 }), TE = ME({ isInternal: !0 });
EE.displayName = "SmoothStepEdge";
TE.displayName = "SmoothStepEdgeInternal";
function AE(n) {
  return st.memo(({ id: t, ...e }) => {
    var r;
    const s = n.isInternal ? void 0 : t;
    return Z.jsx(EE, { ...e, id: s, pathOptions: st.useMemo(() => {
      var l;
      return { borderRadius: 0, offset: (l = e.pathOptions) == null ? void 0 : l.offset };
    }, [(r = e.pathOptions) == null ? void 0 : r.offset]) });
  });
}
const NB = AE({ isInternal: !1 }), wE = AE({ isInternal: !0 });
NB.displayName = "StepEdge";
wE.displayName = "StepEdgeInternal";
function CE(n) {
  return st.memo(({ id: t, sourceX: e, sourceY: s, targetX: r, targetY: l, label: c, labelStyle: f, labelShowBg: d, labelBgStyle: h, labelBgPadding: m, labelBgBorderRadius: p, style: _, markerEnd: x, markerStart: b, interactionWidth: M }) => {
    const [S, y, C] = W1({ sourceX: e, sourceY: s, targetX: r, targetY: l }), T = n.isInternal ? void 0 : t;
    return Z.jsx(Cd, { id: T, path: S, labelX: y, labelY: C, label: c, labelStyle: f, labelShowBg: d, labelBgStyle: h, labelBgPadding: m, labelBgBorderRadius: p, style: _, markerEnd: x, markerStart: b, interactionWidth: M });
  });
}
const LB = CE({ isInternal: !1 }), RE = CE({ isInternal: !0 });
LB.displayName = "StraightEdge";
RE.displayName = "StraightEdgeInternal";
function DE(n) {
  return st.memo(({ id: t, sourceX: e, sourceY: s, targetX: r, targetY: l, sourcePosition: c = ne.Bottom, targetPosition: f = ne.Top, label: d, labelStyle: h, labelShowBg: m, labelBgStyle: p, labelBgPadding: _, labelBgBorderRadius: x, style: b, markerEnd: M, markerStart: S, pathOptions: y, interactionWidth: C }) => {
    const [T, E, O] = G1({
      sourceX: e,
      sourceY: s,
      sourcePosition: c,
      targetX: r,
      targetY: l,
      targetPosition: f,
      curvature: y == null ? void 0 : y.curvature
    }), N = n.isInternal ? void 0 : t;
    return Z.jsx(Cd, { id: N, path: T, labelX: E, labelY: O, label: d, labelStyle: h, labelShowBg: m, labelBgStyle: p, labelBgPadding: _, labelBgBorderRadius: x, style: b, markerEnd: M, markerStart: S, interactionWidth: C });
  });
}
const UB = DE({ isInternal: !1 }), NE = DE({ isInternal: !0 });
UB.displayName = "BezierEdge";
NE.displayName = "BezierEdgeInternal";
const Ib = {
  default: NE,
  straight: RE,
  step: wE,
  smoothstep: TE,
  simplebezier: bE
}, Bb = {
  sourceX: null,
  sourceY: null,
  targetX: null,
  targetY: null,
  sourcePosition: null,
  targetPosition: null
}, OB = (n, t, e) => e === ne.Left ? n - t : e === ne.Right ? n + t : n, PB = (n, t, e) => e === ne.Top ? n - t : e === ne.Bottom ? n + t : n, Fb = "react-flow__edgeupdater";
function Hb({ position: n, centerX: t, centerY: e, radius: s = 10, onMouseDown: r, onMouseEnter: l, onMouseOut: c, type: f }) {
  return Z.jsx("circle", { onMouseDown: r, onMouseEnter: l, onMouseOut: c, className: bn([Fb, `${Fb}-${f}`]), cx: OB(t, s, n), cy: PB(e, s, n), r: s, stroke: "transparent", fill: "transparent" });
}
function zB({ isReconnectable: n, reconnectRadius: t, edge: e, sourceX: s, sourceY: r, targetX: l, targetY: c, sourcePosition: f, targetPosition: d, onReconnect: h, onReconnectStart: m, onReconnectEnd: p, setReconnecting: _, setUpdateHover: x }) {
  const b = rn(), M = (E, O) => {
    if (E.button !== 0)
      return;
    const { autoPanOnConnect: N, domNode: D, connectionMode: z, connectionRadius: A, lib: R, onConnectStart: L, cancelConnection: H, nodeLookup: k, rfId: P, panBy: Y, updateConnection: U } = b.getState(), X = O.type === "target", V = (I, q) => {
      _(!1), p == null || p(I, e, O.type, q);
    }, W = (I) => h == null ? void 0 : h(e, I), J = (I, q) => {
      _(!0), m == null || m(E, e, O.type), L == null || L(I, q);
    };
    Vg.onPointerDown(E.nativeEvent, {
      autoPanOnConnect: N,
      connectionMode: z,
      connectionRadius: A,
      domNode: D,
      handleId: O.id,
      nodeId: O.nodeId,
      nodeLookup: k,
      isTarget: X,
      edgeUpdaterType: O.type,
      lib: R,
      flowId: P,
      cancelConnection: H,
      panBy: Y,
      isValidConnection: (...I) => {
        var q, lt;
        return ((lt = (q = b.getState()).isValidConnection) == null ? void 0 : lt.call(q, ...I)) ?? !0;
      },
      onConnect: W,
      onConnectStart: J,
      onConnectEnd: (...I) => {
        var q, lt;
        return (lt = (q = b.getState()).onConnectEnd) == null ? void 0 : lt.call(q, ...I);
      },
      onReconnectEnd: V,
      updateConnection: U,
      getTransform: () => b.getState().transform,
      getFromHandle: () => b.getState().connection.fromHandle,
      dragThreshold: b.getState().connectionDragThreshold,
      handleDomNode: E.currentTarget
    });
  }, S = (E) => M(E, { nodeId: e.target, id: e.targetHandle ?? null, type: "target" }), y = (E) => M(E, { nodeId: e.source, id: e.sourceHandle ?? null, type: "source" }), C = () => x(!0), T = () => x(!1);
  return Z.jsxs(Z.Fragment, { children: [(n === !0 || n === "source") && Z.jsx(Hb, { position: f, centerX: s, centerY: r, radius: t, onMouseDown: S, onMouseEnter: C, onMouseOut: T, type: "source" }), (n === !0 || n === "target") && Z.jsx(Hb, { position: d, centerX: l, centerY: c, radius: t, onMouseDown: y, onMouseEnter: C, onMouseOut: T, type: "target" })] });
}
function IB({ id: n, edgesFocusable: t, edgesReconnectable: e, elementsSelectable: s, onClick: r, onDoubleClick: l, onContextMenu: c, onMouseEnter: f, onMouseMove: d, onMouseLeave: h, reconnectRadius: m, onReconnect: p, onReconnectStart: _, onReconnectEnd: x, rfId: b, edgeTypes: M, noPanClassName: S, onError: y, disableKeyboardA11y: C }) {
  let T = Ue((Nt) => Nt.edgeLookup.get(n));
  const E = Ue((Nt) => Nt.defaultEdgeOptions);
  T = E ? { ...E, ...T } : T;
  let O = T.type || "default", N = (M == null ? void 0 : M[O]) || Ib[O];
  N === void 0 && (y == null || y("011", rs.error011(O)), O = "default", N = (M == null ? void 0 : M.default) || Ib.default);
  const D = !!(T.focusable || t && typeof T.focusable > "u"), z = typeof p < "u" && (T.reconnectable || e && typeof T.reconnectable > "u"), A = !!(T.selectable || s && typeof T.selectable > "u"), R = st.useRef(null), [L, H] = st.useState(!1), [k, P] = st.useState(!1), Y = rn(), { zIndex: U, sourceX: X, sourceY: V, targetX: W, targetY: J, sourcePosition: I, targetPosition: q } = Ue(st.useCallback((Nt) => {
    const Bt = Nt.nodeLookup.get(T.source), K = Nt.nodeLookup.get(T.target);
    if (!Bt || !K)
      return {
        zIndex: T.zIndex,
        ...Bb
      };
    const pe = Cz({
      id: n,
      sourceNode: Bt,
      targetNode: K,
      sourceHandle: T.sourceHandle || null,
      targetHandle: T.targetHandle || null,
      connectionMode: Nt.connectionMode,
      onError: y
    });
    return {
      zIndex: Sz({
        selected: T.selected,
        zIndex: T.zIndex,
        sourceNode: Bt,
        targetNode: K,
        elevateOnSelect: Nt.elevateEdgesOnSelect,
        zIndexMode: Nt.zIndexMode
      }),
      ...pe || Bb
    };
  }, [T.source, T.target, T.sourceHandle, T.targetHandle, T.selected, T.zIndex]), an), lt = st.useMemo(() => T.markerStart ? `url('#${Fg(T.markerStart, b)}')` : void 0, [T.markerStart, b]), $ = st.useMemo(() => T.markerEnd ? `url('#${Fg(T.markerEnd, b)}')` : void 0, [T.markerEnd, b]);
  if (T.hidden || X === null || V === null || W === null || J === null)
    return null;
  const ot = (Nt) => {
    var Xt;
    const { addSelectedEdges: Bt, unselectNodesAndEdges: K, multiSelectionActive: pe } = Y.getState();
    A && (Y.setState({ nodesSelectionActive: !1 }), T.selected && pe ? (K({ nodes: [], edges: [T] }), (Xt = R.current) == null || Xt.blur()) : Bt([n])), r && r(Nt, T);
  }, gt = l ? (Nt) => {
    l(Nt, { ...T });
  } : void 0, ht = c ? (Nt) => {
    c(Nt, { ...T });
  } : void 0, _t = f ? (Nt) => {
    f(Nt, { ...T });
  } : void 0, Et = d ? (Nt) => {
    d(Nt, { ...T });
  } : void 0, Lt = h ? (Nt) => {
    h(Nt, { ...T });
  } : void 0, Gt = (Nt) => {
    var Bt;
    if (!C && w1.includes(Nt.key) && A) {
      const { unselectNodesAndEdges: K, addSelectedEdges: pe } = Y.getState();
      Nt.key === "Escape" ? ((Bt = R.current) == null || Bt.blur(), K({ edges: [T] })) : pe([n]);
    }
  };
  return Z.jsx("svg", { style: { zIndex: U }, children: Z.jsxs("g", { className: bn([
    "react-flow__edge",
    `react-flow__edge-${O}`,
    T.className,
    S,
    {
      selected: T.selected,
      animated: T.animated,
      inactive: !A && !r,
      updating: L,
      selectable: A
    }
  ]), onClick: ot, onDoubleClick: gt, onContextMenu: ht, onMouseEnter: _t, onMouseMove: Et, onMouseLeave: Lt, onKeyDown: D ? Gt : void 0, tabIndex: D ? 0 : void 0, role: T.ariaRole ?? (D ? "group" : "img"), "aria-roledescription": "edge", "data-id": n, "data-testid": `rf__edge-${n}`, "aria-label": T.ariaLabel === null ? void 0 : T.ariaLabel || `Edge from ${T.source} to ${T.target}`, "aria-describedby": D ? `${rE}-${b}` : void 0, ref: R, ...T.domAttributes, children: [!k && Z.jsx(N, { id: n, source: T.source, target: T.target, type: T.type, selected: T.selected, animated: T.animated, selectable: A, deletable: T.deletable ?? !0, label: T.label, labelStyle: T.labelStyle, labelShowBg: T.labelShowBg, labelBgStyle: T.labelBgStyle, labelBgPadding: T.labelBgPadding, labelBgBorderRadius: T.labelBgBorderRadius, sourceX: X, sourceY: V, targetX: W, targetY: J, sourcePosition: I, targetPosition: q, data: T.data, style: T.style, sourceHandleId: T.sourceHandle, targetHandleId: T.targetHandle, markerStart: lt, markerEnd: $, pathOptions: "pathOptions" in T ? T.pathOptions : void 0, interactionWidth: T.interactionWidth }), z && Z.jsx(zB, { edge: T, isReconnectable: z, reconnectRadius: m, onReconnect: p, onReconnectStart: _, onReconnectEnd: x, sourceX: X, sourceY: V, targetX: W, targetY: J, sourcePosition: I, targetPosition: q, setUpdateHover: H, setReconnecting: P })] }) });
}
var BB = st.memo(IB);
const FB = (n) => ({
  edgesFocusable: n.edgesFocusable,
  edgesReconnectable: n.edgesReconnectable,
  elementsSelectable: n.elementsSelectable,
  connectionMode: n.connectionMode,
  onError: n.onError
});
function LE({ defaultMarkerColor: n, onlyRenderVisibleElements: t, rfId: e, edgeTypes: s, noPanClassName: r, onReconnect: l, onEdgeContextMenu: c, onEdgeMouseEnter: f, onEdgeMouseMove: d, onEdgeMouseLeave: h, onEdgeClick: m, reconnectRadius: p, onEdgeDoubleClick: _, onReconnectStart: x, onReconnectEnd: b, disableKeyboardA11y: M }) {
  const { edgesFocusable: S, edgesReconnectable: y, elementsSelectable: C, onError: T } = Ue(FB, an), E = MB(t);
  return Z.jsxs("div", { className: "react-flow__edges", children: [Z.jsx(CB, { defaultColor: n, rfId: e }), E.map((O) => Z.jsx(BB, { id: O, edgesFocusable: S, edgesReconnectable: y, elementsSelectable: C, noPanClassName: r, onReconnect: l, onContextMenu: c, onMouseEnter: f, onMouseMove: d, onMouseLeave: h, onClick: m, reconnectRadius: p, onDoubleClick: _, onReconnectStart: x, onReconnectEnd: b, rfId: e, onError: T, edgeTypes: s, disableKeyboardA11y: M }, O))] });
}
LE.displayName = "EdgeRenderer";
const HB = st.memo(LE), VB = (n) => `translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]})`;
function GB({ children: n }) {
  const t = Ue(VB);
  return Z.jsx("div", { className: "react-flow__viewport xyflow__viewport react-flow__container", style: { transform: t }, children: n });
}
function kB(n) {
  const t = E0(), e = st.useRef(!1);
  st.useEffect(() => {
    !e.current && t.viewportInitialized && n && (setTimeout(() => n(t), 1), e.current = !0);
  }, [n, t.viewportInitialized]);
}
const XB = (n) => {
  var t;
  return (t = n.panZoom) == null ? void 0 : t.syncViewport;
};
function WB(n) {
  const t = Ue(XB), e = rn();
  return st.useEffect(() => {
    n && (t == null || t(n), e.setState({ transform: [n.x, n.y, n.zoom] }));
  }, [n, t]), null;
}
function YB(n) {
  return n.connection.inProgress ? { ...n.connection, to: Ic(n.connection.to, n.transform) } : { ...n.connection };
}
function jB(n) {
  return YB;
}
function qB(n) {
  const t = jB();
  return Ue(t, an);
}
const ZB = (n) => ({
  nodesConnectable: n.nodesConnectable,
  isValid: n.connection.isValid,
  inProgress: n.connection.inProgress,
  width: n.width,
  height: n.height
});
function KB({ containerStyle: n, style: t, type: e, component: s }) {
  const { nodesConnectable: r, width: l, height: c, isValid: f, inProgress: d } = Ue(ZB, an);
  return !(l && r && d) ? null : Z.jsx("svg", { style: n, width: l, height: c, className: "react-flow__connectionline react-flow__container", children: Z.jsx("g", { className: bn(["react-flow__connection", D1(f)]), children: Z.jsx(UE, { style: t, type: e, CustomComponent: s, isValid: f }) }) });
}
const UE = ({ style: n, type: t = Aa.Bezier, CustomComponent: e, isValid: s }) => {
  const { inProgress: r, from: l, fromNode: c, fromHandle: f, fromPosition: d, to: h, toNode: m, toHandle: p, toPosition: _, pointer: x } = qB();
  if (!r)
    return;
  if (e)
    return Z.jsx(e, { connectionLineType: t, connectionLineStyle: n, fromNode: c, fromHandle: f, fromX: l.x, fromY: l.y, toX: h.x, toY: h.y, fromPosition: d, toPosition: _, connectionStatus: D1(s), toNode: m, toHandle: p, pointer: x });
  let b = "";
  const M = {
    sourceX: l.x,
    sourceY: l.y,
    sourcePosition: d,
    targetX: h.x,
    targetY: h.y,
    targetPosition: _
  };
  switch (t) {
    case Aa.Bezier:
      [b] = G1(M);
      break;
    case Aa.SimpleBezier:
      [b] = xE(M);
      break;
    case Aa.Step:
      [b] = Bg({
        ...M,
        borderRadius: 0
      });
      break;
    case Aa.SmoothStep:
      [b] = Bg(M);
      break;
    default:
      [b] = W1(M);
  }
  return Z.jsx("path", { d: b, fill: "none", className: "react-flow__connection-path", style: n });
};
UE.displayName = "ConnectionLine";
const $B = {};
function Vb(n = $B) {
  st.useRef(n), rn(), st.useEffect(() => {
  }, [n]);
}
function QB() {
  rn(), st.useRef(!1), st.useEffect(() => {
  }, []);
}
function OE({ nodeTypes: n, edgeTypes: t, onInit: e, onNodeClick: s, onEdgeClick: r, onNodeDoubleClick: l, onEdgeDoubleClick: c, onNodeMouseEnter: f, onNodeMouseMove: d, onNodeMouseLeave: h, onNodeContextMenu: m, onSelectionContextMenu: p, onSelectionStart: _, onSelectionEnd: x, connectionLineType: b, connectionLineStyle: M, connectionLineComponent: S, connectionLineContainerStyle: y, selectionKeyCode: C, selectionOnDrag: T, selectionMode: E, multiSelectionKeyCode: O, panActivationKeyCode: N, zoomActivationKeyCode: D, deleteKeyCode: z, onlyRenderVisibleElements: A, elementsSelectable: R, defaultViewport: L, translateExtent: H, minZoom: k, maxZoom: P, preventScrolling: Y, defaultMarkerColor: U, zoomOnScroll: X, zoomOnPinch: V, panOnScroll: W, panOnScrollSpeed: J, panOnScrollMode: I, zoomOnDoubleClick: q, panOnDrag: lt, onPaneClick: $, onPaneMouseEnter: ot, onPaneMouseMove: gt, onPaneMouseLeave: ht, onPaneScroll: _t, onPaneContextMenu: Et, paneClickDistance: Lt, nodeClickDistance: Gt, onEdgeContextMenu: Nt, onEdgeMouseEnter: Bt, onEdgeMouseMove: K, onEdgeMouseLeave: pe, reconnectRadius: Xt, onReconnect: se, onReconnectStart: qt, onReconnectEnd: xe, noDragClassName: jt, noWheelClassName: j, noPanClassName: B, disableKeyboardA11y: ft, nodeExtent: St, rfId: wt, viewport: bt, onViewportChange: Zt }) {
  return Vb(n), Vb(t), QB(), kB(e), WB(bt), Z.jsx(hB, { onPaneClick: $, onPaneMouseEnter: ot, onPaneMouseMove: gt, onPaneMouseLeave: ht, onPaneContextMenu: Et, onPaneScroll: _t, paneClickDistance: Lt, deleteKeyCode: z, selectionKeyCode: C, selectionOnDrag: T, selectionMode: E, onSelectionStart: _, onSelectionEnd: x, multiSelectionKeyCode: O, panActivationKeyCode: N, zoomActivationKeyCode: D, elementsSelectable: R, zoomOnScroll: X, zoomOnPinch: V, zoomOnDoubleClick: q, panOnScroll: W, panOnScrollSpeed: J, panOnScrollMode: I, panOnDrag: lt, defaultViewport: L, translateExtent: H, minZoom: k, maxZoom: P, onSelectionContextMenu: p, preventScrolling: Y, noDragClassName: jt, noWheelClassName: j, noPanClassName: B, disableKeyboardA11y: ft, onViewportChange: Zt, isControlledViewport: !!bt, children: Z.jsxs(GB, { children: [Z.jsx(HB, { edgeTypes: t, onEdgeClick: r, onEdgeDoubleClick: c, onReconnect: se, onReconnectStart: qt, onReconnectEnd: xe, onlyRenderVisibleElements: A, onEdgeContextMenu: Nt, onEdgeMouseEnter: Bt, onEdgeMouseMove: K, onEdgeMouseLeave: pe, reconnectRadius: Xt, defaultMarkerColor: U, noPanClassName: B, disableKeyboardA11y: ft, rfId: wt }), Z.jsx(KB, { style: M, type: b, component: S, containerStyle: y }), Z.jsx("div", { className: "react-flow__edgelabel-renderer" }), Z.jsx(bB, { nodeTypes: n, onNodeClick: s, onNodeDoubleClick: l, onNodeMouseEnter: f, onNodeMouseMove: d, onNodeMouseLeave: h, onNodeContextMenu: m, nodeClickDistance: Gt, onlyRenderVisibleElements: A, noPanClassName: B, noDragClassName: jt, disableKeyboardA11y: ft, nodeExtent: St, rfId: wt }), Z.jsx("div", { className: "react-flow__viewport-portal" })] }) });
}
OE.displayName = "GraphView";
const JB = st.memo(OE), Gb = ({ nodes: n, edges: t, defaultNodes: e, defaultEdges: s, width: r, height: l, fitView: c, fitViewOptions: f, minZoom: d = 0.5, maxZoom: h = 2, nodeOrigin: m, nodeExtent: p, zIndexMode: _ = "basic" } = {}) => {
  const x = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), y = s ?? t ?? [], C = e ?? n ?? [], T = m ?? [0, 0], E = p ?? Sc;
  q1(M, S, y);
  const O = Hg(C, x, b, {
    nodeOrigin: T,
    nodeExtent: E,
    zIndexMode: _
  });
  let N = [0, 0, 1];
  if (c && r && l) {
    const D = Pc(x, {
      filter: (L) => !!((L.width || L.initialWidth) && (L.height || L.initialHeight))
    }), { x: z, y: A, zoom: R } = _0(D, r, l, d, h, (f == null ? void 0 : f.padding) ?? 0.1);
    N = [z, A, R];
  }
  return {
    rfId: "1",
    width: r ?? 0,
    height: l ?? 0,
    transform: N,
    nodes: C,
    nodesInitialized: O,
    nodeLookup: x,
    parentLookup: b,
    edges: y,
    edgeLookup: S,
    connectionLookup: M,
    onNodesChange: null,
    onEdgesChange: null,
    hasDefaultNodes: e !== void 0,
    hasDefaultEdges: s !== void 0,
    panZoom: null,
    minZoom: d,
    maxZoom: h,
    translateExtent: Sc,
    nodeExtent: E,
    nodesSelectionActive: !1,
    userSelectionActive: !1,
    userSelectionRect: null,
    connectionMode: Ko.Strict,
    domNode: null,
    paneDragging: !1,
    noPanClassName: "nopan",
    nodeOrigin: T,
    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: f,
    fitViewResolver: null,
    connection: { ...R1 },
    connectionClickStartHandle: null,
    connectOnClick: !0,
    ariaLiveMessage: "",
    autoPanOnConnect: !0,
    autoPanOnNodeDrag: !0,
    autoPanOnNodeFocus: !0,
    autoPanSpeed: 15,
    connectionRadius: 20,
    onError: mz,
    isValidConnection: void 0,
    onSelectionChangeHandlers: [],
    lib: "react",
    debug: !1,
    ariaLabelConfig: C1,
    zIndexMode: _,
    onNodesChangeMiddlewareMap: /* @__PURE__ */ new Map(),
    onEdgesChangeMiddlewareMap: /* @__PURE__ */ new Map()
  };
}, t4 = ({ nodes: n, edges: t, defaultNodes: e, defaultEdges: s, width: r, height: l, fitView: c, fitViewOptions: f, minZoom: d, maxZoom: h, nodeOrigin: m, nodeExtent: p, zIndexMode: _ }) => vI((x, b) => {
  async function M() {
    const { nodeLookup: S, panZoom: y, fitViewOptions: C, fitViewResolver: T, width: E, height: O, minZoom: N, maxZoom: D } = b();
    y && (await hz({
      nodes: S,
      width: E,
      height: O,
      panZoom: y,
      minZoom: N,
      maxZoom: D
    }, C), T == null || T.resolve(!0), x({ fitViewResolver: null }));
  }
  return {
    ...Gb({
      nodes: n,
      edges: t,
      width: r,
      height: l,
      fitView: c,
      fitViewOptions: f,
      minZoom: d,
      maxZoom: h,
      nodeOrigin: m,
      nodeExtent: p,
      defaultNodes: e,
      defaultEdges: s,
      zIndexMode: _
    }),
    setNodes: (S) => {
      const { nodeLookup: y, parentLookup: C, nodeOrigin: T, elevateNodesOnSelect: E, fitViewQueued: O, zIndexMode: N } = b(), D = Hg(S, y, C, {
        nodeOrigin: T,
        nodeExtent: p,
        elevateNodesOnSelect: E,
        checkEquality: !0,
        zIndexMode: N
      });
      O && D ? (M(), x({ nodes: S, nodesInitialized: D, fitViewQueued: !1, fitViewOptions: void 0 })) : x({ nodes: S, nodesInitialized: D });
    },
    setEdges: (S) => {
      const { connectionLookup: y, edgeLookup: C } = b();
      q1(y, C, S), x({ edges: S });
    },
    setDefaultNodesAndEdges: (S, y) => {
      if (S) {
        const { setNodes: C } = b();
        C(S), x({ hasDefaultNodes: !0 });
      }
      if (y) {
        const { setEdges: C } = b();
        C(y), x({ 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: C, parentLookup: T, domNode: E, nodeOrigin: O, nodeExtent: N, debug: D, fitViewQueued: z, zIndexMode: A } = b(), { changes: R, updatedInternals: L } = zz(S, C, T, E, O, N, A);
      L && (Lz(C, T, { nodeOrigin: O, nodeExtent: N, zIndexMode: A }), z ? (M(), x({ fitViewQueued: !1, fitViewOptions: void 0 })) : x({}), (R == null ? void 0 : R.length) > 0 && (D && console.log("React Flow: trigger node changes", R), y == null || y(R)));
    },
    updateNodePositions: (S, y = !1) => {
      const C = [];
      let T = [];
      const { nodeLookup: E, triggerNodeChanges: O, connection: N, updateConnection: D, onNodesChangeMiddlewareMap: z } = b();
      for (const [A, R] of S) {
        const L = E.get(A), H = !!(L != null && L.expandParent && (L != null && L.parentId) && (R != null && R.position)), k = {
          id: A,
          type: "position",
          position: H ? {
            x: Math.max(0, R.position.x),
            y: Math.max(0, R.position.y)
          } : R.position,
          dragging: y
        };
        if (L && N.inProgress && N.fromNode.id === L.id) {
          const P = br(L, N.fromHandle, ne.Left, !0);
          D({ ...N, from: P });
        }
        H && L.parentId && C.push({
          id: A,
          parentId: L.parentId,
          rect: {
            ...R.internals.positionAbsolute,
            width: R.measured.width ?? 0,
            height: R.measured.height ?? 0
          }
        }), T.push(k);
      }
      if (C.length > 0) {
        const { parentLookup: A, nodeOrigin: R } = b(), L = M0(C, E, A, R);
        T.push(...L);
      }
      for (const A of z.values())
        T = A(T);
      O(T);
    },
    triggerNodeChanges: (S) => {
      const { onNodesChange: y, setNodes: C, nodes: T, hasDefaultNodes: E, debug: O } = b();
      if (S != null && S.length) {
        if (E) {
          const N = cE(S, T);
          C(N);
        }
        O && console.log("React Flow: trigger node changes", S), y == null || y(S);
      }
    },
    triggerEdgeChanges: (S) => {
      const { onEdgesChange: y, setEdges: C, edges: T, hasDefaultEdges: E, debug: O } = b();
      if (S != null && S.length) {
        if (E) {
          const N = uE(S, T);
          C(N);
        }
        O && console.log("React Flow: trigger edge changes", S), y == null || y(S);
      }
    },
    addSelectedNodes: (S) => {
      const { multiSelectionActive: y, edgeLookup: C, nodeLookup: T, triggerNodeChanges: E, triggerEdgeChanges: O } = b();
      if (y) {
        const N = S.map((D) => lr(D, !0));
        E(N);
        return;
      }
      E(Oo(T, /* @__PURE__ */ new Set([...S]), !0)), O(Oo(C));
    },
    addSelectedEdges: (S) => {
      const { multiSelectionActive: y, edgeLookup: C, nodeLookup: T, triggerNodeChanges: E, triggerEdgeChanges: O } = b();
      if (y) {
        const N = S.map((D) => lr(D, !0));
        O(N);
        return;
      }
      O(Oo(C, /* @__PURE__ */ new Set([...S]))), E(Oo(T, /* @__PURE__ */ new Set(), !0));
    },
    unselectNodesAndEdges: ({ nodes: S, edges: y } = {}) => {
      const { edges: C, nodes: T, nodeLookup: E, triggerNodeChanges: O, triggerEdgeChanges: N } = b(), D = S || T, z = y || C, A = [];
      for (const L of D) {
        if (!L.selected)
          continue;
        const H = E.get(L.id);
        H && (H.selected = !1), A.push(lr(L.id, !1));
      }
      const R = [];
      for (const L of z)
        L.selected && R.push(lr(L.id, !1));
      O(A), N(R);
    },
    setMinZoom: (S) => {
      const { panZoom: y, maxZoom: C } = b();
      y == null || y.setScaleExtent([S, C]), x({ minZoom: S });
    },
    setMaxZoom: (S) => {
      const { panZoom: y, minZoom: C } = b();
      y == null || y.setScaleExtent([C, S]), x({ maxZoom: S });
    },
    setTranslateExtent: (S) => {
      var y;
      (y = b().panZoom) == null || y.setTranslateExtent(S), x({ translateExtent: S });
    },
    resetSelectedElements: () => {
      const { edges: S, nodes: y, triggerNodeChanges: C, triggerEdgeChanges: T, elementsSelectable: E } = b();
      if (!E)
        return;
      const O = y.reduce((D, z) => z.selected ? [...D, lr(z.id, !1)] : D, []), N = S.reduce((D, z) => z.selected ? [...D, lr(z.id, !1)] : D, []);
      C(O), T(N);
    },
    setNodeExtent: (S) => {
      const { nodes: y, nodeLookup: C, parentLookup: T, nodeOrigin: E, elevateNodesOnSelect: O, nodeExtent: N, zIndexMode: D } = b();
      S[0][0] === N[0][0] && S[0][1] === N[0][1] && S[1][0] === N[1][0] && S[1][1] === N[1][1] || (Hg(y, C, T, {
        nodeOrigin: E,
        nodeExtent: S,
        elevateNodesOnSelect: O,
        checkEquality: !1,
        zIndexMode: D
      }), x({ nodeExtent: S }));
    },
    panBy: (S) => {
      const { transform: y, width: C, height: T, panZoom: E, translateExtent: O } = b();
      return Iz({ delta: S, panZoom: E, transform: y, translateExtent: O, width: C, height: T });
    },
    setCenter: async (S, y, C) => {
      const { width: T, height: E, maxZoom: O, panZoom: N } = b();
      if (!N)
        return Promise.resolve(!1);
      const D = typeof (C == null ? void 0 : C.zoom) < "u" ? C.zoom : O;
      return await N.setViewport({
        x: T / 2 - S * D,
        y: E / 2 - y * D,
        zoom: D
      }, { duration: C == null ? void 0 : C.duration, ease: C == null ? void 0 : C.ease, interpolate: C == null ? void 0 : C.interpolate }), Promise.resolve(!0);
    },
    cancelConnection: () => {
      x({
        connection: { ...R1 }
      });
    },
    updateConnection: (S) => {
      x({ connection: S });
    },
    reset: () => x({ ...Gb() })
  };
}, Object.is);
function PE({ initialNodes: n, initialEdges: t, defaultNodes: e, defaultEdges: s, initialWidth: r, initialHeight: l, initialMinZoom: c, initialMaxZoom: f, initialFitViewOptions: d, fitView: h, nodeOrigin: m, nodeExtent: p, zIndexMode: _, children: x }) {
  const [b] = st.useState(() => t4({
    nodes: n,
    edges: t,
    defaultNodes: e,
    defaultEdges: s,
    width: r,
    height: l,
    fitView: h,
    minZoom: c,
    maxZoom: f,
    fitViewOptions: d,
    nodeOrigin: m,
    nodeExtent: p,
    zIndexMode: _
  }));
  return Z.jsx(yI, { value: b, children: Z.jsx(GI, { children: x }) });
}
function e4({ children: n, nodes: t, edges: e, defaultNodes: s, defaultEdges: r, width: l, height: c, fitView: f, fitViewOptions: d, minZoom: h, maxZoom: m, nodeOrigin: p, nodeExtent: _, zIndexMode: x }) {
  return st.useContext(Td) ? Z.jsx(Z.Fragment, { children: n }) : Z.jsx(PE, { initialNodes: t, initialEdges: e, defaultNodes: s, defaultEdges: r, initialWidth: l, initialHeight: c, fitView: f, initialFitViewOptions: d, initialMinZoom: h, initialMaxZoom: m, nodeOrigin: p, nodeExtent: _, zIndexMode: x, children: n });
}
const n4 = {
  width: "100%",
  height: "100%",
  overflow: "hidden",
  position: "relative",
  zIndex: 0
};
function i4({ nodes: n, edges: t, defaultNodes: e, defaultEdges: s, className: r, nodeTypes: l, edgeTypes: c, onNodeClick: f, onEdgeClick: d, onInit: h, onMove: m, onMoveStart: p, onMoveEnd: _, onConnect: x, onConnectStart: b, onConnectEnd: M, onClickConnectStart: S, onClickConnectEnd: y, onNodeMouseEnter: C, onNodeMouseMove: T, onNodeMouseLeave: E, onNodeContextMenu: O, onNodeDoubleClick: N, onNodeDragStart: D, onNodeDrag: z, onNodeDragStop: A, onNodesDelete: R, onEdgesDelete: L, onDelete: H, onSelectionChange: k, onSelectionDragStart: P, onSelectionDrag: Y, onSelectionDragStop: U, onSelectionContextMenu: X, onSelectionStart: V, onSelectionEnd: W, onBeforeDelete: J, connectionMode: I, connectionLineType: q = Aa.Bezier, connectionLineStyle: lt, connectionLineComponent: $, connectionLineContainerStyle: ot, deleteKeyCode: gt = "Backspace", selectionKeyCode: ht = "Shift", selectionOnDrag: _t = !1, selectionMode: Et = bc.Full, panActivationKeyCode: Lt = "Space", multiSelectionKeyCode: Gt = Ec() ? "Meta" : "Control", zoomActivationKeyCode: Nt = Ec() ? "Meta" : "Control", snapToGrid: Bt, snapGrid: K, onlyRenderVisibleElements: pe = !1, selectNodesOnDrag: Xt, nodesDraggable: se, autoPanOnNodeFocus: qt, nodesConnectable: xe, nodesFocusable: jt, nodeOrigin: j = oE, edgesFocusable: B, edgesReconnectable: ft, elementsSelectable: St = !0, defaultViewport: wt = LI, minZoom: bt = 0.5, maxZoom: Zt = 2, translateExtent: Ut = Sc, preventScrolling: Wt = !0, nodeExtent: ve, defaultMarkerColor: Dt = "#b1b1b7", zoomOnScroll: Yt = !0, zoomOnPinch: Jt = !0, panOnScroll: $t = !1, panOnScrollSpeed: Vt = 0.5, panOnScrollMode: re = gr.Free, zoomOnDoubleClick: de = !0, panOnDrag: Fe = !0, onPaneClick: nt, onPaneMouseEnter: Ot, onPaneMouseMove: yt, onPaneMouseLeave: At, onPaneScroll: Pt, onPaneContextMenu: zt, paneClickDistance: ce = 1, nodeClickDistance: $e = 0, children: fn, onReconnect: De, onReconnectStart: Mn, onReconnectEnd: ci, onEdgeContextMenu: Oa, onEdgeDoubleClick: Pa, onEdgeMouseEnter: Ei, onEdgeMouseMove: ls, onEdgeMouseLeave: Xs, reconnectRadius: za = 10, onNodesChange: cs, onEdgesChange: ui, noDragClassName: nn = "nodrag", noWheelClassName: En = "nowheel", noPanClassName: Ti = "nopan", fitView: Ws, fitViewOptions: Ar, connectOnClick: sl, attributionPosition: wr, proOptions: us, defaultEdgeOptions: Ia, elevateNodesOnSelect: G = !0, elevateEdgesOnSelect: it = !1, disableKeyboardA11y: dt = !1, autoPanOnConnect: mt, autoPanOnNodeDrag: et, autoPanSpeed: Rt, connectionRadius: It, isValidConnection: Ft, onError: kt, style: ue, id: oe, nodeDragThreshold: te, connectionDragThreshold: be, viewport: Me, onViewportChange: Ze, width: Le, height: fe, colorMode: ee = "light", debug: dn, onScroll: Se, ariaLabelConfig: kn, zIndexMode: Qn = "basic", ...On }, mn) {
  const Oe = oe || "1", Pn = zI(ee), Dn = st.useCallback((Qe) => {
    Qe.currentTarget.scrollTo({ top: 0, left: 0, behavior: "instant" }), Se == null || Se(Qe);
  }, [Se]);
  return Z.jsx("div", { "data-testid": "rf__wrapper", ...On, onScroll: Dn, style: { ...ue, ...n4 }, ref: mn, className: bn(["react-flow", r, Pn]), id: oe, role: "application", children: Z.jsxs(e4, { nodes: n, edges: t, width: Le, height: fe, fitView: Ws, fitViewOptions: Ar, minZoom: bt, maxZoom: Zt, nodeOrigin: j, nodeExtent: ve, zIndexMode: Qn, children: [Z.jsx(JB, { onInit: h, onNodeClick: f, onEdgeClick: d, onNodeMouseEnter: C, onNodeMouseMove: T, onNodeMouseLeave: E, onNodeContextMenu: O, onNodeDoubleClick: N, nodeTypes: l, edgeTypes: c, connectionLineType: q, connectionLineStyle: lt, connectionLineComponent: $, connectionLineContainerStyle: ot, selectionKeyCode: ht, selectionOnDrag: _t, selectionMode: Et, deleteKeyCode: gt, multiSelectionKeyCode: Gt, panActivationKeyCode: Lt, zoomActivationKeyCode: Nt, onlyRenderVisibleElements: pe, defaultViewport: wt, translateExtent: Ut, minZoom: bt, maxZoom: Zt, preventScrolling: Wt, zoomOnScroll: Yt, zoomOnPinch: Jt, zoomOnDoubleClick: de, panOnScroll: $t, panOnScrollSpeed: Vt, panOnScrollMode: re, panOnDrag: Fe, onPaneClick: nt, onPaneMouseEnter: Ot, onPaneMouseMove: yt, onPaneMouseLeave: At, onPaneScroll: Pt, onPaneContextMenu: zt, paneClickDistance: ce, nodeClickDistance: $e, onSelectionContextMenu: X, onSelectionStart: V, onSelectionEnd: W, onReconnect: De, onReconnectStart: Mn, onReconnectEnd: ci, onEdgeContextMenu: Oa, onEdgeDoubleClick: Pa, onEdgeMouseEnter: Ei, onEdgeMouseMove: ls, onEdgeMouseLeave: Xs, reconnectRadius: za, defaultMarkerColor: Dt, noDragClassName: nn, noWheelClassName: En, noPanClassName: Ti, rfId: Oe, disableKeyboardA11y: dt, nodeExtent: ve, viewport: Me, onViewportChange: Ze }), Z.jsx(PI, { nodes: n, edges: t, defaultNodes: e, defaultEdges: s, onConnect: x, onConnectStart: b, onConnectEnd: M, onClickConnectStart: S, onClickConnectEnd: y, nodesDraggable: se, autoPanOnNodeFocus: qt, nodesConnectable: xe, nodesFocusable: jt, edgesFocusable: B, edgesReconnectable: ft, elementsSelectable: St, elevateNodesOnSelect: G, elevateEdgesOnSelect: it, minZoom: bt, maxZoom: Zt, nodeExtent: ve, onNodesChange: cs, onEdgesChange: ui, snapToGrid: Bt, snapGrid: K, connectionMode: I, translateExtent: Ut, connectOnClick: sl, defaultEdgeOptions: Ia, fitView: Ws, fitViewOptions: Ar, onNodesDelete: R, onEdgesDelete: L, onDelete: H, onNodeDragStart: D, onNodeDrag: z, onNodeDragStop: A, onSelectionDrag: Y, onSelectionDragStart: P, onSelectionDragStop: U, onMove: m, onMoveStart: p, onMoveEnd: _, noPanClassName: Ti, nodeOrigin: j, rfId: Oe, autoPanOnConnect: mt, autoPanOnNodeDrag: et, autoPanSpeed: Rt, onError: kt, connectionRadius: It, isValidConnection: Ft, selectNodesOnDrag: Xt, nodeDragThreshold: te, connectionDragThreshold: be, onBeforeDelete: J, debug: dn, ariaLabelConfig: kn, zIndexMode: Qn }), Z.jsx(NI, { onSelectionChange: k }), fn, Z.jsx(AI, { proOptions: us, position: wr }), Z.jsx(TI, { rfId: Oe, disableKeyboardA11y: dt })] }) });
}
var s4 = fE(i4);
function a4({ dimensions: n, lineWidth: t, variant: e, className: s }) {
  return Z.jsx("path", { strokeWidth: t, d: `M${n[0] / 2} 0 V${n[1]} M0 ${n[1] / 2} H${n[0]}`, className: bn(["react-flow__background-pattern", e, s]) });
}
function r4({ radius: n, className: t }) {
  return Z.jsx("circle", { cx: n, cy: n, r: n, className: bn(["react-flow__background-pattern", "dots", t]) });
}
var Fs;
(function(n) {
  n.Lines = "lines", n.Dots = "dots", n.Cross = "cross";
})(Fs || (Fs = {}));
const o4 = {
  [Fs.Dots]: 1,
  [Fs.Lines]: 1,
  [Fs.Cross]: 6
}, l4 = (n) => ({ transform: n.transform, patternId: `pattern-${n.rfId}` });
function zE({
  id: n,
  variant: t = Fs.Dots,
  // only used for dots and cross
  gap: e = 20,
  // only used for lines and cross
  size: s,
  lineWidth: r = 1,
  offset: l = 0,
  color: c,
  bgColor: f,
  style: d,
  className: h,
  patternClassName: m
}) {
  const p = st.useRef(null), { transform: _, patternId: x } = Ue(l4, an), b = s || o4[t], M = t === Fs.Dots, S = t === Fs.Cross, y = Array.isArray(e) ? e : [e, e], C = [y[0] * _[2] || 1, y[1] * _[2] || 1], T = b * _[2], E = Array.isArray(l) ? l : [l, l], O = S ? [T, T] : C, N = [
    E[0] * _[2] || 1 + O[0] / 2,
    E[1] * _[2] || 1 + O[1] / 2
  ], D = `${x}${n || ""}`;
  return Z.jsxs("svg", { className: bn(["react-flow__background", h]), style: {
    ...d,
    ...wd,
    "--xy-background-color-props": f,
    "--xy-background-pattern-color-props": c
  }, ref: p, "data-testid": "rf__background", children: [Z.jsx("pattern", { id: D, x: _[0] % C[0], y: _[1] % C[1], width: C[0], height: C[1], patternUnits: "userSpaceOnUse", patternTransform: `translate(-${N[0]},-${N[1]})`, children: M ? Z.jsx(r4, { radius: T / 2, className: m }) : Z.jsx(a4, { dimensions: O, lineWidth: r, variant: t, className: m }) }), Z.jsx("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: `url(#${D})` })] });
}
zE.displayName = "Background";
const c4 = st.memo(zE);
function u4() {
  return Z.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 32", children: Z.jsx("path", { d: "M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z" }) });
}
function f4() {
  return Z.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 5", children: Z.jsx("path", { d: "M0 0h32v4.2H0z" }) });
}
function d4() {
  return Z.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 30", children: Z.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 h4() {
  return Z.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 25 32", children: Z.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 p4() {
  return Z.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 25 32", children: Z.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 Uf({ children: n, className: t, ...e }) {
  return Z.jsx("button", { type: "button", className: bn(["react-flow__controls-button", t]), ...e, children: n });
}
const m4 = (n) => ({
  isInteractive: n.nodesDraggable || n.nodesConnectable || n.elementsSelectable,
  minZoomReached: n.transform[2] <= n.minZoom,
  maxZoomReached: n.transform[2] >= n.maxZoom,
  ariaLabelConfig: n.ariaLabelConfig
});
function IE({ style: n, showZoom: t = !0, showFitView: e = !0, showInteractive: s = !0, fitViewOptions: r, onZoomIn: l, onZoomOut: c, onFitView: f, onInteractiveChange: d, className: h, children: m, position: p = "bottom-left", orientation: _ = "vertical", "aria-label": x }) {
  const b = rn(), { isInteractive: M, minZoomReached: S, maxZoomReached: y, ariaLabelConfig: C } = Ue(m4, an), { zoomIn: T, zoomOut: E, fitView: O } = E0(), N = () => {
    T(), l == null || l();
  }, D = () => {
    E(), c == null || c();
  }, z = () => {
    O(r), f == null || f();
  }, A = () => {
    b.setState({
      nodesDraggable: !M,
      nodesConnectable: !M,
      elementsSelectable: !M
    }), d == null || d(!M);
  }, R = _ === "horizontal" ? "horizontal" : "vertical";
  return Z.jsxs(Ad, { className: bn(["react-flow__controls", R, h]), position: p, style: n, "data-testid": "rf__controls", "aria-label": x ?? C["controls.ariaLabel"], children: [t && Z.jsxs(Z.Fragment, { children: [Z.jsx(Uf, { onClick: N, className: "react-flow__controls-zoomin", title: C["controls.zoomIn.ariaLabel"], "aria-label": C["controls.zoomIn.ariaLabel"], disabled: y, children: Z.jsx(u4, {}) }), Z.jsx(Uf, { onClick: D, className: "react-flow__controls-zoomout", title: C["controls.zoomOut.ariaLabel"], "aria-label": C["controls.zoomOut.ariaLabel"], disabled: S, children: Z.jsx(f4, {}) })] }), e && Z.jsx(Uf, { className: "react-flow__controls-fitview", onClick: z, title: C["controls.fitView.ariaLabel"], "aria-label": C["controls.fitView.ariaLabel"], children: Z.jsx(d4, {}) }), s && Z.jsx(Uf, { className: "react-flow__controls-interactive", onClick: A, title: C["controls.interactive.ariaLabel"], "aria-label": C["controls.interactive.ariaLabel"], children: M ? Z.jsx(p4, {}) : Z.jsx(h4, {}) }), m] });
}
IE.displayName = "Controls";
const g4 = st.memo(IE);
function _4({ id: n, x: t, y: e, width: s, height: r, style: l, color: c, strokeColor: f, strokeWidth: d, className: h, borderRadius: m, shapeRendering: p, selected: _, onClick: x }) {
  const { background: b, backgroundColor: M } = l || {}, S = c || b || M;
  return Z.jsx("rect", { className: bn(["react-flow__minimap-node", { selected: _ }, h]), x: t, y: e, rx: m, ry: m, width: s, height: r, style: {
    fill: S,
    stroke: f,
    strokeWidth: d
  }, shapeRendering: p, onClick: x ? (y) => x(y, n) : void 0 });
}
const v4 = st.memo(_4), y4 = (n) => n.nodes.map((t) => t.id), Pm = (n) => n instanceof Function ? n : () => n;
function x4({
  nodeStrokeColor: n,
  nodeColor: t,
  nodeClassName: e = "",
  nodeBorderRadius: s = 5,
  nodeStrokeWidth: r,
  /*
   * We need to rename the prop to be `CapitalCase` so that JSX will render it as
   * a component properly.
   */
  nodeComponent: l = v4,
  onClick: c
}) {
  const f = Ue(y4, an), d = Pm(t), h = Pm(n), m = Pm(e), p = typeof window > "u" || window.chrome ? "crispEdges" : "geometricPrecision";
  return Z.jsx(Z.Fragment, { children: f.map((_) => (
    /*
     * 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`.
     */
    Z.jsx(b4, { id: _, nodeColorFunc: d, nodeStrokeColorFunc: h, nodeClassNameFunc: m, nodeBorderRadius: s, nodeStrokeWidth: r, NodeComponent: l, onClick: c, shapeRendering: p }, _)
  )) });
}
function S4({ id: n, nodeColorFunc: t, nodeStrokeColorFunc: e, nodeClassNameFunc: s, nodeBorderRadius: r, nodeStrokeWidth: l, shapeRendering: c, NodeComponent: f, onClick: d }) {
  const { node: h, x: m, y: p, width: _, height: x } = Ue((b) => {
    const M = b.nodeLookup.get(n);
    if (!M)
      return { node: void 0, x: 0, y: 0, width: 0, height: 0 };
    const S = M.internals.userNode, { x: y, y: C } = M.internals.positionAbsolute, { width: T, height: E } = ks(S);
    return {
      node: S,
      x: y,
      y: C,
      width: T,
      height: E
    };
  }, an);
  return !h || h.hidden || !z1(h) ? null : Z.jsx(f, { x: m, y: p, width: _, height: x, style: h.style, selected: !!h.selected, className: s(h), color: t(h), borderRadius: r, strokeColor: e(h), strokeWidth: l, shapeRendering: c, onClick: d, id: h.id });
}
const b4 = st.memo(S4);
var M4 = st.memo(x4);
const E4 = 200, T4 = 150, A4 = (n) => !n.hidden, w4 = (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 ? P1(Pc(n.nodeLookup, { filter: A4 }), t) : t,
    rfId: n.rfId,
    panZoom: n.panZoom,
    translateExtent: n.translateExtent,
    flowWidth: n.width,
    flowHeight: n.height,
    ariaLabelConfig: n.ariaLabelConfig
  };
}, C4 = "react-flow__minimap-desc";
function BE({
  style: n,
  className: t,
  nodeStrokeColor: e,
  nodeColor: s,
  nodeClassName: r = "",
  nodeBorderRadius: l = 5,
  nodeStrokeWidth: c,
  /*
   * We need to rename the prop to be `CapitalCase` so that JSX will render it as
   * a component properly.
   */
  nodeComponent: f,
  bgColor: d,
  maskColor: h,
  maskStrokeColor: m,
  maskStrokeWidth: p,
  position: _ = "bottom-right",
  onClick: x,
  onNodeClick: b,
  pannable: M = !1,
  zoomable: S = !1,
  ariaLabel: y,
  inversePan: C,
  zoomStep: T = 1,
  offsetScale: E = 5
}) {
  const O = rn(), N = st.useRef(null), { boundingRect: D, viewBB: z, rfId: A, panZoom: R, translateExtent: L, flowWidth: H, flowHeight: k, ariaLabelConfig: P } = Ue(w4, an), Y = (n == null ? void 0 : n.width) ?? E4, U = (n == null ? void 0 : n.height) ?? T4, X = D.width / Y, V = D.height / U, W = Math.max(X, V), J = W * Y, I = W * U, q = E * W, lt = D.x - (J - D.width) / 2 - q, $ = D.y - (I - D.height) / 2 - q, ot = J + q * 2, gt = I + q * 2, ht = `${C4}-${A}`, _t = st.useRef(0), Et = st.useRef();
  _t.current = W, st.useEffect(() => {
    if (N.current && R)
      return Et.current = Yz({
        domNode: N.current,
        panZoom: R,
        getTransform: () => O.getState().transform,
        getViewScale: () => _t.current
      }), () => {
        var Bt;
        (Bt = Et.current) == null || Bt.destroy();
      };
  }, [R]), st.useEffect(() => {
    var Bt;
    (Bt = Et.current) == null || Bt.update({
      translateExtent: L,
      width: H,
      height: k,
      inversePan: C,
      pannable: M,
      zoomStep: T,
      zoomable: S
    });
  }, [M, S, C, T, L, H, k]);
  const Lt = x ? (Bt) => {
    var Xt;
    const [K, pe] = ((Xt = Et.current) == null ? void 0 : Xt.pointer(Bt)) || [0, 0];
    x(Bt, { x: K, y: pe });
  } : void 0, Gt = b ? st.useCallback((Bt, K) => {
    const pe = O.getState().nodeLookup.get(K).internals.userNode;
    b(Bt, pe);
  }, []) : void 0, Nt = y ?? P["minimap.ariaLabel"];
  return Z.jsx(Ad, { position: _, 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 m == "string" ? m : void 0,
    "--xy-minimap-mask-stroke-width-props": typeof p == "number" ? p * W : void 0,
    "--xy-minimap-node-background-color-props": typeof s == "string" ? s : 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: bn(["react-flow__minimap", t]), "data-testid": "rf__minimap", children: Z.jsxs("svg", { width: Y, height: U, viewBox: `${lt} ${$} ${ot} ${gt}`, className: "react-flow__minimap-svg", role: "img", "aria-labelledby": ht, ref: N, onClick: Lt, children: [Nt && Z.jsx("title", { id: ht, children: Nt }), Z.jsx(M4, { onClick: Gt, nodeColor: s, nodeStrokeColor: e, nodeBorderRadius: l, nodeClassName: r, nodeStrokeWidth: c, nodeComponent: f }), Z.jsx("path", { className: "react-flow__minimap-mask", d: `M${lt - q},${$ - q}h${ot + q * 2}v${gt + q * 2}h${-ot - q * 2}z
        M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`, fillRule: "evenodd", pointerEvents: "none" })] }) });
}
BE.displayName = "MiniMap";
const R4 = st.memo(BE), D4 = (n) => (t) => n ? `${Math.max(1 / t.transform[2], 1)}` : void 0, N4 = {
  [tl.Line]: "right",
  [tl.Handle]: "bottom-right"
};
function L4({ nodeId: n, position: t, variant: e = tl.Handle, className: s, style: r = void 0, children: l, color: c, minWidth: f = 10, minHeight: d = 10, maxWidth: h = Number.MAX_VALUE, maxHeight: m = Number.MAX_VALUE, keepAspectRatio: p = !1, resizeDirection: _, autoScale: x = !0, shouldResize: b, onResizeStart: M, onResize: S, onResizeEnd: y }) {
  const C = mE(), T = typeof n == "string" ? n : C, E = rn(), O = st.useRef(null), N = e === tl.Handle, D = Ue(st.useCallback(D4(N && x), [N, x]), an), z = st.useRef(null), A = t ?? N4[e];
  st.useEffect(() => {
    if (!(!O.current || !T))
      return z.current || (z.current = rI({
        domNode: O.current,
        nodeId: T,
        getStoreItems: () => {
          const { nodeLookup: L, transform: H, snapGrid: k, snapToGrid: P, nodeOrigin: Y, domNode: U } = E.getState();
          return {
            nodeLookup: L,
            transform: H,
            snapGrid: k,
            snapToGrid: P,
            nodeOrigin: Y,
            paneDomNode: U
          };
        },
        onChange: (L, H) => {
          const { triggerNodeChanges: k, nodeLookup: P, parentLookup: Y, nodeOrigin: U } = E.getState(), X = [], V = { x: L.x, y: L.y }, W = P.get(T);
          if (W && W.expandParent && W.parentId) {
            const J = W.origin ?? U, I = L.width ?? W.measured.width ?? 0, q = L.height ?? W.measured.height ?? 0, lt = {
              id: W.id,
              parentId: W.parentId,
              rect: {
                width: I,
                height: q,
                ...I1({
                  x: L.x ?? W.position.x,
                  y: L.y ?? W.position.y
                }, { width: I, height: q }, W.parentId, P, J)
              }
            }, $ = M0([lt], P, Y, U);
            X.push(...$), V.x = L.x ? Math.max(J[0] * I, L.x) : void 0, V.y = L.y ? Math.max(J[1] * q, L.y) : void 0;
          }
          if (V.x !== void 0 && V.y !== void 0) {
            const J = {
              id: T,
              type: "position",
              position: { ...V }
            };
            X.push(J);
          }
          if (L.width !== void 0 && L.height !== void 0) {
            const I = {
              id: T,
              type: "dimensions",
              resizing: !0,
              setAttributes: _ ? _ === "horizontal" ? "width" : "height" : !0,
              dimensions: {
                width: L.width,
                height: L.height
              }
            };
            X.push(I);
          }
          for (const J of H) {
            const I = {
              ...J,
              type: "position"
            };
            X.push(I);
          }
          k(X);
        },
        onEnd: ({ width: L, height: H }) => {
          const k = {
            id: T,
            type: "dimensions",
            resizing: !1,
            dimensions: {
              width: L,
              height: H
            }
          };
          E.getState().triggerNodeChanges([k]);
        }
      })), z.current.update({
        controlPosition: A,
        boundaries: {
          minWidth: f,
          minHeight: d,
          maxWidth: h,
          maxHeight: m
        },
        keepAspectRatio: p,
        resizeDirection: _,
        onResizeStart: M,
        onResize: S,
        onResizeEnd: y,
        shouldResize: b
      }), () => {
        var L;
        (L = z.current) == null || L.destroy();
      };
  }, [
    A,
    f,
    d,
    h,
    m,
    p,
    M,
    S,
    y,
    b
  ]);
  const R = A.split("-");
  return Z.jsx("div", { className: bn(["react-flow__resize-control", "nodrag", ...R, e, s]), ref: O, style: {
    ...r,
    scale: D,
    ...c && { [N ? "backgroundColor" : "borderColor"]: c }
  }, children: l });
}
st.memo(L4);
const kb = (n) => {
  let t;
  const e = /* @__PURE__ */ new Set(), s = (h, m) => {
    const p = typeof h == "function" ? h(t) : h;
    if (!Object.is(p, t)) {
      const _ = t;
      t = m ?? (typeof p != "object" || p === null) ? p : Object.assign({}, t, p), e.forEach((x) => x(t, _));
    }
  }, r = () => t, f = { setState: s, getState: r, getInitialState: () => d, subscribe: (h) => (e.add(h), () => e.delete(h)) }, d = t = n(s, r, f);
  return f;
}, U4 = ((n) => n ? kb(n) : kb), O4 = (n) => n;
function P4(n, t = O4) {
  const e = lc.useSyncExternalStore(
    n.subscribe,
    lc.useCallback(() => t(n.getState()), [n, t]),
    lc.useCallback(() => t(n.getInitialState()), [n, t])
  );
  return lc.useDebugValue(e), e;
}
const Xb = (n) => {
  const t = U4(n), e = (s) => P4(t, s);
  return Object.assign(e, t), e;
}, z4 = ((n) => n ? Xb(n) : Xb), FE = {
  particle: "#3b82f6",
  // blue
  bond: "#f59e0b",
  // amber
  cell: "#10b981",
  // emerald
  label: "#8b5cf6",
  // violet
  mesh: "#6b7280",
  // gray
  trajectory: "#ec4899"
  // pink
}, HE = {
  load_structure: "Load Structure",
  load_trajectory: "Load Trajectory",
  add_bond: "Add Bond",
  viewport: "Viewport",
  filter: "Filter",
  modify: "Modify",
  label_generator: "Labels",
  polyhedron_generator: "Polyhedra"
}, I4 = {
  load_structure: "data_load",
  load_trajectory: "data_load",
  add_bond: "bond",
  filter: "filter",
  modify: "modify",
  label_generator: "overlay",
  polyhedron_generator: "overlay",
  viewport: "viewport"
}, VE = {
  data_load: "#3b82f6",
  // blue
  bond: "#f59e0b",
  // amber
  filter: "#10b981",
  // green
  modify: "#8b5cf6",
  // purple
  overlay: "#ec4899",
  // pink
  viewport: "#64748b"
  // slate
}, Ac = {
  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" }
    ]
  },
  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" }
    ],
    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" }]
  }
}, B4 = {
  filter: ["particle", "bond"],
  modify: ["particle", "bond"]
};
function GE(n) {
  switch (n) {
    case "load_structure":
      return { type: n, fileName: null, hasTrajectory: !1, hasCell: !1 };
    case "load_trajectory":
      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
      };
  }
}
function kE(n, t, e, s) {
  if (!t || !s) return !1;
  const r = Ac[n], l = Ac[e], c = r.outputs.find((h) => h.name === t), f = l.inputs.find((h) => h.name === s);
  if (!c || !f) return !1;
  const d = B4[e];
  return d ? d.includes(c.dataType) : c.dataType === f.dataType;
}
const qf = {
  particles: [],
  bonds: [],
  cells: [],
  trajectories: [],
  labels: [],
  meshes: [],
  perspective: !1,
  cellAxesVisible: !0
};
function F4(n, t) {
  var c;
  const e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
  for (const f of n)
    e.set(f.id, 0), s.set(f.id, []);
  for (const f of t) {
    const d = e.get(f.target) ?? 0;
    e.set(f.target, d + 1), (c = s.get(f.source)) == null || c.push(f.target);
  }
  const r = [];
  for (const [f, d] of e)
    d === 0 && r.push(f);
  const l = [];
  for (; r.length > 0; ) {
    const f = r.shift();
    l.push(f);
    for (const d of s.get(f) ?? []) {
      const h = (e.get(d) ?? 1) - 1;
      e.set(d, h), h === 0 && r.push(d);
    }
  }
  return l;
}
function Wb(n, t, e) {
  const s = /* @__PURE__ */ new Map();
  for (const r of t) {
    if (r.target !== n) continue;
    const l = r.sourceHandle, c = r.targetHandle;
    if (!l || !c) continue;
    const f = e.get(r.source);
    if (!f) continue;
    const d = f.get(l);
    d && (s.has(c) || s.set(c, []), s.get(c).push(d));
  }
  return s;
}
function H4(n, t, e, s) {
  const r = /* @__PURE__ */ new Map();
  if (!t) return r;
  const l = {
    type: "particle",
    source: t,
    indices: null,
    scaleOverrides: null,
    opacityOverrides: null
  };
  if (r.set("particle", l), e && e.length > 0 && s) {
    const c = {
      type: "trajectory",
      frames: e,
      meta: s,
      source: "structure"
    };
    r.set("trajectory", c);
  }
  if (t.box) {
    const c = {
      type: "cell",
      box: t.box,
      visible: !0,
      axesVisible: !0
    };
    r.set("cell", c);
  }
  return r;
}
function V4(n, t, e, s) {
  const r = /* @__PURE__ */ new Map();
  if (e && e.length > 0 && s) {
    const l = {
      type: "trajectory",
      frames: e,
      meta: s,
      source: "file"
    };
    r.set("trajectory", l);
  }
  return r;
}
const G4 = 0.6, Yb = 0.4, Co = 2;
function XE(n, t, e, s = G4) {
  if (e < 2) return new Uint32Array(0);
  let r = 1 / 0, l = 1 / 0, c = 1 / 0, f = -1 / 0, d = -1 / 0, h = -1 / 0;
  for (let T = 0; T < e; T++) {
    const E = n[T * 3], O = n[T * 3 + 1], N = n[T * 3 + 2];
    E < r && (r = E), O < l && (l = O), N < c && (c = N), E > f && (f = E), O > d && (d = O), N > h && (h = N);
  }
  const m = Math.max(1, Math.floor((f - r) / Co) + 1), p = Math.max(1, Math.floor((d - l) / Co) + 1), _ = Math.max(1, Math.floor((h - c) / Co) + 1), x = m * p * _, b = new Array(x);
  for (let T = 0; T < x; T++) b[T] = [];
  for (let T = 0; T < e; T++) {
    const E = Math.min(Math.floor((n[T * 3] - r) / Co), m - 1), O = Math.min(Math.floor((n[T * 3 + 1] - l) / Co), p - 1), N = Math.min(Math.floor((n[T * 3 + 2] - c) / Co), _ - 1);
    b[E * p * _ + O * _ + N].push(T);
  }
  const M = [
    [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]
  ], S = Yb * Yb, y = [];
  function C(T, E) {
    const O = wg[t[T]] ?? Cg, N = wg[t[E]] ?? Cg, D = (O + N) * s, z = D * D, A = n[E * 3] - n[T * 3], R = n[E * 3 + 1] - n[T * 3 + 1], L = n[E * 3 + 2] - n[T * 3 + 2], H = A * A + R * R + L * L;
    if (H > S && H <= z) {
      const k = T < E ? T : E, P = T < E ? E : T;
      y.push(k, P);
    }
  }
  for (let T = 0; T < m; T++)
    for (let E = 0; E < p; E++)
      for (let O = 0; O < _; O++) {
        const N = T * p * _ + E * _ + O, D = b[N];
        for (let z = 0; z < D.length; z++)
          for (let A = z + 1; A < D.length; A++)
            C(D[z], D[A]);
        for (const [z, A, R] of M) {
          const L = T + z, H = E + A, k = O + R;
          if (L < 0 || L >= m || H < 0 || H >= p || k < 0 || k >= _) continue;
          const P = L * p * _ + H * _ + k, Y = b[P];
          for (const U of D)
            for (const X of Y)
              C(U, X);
        }
      }
  return new Uint32Array(y);
}
function k4(n, t) {
  var l;
  const e = /* @__PURE__ */ new Map(), s = (l = t.get("particle")) == null ? void 0 : l[0];
  if (!s) return e;
  const r = s.source;
  if (n.bondSource === "structure") {
    if (r.nFileBonds > 0) {
      const c = {
        type: "bond",
        bondIndices: r.bonds,
        bondOrders: r.bondOrders,
        nBonds: r.nBonds,
        scale: 1,
        opacity: 1
      };
      e.set("bond", c);
    }
  } else if (n.bondSource === "distance") {
    const c = XE(
      r.positions,
      r.elements,
      r.nAtoms,
      0.6
    );
    if (c.length > 0) {
      const f = {
        type: "bond",
        bondIndices: c,
        bondOrders: null,
        nBonds: c.length / 2,
        scale: 1,
        opacity: 1
      };
      e.set("bond", f);
    }
  }
  return e;
}
const X4 = /* @__PURE__ */ new Set(["element", "index", "x", "y", "z", "resname", "mass"]);
function WE(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 s = n[e];
      let r = e + 1;
      for (; r < n.length && n[r] !== s; ) r++;
      if (r >= n.length) throw new Error(`Unterminated string at position ${e}`);
      t.push({ type: "string", value: n.slice(e + 1, r) }), e = r + 1;
      continue;
    }
    if (/[\d.]/.test(n[e]) || n[e] === "-" && e + 1 < n.length && /[\d.]/.test(n[e + 1])) {
      let s = e;
      for (n[s] === "-" && s++; s < n.length && /[\d.]/.test(n[s]); ) s++;
      t.push({ type: "number", value: n.slice(e, s) }), e = s;
      continue;
    }
    if (/[a-zA-Z_]/.test(n[e])) {
      let s = e;
      for (; s < n.length && /[a-zA-Z_0-9]/.test(n[s]); ) s++;
      const r = n.slice(e, s);
      if (r === "and") t.push({ type: "and", value: r });
      else if (r === "or") t.push({ type: "or", value: r });
      else if (r === "not") t.push({ type: "not", value: r });
      else if (r === "all") t.push({ type: "all", value: r });
      else if (r === "none") t.push({ type: "none", value: r });
      else if (X4.has(r)) t.push({ type: "field", value: r });
      else throw new Error(`Unknown identifier: "${r}"`);
      e = s;
      continue;
    }
    throw new Error(`Unexpected character: "${n[e]}" at position ${e}`);
  }
  return t.push({ type: "eof", value: "" }), t;
}
class YE {
  constructor(t) {
    Ct(this, "tokens");
    Ct(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, s = this.expect("op").value, r = this.peek();
      let l;
      if (r.type === "string")
        l = this.advance().value;
      else if (r.type === "number") {
        if (l = parseFloat(this.advance().value), isNaN(l)) throw new Error("Invalid number");
      } else
        throw new Error(`Expected value after operator, got ${r.type}`);
      return { kind: "comparison", field: e, op: s, value: l };
    }
    throw new Error(`Unexpected token: "${t.value}" (${t.type})`);
  }
}
function W4(n) {
  const t = n.match(/^([A-Za-z]+)/);
  return t ? t[1] : n;
}
function Do(n, t, e) {
  switch (n.kind) {
    case "all":
      return () => !0;
    case "none":
      return () => !1;
    case "not": {
      const s = Do(n.operand, t, e);
      return (r) => !s(r);
    }
    case "and": {
      const s = Do(n.left, t, e), r = Do(n.right, t, e);
      return (l) => s(l) && r(l);
    }
    case "or": {
      const s = Do(n.left, t, e), r = Do(n.right, t, e);
      return (l) => s(l) || r(l);
    }
    case "comparison": {
      const { field: s, op: r, value: l } = n;
      return (c) => {
        let f;
        switch (s) {
          case "element":
            f = o0(t.elements[c]);
            break;
          case "index":
            f = c;
            break;
          case "x":
            f = t.positions[c * 3];
            break;
          case "y":
            f = t.positions[c * 3 + 1];
            break;
          case "z":
            f = t.positions[c * 3 + 2];
            break;
          case "resname":
            f = e != null && e[c] ? W4(e[c]) : "";
            break;
          case "mass":
            f = JN(t.elements[c]);
            break;
          default:
            return !1;
        }
        switch (r) {
          case "==":
            return f === l;
          case "!=":
            return f !== l;
          case ">":
            return f > l;
          case "<":
            return f < l;
          case ">=":
            return f >= l;
          case "<=":
            return f <= l;
          default:
            return !1;
        }
      };
    }
  }
}
function Y4(n, t, e) {
  const s = n.trim();
  if (s === "" || s === "all") return null;
  const r = WE(s), c = new YE(r).parse();
  if (c.kind === "all") return null;
  if (c.kind === "none") return /* @__PURE__ */ new Set();
  const f = Do(c, t, e), d = /* @__PURE__ */ new Set();
  for (let h = 0; h < t.nAtoms; h++)
    f(h) && d.add(h);
  return d;
}
function j4(n) {
  const t = n.trim();
  if (t === "" || t === "all" || t === "none")
    return { valid: !0 };
  try {
    const e = WE(t);
    return new YE(e).parse(), { valid: !0 };
  } catch (e) {
    return { valid: !1, error: e.message };
  }
}
function q4(n, t, e) {
  var l;
  const s = /* @__PURE__ */ new Map(), r = (l = t.get("in")) == null ? void 0 : l[0];
  if (!r) return s;
  if (r.type === "particle") {
    const c = r;
    if (!n.query.trim())
      return s.set("out", c), s;
    try {
      const f = Y4(
        n.query,
        c.source,
        e
      );
      if (f === null)
        s.set("out", c);
      else {
        let d;
        if (c.indices === null)
          d = new Uint32Array(f);
        else {
          const m = new Set(c.indices), p = [...f].filter((_) => m.has(_));
          d = new Uint32Array(p);
        }
        const h = {
          ...c,
          indices: d,
          scaleOverrides: c.scaleOverrides,
          opacityOverrides: c.opacityOverrides
        };
        s.set("out", h);
      }
    } catch {
      s.set("out", c);
    }
  } else r.type === "bond" && s.set("out", r);
  return s;
}
function Z4(n, t) {
  var r;
  const e = /* @__PURE__ */ new Map(), s = (r = t.get("in")) == null ? void 0 : r[0];
  if (!s) return e;
  if (s.type === "particle") {
    const l = s, c = l.source.nAtoms;
    let f = l.scaleOverrides;
    if (l.indices !== null && l.indices.length > 0) {
      f ? f = new Float32Array(f) : f = new Float32Array(c).fill(1);
      for (const m of l.indices)
        f[m] = n.scale;
    } else l.indices === null && n.scale !== 1 && (f = new Float32Array(c).fill(n.scale));
    let d = l.opacityOverrides;
    if (l.indices !== null && l.indices.length > 0) {
      d ? d = new Float32Array(d) : d = new Float32Array(c).fill(1);
      for (const m of l.indices)
        d[m] = n.opacity;
    } else l.indices === null && n.opacity !== 1 && (d = new Float32Array(c).fill(n.opacity));
    const h = {
      ...l,
      scaleOverrides: f,
      opacityOverrides: d
    };
    e.set("out", h);
  } else if (s.type === "bond") {
    const c = {
      ...s,
      scale: n.scale,
      opacity: n.opacity
    };
    e.set("out", c);
  }
  return e;
}
function K4(n, t, e) {
  var d;
  const s = /* @__PURE__ */ new Map(), r = (d = t.get("particle")) == null ? void 0 : d[0];
  if (!r) return s;
  const l = r.source;
  let c;
  switch (n.source) {
    case "element":
      c = Array.from(l.elements).map((h) => o0(h));
      break;
    case "resname":
      c = (e == null ? void 0 : e.slice(0, l.nAtoms)) ?? [];
      break;
    case "index":
      c = Array.from({ length: l.nAtoms }, (h, m) => String(m));
      break;
    default:
      c = [];
  }
  if (r.indices !== null) {
    const h = new Array(l.nAtoms).fill("");
    for (const m of r.indices)
      h[m] = c[m];
    c = h;
  }
  const f = {
    type: "label",
    labels: c,
    particleRef: r
  };
  return s.set("label", f), s;
}
function jE(n, t, e, s, r, l) {
  return [
    t * l - e * r,
    e * s - n * l,
    n * r - t * s
  ];
}
function oc(n, t, e, s, r) {
  const l = s[n * 3], c = s[n * 3 + 1], f = s[n * 3 + 2], d = s[t * 3], h = s[t * 3 + 1], m = s[t * 3 + 2], p = s[e * 3], _ = s[e * 3 + 1], x = s[e * 3 + 2], b = d - l, M = h - c, S = m - f, y = p - l, C = _ - c, T = x - f;
  let [E, O, N] = jE(b, M, S, y, C, T);
  const D = Math.sqrt(E * E + O * O + N * N);
  if (D < 1e-12)
    return { a: n, b: t, c: e, nx: 0, ny: 0, nz: 0, d: 0 };
  E /= D, O /= D, N /= D;
  const z = -(E * l + O * c + N * f);
  return E * r[0] + O * r[1] + N * r[2] + z > 0 ? (E = -E, O = -O, N = -N, { a: n, b: e, c: t, nx: E, ny: O, nz: N, d: -z }) : { a: n, b: t, c: e, nx: E, ny: O, nz: N, d: z };
}
function $4(n, t, e, s) {
  return n.nx * t + n.ny * e + n.nz * s + n.d;
}
function Q4(n, t) {
  if (t < 4) return null;
  let e = 0, s = 1, r = -1;
  for (let L = 0; L < t; L++)
    for (let H = L + 1; H < t; H++) {
      const k = n[H * 3] - n[L * 3], P = n[H * 3 + 1] - n[L * 3 + 1], Y = n[H * 3 + 2] - n[L * 3 + 2], U = k * k + P * P + Y * Y;
      U > r && (r = U, e = L, s = H);
    }
  if (r < 1e-20) return null;
  const l = n[s * 3] - n[e * 3], c = n[s * 3 + 1] - n[e * 3 + 1], f = n[s * 3 + 2] - n[e * 3 + 2], d = Math.sqrt(l * l + c * c + f * f), h = l / d, m = c / d, p = f / d;
  let _ = -1, x = -1;
  for (let L = 0; L < t; L++) {
    if (L === e || L === s) continue;
    const H = n[L * 3] - n[e * 3], k = n[L * 3 + 1] - n[e * 3 + 1], P = n[L * 3 + 2] - n[e * 3 + 2], Y = H * h + k * m + P * p, U = H - Y * h, X = k - Y * m, V = P - Y * p, W = U * U + X * X + V * V;
    W > x && (x = W, _ = L);
  }
  if (_ < 0 || x < 1e-20) return null;
  const b = n[s * 3] - n[e * 3], M = n[s * 3 + 1] - n[e * 3 + 1], S = n[s * 3 + 2] - n[e * 3 + 2], y = n[_ * 3] - n[e * 3], C = n[_ * 3 + 1] - n[e * 3 + 1], T = n[_ * 3 + 2] - n[e * 3 + 2];
  let [E, O, N] = jE(b, M, S, y, C, T);
  const D = Math.sqrt(E * E + O * O + N * N);
  if (D < 1e-12) return null;
  E /= D, O /= D, N /= D;
  const z = -(E * n[e * 3] + O * n[e * 3 + 1] + N * n[e * 3 + 2]);
  let A = -1, R = -1;
  for (let L = 0; L < t; L++) {
    if (L === e || L === s || L === _) continue;
    const H = Math.abs(E * n[L * 3] + O * n[L * 3 + 1] + N * n[L * 3 + 2] + z);
    H > R && (R = H, A = L);
  }
  return A < 0 || R < 1e-10 ? null : [e, s, _, A];
}
function J4(n, t) {
  if (t < 4) return null;
  const e = Q4(n, t);
  if (!e) return null;
  const [s, r, l, c] = e, f = [
    (n[s * 3] + n[r * 3] + n[l * 3] + n[c * 3]) / 4,
    (n[s * 3 + 1] + n[r * 3 + 1] + n[l * 3 + 1] + n[c * 3 + 1]) / 4,
    (n[s * 3 + 2] + n[r * 3 + 2] + n[l * 3 + 2] + n[c * 3 + 2]) / 4
  ], d = [
    oc(s, r, l, n, f),
    oc(s, r, c, n, f),
    oc(s, l, c, n, f),
    oc(r, l, c, n, f)
  ], h = /* @__PURE__ */ new Set([s, r, l, c]);
  for (let y = 0; y < t; y++) {
    if (h.has(y)) continue;
    const C = n[y * 3], T = n[y * 3 + 1], E = n[y * 3 + 2], O = [];
    for (let A = 0; A < d.length; A++)
      $4(d[A], C, T, E) > 1e-10 && O.push(A);
    if (O.length === 0) continue;
    const N = [], D = new Set(O);
    for (const A of O) {
      const R = d[A], L = [
        [R.a, R.b],
        [R.b, R.c],
        [R.c, R.a]
      ];
      for (const [H, k] of L) {
        let P = !1;
        for (let Y = 0; Y < d.length; Y++) {
          if (Y === A || D.has(Y)) continue;
          const U = d[Y];
          if (U.a === k && U.b === H || U.b === k && U.c === H || U.c === k && U.a === H) {
            P = !0;
            break;
          }
        }
        P && N.push([H, k]);
      }
    }
    const z = [...O].sort((A, R) => R - A);
    for (const A of z)
      d.splice(A, 1);
    for (const [A, R] of N)
      d.push(oc(A, R, y, n, f));
  }
  const m = d.length, p = new Uint32Array(m * 3), _ = new Float32Array(t * 3), x = new Float32Array(t);
  for (let y = 0; y < m; y++) {
    const C = d[y];
    p[y * 3] = C.a, p[y * 3 + 1] = C.b, p[y * 3 + 2] = C.c;
    for (const T of [C.a, C.b, C.c])
      _[T * 3] += C.nx, _[T * 3 + 1] += C.ny, _[T * 3 + 2] += C.nz, x[T]++;
  }
  for (let y = 0; y < t; y++)
    if (x[y] > 0) {
      const C = Math.sqrt(
        _[y * 3] ** 2 + _[y * 3 + 1] ** 2 + _[y * 3 + 2] ** 2
      );
      C > 1e-12 && (_[y * 3] /= C, _[y * 3 + 1] /= C, _[y * 3 + 2] /= C);
    }
  const b = /* @__PURE__ */ new Set(), M = [];
  for (let y = 0; y < m; y++) {
    const C = d[y], T = [
      [C.a, C.b],
      [C.b, C.c],
      [C.c, C.a]
    ];
    for (const [E, O] of T) {
      const N = E < O ? `${E}-${O}` : `${O}-${E}`;
      b.has(N) || (b.add(N), M.push(E, O));
    }
  }
  const S = new Float32Array(M.length * 3);
  for (let y = 0; y < M.length; y++) {
    const C = M[y];
    S[y * 3] = n[C * 3], S[y * 3 + 1] = n[C * 3 + 1], S[y * 3 + 2] = n[C * 3 + 2];
  }
  return {
    vertices: new Float32Array(n.buffer, n.byteOffset, t * 3),
    indices: p,
    normals: _,
    edges: S
  };
}
function tF(n) {
  const [t, e, s, r, l, c, f, d, h] = n, m = t * (l * h - c * d) - e * (r * h - c * f) + s * (r * d - l * f);
  if (Math.abs(m) < 1e-20) return null;
  const p = 1 / m;
  return new Float32Array([
    (l * h - c * d) * p,
    (s * d - e * h) * p,
    (e * c - s * l) * p,
    (c * f - r * h) * p,
    (t * h - s * f) * p,
    (s * r - t * c) * p,
    (r * d - l * f) * p,
    (e * f - t * d) * p,
    (t * l - e * r) * p
  ]);
}
function eF(n, t, e, s, r) {
  let l = r[0] * n + r[3] * t + r[6] * e, c = r[1] * n + r[4] * t + r[7] * e, f = r[2] * n + r[5] * t + r[8] * e;
  return l -= Math.round(l), c -= Math.round(c), f -= Math.round(f), [
    s[0] * l + s[3] * c + s[6] * f,
    s[1] * l + s[4] * c + s[7] * f,
    s[2] * l + s[5] * c + s[8] * f
  ];
}
function nF(n, t) {
  var N;
  const e = /* @__PURE__ */ new Map(), s = (N = t.get("particle")) == null ? void 0 : N[0];
  if (!s) return e;
  const r = s.source, { positions: l, elements: c, nAtoms: f } = r, d = new Set(n.centerElements), h = new Set(n.ligandElements);
  if (d.size === 0 || h.size === 0) return e;
  const m = [], p = [];
  for (let D = 0; D < f; D++)
    d.has(c[D]) && m.push(D), h.has(c[D]) && p.push(D);
  if (m.length === 0 || p.length === 0) return e;
  const _ = r.box;
  let x = null;
  _ && _.some((D) => D !== 0) && (x = tF(_));
  const b = n.maxDistance * n.maxDistance, M = [], S = [], y = [], C = [], T = [];
  let E = 0;
  for (const D of m) {
    const z = l[D * 3], A = l[D * 3 + 1], R = l[D * 3 + 2], L = [];
    for (const W of p) {
      let J = l[W * 3] - z, I = l[W * 3 + 1] - A, q = l[W * 3 + 2] - R;
      x && _ && ([J, I, q] = eF(J, I, q, _, x));
      const lt = J * J + I * I + q * q;
      lt <= b && lt > 0.01 && L.push(z + J, A + I, R + q);
    }
    const H = L.length / 3;
    if (H < 4) continue;
    const k = new Float32Array(L), P = J4(k, H);
    if (!P) continue;
    const [Y, U, X] = gc(c[D]), V = P.vertices.length / 3;
    for (let W = 0; W < V; W++)
      M.push(P.vertices[W * 3], P.vertices[W * 3 + 1], P.vertices[W * 3 + 2]), y.push(P.normals[W * 3], P.normals[W * 3 + 1], P.normals[W * 3 + 2]), C.push(Y, U, X, n.opacity);
    for (let W = 0; W < P.indices.length; W++)
      S.push(P.indices[W] + E);
    for (let W = 0; W < P.edges.length; W++)
      T.push(P.edges[W]);
    E += V;
  }
  if (S.length === 0) return e;
  const O = {
    type: "mesh",
    positions: new Float32Array(M),
    indices: new Uint32Array(S),
    normals: new Float32Array(y),
    colors: new Float32Array(C),
    opacity: n.opacity,
    showEdges: n.showEdges,
    edgePositions: n.showEdges ? new Float32Array(T) : null
  };
  return e.set("mesh", O), e;
}
function iF(n, t) {
  const e = t.get("particle") ?? [], s = t.get("bond") ?? [], r = t.get("cell") ?? [], l = t.get("trajectory") ?? [], c = t.get("label") ?? [], f = t.get("mesh") ?? [], d = sF(s, e), h = [...l].sort((m, p) => m.source === "file" && p.source !== "file" ? -1 : m.source !== "file" && p.source === "file" ? 1 : 0);
  return {
    particles: e,
    bonds: d,
    cells: r,
    trajectories: h,
    labels: c,
    meshes: f,
    perspective: n.perspective,
    cellAxesVisible: n.cellAxesVisible
  };
}
function sF(n, t) {
  if (n.length === 0 || t.length === 0) return n;
  let e = null;
  for (const s of t) {
    if (s.indices === null)
      return n;
    if (!e)
      e = new Set(s.indices);
    else
      for (const r of s.indices)
        e.add(r);
  }
  return e ? n.map((s) => {
    const r = [], l = [];
    for (let c = 0; c < s.nBonds; c++) {
      const f = s.bondIndices[c * 2], d = s.bondIndices[c * 2 + 1];
      e.has(f) && e.has(d) && (r.push(f, d), s.bondOrders && l.push(s.bondOrders[c]));
    }
    return r.length === s.nBonds * 2 ? s : {
      ...s,
      bondIndices: new Uint32Array(r),
      bondOrders: s.bondOrders ? new Uint8Array(l) : null,
      nBonds: r.length / 2
    };
  }) : n;
}
function aF(n, t, e = {}) {
  const s = F4(n, t), r = new Map(n.map((f) => [f.id, f])), l = /* @__PURE__ */ new Map();
  let c = { ...qf };
  for (const f of s) {
    const d = r.get(f);
    if (!d) continue;
    const h = d.data;
    if (!h.enabled) {
      const p = Wb(f, t, l), _ = /* @__PURE__ */ new Map(), x = h.params.type, b = Ac[x];
      for (const [M, S] of p)
        if (S.length > 0) {
          const y = b.outputs.find((C) => {
            const T = b.inputs.find((E) => E.name === M);
            return T && C.dataType === T.dataType;
          });
          y && _.set(y.name, S[0]);
        }
      l.set(f, _);
      continue;
    }
    const m = Wb(f, t, l);
    switch (h.params.type) {
      case "load_structure": {
        const p = H4(
          h.params,
          e.snapshot ?? null,
          e.structureFrames ?? null,
          e.structureMeta ?? null
        );
        l.set(f, p);
        break;
      }
      case "load_trajectory": {
        const p = V4(
          h.params,
          m,
          e.fileFrames ?? null,
          e.fileMeta ?? null
        );
        l.set(f, p);
        break;
      }
      case "add_bond": {
        const p = k4(
          h.params,
          m
        );
        l.set(f, p);
        break;
      }
      case "filter": {
        const p = q4(
          h.params,
          m,
          e.atomLabels ?? null
        );
        l.set(f, p);
        break;
      }
      case "modify": {
        const p = Z4(
          h.params,
          m
        );
        l.set(f, p);
        break;
      }
      case "label_generator": {
        const p = K4(
          h.params,
          m,
          e.atomLabels ?? null
        );
        l.set(f, p);
        break;
      }
      case "polyhedron_generator": {
        const p = nF(
          h.params,
          m
        );
        l.set(f, p);
        break;
      }
      case "viewport": {
        c = iF(
          h.params,
          m
        );
        break;
      }
    }
  }
  return c;
}
const rF = /* @__PURE__ */ new Set([
  "load_structure",
  "load_trajectory",
  "add_bond",
  "viewport",
  "filter",
  "modify",
  "label_generator",
  "polyhedron_generator"
]);
function oF(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 lF(n) {
  if (n.version !== 3)
    throw new Error(`Unsupported pipeline version: ${n.version}`);
  const t = n.nodes.map((s) => {
    if (!rF.has(s.type))
      throw new Error(`Unknown node type: ${s.type}`);
    const r = s.type, l = GE(r), { id: c, position: f, enabled: d, ...h } = s, m = { ...l, ...h, type: r };
    return {
      id: c,
      type: r,
      position: f ?? { x: 0, y: 0 },
      data: {
        params: m,
        enabled: d !== !1
      }
    };
  }), e = (n.edges ?? []).map((s, r) => ({
    id: `e-${s.source}-${s.sourceHandle}-${s.target}-${s.targetHandle}-${r}`,
    source: s.source,
    target: s.target,
    sourceHandle: s.sourceHandle || null,
    targetHandle: s.targetHandle || null
  }));
  return { nodes: t, edges: e };
}
function qE() {
  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 cF() {
  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 uF() {
  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 fF() {
  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
          },
          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 ZE = [
  {
    id: "molecule",
    label: "Molecule",
    description: "Caffeine with bonds and trajectory",
    create: uF
  },
  {
    id: "solid",
    label: "Solid",
    description: "Perovskite with coordination polyhedra",
    create: fF
  }
];
let dF = 1;
function hF() {
  return `node-${dF++}`;
}
var dM;
const jb = new URLSearchParams(((dM = globalThis.location) == null ? void 0 : dM.search) ?? "").has("demo") ? cF() : qE(), en = z4((n, t) => ({
  nodes: jb.nodes,
  edges: jb.edges,
  viewportState: { ...qf },
  snapshot: null,
  atomLabels: null,
  structureFrames: null,
  structureMeta: null,
  fileFrames: null,
  fileMeta: null,
  setSnapshot: (e) => {
    n({ snapshot: e }), t().execute();
  },
  setAtomLabels: (e) => {
    n({ atomLabels: e }), t().execute();
  },
  setStructureFrames: (e, s) => {
    n({ structureFrames: e, structureMeta: s }), t().execute();
  },
  setFileFrames: (e, s) => {
    n({ fileFrames: e, fileMeta: s }), t().execute();
  },
  onNodesChange: (e) => {
    const { nodes: s } = t(), r = e.filter((l) => {
      if (l.type === "remove") {
        const c = s.find((f) => f.id === l.id);
        if ((c == null ? void 0 : c.type) === "viewport") return !1;
      }
      return !0;
    });
    r.length !== 0 && (n((l) => ({
      nodes: cE(r, l.nodes)
    })), t().execute());
  },
  onEdgesChange: (e) => {
    n((s) => ({
      edges: uE(e, s.edges)
    })), t().execute();
  },
  onConnect: (e) => {
    const { nodes: s } = t(), r = s.find((c) => c.id === e.source), l = s.find((c) => c.id === e.target);
    !(r != null && r.type) || !(l != null && l.type) || kE(
      r.type,
      e.sourceHandle ?? null,
      l.type,
      e.targetHandle ?? null
    ) && (n((c) => ({
      edges: X1(
        {
          ...e,
          id: `e-${e.source}-${e.sourceHandle}-${e.target}-${e.targetHandle}`
        },
        c.edges
      )
    })), t().execute());
  },
  addNode: (e, s) => {
    const r = hF(), l = {
      id: r,
      type: e,
      position: s ?? { x: 425, y: t().nodes.length * 340 + 50 },
      data: {
        params: GE(e),
        enabled: !0
      }
    };
    return n((c) => ({
      nodes: [...c.nodes, l]
    })), r;
  },
  removeNode: (e) => {
    n((s) => ({
      nodes: s.nodes.filter((r) => r.id !== e),
      edges: s.edges.filter((r) => r.source !== e && r.target !== e)
    })), t().execute();
  },
  updateNodeParams: (e, s) => {
    n((r) => ({
      nodes: r.nodes.map((l) => l.id !== e ? l : {
        ...l,
        data: {
          ...l.data,
          params: { ...l.data.params, ...s }
        }
      })
    })), t().execute();
  },
  toggleNode: (e) => {
    n((s) => ({
      nodes: s.nodes.map((r) => r.id !== e ? r : {
        ...r,
        data: { ...r.data, enabled: !r.data.enabled }
      })
    })), t().execute();
  },
  execute: () => {
    const { nodes: e, edges: s, snapshot: r, atomLabels: l, structureFrames: c, structureMeta: f, fileFrames: d, fileMeta: h } = t(), p = aF(e, s, {
      snapshot: r,
      atomLabels: l,
      structureFrames: c,
      structureMeta: f,
      fileFrames: d,
      fileMeta: h
    });
    n({ viewportState: p });
  },
  serialize: () => {
    const { nodes: e, edges: s } = t();
    return oF(e, s);
  },
  deserialize: (e) => {
    const { nodes: s, edges: r } = lF(e);
    n({ nodes: s, edges: r }), t().execute();
  },
  pendingTemplateId: null,
  applyTemplate: (e) => {
    const s = ZE.find((c) => c.id === e);
    if (!s) return;
    const { nodes: r, edges: l } = s.create();
    n({
      nodes: r,
      edges: l,
      viewportState: { ...qf },
      pendingTemplateId: e
    }), t().execute();
  },
  clearPendingTemplate: () => {
    n({ pendingTemplateId: null });
  },
  reset: () => {
    const e = qE();
    n({
      nodes: e.nodes,
      edges: e.edges,
      viewportState: { ...qf }
    });
  }
})), pF = {
  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"
}, mF = {
  padding: "10px 14px",
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  borderBottom: "1px solid rgba(226,232,240,0.6)",
  flexShrink: 0
}, gF = {
  fontWeight: 600,
  color: "#1e293b",
  fontSize: 13,
  letterSpacing: "-0.02em"
}, _F = {
  background: "none",
  border: "none",
  cursor: "pointer",
  fontSize: 13,
  color: "#94a3b8",
  padding: "2px 4px"
}, vF = {
  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 yF({
  title: n,
  collapsed: t,
  onToggleCollapse: e,
  width: s = 220,
  headerExtra: r,
  containerExtra: l,
  children: c
}) {
  return t ? /* @__PURE__ */ Z.jsx("div", { style: { position: "absolute", top: 12, right: 12, zIndex: 10 }, children: /* @__PURE__ */ Z.jsxs(
    "button",
    {
      onClick: e,
      style: vF,
      title: `Open ${n.toLowerCase()}`,
      children: [
        /* @__PURE__ */ Z.jsx("span", { style: { fontSize: 11, color: "#94a3b8", fontWeight: 400 }, children: "◀" }),
        n
      ]
    }
  ) }) : /* @__PURE__ */ Z.jsxs("div", { style: { ...pF, width: s }, children: [
    l,
    /* @__PURE__ */ Z.jsxs("div", { style: mF, children: [
      /* @__PURE__ */ Z.jsx("span", { style: gF, children: n }),
      /* @__PURE__ */ Z.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, position: "relative" }, children: [
        r,
        /* @__PURE__ */ Z.jsx(
          "button",
          {
            onClick: e,
            style: _F,
            title: "Collapse panel",
            children: "▶"
          }
        )
      ] })
    ] }),
    c
  ] });
}
const KE = {
  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)"
}, xF = {
  ...KE,
  opacity: 0.5
}, SF = {
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  padding: "10px 17px",
  borderBottom: "1px solid #e2e8f0",
  gap: 10
}, bF = {
  fontWeight: 600,
  fontSize: 19,
  color: "#1e293b",
  letterSpacing: "-0.02em",
  flex: 1
}, MF = {
  background: "none",
  border: "none",
  cursor: "pointer",
  fontSize: 19,
  color: "#94a3b8",
  padding: "3px 7px",
  lineHeight: 1
}, EF = {
  padding: "14px 17px"
}, qb = {
  width: 14,
  height: 14,
  border: "3px solid white",
  boxShadow: "0 0 3px rgba(0,0,0,0.2)"
}, Zb = {
  position: "absolute",
  fontSize: 14,
  color: "#94a3b8",
  whiteSpace: "nowrap",
  pointerEvents: "none"
};
function Kb(n, t) {
  return t ? "#cbd5e1" : FE[n.dataType];
}
function $b(n, t) {
  return t === 1 ? "50%" : `${10 + 80 / (t - 1) * n}%`;
}
function Ua({ id: n, nodeType: t, enabled: e, children: s, disabledPorts: r }) {
  const l = en((m) => m.toggleNode), c = en((m) => m.removeNode), f = Ac[t], d = VE[I4[t]], h = {
    ...e ? KE : xF,
    borderLeft: `5px solid ${d}`
  };
  return /* @__PURE__ */ Z.jsxs("div", { style: h, children: [
    f.inputs.map((m, p) => {
      const _ = (r == null ? void 0 : r.has(m.name)) ?? !1;
      return /* @__PURE__ */ Z.jsx(
        el,
        {
          type: "target",
          position: ne.Top,
          id: m.name,
          style: {
            ...qb,
            background: Kb(m, _),
            left: $b(p, f.inputs.length)
          },
          children: /* @__PURE__ */ Z.jsx(
            "span",
            {
              style: {
                ...Zb,
                top: -22,
                left: "50%",
                transform: "translateX(-50%)",
                color: _ ? "#cbd5e1" : "#94a3b8"
              },
              children: m.label
            }
          )
        },
        `in-${m.name}`
      );
    }),
    /* @__PURE__ */ Z.jsxs("div", { style: SF, children: [
      /* @__PURE__ */ Z.jsx("span", { style: bF, children: HE[t] }),
      /* @__PURE__ */ Z.jsx(
        "div",
        {
          onClick: () => l(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__ */ Z.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__ */ Z.jsx(
        "button",
        {
          onClick: () => c(n),
          style: MF,
          title: "Remove node",
          children: "×"
        }
      )
    ] }),
    /* @__PURE__ */ Z.jsx("div", { style: EF, children: s }),
    f.outputs.map((m, p) => {
      const _ = (r == null ? void 0 : r.has(m.name)) ?? !1;
      return /* @__PURE__ */ Z.jsx(
        el,
        {
          type: "source",
          position: ne.Bottom,
          id: m.name,
          style: {
            ...qb,
            background: Kb(m, _),
            left: $b(p, f.outputs.length)
          },
          children: /* @__PURE__ */ Z.jsx(
            "span",
            {
              style: {
                ...Zb,
                bottom: -22,
                left: "50%",
                transform: "translateX(-50%)",
                color: _ ? "#cbd5e1" : "#94a3b8"
              },
              children: m.label
            }
          )
        },
        `out-${m.name}`
      );
    })
  ] });
}
const $E = {
  background: "none",
  border: "1px solid #e2e8f0",
  borderRadius: 8,
  padding: "3px 17px",
  cursor: "pointer",
  fontSize: 19,
  fontWeight: 500,
  color: "#64748b",
  transition: "all 0.15s"
}, QE = {
  fontSize: 22,
  fontWeight: 600,
  color: "#1e293b",
  wordBreak: "break-all"
};
function JE({
  options: n,
  value: t,
  onChange: e,
  disabledOptions: s
}) {
  return /* @__PURE__ */ Z.jsx(
    "div",
    {
      style: {
        display: "flex",
        borderRadius: 10,
        overflow: "hidden",
        border: "1px solid #e2e8f0",
        marginBottom: 10
      },
      children: n.map((r, l) => {
        const c = r.value === t, f = (s == null ? void 0 : s.has(r.value)) ?? !1;
        return /* @__PURE__ */ Z.jsx(
          "button",
          {
            onClick: c || f ? void 0 : () => e(r.value),
            style: {
              flex: 1,
              background: c ? "rgba(59,130,246,0.08)" : "none",
              border: "none",
              borderRight: l < n.length - 1 ? "1px solid #e2e8f0" : "none",
              padding: "7px 0",
              cursor: c || f ? "default" : "pointer",
              fontSize: 19,
              fontWeight: 500,
              color: f ? "#cbd5e1" : c ? "#3b82f6" : "#94a3b8",
              transition: "all 0.15s"
            },
            disabled: f,
            children: r.label
          },
          r.value
        );
      })
    }
  );
}
const TF = ".pdb,.gro,.xyz,.mol,.sdf", Qb = [".pdb", ".gro", ".xyz", ".mol", ".sdf"];
function AF({ id: n, data: t }) {
  const e = en((h) => h.updateNodeParams), s = t.params, r = st.useRef(null), l = st.useCallback(
    (h) => {
      const m = h.name.toLowerCase();
      Qb.some((p) => m.endsWith(p)) && e(n, { fileName: h.name });
    },
    [n, e]
  ), c = st.useCallback(
    (h) => {
      h.preventDefault(), h.stopPropagation();
      const p = Array.from(h.dataTransfer.files).find(
        (_) => Qb.some((x) => _.name.toLowerCase().endsWith(x))
      );
      p && l(p);
    },
    [l]
  ), f = st.useCallback((h) => {
    h.preventDefault(), h.stopPropagation();
  }, []), d = /* @__PURE__ */ new Set();
  return s.hasTrajectory || d.add("trajectory"), s.hasCell || d.add("cell"), /* @__PURE__ */ Z.jsx(Ua, { id: n, nodeType: "load_structure", enabled: t.enabled, disabledPorts: d, children: /* @__PURE__ */ Z.jsxs("div", { onDrop: c, onDragOver: f, children: [
    s.fileName ? /* @__PURE__ */ Z.jsx("div", { style: QE, children: s.fileName }) : /* @__PURE__ */ Z.jsx("div", { style: { fontSize: 20, color: "#94a3b8", fontStyle: "italic" }, children: "No structure loaded" }),
    /* @__PURE__ */ Z.jsx(
      "button",
      {
        onClick: () => {
          var h;
          return (h = r.current) == null ? void 0 : h.click();
        },
        style: { ...$E, marginTop: 6, width: "100%" },
        children: "Load structure..."
      }
    ),
    /* @__PURE__ */ Z.jsx(
      "input",
      {
        ref: r,
        type: "file",
        accept: TF,
        onChange: (h) => {
          var p;
          const m = (p = h.target.files) == null ? void 0 : p[0];
          m && l(m), h.target.value = "";
        },
        style: { display: "none" }
      }
    )
  ] }) });
}
const wF = ".xtc", Jb = [".xtc"];
function CF({ id: n, data: t }) {
  const e = en((d) => d.updateNodeParams), s = t.params, r = st.useRef(null), l = st.useCallback(
    (d) => {
      const h = d.name.toLowerCase();
      Jb.some((m) => h.endsWith(m)) && e(n, { fileName: d.name });
    },
    [n, e]
  ), c = st.useCallback(
    (d) => {
      d.preventDefault(), d.stopPropagation();
      const m = Array.from(d.dataTransfer.files).find(
        (p) => Jb.some((_) => p.name.toLowerCase().endsWith(_))
      );
      m && l(m);
    },
    [l]
  ), f = st.useCallback((d) => {
    d.preventDefault(), d.stopPropagation();
  }, []);
  return /* @__PURE__ */ Z.jsx(Ua, { id: n, nodeType: "load_trajectory", enabled: t.enabled, children: /* @__PURE__ */ Z.jsxs("div", { onDrop: c, onDragOver: f, children: [
    s.fileName ? /* @__PURE__ */ Z.jsx("div", { style: QE, children: s.fileName }) : /* @__PURE__ */ Z.jsx("div", { style: { fontSize: 20, color: "#94a3b8", fontStyle: "italic" }, children: "No trajectory loaded" }),
    /* @__PURE__ */ Z.jsx(
      "button",
      {
        onClick: () => {
          var d;
          return (d = r.current) == null ? void 0 : d.click();
        },
        style: { ...$E, marginTop: 6, width: "100%" },
        children: "Load trajectory..."
      }
    ),
    /* @__PURE__ */ Z.jsx(
      "input",
      {
        ref: r,
        type: "file",
        accept: wF,
        onChange: (d) => {
          var m;
          const h = (m = d.target.files) == null ? void 0 : m[0];
          h && l(h), d.target.value = "";
        },
        style: { display: "none" }
      }
    )
  ] }) });
}
const RF = {
  fontSize: 17,
  fontWeight: 600,
  color: "#94a3b8",
  textTransform: "uppercase",
  letterSpacing: "0.06em",
  marginBottom: 7,
  marginTop: 0
};
function DF({ id: n, data: t }) {
  const e = en((r) => r.updateNodeParams), s = t.params;
  return /* @__PURE__ */ Z.jsxs(Ua, { id: n, nodeType: "add_bond", enabled: t.enabled, children: [
    /* @__PURE__ */ Z.jsx("div", { style: RF, children: "Source" }),
    /* @__PURE__ */ Z.jsx(
      JE,
      {
        options: [
          { value: "structure", label: "File" },
          { value: "distance", label: "VDW" }
        ],
        value: s.bondSource,
        onChange: (r) => e(n, { bondSource: r })
      }
    )
  ] });
}
const tM = {
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  fontSize: 19,
  color: "#475569",
  padding: "3px 0"
}, eM = {
  cursor: "pointer",
  accentColor: "#3b82f6"
};
function NF({ id: n, data: t }) {
  const e = en((r) => r.updateNodeParams), s = t.params;
  return /* @__PURE__ */ Z.jsx(Ua, { id: n, nodeType: "viewport", enabled: t.enabled, children: /* @__PURE__ */ Z.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 7 }, children: [
    /* @__PURE__ */ Z.jsxs("label", { style: tM, children: [
      "Perspective",
      /* @__PURE__ */ Z.jsx(
        "input",
        {
          type: "checkbox",
          checked: s.perspective,
          onChange: (r) => e(n, { perspective: r.target.checked }),
          style: eM
        }
      )
    ] }),
    /* @__PURE__ */ Z.jsxs("label", { style: tM, children: [
      "Cell axes",
      /* @__PURE__ */ Z.jsx(
        "input",
        {
          type: "checkbox",
          checked: s.cellAxesVisible,
          onChange: (r) => e(n, { cellAxesVisible: r.target.checked }),
          style: eM
        }
      )
    ] })
  ] }) });
}
const tT = {
  width: "100%",
  padding: "7px 10px",
  fontSize: 19,
  fontFamily: "monospace",
  border: "1px solid #e2e8f0",
  borderRadius: 7,
  outline: "none",
  background: "#f8fafc",
  color: "#1e293b",
  boxSizing: "border-box"
}, LF = {
  ...tT,
  borderColor: "#ef4444",
  background: "#fef2f2"
}, UF = {
  fontSize: 17,
  color: "#ef4444",
  marginTop: 7,
  lineHeight: 1.3
}, OF = {
  fontSize: 15,
  color: "#94a3b8",
  marginTop: 7,
  lineHeight: 1.3
};
function PF({ id: n, data: t }) {
  const e = en((m) => m.updateNodeParams), s = t.params, [r, l] = st.useState(s.query), [c, f] = st.useState(null);
  st.useEffect(() => {
    l(s.query);
  }, [s.query]);
  const d = st.useCallback(() => {
    const m = j4(r);
    f(m.valid ? null : m.error ?? "Invalid query"), e(n, { query: r });
  }, [n, r, e]), h = st.useCallback(
    (m) => {
      m.key === "Enter" && d();
    },
    [d]
  );
  return /* @__PURE__ */ Z.jsxs(Ua, { id: n, nodeType: "filter", enabled: t.enabled, children: [
    /* @__PURE__ */ Z.jsx(
      "input",
      {
        value: r,
        onChange: (m) => l(m.target.value),
        onBlur: d,
        onKeyDown: h,
        placeholder: 'element == "C"',
        style: c ? LF : tT
      }
    ),
    c && /* @__PURE__ */ Z.jsx("div", { style: UF, children: c }),
    !c && !r && /* @__PURE__ */ Z.jsx("div", { style: OF, children: "element, index, x, y, z, resname, mass" })
  ] });
}
const nM = {
  width: "100%",
  height: 7,
  cursor: "pointer",
  appearance: "none",
  WebkitAppearance: "none",
  borderRadius: 3,
  outline: "none"
}, iM = {
  fontSize: 19,
  fontWeight: 500,
  color: "#3b82f6",
  minWidth: 50,
  textAlign: "right"
}, sM = {
  fontSize: 17,
  fontWeight: 500,
  color: "#64748b",
  marginBottom: 3
};
function zF({ id: n, data: t }) {
  const e = en((r) => r.updateNodeParams), s = t.params;
  return /* @__PURE__ */ Z.jsx(Ua, { id: n, nodeType: "modify", enabled: t.enabled, children: /* @__PURE__ */ Z.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 10 }, children: [
    /* @__PURE__ */ Z.jsxs("div", { children: [
      /* @__PURE__ */ Z.jsx("div", { style: sM, children: "Scale" }),
      /* @__PURE__ */ Z.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
        /* @__PURE__ */ Z.jsx(
          "input",
          {
            type: "range",
            min: 0.1,
            max: 2,
            step: 0.01,
            value: s.scale,
            onChange: (r) => e(n, { scale: parseFloat(r.target.value) }),
            style: nM
          }
        ),
        /* @__PURE__ */ Z.jsx("span", { style: iM, children: s.scale.toFixed(2) })
      ] })
    ] }),
    /* @__PURE__ */ Z.jsxs("div", { children: [
      /* @__PURE__ */ Z.jsx("div", { style: sM, children: "Opacity" }),
      /* @__PURE__ */ Z.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
        /* @__PURE__ */ Z.jsx(
          "input",
          {
            type: "range",
            min: 0,
            max: 1,
            step: 0.01,
            value: s.opacity,
            onChange: (r) => e(n, { opacity: parseFloat(r.target.value) }),
            style: nM
          }
        ),
        /* @__PURE__ */ Z.jsx("span", { style: iM, children: `${Math.round(s.opacity * 100)}%` })
      ] })
    ] })
  ] }) });
}
function IF({ id: n, data: t }) {
  const e = en((r) => r.updateNodeParams), s = t.params;
  return /* @__PURE__ */ Z.jsx(Ua, { id: n, nodeType: "label_generator", enabled: t.enabled, children: /* @__PURE__ */ Z.jsx(
    JE,
    {
      options: [
        { value: "element", label: "Element" },
        { value: "resname", label: "Resname" },
        { value: "index", label: "Index" }
      ],
      value: s.source,
      onChange: (r) => e(n, { source: r })
    }
  ) });
}
const BF = [
  { 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" }
], FF = [
  { z: 8, sym: "O" },
  { z: 9, sym: "F" },
  { z: 17, sym: "Cl" },
  { z: 7, sym: "N" },
  { z: 16, sym: "S" }
], Of = {
  fontSize: 17,
  fontWeight: 500,
  color: "#64748b",
  marginBottom: 3
}, HF = {
  display: "flex",
  flexWrap: "wrap",
  gap: 5,
  marginBottom: 10
}, eT = {
  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"
}, VF = {
  ...eT,
  background: "rgba(59, 130, 246, 0.08)",
  borderColor: "rgba(59, 130, 246, 0.25)",
  color: "#3b82f6"
}, aM = {
  width: "100%",
  height: 7,
  cursor: "pointer",
  appearance: "none",
  WebkitAppearance: "none",
  borderRadius: 3,
  outline: "none"
}, rM = {
  fontSize: 19,
  fontWeight: 500,
  color: "#3b82f6",
  minWidth: 50,
  textAlign: "right"
}, GF = {
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  fontSize: 19,
  color: "#475569",
  padding: "3px 0"
}, kF = {
  cursor: "pointer",
  accentColor: "#3b82f6"
};
function oM({
  elements: n,
  selected: t,
  onChange: e
}) {
  const s = new Set(t), r = st.useCallback(
    (l) => {
      const c = new Set(s);
      c.has(l) ? c.delete(l) : c.add(l), e([...c]);
    },
    [s, e]
  );
  return /* @__PURE__ */ Z.jsx("div", { style: HF, children: n.map(({ z: l, sym: c }) => /* @__PURE__ */ Z.jsx(
    "button",
    {
      onClick: () => r(l),
      style: s.has(l) ? VF : eT,
      children: c
    },
    l
  )) });
}
function XF({ id: n, data: t }) {
  const e = en((r) => r.updateNodeParams), s = t.params;
  return /* @__PURE__ */ Z.jsx(Ua, { id: n, nodeType: "polyhedron_generator", enabled: t.enabled, children: /* @__PURE__ */ Z.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
    /* @__PURE__ */ Z.jsxs("div", { children: [
      /* @__PURE__ */ Z.jsx("div", { style: Of, children: "Center" }),
      /* @__PURE__ */ Z.jsx(
        oM,
        {
          elements: BF,
          selected: s.centerElements,
          onChange: (r) => e(n, { centerElements: r })
        }
      )
    ] }),
    /* @__PURE__ */ Z.jsxs("div", { children: [
      /* @__PURE__ */ Z.jsx("div", { style: Of, children: "Ligand" }),
      /* @__PURE__ */ Z.jsx(
        oM,
        {
          elements: FF,
          selected: s.ligandElements,
          onChange: (r) => e(n, { ligandElements: r })
        }
      )
    ] }),
    /* @__PURE__ */ Z.jsxs("div", { children: [
      /* @__PURE__ */ Z.jsx("div", { style: Of, children: "Max distance" }),
      /* @__PURE__ */ Z.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
        /* @__PURE__ */ Z.jsx(
          "input",
          {
            type: "range",
            min: 1,
            max: 5,
            step: 0.1,
            value: s.maxDistance,
            onChange: (r) => e(n, { maxDistance: parseFloat(r.target.value) }),
            style: aM
          }
        ),
        /* @__PURE__ */ Z.jsx("span", { style: rM, children: s.maxDistance.toFixed(1) })
      ] })
    ] }),
    /* @__PURE__ */ Z.jsxs("div", { children: [
      /* @__PURE__ */ Z.jsx("div", { style: Of, children: "Opacity" }),
      /* @__PURE__ */ Z.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
        /* @__PURE__ */ Z.jsx(
          "input",
          {
            type: "range",
            min: 0,
            max: 1,
            step: 0.05,
            value: s.opacity,
            onChange: (r) => e(n, { opacity: parseFloat(r.target.value) }),
            style: aM
          }
        ),
        /* @__PURE__ */ Z.jsx("span", { style: rM, children: `${Math.round(s.opacity * 100)}%` })
      ] })
    ] }),
    /* @__PURE__ */ Z.jsxs("label", { style: GF, children: [
      "Show edges",
      /* @__PURE__ */ Z.jsx(
        "input",
        {
          type: "checkbox",
          checked: s.showEdges,
          onChange: (r) => e(n, { showEdges: r.target.checked }),
          style: kF
        }
      )
    ] })
  ] }) });
}
const WF = {
  load_structure: AF,
  load_trajectory: CF,
  add_bond: DF,
  viewport: NF,
  filter: PF,
  modify: zF,
  label_generator: IF,
  polyhedron_generator: XF
}, YF = [
  { category: "data_load", label: "Data Load", types: ["load_structure", "load_trajectory"] },
  { 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"] }
], jF = 320, qF = 600, ZF = 480, KF = {
  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"
}, lM = {
  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"
}, cM = {
  display: "block",
  width: "100%",
  background: "none",
  border: "none",
  padding: "6px 14px 6px 20px",
  cursor: "pointer",
  fontSize: 12,
  color: "#334155",
  textAlign: "left"
}, $F = {
  fontSize: 10,
  fontWeight: 600,
  color: "#94a3b8",
  textTransform: "uppercase",
  letterSpacing: "0.06em",
  padding: "6px 14px 2px",
  display: "flex",
  alignItems: "center",
  gap: 6
}, QF = {
  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"
}, JF = {
  fontSize: 10,
  color: "#94a3b8",
  marginTop: 1
}, t5 = {
  position: "absolute",
  left: 0,
  top: 0,
  bottom: 0,
  width: 5,
  cursor: "col-resize",
  zIndex: 20,
  background: "transparent"
};
function e5(n, t) {
  if (!n || !t) return "#94a3b8";
  const e = Ac[n];
  if (!e) return "#94a3b8";
  const s = e.outputs.find((r) => r.name === t);
  return s ? FE[s.dataType] : "#94a3b8";
}
function n5({
  collapsed: n,
  onToggleCollapse: t,
  onWidthChange: e
}) {
  const s = en((A) => A.nodes), r = en((A) => A.edges), l = en((A) => A.onNodesChange), c = en((A) => A.onEdgesChange), f = en((A) => A.onConnect), d = en((A) => A.addNode), h = en((A) => A.applyTemplate), [m, p] = st.useState(!1), [_, x] = st.useState(!1), [b, M] = st.useState(ZF), S = st.useRef(null), y = st.useCallback((A) => {
    A.preventDefault(), S.current = { startX: A.clientX, startWidth: b };
    const R = (H) => {
      if (!S.current) return;
      const k = S.current.startWidth - (H.clientX - S.current.startX), P = Math.max(jF, Math.min(qF, k));
      M(P), e == null || e(P);
    }, L = () => {
      S.current = null, document.removeEventListener("mousemove", R), document.removeEventListener("mouseup", L);
    };
    document.addEventListener("mousemove", R), document.addEventListener("mouseup", L);
  }, [b, e]), C = st.useCallback(
    (A) => {
      if (A.source === A.target) return !1;
      const R = s.find((H) => H.id === A.source), L = s.find((H) => H.id === A.target);
      return !(R != null && R.type) || !(L != null && L.type) ? !1 : kE(
        R.type,
        A.sourceHandle ?? null,
        L.type,
        A.targetHandle ?? null
      );
    },
    [s]
  ), T = st.useMemo(() => r.map((A) => {
    const R = s.find((H) => H.id === A.source), L = e5(R == null ? void 0 : R.type, A.sourceHandle ?? null);
    return {
      ...A,
      animated: !0,
      style: {
        stroke: L,
        strokeWidth: 2
      }
    };
  }), [r, s]), E = st.useCallback(
    (A) => {
      d(A), p(!1);
    },
    [d]
  ), O = st.useCallback(
    (A) => {
      h(A), x(!1);
    },
    [h]
  ), N = st.useMemo(() => WF, []), D = /* @__PURE__ */ Z.jsxs(Z.Fragment, { children: [
    /* @__PURE__ */ Z.jsx(
      "button",
      {
        onClick: () => {
          x(!_), p(!1);
        },
        style: QF,
        children: "Templates"
      }
    ),
    _ && /* @__PURE__ */ Z.jsx("div", { style: { ...lM, right: "auto", left: 0 }, children: ZE.map((A) => /* @__PURE__ */ Z.jsxs(
      "button",
      {
        onClick: () => O(A.id),
        style: { ...cM, padding: "8px 14px" },
        onMouseEnter: (R) => {
          R.target.style.background = "rgba(139,92,246,0.06)";
        },
        onMouseLeave: (R) => {
          R.target.style.background = "none";
        },
        children: [
          /* @__PURE__ */ Z.jsx("div", { style: { fontWeight: 500 }, children: A.label }),
          /* @__PURE__ */ Z.jsx("div", { style: JF, children: A.description })
        ]
      },
      A.id
    )) }),
    /* @__PURE__ */ Z.jsx(
      "button",
      {
        onClick: () => {
          p(!m), x(!1);
        },
        style: KF,
        children: "+ Add Node"
      }
    ),
    m && /* @__PURE__ */ Z.jsx("div", { style: lM, children: YF.map((A) => /* @__PURE__ */ Z.jsxs("div", { children: [
      /* @__PURE__ */ Z.jsxs("div", { style: $F, children: [
        /* @__PURE__ */ Z.jsx(
          "span",
          {
            style: {
              width: 6,
              height: 6,
              borderRadius: "50%",
              background: VE[A.category],
              display: "inline-block",
              flexShrink: 0
            }
          }
        ),
        A.label
      ] }),
      A.types.map((R) => /* @__PURE__ */ Z.jsx(
        "button",
        {
          onClick: () => E(R),
          style: cM,
          onMouseEnter: (L) => {
            L.target.style.background = "rgba(59,130,246,0.06)";
          },
          onMouseLeave: (L) => {
            L.target.style.background = "none";
          },
          children: HE[R]
        },
        R
      ))
    ] }, A.category)) })
  ] }), z = /* @__PURE__ */ Z.jsx(
    "div",
    {
      style: t5,
      onMouseDown: y,
      onMouseEnter: (A) => {
        A.currentTarget.style.background = "rgba(59,130,246,0.15)";
      },
      onMouseLeave: (A) => {
        A.currentTarget.style.background = "transparent";
      }
    }
  );
  return /* @__PURE__ */ Z.jsx(
    yF,
    {
      title: "Pipeline",
      collapsed: n,
      onToggleCollapse: t,
      width: b,
      headerExtra: D,
      containerExtra: z,
      children: /* @__PURE__ */ Z.jsx("div", { style: { flex: 1, position: "relative" }, children: /* @__PURE__ */ Z.jsxs(
        s4,
        {
          nodes: s,
          edges: T,
          onNodesChange: l,
          onEdgesChange: c,
          onConnect: f,
          isValidConnection: C,
          nodeTypes: N,
          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__ */ Z.jsx(c4, { variant: Fs.Dots, gap: 16, size: 1, color: "#e2e8f0" }),
            /* @__PURE__ */ Z.jsx(
              R4,
              {
                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__ */ Z.jsx(
              g4,
              {
                showInteractive: !1,
                style: {
                  border: "1px solid #e2e8f0",
                  borderRadius: 6,
                  boxShadow: "none"
                }
              }
            )
          ]
        }
      ) })
    }
  );
}
function i5({
  collapsed: n,
  onToggleCollapse: t,
  onWidthChange: e
}) {
  return /* @__PURE__ */ Z.jsx(PE, { children: /* @__PURE__ */ Z.jsx(
    n5,
    {
      collapsed: n,
      onToggleCollapse: t,
      onWidthChange: e
    }
  ) });
}
function nT({
  currentFrame: n,
  totalFrames: t,
  playing: e,
  fps: s,
  onSeek: r,
  onPlayPause: l,
  onFpsChange: c
}) {
  return t <= 1 ? null : /* @__PURE__ */ Z.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__ */ Z.jsx(
          "button",
          {
            onClick: l,
            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__ */ Z.jsxs(
          "span",
          {
            style: {
              minWidth: 80,
              textAlign: "center",
              fontVariantNumeric: "tabular-nums",
              fontWeight: 500,
              color: "#64748b",
              flexShrink: 0
            },
            children: [
              n + 1,
              " / ",
              t
            ]
          }
        ),
        /* @__PURE__ */ Z.jsx(
          "input",
          {
            type: "range",
            min: 0,
            max: t - 1,
            value: n,
            onChange: (f) => r(parseInt(f.target.value, 10)),
            style: {
              flex: 1,
              height: 4,
              cursor: "pointer",
              accentColor: "#3b82f6"
            }
          }
        ),
        /* @__PURE__ */ Z.jsxs(
          "select",
          {
            value: s,
            onChange: (f) => c(parseInt(f.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__ */ Z.jsx("option", { value: 10, children: "10 fps" }),
              /* @__PURE__ */ Z.jsx("option", { value: 20, children: "20 fps" }),
              /* @__PURE__ */ Z.jsx("option", { value: 30, children: "30 fps" }),
              /* @__PURE__ */ Z.jsx("option", { value: 60, children: "60 fps" })
            ]
          }
        )
      ]
    }
  );
}
function zm(n, t, e) {
  const s = t.particles.length > 0, r = ((e == null ? void 0 : e.particles.length) ?? 0) > 0;
  (!e || s !== r) && n.setAtomsVisible(s), s5(n, t.particles, (e == null ? void 0 : e.particles) ?? null), a5(n, t.bonds, (e == null ? void 0 : e.bonds) ?? null);
  const l = t.cells.length > 0, c = ((e == null ? void 0 : e.cells.length) ?? 0) > 0, f = l && t.cells.some((_) => _.visible), d = c && ((e == null ? void 0 : e.cells.some((_) => _.visible)) ?? !1);
  (!e || f !== d) && n.setCellVisible(f);
  const h = l && t.cells.some((_) => _.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), r5(n, t.labels, (e == null ? void 0 : e.labels) ?? null), o5(n, t.meshes, (e == null ? void 0 : e.meshes) ?? null);
  const m = t.bonds.length > 0, p = ((e == null ? void 0 : e.bonds.length) ?? 0) > 0;
  (!e || m !== p) && n.setBondsVisible(m);
}
function s5(n, t, e) {
  if (t.length === 0) {
    e && e.length > 0 && (n.clearAtomOverrides(), n.setAtomScale(1), n.setAtomOpacity(1));
    return;
  }
  let s = null, r = null;
  for (const l of t) {
    if (l.scaleOverrides)
      if (!s)
        s = new Float32Array(l.scaleOverrides);
      else
        for (let c = 0; c < s.length; c++)
          l.scaleOverrides[c] !== 1 && (s[c] = l.scaleOverrides[c]);
    if (l.opacityOverrides)
      if (!r)
        r = new Float32Array(l.opacityOverrides);
      else
        for (let c = 0; c < r.length; c++)
          l.opacityOverrides[c] !== 1 && (r[c] = l.opacityOverrides[c]);
  }
  s ? (n.setAtomScale(1), n.setAtomScaleOverrides(s)) : (n.clearAtomOverrides(), n.setAtomScale(1)), r ? (n.setAtomOpacity(1), n.setAtomOpacityOverrides(r)) : n.setAtomOpacity(1);
}
function a5(n, t, e) {
  if (t.length === 0) return;
  const s = t[0], r = e == null ? void 0 : e[0];
  (!r || s.scale !== r.scale) && n.setBondScale(s.scale), (!r || s.opacity !== r.opacity) && n.setBondOpacity(s.opacity);
}
function r5(n, t, e) {
  t.length > 0 ? n.setLabels(t[0].labels) : e && e.length > 0 && n.setLabels(null);
}
function o5(n, t, e) {
  t.length > 0 ? n.loadPolyhedra(t[0]) : e && e.length > 0 && n.clearPolyhedra();
}
function l5(n) {
  return n.pipeline ? /* @__PURE__ */ Z.jsx(c5, { ...n }) : /* @__PURE__ */ Z.jsx(u5, { ...n });
}
function c5({
  snapshot: n,
  frame: t,
  currentFrame: e,
  totalFrames: s,
  onSeek: r,
  pipelineJson: l,
  onPipelineChange: c
}) {
  const f = st.useRef(null), d = st.useRef(null), [h, m] = st.useState(!1), [p, _] = st.useState(30), x = typeof window < "u" && window.innerWidth < 768, [b, M] = st.useState(x), S = st.useRef(x), y = st.useRef(480), C = st.useRef(null);
  st.useEffect(() => {
    S.current = b;
  }, [b]);
  const T = en((k) => k.viewportState), E = en((k) => k.setSnapshot);
  st.useEffect(() => {
    E(n);
    const k = f.current;
    if (k) {
      const P = en.getState().viewportState;
      zm(k, P, null), C.current = P;
    }
  }, [n, E]), st.useEffect(() => {
    const k = f.current;
    k && (zm(k, T, C.current), C.current = T);
  }, [T]), st.useEffect(() => {
    const P = en.getState().nodes.find((V) => V.type === "add_bond");
    if (!P) return;
    const Y = P.data.params;
    if (Y.type !== "add_bond" || Y.bondSource !== "distance" || !n || !t) return;
    const U = f.current;
    if (!U) return;
    const X = XE(
      t.positions,
      n.elements,
      n.nAtoms,
      0.6
    );
    U.updateBonds(X, null);
  }, [t, n]);
  const O = st.useRef("");
  st.useEffect(() => {
    if (!(!l || l === O.current)) {
      O.current = l;
      try {
        const k = JSON.parse(l);
        en.getState().deserialize(k);
      } catch {
      }
    }
  }, [l]);
  const N = st.useRef(null);
  st.useEffect(() => {
    c && (N.current && clearTimeout(N.current), N.current = setTimeout(() => {
      const k = en.getState().serialize(), P = JSON.stringify(k);
      P !== O.current && (O.current = P, c(P));
    }, 500));
  }, [T, c]);
  const D = st.useCallback((k) => {
    f.current = k, k.setViewInsets(
      0,
      S.current ? 0 : y.current + 12
    ), zm(k, en.getState().viewportState, null), C.current = en.getState().viewportState;
  }, []), z = st.useCallback(() => {
    M((k) => !k);
  }, []), A = st.useCallback((k) => {
    var P;
    y.current = k, S.current || (P = f.current) == null || P.setViewInsets(0, k + 12);
  }, []);
  st.useEffect(() => {
    var k;
    (k = f.current) == null || k.setViewInsets(
      0,
      b ? 0 : y.current + 12
    );
  }, [b]);
  const R = st.useCallback(() => {
    m((k) => k ? (d.current && (clearInterval(d.current), d.current = null), !1) : (d.current = setInterval(() => {
      r(-1);
    }, 1e3 / p), !0));
  }, [p, r]), L = st.useCallback(
    (k) => {
      _(k), d.current && (clearInterval(d.current), d.current = setInterval(() => {
        r(-1);
      }, 1e3 / k));
    },
    [r]
  ), H = st.useCallback(
    (k) => {
      h && (m(!1), d.current && (clearInterval(d.current), d.current = null)), r(k);
    },
    [r, h]
  );
  return /* @__PURE__ */ Z.jsxs(
    "div",
    {
      style: {
        width: "100%",
        height: "100%",
        position: "relative",
        overflow: "hidden"
      },
      children: [
        /* @__PURE__ */ Z.jsx(
          KM,
          {
            snapshot: n,
            frame: t,
            onRendererReady: D,
            onHover: () => {
            },
            onAtomRightClick: () => {
            },
            onFrameUpdated: () => {
            }
          }
        ),
        /* @__PURE__ */ Z.jsx(
          i5,
          {
            collapsed: b,
            onToggleCollapse: z,
            onWidthChange: A
          }
        ),
        s > 1 && /* @__PURE__ */ Z.jsx(
          nT,
          {
            currentFrame: e,
            totalFrames: s,
            playing: h,
            fps: p,
            onSeek: H,
            onPlayPause: R,
            onFpsChange: L
          }
        )
      ]
    }
  );
}
function u5({
  snapshot: n,
  frame: t,
  currentFrame: e,
  totalFrames: s,
  onSeek: r
}) {
  const l = st.useRef(null), c = st.useRef(null), [f, d] = st.useState(!1), [h, m] = st.useState(30), p = st.useCallback((M) => {
    l.current = M;
  }, []), _ = st.useCallback(() => {
    d((M) => M ? (c.current && (clearInterval(c.current), c.current = null), !1) : (c.current = setInterval(() => {
      r(-1);
    }, 1e3 / h), !0));
  }, [h, r]), x = st.useCallback(
    (M) => {
      m(M), c.current && (clearInterval(c.current), c.current = setInterval(() => {
        r(-1);
      }, 1e3 / M));
    },
    [r]
  ), b = st.useCallback(
    (M) => {
      f && (d(!1), c.current && (clearInterval(c.current), c.current = null)), r(M);
    },
    [r, f]
  );
  return /* @__PURE__ */ Z.jsxs(
    "div",
    {
      style: {
        width: "100%",
        height: "100%",
        position: "relative",
        overflow: "hidden"
      },
      children: [
        /* @__PURE__ */ Z.jsx(
          KM,
          {
            snapshot: n,
            frame: t,
            onRendererReady: p,
            onHover: () => {
            },
            onAtomRightClick: () => {
            },
            onFrameUpdated: () => {
            }
          }
        ),
        s > 1 && /* @__PURE__ */ Z.jsx(
          nT,
          {
            currentFrame: e,
            totalFrames: s,
            playing: f,
            fps: h,
            onSeek: b,
            onPlayPause: _,
            onFpsChange: x
          }
        )
      ]
    }
  );
}
const uM = 1313293645, f5 = 0, d5 = 1, h5 = 1, p5 = 2;
function fM(n) {
  const t = new DataView(n), e = t.getUint32(0, !0);
  if (e !== uM)
    throw new Error(
      `Invalid magic: 0x${e.toString(16)}, expected 0x${uM.toString(16)}`
    );
  return {
    msgType: t.getUint8(4),
    flags: t.getUint8(5)
  };
}
function m5(n) {
  const t = new DataView(n), e = t.getUint8(5);
  let s = 8;
  const r = t.getUint32(s, !0);
  s += 4;
  const l = t.getUint32(s, !0);
  s += 4;
  const c = new Float32Array(n, s, r * 3);
  s += r * 3 * 4;
  const f = new Uint8Array(n, s, r);
  s += r, s += (4 - s % 4) % 4;
  const d = new Uint32Array(n, s, l * 2);
  s += l * 2 * 4;
  let h = null;
  e & h5 && (h = new Uint8Array(n, s, l), s += l, s += (4 - s % 4) % 4);
  let m = null;
  return e & p5 && (m = new Float32Array(n, s, 9), s += 36), { nAtoms: r, nBonds: l, nFileBonds: l, positions: c, elements: f, bonds: d, bondOrders: h, box: m };
}
function g5(n) {
  const t = new DataView(n);
  let e = 8;
  const s = t.getUint32(e, !0);
  e += 4;
  const r = t.getUint32(e, !0);
  e += 4;
  const l = new Float32Array(n, e, r * 3);
  return { frameId: s, nAtoms: r, positions: l };
}
function _5({ 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 s = null, r = null, l = null, c = !1;
  function f() {
    const M = n.get("_snapshot_data");
    if (!M || M.byteLength === 0) return null;
    const S = new ArrayBuffer(M.byteLength);
    new Uint8Array(S).set(
      new Uint8Array(M.buffer, M.byteOffset, M.byteLength)
    );
    const { msgType: y } = fM(S);
    return y === f5 ? m5(S) : null;
  }
  function d() {
    const M = n.get("_frame_data");
    if (!M || M.byteLength === 0) return null;
    const S = new ArrayBuffer(M.byteLength);
    new Uint8Array(S).set(
      new Uint8Array(M.buffer, M.byteOffset, M.byteLength)
    );
    const { msgType: y } = fM(S);
    return y === d5 ? g5(S) : null;
  }
  function h(M) {
    const S = n.get("total_frames") || 0;
    if (M === -1) {
      const C = ((n.get("frame_index") || 0) + 1) % S;
      n.set("frame_index", C);
    } else
      n.set("frame_index", M);
    n.save_changes();
  }
  function m(M) {
    const S = M ? JSON.stringify(M) : "";
    n.set("_measurement_json", S), n.save_changes();
  }
  function p(M) {
    n.set("_pipeline_json", M), n.save_changes();
  }
  function _() {
    if (!s || c) return;
    const M = n.get("frame_index") || 0, S = n.get("total_frames") || 0, y = n.get("selected_atoms") || [], C = n.get("pipeline") || !1, T = n.get("_pipeline_json") || "";
    s.render(
      st.createElement(l5, {
        snapshot: r,
        frame: l,
        currentFrame: M,
        totalFrames: S,
        onSeek: h,
        selectedAtoms: y,
        onMeasurementChange: m,
        pipeline: C,
        pipelineJson: T,
        onPipelineChange: p
      })
    );
  }
  function x() {
    return s || c ? !!s : e.clientWidth === 0 || e.clientHeight === 0 ? !1 : (s = gw.createRoot(e), r = f(), l = d(), _(), !0);
  }
  const b = new ResizeObserver(() => {
    !s && !c && x();
  });
  return b.observe(e), x(), n.on("change:_snapshot_data", () => {
    r = f(), s ? _() : x();
  }), n.on("change:_frame_data", () => {
    l = d(), _();
  }), n.on("change:frame_index", () => {
    _();
  }), n.on("change:total_frames", () => {
    _();
  }), n.on("change:selected_atoms", () => {
    _();
  }), n.on("change:pipeline", () => {
    _();
  }), n.on("change:_pipeline_json", () => {
    _();
  }), () => {
    c = !0, b.disconnect(), s == null || s.unmount(), s = null;
  };
}
const S5 = { render: _5 };
export {
  S5 as default
};
