import { jsx as F, jsxs as qt } from "react/jsx-runtime";
import { cn as it } from "./utils/functions.js";
import { useMemo as ce, createContext as Oe, useState as pe, useRef as K, useCallback as we, useLayoutEffect as pn, useEffect as me, useReducer as mn, useContext as he, forwardRef as st, useImperativeHandle as yn, Fragment as vn, cloneElement as hn, memo as bn } from "react";
import { unstable_batchedUpdates as En, flushSync as gn, createPortal as St } from "react-dom";
var tt = { exports: {} }, Ve, wt;
function ct() {
  if (wt)
    return Ve;
  wt = 1;
  var e = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
  return Ve = e, Ve;
}
var Ke, Ot;
function Tn() {
  if (Ot)
    return Ke;
  Ot = 1;
  var e = ct();
  function t() {
  }
  function n() {
  }
  return n.resetWarningCache = t, Ke = function() {
    function o(c, l, h, y, p, d) {
      if (d !== e) {
        var S = new Error(
          "Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
        );
        throw S.name = "Invariant Violation", S;
      }
    }
    o.isRequired = o;
    function a() {
      return o;
    }
    var r = {
      array: o,
      bigint: o,
      bool: o,
      func: o,
      number: o,
      object: o,
      string: o,
      symbol: o,
      any: o,
      arrayOf: a,
      element: o,
      elementType: o,
      instanceOf: a,
      node: o,
      objectOf: a,
      oneOf: a,
      oneOfType: a,
      shape: a,
      exact: a,
      checkPropTypes: n,
      resetWarningCache: t
    };
    return r.PropTypes = r, r;
  }, Ke;
}
var Ne = { exports: {} }, D = {};
/** @license React v16.13.1
 * react-is.development.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var _t;
function Sn() {
  return _t || (_t = 1, process.env.NODE_ENV !== "production" && function() {
    var e = typeof Symbol == "function" && Symbol.for, t = e ? Symbol.for("react.element") : 60103, n = e ? Symbol.for("react.portal") : 60106, o = e ? Symbol.for("react.fragment") : 60107, a = e ? Symbol.for("react.strict_mode") : 60108, r = e ? Symbol.for("react.profiler") : 60114, c = e ? Symbol.for("react.provider") : 60109, l = e ? Symbol.for("react.context") : 60110, h = e ? Symbol.for("react.async_mode") : 60111, y = e ? Symbol.for("react.concurrent_mode") : 60111, p = e ? Symbol.for("react.forward_ref") : 60112, d = e ? Symbol.for("react.suspense") : 60113, S = e ? Symbol.for("react.suspense_list") : 60120, b = e ? Symbol.for("react.memo") : 60115, i = e ? Symbol.for("react.lazy") : 60116, f = e ? Symbol.for("react.block") : 60121, g = e ? Symbol.for("react.fundamental") : 60117, O = e ? Symbol.for("react.responder") : 60118, T = e ? Symbol.for("react.scope") : 60119;
    function w(m) {
      return typeof m == "string" || typeof m == "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
      m === o || m === y || m === r || m === a || m === d || m === S || typeof m == "object" && m !== null && (m.$$typeof === i || m.$$typeof === b || m.$$typeof === c || m.$$typeof === l || m.$$typeof === p || m.$$typeof === g || m.$$typeof === O || m.$$typeof === T || m.$$typeof === f);
    }
    function M(m) {
      if (typeof m == "object" && m !== null) {
        var Q = m.$$typeof;
        switch (Q) {
          case t:
            var ee = m.type;
            switch (ee) {
              case h:
              case y:
              case o:
              case r:
              case a:
              case d:
                return ee;
              default:
                var ye = ee && ee.$$typeof;
                switch (ye) {
                  case l:
                  case p:
                  case i:
                  case b:
                  case c:
                    return ye;
                  default:
                    return Q;
                }
            }
          case n:
            return Q;
        }
      }
    }
    var u = h, Y = y, X = l, J = c, ue = t, V = p, L = o, W = i, fe = b, le = n, _e = r, z = a, Z = d, oe = !1;
    function Ce(m) {
      return oe || (oe = !0, console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")), s(m) || M(m) === h;
    }
    function s(m) {
      return M(m) === y;
    }
    function E(m) {
      return M(m) === l;
    }
    function R(m) {
      return M(m) === c;
    }
    function x(m) {
      return typeof m == "object" && m !== null && m.$$typeof === t;
    }
    function _(m) {
      return M(m) === p;
    }
    function A(m) {
      return M(m) === o;
    }
    function C(m) {
      return M(m) === i;
    }
    function P(m) {
      return M(m) === b;
    }
    function k(m) {
      return M(m) === n;
    }
    function j(m) {
      return M(m) === r;
    }
    function I(m) {
      return M(m) === a;
    }
    function U(m) {
      return M(m) === d;
    }
    D.AsyncMode = u, D.ConcurrentMode = Y, D.ContextConsumer = X, D.ContextProvider = J, D.Element = ue, D.ForwardRef = V, D.Fragment = L, D.Lazy = W, D.Memo = fe, D.Portal = le, D.Profiler = _e, D.StrictMode = z, D.Suspense = Z, D.isAsyncMode = Ce, D.isConcurrentMode = s, D.isContextConsumer = E, D.isContextProvider = R, D.isElement = x, D.isForwardRef = _, D.isFragment = A, D.isLazy = C, D.isMemo = P, D.isPortal = k, D.isProfiler = j, D.isStrictMode = I, D.isSuspense = U, D.isValidElementType = w, D.typeOf = M;
  }()), D;
}
var $ = {};
/** @license React v16.13.1
 * react-is.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var Ct;
function wn() {
  if (Ct)
    return $;
  Ct = 1;
  var e = typeof Symbol == "function" && Symbol.for, t = e ? Symbol.for("react.element") : 60103, n = e ? Symbol.for("react.portal") : 60106, o = e ? Symbol.for("react.fragment") : 60107, a = e ? Symbol.for("react.strict_mode") : 60108, r = e ? Symbol.for("react.profiler") : 60114, c = e ? Symbol.for("react.provider") : 60109, l = e ? Symbol.for("react.context") : 60110, h = e ? Symbol.for("react.async_mode") : 60111, y = e ? Symbol.for("react.concurrent_mode") : 60111, p = e ? Symbol.for("react.forward_ref") : 60112, d = e ? Symbol.for("react.suspense") : 60113, S = e ? Symbol.for("react.suspense_list") : 60120, b = e ? Symbol.for("react.memo") : 60115, i = e ? Symbol.for("react.lazy") : 60116, f = e ? Symbol.for("react.block") : 60121, g = e ? Symbol.for("react.fundamental") : 60117, O = e ? Symbol.for("react.responder") : 60118, T = e ? Symbol.for("react.scope") : 60119;
  function w(u) {
    if (typeof u == "object" && u !== null) {
      var Y = u.$$typeof;
      switch (Y) {
        case t:
          switch (u = u.type, u) {
            case h:
            case y:
            case o:
            case r:
            case a:
            case d:
              return u;
            default:
              switch (u = u && u.$$typeof, u) {
                case l:
                case p:
                case i:
                case b:
                case c:
                  return u;
                default:
                  return Y;
              }
          }
        case n:
          return Y;
      }
    }
  }
  function M(u) {
    return w(u) === y;
  }
  return $.AsyncMode = h, $.ConcurrentMode = y, $.ContextConsumer = l, $.ContextProvider = c, $.Element = t, $.ForwardRef = p, $.Fragment = o, $.Lazy = i, $.Memo = b, $.Portal = n, $.Profiler = r, $.StrictMode = a, $.Suspense = d, $.isAsyncMode = function(u) {
    return M(u) || w(u) === h;
  }, $.isConcurrentMode = M, $.isContextConsumer = function(u) {
    return w(u) === l;
  }, $.isContextProvider = function(u) {
    return w(u) === c;
  }, $.isElement = function(u) {
    return typeof u == "object" && u !== null && u.$$typeof === t;
  }, $.isForwardRef = function(u) {
    return w(u) === p;
  }, $.isFragment = function(u) {
    return w(u) === o;
  }, $.isLazy = function(u) {
    return w(u) === i;
  }, $.isMemo = function(u) {
    return w(u) === b;
  }, $.isPortal = function(u) {
    return w(u) === n;
  }, $.isProfiler = function(u) {
    return w(u) === r;
  }, $.isStrictMode = function(u) {
    return w(u) === a;
  }, $.isSuspense = function(u) {
    return w(u) === d;
  }, $.isValidElementType = function(u) {
    return typeof u == "string" || typeof u == "function" || u === o || u === y || u === r || u === a || u === d || u === S || typeof u == "object" && u !== null && (u.$$typeof === i || u.$$typeof === b || u.$$typeof === c || u.$$typeof === l || u.$$typeof === p || u.$$typeof === g || u.$$typeof === O || u.$$typeof === T || u.$$typeof === f);
  }, $.typeOf = w, $;
}
var Pt;
function zt() {
  return Pt || (Pt = 1, process.env.NODE_ENV === "production" ? Ne.exports = wn() : Ne.exports = Sn()), Ne.exports;
}
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
var Xe, xt;
function On() {
  if (xt)
    return Xe;
  xt = 1;
  var e = Object.getOwnPropertySymbols, t = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
  function o(r) {
    if (r == null)
      throw new TypeError("Object.assign cannot be called with null or undefined");
    return Object(r);
  }
  function a() {
    try {
      if (!Object.assign)
        return !1;
      var r = new String("abc");
      if (r[5] = "de", Object.getOwnPropertyNames(r)[0] === "5")
        return !1;
      for (var c = {}, l = 0; l < 10; l++)
        c["_" + String.fromCharCode(l)] = l;
      var h = Object.getOwnPropertyNames(c).map(function(p) {
        return c[p];
      });
      if (h.join("") !== "0123456789")
        return !1;
      var y = {};
      return "abcdefghijklmnopqrst".split("").forEach(function(p) {
        y[p] = p;
      }), Object.keys(Object.assign({}, y)).join("") === "abcdefghijklmnopqrst";
    } catch {
      return !1;
    }
  }
  return Xe = a() ? Object.assign : function(r, c) {
    for (var l, h = o(r), y, p = 1; p < arguments.length; p++) {
      l = Object(arguments[p]);
      for (var d in l)
        t.call(l, d) && (h[d] = l[d]);
      if (e) {
        y = e(l);
        for (var S = 0; S < y.length; S++)
          n.call(l, y[S]) && (h[y[S]] = l[y[S]]);
      }
    }
    return h;
  }, Xe;
}
var Ge, Rt;
function Ft() {
  return Rt || (Rt = 1, Ge = Function.call.bind(Object.prototype.hasOwnProperty)), Ge;
}
var Je, Mt;
function _n() {
  if (Mt)
    return Je;
  Mt = 1;
  var e = function() {
  };
  if (process.env.NODE_ENV !== "production") {
    var t = ct(), n = {}, o = Ft();
    e = function(r) {
      var c = "Warning: " + r;
      typeof console < "u" && console.error(c);
      try {
        throw new Error(c);
      } catch {
      }
    };
  }
  function a(r, c, l, h, y) {
    if (process.env.NODE_ENV !== "production") {
      for (var p in r)
        if (o(r, p)) {
          var d;
          try {
            if (typeof r[p] != "function") {
              var S = Error(
                (h || "React class") + ": " + l + " type `" + p + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof r[p] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
              );
              throw S.name = "Invariant Violation", S;
            }
            d = r[p](c, p, h, l, null, t);
          } catch (i) {
            d = i;
          }
          if (d && !(d instanceof Error) && e(
            (h || "React class") + ": type specification of " + l + " `" + p + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof d + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."
          ), d instanceof Error && !(d.message in n)) {
            n[d.message] = !0;
            var b = y ? y() : "";
            e(
              "Failed " + l + " type: " + d.message + (b ?? "")
            );
          }
        }
    }
  }
  return a.resetWarningCache = function() {
    process.env.NODE_ENV !== "production" && (n = {});
  }, Je = a, Je;
}
var Ze, It;
function Cn() {
  if (It)
    return Ze;
  It = 1;
  var e = zt(), t = On(), n = ct(), o = Ft(), a = _n(), r = function() {
  };
  process.env.NODE_ENV !== "production" && (r = function(l) {
    var h = "Warning: " + l;
    typeof console < "u" && console.error(h);
    try {
      throw new Error(h);
    } catch {
    }
  });
  function c() {
    return null;
  }
  return Ze = function(l, h) {
    var y = typeof Symbol == "function" && Symbol.iterator, p = "@@iterator";
    function d(s) {
      var E = s && (y && s[y] || s[p]);
      if (typeof E == "function")
        return E;
    }
    var S = "<<anonymous>>", b = {
      array: O("array"),
      bigint: O("bigint"),
      bool: O("boolean"),
      func: O("function"),
      number: O("number"),
      object: O("object"),
      string: O("string"),
      symbol: O("symbol"),
      any: T(),
      arrayOf: w,
      element: M(),
      elementType: u(),
      instanceOf: Y,
      node: V(),
      objectOf: J,
      oneOf: X,
      oneOfType: ue,
      shape: W,
      exact: fe
    };
    function i(s, E) {
      return s === E ? s !== 0 || 1 / s === 1 / E : s !== s && E !== E;
    }
    function f(s, E) {
      this.message = s, this.data = E && typeof E == "object" ? E : {}, this.stack = "";
    }
    f.prototype = Error.prototype;
    function g(s) {
      if (process.env.NODE_ENV !== "production")
        var E = {}, R = 0;
      function x(A, C, P, k, j, I, U) {
        if (k = k || S, I = I || P, U !== n) {
          if (h) {
            var m = new Error(
              "Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"
            );
            throw m.name = "Invariant Violation", m;
          } else if (process.env.NODE_ENV !== "production" && typeof console < "u") {
            var Q = k + ":" + P;
            !E[Q] && // Avoid spamming the console because they are often not actionable except for lib authors
            R < 3 && (r(
              "You are manually calling a React.PropTypes validation function for the `" + I + "` prop on `" + k + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."
            ), E[Q] = !0, R++);
          }
        }
        return C[P] == null ? A ? C[P] === null ? new f("The " + j + " `" + I + "` is marked as required " + ("in `" + k + "`, but its value is `null`.")) : new f("The " + j + " `" + I + "` is marked as required in " + ("`" + k + "`, but its value is `undefined`.")) : null : s(C, P, k, j, I);
      }
      var _ = x.bind(null, !1);
      return _.isRequired = x.bind(null, !0), _;
    }
    function O(s) {
      function E(R, x, _, A, C, P) {
        var k = R[x], j = z(k);
        if (j !== s) {
          var I = Z(k);
          return new f(
            "Invalid " + A + " `" + C + "` of type " + ("`" + I + "` supplied to `" + _ + "`, expected ") + ("`" + s + "`."),
            { expectedType: s }
          );
        }
        return null;
      }
      return g(E);
    }
    function T() {
      return g(c);
    }
    function w(s) {
      function E(R, x, _, A, C) {
        if (typeof s != "function")
          return new f("Property `" + C + "` of component `" + _ + "` has invalid PropType notation inside arrayOf.");
        var P = R[x];
        if (!Array.isArray(P)) {
          var k = z(P);
          return new f("Invalid " + A + " `" + C + "` of type " + ("`" + k + "` supplied to `" + _ + "`, expected an array."));
        }
        for (var j = 0; j < P.length; j++) {
          var I = s(P, j, _, A, C + "[" + j + "]", n);
          if (I instanceof Error)
            return I;
        }
        return null;
      }
      return g(E);
    }
    function M() {
      function s(E, R, x, _, A) {
        var C = E[R];
        if (!l(C)) {
          var P = z(C);
          return new f("Invalid " + _ + " `" + A + "` of type " + ("`" + P + "` supplied to `" + x + "`, expected a single ReactElement."));
        }
        return null;
      }
      return g(s);
    }
    function u() {
      function s(E, R, x, _, A) {
        var C = E[R];
        if (!e.isValidElementType(C)) {
          var P = z(C);
          return new f("Invalid " + _ + " `" + A + "` of type " + ("`" + P + "` supplied to `" + x + "`, expected a single ReactElement type."));
        }
        return null;
      }
      return g(s);
    }
    function Y(s) {
      function E(R, x, _, A, C) {
        if (!(R[x] instanceof s)) {
          var P = s.name || S, k = Ce(R[x]);
          return new f("Invalid " + A + " `" + C + "` of type " + ("`" + k + "` supplied to `" + _ + "`, expected ") + ("instance of `" + P + "`."));
        }
        return null;
      }
      return g(E);
    }
    function X(s) {
      if (!Array.isArray(s))
        return process.env.NODE_ENV !== "production" && (arguments.length > 1 ? r(
          "Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."
        ) : r("Invalid argument supplied to oneOf, expected an array.")), c;
      function E(R, x, _, A, C) {
        for (var P = R[x], k = 0; k < s.length; k++)
          if (i(P, s[k]))
            return null;
        var j = JSON.stringify(s, function(U, m) {
          var Q = Z(m);
          return Q === "symbol" ? String(m) : m;
        });
        return new f("Invalid " + A + " `" + C + "` of value `" + String(P) + "` " + ("supplied to `" + _ + "`, expected one of " + j + "."));
      }
      return g(E);
    }
    function J(s) {
      function E(R, x, _, A, C) {
        if (typeof s != "function")
          return new f("Property `" + C + "` of component `" + _ + "` has invalid PropType notation inside objectOf.");
        var P = R[x], k = z(P);
        if (k !== "object")
          return new f("Invalid " + A + " `" + C + "` of type " + ("`" + k + "` supplied to `" + _ + "`, expected an object."));
        for (var j in P)
          if (o(P, j)) {
            var I = s(P, j, _, A, C + "." + j, n);
            if (I instanceof Error)
              return I;
          }
        return null;
      }
      return g(E);
    }
    function ue(s) {
      if (!Array.isArray(s))
        return process.env.NODE_ENV !== "production" && r("Invalid argument supplied to oneOfType, expected an instance of array."), c;
      for (var E = 0; E < s.length; E++) {
        var R = s[E];
        if (typeof R != "function")
          return r(
            "Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + oe(R) + " at index " + E + "."
          ), c;
      }
      function x(_, A, C, P, k) {
        for (var j = [], I = 0; I < s.length; I++) {
          var U = s[I], m = U(_, A, C, P, k, n);
          if (m == null)
            return null;
          m.data && o(m.data, "expectedType") && j.push(m.data.expectedType);
        }
        var Q = j.length > 0 ? ", expected one of type [" + j.join(", ") + "]" : "";
        return new f("Invalid " + P + " `" + k + "` supplied to " + ("`" + C + "`" + Q + "."));
      }
      return g(x);
    }
    function V() {
      function s(E, R, x, _, A) {
        return le(E[R]) ? null : new f("Invalid " + _ + " `" + A + "` supplied to " + ("`" + x + "`, expected a ReactNode."));
      }
      return g(s);
    }
    function L(s, E, R, x, _) {
      return new f(
        (s || "React class") + ": " + E + " type `" + R + "." + x + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + _ + "`."
      );
    }
    function W(s) {
      function E(R, x, _, A, C) {
        var P = R[x], k = z(P);
        if (k !== "object")
          return new f("Invalid " + A + " `" + C + "` of type `" + k + "` " + ("supplied to `" + _ + "`, expected `object`."));
        for (var j in s) {
          var I = s[j];
          if (typeof I != "function")
            return L(_, A, C, j, Z(I));
          var U = I(P, j, _, A, C + "." + j, n);
          if (U)
            return U;
        }
        return null;
      }
      return g(E);
    }
    function fe(s) {
      function E(R, x, _, A, C) {
        var P = R[x], k = z(P);
        if (k !== "object")
          return new f("Invalid " + A + " `" + C + "` of type `" + k + "` " + ("supplied to `" + _ + "`, expected `object`."));
        var j = t({}, R[x], s);
        for (var I in j) {
          var U = s[I];
          if (o(s, I) && typeof U != "function")
            return L(_, A, C, I, Z(U));
          if (!U)
            return new f(
              "Invalid " + A + " `" + C + "` key `" + I + "` supplied to `" + _ + "`.\nBad object: " + JSON.stringify(R[x], null, "  ") + `
Valid keys: ` + JSON.stringify(Object.keys(s), null, "  ")
            );
          var m = U(P, I, _, A, C + "." + I, n);
          if (m)
            return m;
        }
        return null;
      }
      return g(E);
    }
    function le(s) {
      switch (typeof s) {
        case "number":
        case "string":
        case "undefined":
          return !0;
        case "boolean":
          return !s;
        case "object":
          if (Array.isArray(s))
            return s.every(le);
          if (s === null || l(s))
            return !0;
          var E = d(s);
          if (E) {
            var R = E.call(s), x;
            if (E !== s.entries) {
              for (; !(x = R.next()).done; )
                if (!le(x.value))
                  return !1;
            } else
              for (; !(x = R.next()).done; ) {
                var _ = x.value;
                if (_ && !le(_[1]))
                  return !1;
              }
          } else
            return !1;
          return !0;
        default:
          return !1;
      }
    }
    function _e(s, E) {
      return s === "symbol" ? !0 : E ? E["@@toStringTag"] === "Symbol" || typeof Symbol == "function" && E instanceof Symbol : !1;
    }
    function z(s) {
      var E = typeof s;
      return Array.isArray(s) ? "array" : s instanceof RegExp ? "object" : _e(E, s) ? "symbol" : E;
    }
    function Z(s) {
      if (typeof s > "u" || s === null)
        return "" + s;
      var E = z(s);
      if (E === "object") {
        if (s instanceof Date)
          return "date";
        if (s instanceof RegExp)
          return "regexp";
      }
      return E;
    }
    function oe(s) {
      var E = Z(s);
      switch (E) {
        case "array":
        case "object":
          return "an " + E;
        case "boolean":
        case "date":
        case "regexp":
          return "a " + E;
        default:
          return E;
      }
    }
    function Ce(s) {
      return !s.constructor || !s.constructor.name ? S : s.constructor.name;
    }
    return b.checkPropTypes = a, b.resetWarningCache = a.resetWarningCache, b.PropTypes = b, b;
  }, Ze;
}
if (process.env.NODE_ENV !== "production") {
  var Pn = zt(), xn = !0;
  tt.exports = Cn()(Pn.isElement, xn);
} else
  tt.exports = Tn()();
var v = tt.exports;
const Yt = (e) => !!e && e[0] === "o", At = En || ((e) => e()), Rn = Object.values || ((e) => Object.keys(e).map((t) => e[t])), Se = (e, t, n = 1e-4) => Math.abs(e - t) < n, Re = (e, t) => e === !0 || !!(e && e[t]), G = (e, t) => typeof e == "function" ? e(t) : e, Mn = "_szhsinMenu", In = (e) => e[Mn], Fe = (e, t) => (t && Object.keys(t).forEach((n) => {
  const o = e[n], a = t[n];
  typeof a == "function" && o ? e[n] = (...r) => {
    a(...r), o(...r);
  } : e[n] = a;
}), e), An = (e) => {
  if (typeof e != "string")
    return {
      top: 0,
      right: 0,
      bottom: 0,
      left: 0
    };
  const t = e.trim().split(/\s+/, 4).map(parseFloat), n = isNaN(t[0]) ? 0 : t[0], o = isNaN(t[1]) ? n : t[1];
  return {
    top: n,
    right: o,
    bottom: isNaN(t[2]) ? n : t[2],
    left: isNaN(t[3]) ? o : t[3]
  };
}, Qe = (e) => {
  for (; e; ) {
    if (e = e.parentNode, !e || e === document.body || !e.parentNode)
      return;
    const {
      overflow: t,
      overflowX: n,
      overflowY: o
    } = getComputedStyle(e);
    if (/auto|scroll|overlay|hidden/.test(t + o + n))
      return e;
  }
};
function Ut(e, t) {
  return {
    "aria-disabled": e || void 0,
    tabIndex: t ? 0 : -1
  };
}
function kt(e, t) {
  for (let n = 0; n < e.length; n++)
    if (e[n] === t)
      return n;
  return -1;
}
const Ht = (e) => ({
  [e ? `${e}ClassName` : "className"]: v.oneOfType([v.string, v.func])
}), kn = {
  className: v.string,
  ...Ht("menu"),
  arrowProps: v.object,
  focusProps: v.object,
  menuStyle: v.object,
  arrow: v.bool,
  setDownOverflow: v.bool,
  gap: v.number,
  shift: v.number,
  align: /* @__PURE__ */ v.oneOf(["start", "center", "end"]),
  direction: /* @__PURE__ */ v.oneOf(["left", "right", "top", "bottom"]),
  position: /* @__PURE__ */ v.oneOf(["auto", "anchor", "initial"]),
  overflow: /* @__PURE__ */ v.oneOf(["auto", "visible", "hidden"])
}, Wt = {
  ...kn,
  containerProps: v.object,
  initialMounted: v.bool,
  unmountOnClose: v.bool,
  transition: /* @__PURE__ */ v.oneOfType([v.bool, /* @__PURE__ */ v.exact({
    open: v.bool,
    close: v.bool,
    item: v.bool
  })]),
  transitionTimeout: v.number,
  boundingBoxRef: v.object,
  boundingBoxPadding: v.string,
  reposition: /* @__PURE__ */ v.oneOf(["auto", "initial"]),
  repositionFlag: /* @__PURE__ */ v.oneOfType([v.string, v.number]),
  viewScroll: /* @__PURE__ */ v.oneOf(["auto", "close", "initial"]),
  submenuOpenDelay: v.number,
  submenuCloseDelay: v.number,
  portal: /* @__PURE__ */ v.oneOfType([v.bool, /* @__PURE__ */ v.exact({
    target: v.object,
    stablePosition: v.bool
  })]),
  theming: v.string,
  onItemClick: v.func
}, Nn = {
  instanceRef: /* @__PURE__ */ v.oneOfType([v.object, v.func]),
  onMenuChange: v.func
}, $e = ({
  block: e,
  element: t,
  modifiers: n,
  className: o
}) => ce(() => {
  const a = t ? `${e}__${t}` : e;
  let r = a;
  n && Object.keys(n).forEach((l) => {
    const h = n[l];
    h && (r += ` ${a}--${h === !0 ? l : `${l}-${h}`}`);
  });
  let c = typeof o == "function" ? o(n) : o;
  return typeof c == "string" && (c = c.trim(), c && (r += ` ${c}`)), r;
}, [e, t, n, o]), jn = "szh-menu-container", je = "szh-menu", Dn = "arrow", $n = "item", Bt = /* @__PURE__ */ Oe(), Vt = /* @__PURE__ */ Oe({}), Nt = /* @__PURE__ */ Oe({}), Kt = /* @__PURE__ */ Oe({}), Ln = /* @__PURE__ */ Oe({}), at = /* @__PURE__ */ Oe({}), se = /* @__PURE__ */ Object.freeze({
  ENTER: "Enter",
  ESC: "Escape",
  SPACE: " ",
  HOME: "Home",
  END: "End",
  LEFT: "ArrowLeft",
  RIGHT: "ArrowRight",
  UP: "ArrowUp",
  DOWN: "ArrowDown"
}), q = /* @__PURE__ */ Object.freeze({
  RESET: 0,
  SET: 1,
  UNSET: 2,
  INCREASE: 3,
  DECREASE: 4,
  FIRST: 5,
  LAST: 6,
  SET_INDEX: 7
}), Me = /* @__PURE__ */ Object.freeze({
  CLICK: "click",
  CANCEL: "cancel",
  BLUR: "blur",
  SCROLL: "scroll"
}), xe = /* @__PURE__ */ Object.freeze({
  FIRST: "first",
  LAST: "last"
}), Xt = /* @__PURE__ */ Object.freeze({
  entering: "opening",
  entered: "open",
  exiting: "closing",
  exited: "closed"
}), et = "absolute", qn = "presentation", Gt = "menuitem", jt = {
  "aria-hidden": !0,
  role: Gt
}, zn = ({
  className: e,
  containerRef: t,
  containerProps: n,
  children: o,
  isOpen: a,
  theming: r,
  transition: c,
  onClose: l
}) => {
  const h = Re(c, "item");
  return /* @__PURE__ */ F("div", {
    ...Fe({
      onKeyDown: ({
        key: d
      }) => {
        switch (d) {
          case se.ESC:
            G(l, {
              key: d,
              reason: Me.CANCEL
            });
            break;
        }
      },
      onBlur: (d) => {
        a && !d.currentTarget.contains(d.relatedTarget) && G(l, {
          reason: Me.BLUR
        });
      }
    }, n),
    className: $e({
      block: jn,
      modifiers: ce(() => ({
        theme: r,
        itemTransition: h
      }), [r, h]),
      className: e
    }),
    style: {
      position: "absolute",
      ...n == null ? void 0 : n.style
    },
    ref: t,
    children: o
  });
}, Fn = () => {
  let e, t = 0;
  return {
    toggle: (n) => {
      n ? t++ : t--, t = Math.max(t, 0);
    },
    on: (n, o, a) => {
      t ? e || (e = setTimeout(() => {
        e = 0, o();
      }, n)) : a == null || a();
    },
    off: () => {
      e && (clearTimeout(e), e = 0);
    }
  };
}, Yn = (e, t) => {
  const [n, o] = pe(), r = K({
    items: [],
    hoverIndex: -1,
    sorted: !1
  }).current, c = we((h, y) => {
    const {
      items: p
    } = r;
    if (!h)
      r.items = [];
    else if (y)
      p.push(h);
    else {
      const d = p.indexOf(h);
      d > -1 && (p.splice(d, 1), h.contains(document.activeElement) && (t.current.focus(), o()));
    }
    r.hoverIndex = -1, r.sorted = !1;
  }, [r, t]), l = we((h, y, p) => {
    const {
      items: d,
      hoverIndex: S
    } = r, b = () => {
      if (r.sorted)
        return;
      const g = e.current.querySelectorAll(".szh-menu__item");
      d.sort((O, T) => kt(g, O) - kt(g, T)), r.sorted = !0;
    };
    let i = -1, f;
    switch (h) {
      case q.RESET:
        break;
      case q.SET:
        f = y;
        break;
      case q.UNSET:
        f = (g) => g === y ? void 0 : g;
        break;
      case q.FIRST:
        b(), i = 0, f = d[i];
        break;
      case q.LAST:
        b(), i = d.length - 1, f = d[i];
        break;
      case q.SET_INDEX:
        b(), i = p, f = d[i];
        break;
      case q.INCREASE:
        b(), i = S, i < 0 && (i = d.indexOf(y)), i++, i >= d.length && (i = 0), f = d[i];
        break;
      case q.DECREASE:
        b(), i = S, i < 0 && (i = d.indexOf(y)), i--, i < 0 && (i = d.length - 1), f = d[i];
        break;
      default:
        if (process.env.NODE_ENV !== "production")
          throw new Error(`[React-Menu] Unknown hover action type: ${h}`);
    }
    f || (i = -1), o(f), r.hoverIndex = i;
  }, [e, r]);
  return {
    hoverItem: n,
    dispatch: l,
    updateItems: c
  };
}, Un = (e, t, n, o) => {
  const a = t.current.getBoundingClientRect(), r = e.current.getBoundingClientRect(), c = n === window ? {
    left: 0,
    top: 0,
    right: document.documentElement.clientWidth,
    bottom: window.innerHeight
  } : n.getBoundingClientRect(), l = An(o), h = (i) => i + r.left - c.left - l.left, y = (i) => i + r.left + a.width - c.right + l.right, p = (i) => i + r.top - c.top - l.top, d = (i) => i + r.top + a.height - c.bottom + l.bottom;
  return {
    menuRect: a,
    containerRect: r,
    getLeftOverflow: h,
    getRightOverflow: y,
    getTopOverflow: p,
    getBottomOverflow: d,
    confineHorizontally: (i) => {
      let f = h(i);
      if (f < 0)
        i -= f;
      else {
        const g = y(i);
        g > 0 && (i -= g, f = h(i), f < 0 && (i -= f));
      }
      return i;
    },
    confineVertically: (i) => {
      let f = p(i);
      if (f < 0)
        i -= f;
      else {
        const g = d(i);
        g > 0 && (i -= g, f = p(i), f < 0 && (i -= f));
      }
      return i;
    }
  };
}, Hn = ({
  arrowRef: e,
  menuY: t,
  anchorRect: n,
  containerRect: o,
  menuRect: a
}) => {
  let r = n.top - o.top - t + n.height / 2;
  const c = e.current.offsetHeight * 1.25;
  return r = Math.max(c, r), r = Math.min(r, a.height - c), r;
}, Wn = ({
  anchorRect: e,
  containerRect: t,
  menuRect: n,
  placeLeftorRightY: o,
  placeLeftX: a,
  placeRightX: r,
  getLeftOverflow: c,
  getRightOverflow: l,
  confineHorizontally: h,
  confineVertically: y,
  arrowRef: p,
  arrow: d,
  direction: S,
  position: b
}) => {
  let i = S, f = o;
  b !== "initial" && (f = y(f), b === "anchor" && (f = Math.min(f, e.bottom - t.top), f = Math.max(f, e.top - t.top - n.height)));
  let g, O, T;
  return i === "left" ? (g = a, b !== "initial" && (O = c(g), O < 0 && (T = l(r), (T <= 0 || -O > T) && (g = r, i = "right")))) : (g = r, b !== "initial" && (T = l(g), T > 0 && (O = c(a), (O >= 0 || -O < T) && (g = a, i = "left")))), b === "auto" && (g = h(g)), {
    arrowY: d ? Hn({
      menuY: f,
      arrowRef: p,
      anchorRect: e,
      containerRect: t,
      menuRect: n
    }) : void 0,
    x: g,
    y: f,
    computedDirection: i
  };
}, Bn = ({
  arrowRef: e,
  menuX: t,
  anchorRect: n,
  containerRect: o,
  menuRect: a
}) => {
  let r = n.left - o.left - t + n.width / 2;
  const c = e.current.offsetWidth * 1.25;
  return r = Math.max(c, r), r = Math.min(r, a.width - c), r;
}, Vn = ({
  anchorRect: e,
  containerRect: t,
  menuRect: n,
  placeToporBottomX: o,
  placeTopY: a,
  placeBottomY: r,
  getTopOverflow: c,
  getBottomOverflow: l,
  confineHorizontally: h,
  confineVertically: y,
  arrowRef: p,
  arrow: d,
  direction: S,
  position: b
}) => {
  let i = S === "top" ? "top" : "bottom", f = o;
  b !== "initial" && (f = h(f), b === "anchor" && (f = Math.min(f, e.right - t.left), f = Math.max(f, e.left - t.left - n.width)));
  let g, O, T;
  return i === "top" ? (g = a, b !== "initial" && (O = c(g), O < 0 && (T = l(r), (T <= 0 || -O > T) && (g = r, i = "bottom")))) : (g = r, b !== "initial" && (T = l(g), T > 0 && (O = c(a), (O >= 0 || -O < T) && (g = a, i = "top")))), b === "auto" && (g = y(g)), {
    arrowX: d ? Bn({
      menuX: f,
      arrowRef: p,
      anchorRect: e,
      containerRect: t,
      menuRect: n
    }) : void 0,
    x: f,
    y: g,
    computedDirection: i
  };
}, Kn = ({
  arrow: e,
  align: t,
  direction: n,
  gap: o,
  shift: a,
  position: r,
  anchorRect: c,
  arrowRef: l,
  positionHelpers: h
}) => {
  const {
    menuRect: y,
    containerRect: p
  } = h, d = n === "left" || n === "right";
  let S = d ? o : a, b = d ? a : o;
  if (e) {
    const u = l.current;
    d ? S += u.offsetWidth : b += u.offsetHeight;
  }
  const i = c.left - p.left - y.width - S, f = c.right - p.left + S, g = c.top - p.top - y.height - b, O = c.bottom - p.top + b;
  let T, w;
  t === "end" ? (T = c.right - p.left - y.width, w = c.bottom - p.top - y.height) : t === "center" ? (T = c.left - p.left - (y.width - c.width) / 2, w = c.top - p.top - (y.height - c.height) / 2) : (T = c.left - p.left, w = c.top - p.top), T += S, w += b;
  const M = {
    ...h,
    anchorRect: c,
    placeLeftX: i,
    placeRightX: f,
    placeLeftorRightY: w,
    placeTopY: g,
    placeBottomY: O,
    placeToporBottomX: T,
    arrowRef: l,
    arrow: e,
    direction: n,
    position: r
  };
  switch (n) {
    case "left":
    case "right":
      return Wn(M);
    case "top":
    case "bottom":
    default:
      return Vn(M);
  }
}, De = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u" ? pn : me;
function Dt(e, t) {
  typeof e == "function" ? e(t) : e.current = t;
}
const ut = (e, t) => ce(() => e ? t ? (n) => {
  Dt(e, n), Dt(t, n);
} : e : t, [e, t]), $t = -9999, Xn = ({
  ariaLabel: e,
  menuClassName: t,
  menuStyle: n,
  arrow: o,
  arrowProps: a = {},
  anchorPoint: r,
  anchorRef: c,
  containerRef: l,
  containerProps: h,
  focusProps: y,
  externalRef: p,
  parentScrollingRef: d,
  align: S = "start",
  direction: b = "bottom",
  position: i = "auto",
  overflow: f = "visible",
  setDownOverflow: g,
  repositionFlag: O,
  captureFocus: T = !0,
  state: w,
  endTransition: M,
  isDisabled: u,
  menuItemFocus: Y,
  gap: X = 0,
  shift: J = 0,
  children: ue,
  onClose: V,
  ...L
}) => {
  const [W, fe] = pe({
    x: $t,
    y: $t
  }), [le, _e] = pe({}), [z, Z] = pe(), [oe, Ce] = pe(b), [s] = pe(Fn), [E, R] = mn((N) => N + 1, 1), {
    transition: x,
    boundingBoxRef: _,
    boundingBoxPadding: A,
    rootMenuRef: C,
    rootAnchorRef: P,
    scrollNodesRef: k,
    reposition: j,
    viewScroll: I,
    submenuCloseDelay: U
  } = he(at), {
    submenuCtx: m,
    reposSubmenu: Q = O
  } = he(Nt), ee = K(null), ye = K(), dt = K(), pt = K(!1), Ie = K({
    width: 0,
    height: 0
  }), mt = K(() => {
  }), {
    hoverItem: Ye,
    dispatch: te,
    updateItems: Ae
  } = Yn(ee, ye), ne = Yt(w), yt = Re(x, "open"), vt = Re(x, "close"), ie = k.current, tn = (N) => {
    switch (N.key) {
      case se.HOME:
        te(q.FIRST);
        break;
      case se.END:
        te(q.LAST);
        break;
      case se.UP:
        te(q.DECREASE, Ye);
        break;
      case se.DOWN:
        te(q.INCREASE, Ye);
        break;
      case se.SPACE:
        N.target && N.target.className.indexOf(je) !== -1 && N.preventDefault();
        return;
      default:
        return;
    }
    N.preventDefault(), N.stopPropagation();
  }, nn = () => {
    w === "closing" && Z(), G(M);
  }, rn = (N) => {
    N.stopPropagation(), s.on(U, () => {
      te(q.RESET), ye.current.focus();
    });
  }, on = (N) => {
    N.target === N.currentTarget && s.off();
  }, ve = we((N) => {
    var B;
    const ae = c ? (B = c.current) == null ? void 0 : B.getBoundingClientRect() : r ? {
      left: r.x,
      right: r.x,
      top: r.y,
      bottom: r.y,
      width: 0,
      height: 0
    } : null;
    if (!ae) {
      process.env.NODE_ENV !== "production" && console.warn("[React-Menu] Menu might not be positioned properly as one of the anchorRef or anchorPoint prop should be provided. If `anchorRef` is provided, the anchor must be mounted before menu is open.");
      return;
    }
    ie.menu || (ie.menu = (_ ? _.current : Qe(C.current)) || window);
    const re = Un(l, ee, ie.menu, A);
    let {
      arrowX: H,
      arrowY: be,
      x: Ee,
      y: de,
      computedDirection: We
    } = Kn({
      arrow: o,
      align: S,
      direction: b,
      gap: X,
      shift: J,
      position: i,
      anchorRect: ae,
      arrowRef: dt,
      positionHelpers: re
    });
    const {
      menuRect: gt
    } = re;
    let ge = gt.height;
    if (!N && f !== "visible") {
      const {
        getTopOverflow: ln,
        getBottomOverflow: dn
      } = re;
      let Te, Be;
      const Tt = Ie.current.height, ke = dn(de);
      if (ke > 0 || Se(ke, 0) && Se(ge, Tt))
        Te = ge - ke, Be = ke;
      else {
        const Pe = ln(de);
        (Pe < 0 || Se(Pe, 0) && Se(ge, Tt)) && (Te = ge + Pe, Be = 0 - Pe, Te >= 0 && (de -= Pe));
      }
      Te >= 0 ? (ge = Te, Z({
        height: Te,
        overflowAmt: Be
      })) : Z();
    }
    o && _e({
      x: H,
      y: be
    }), fe({
      x: Ee,
      y: de
    }), Ce(We), Ie.current = {
      width: gt.width,
      height: ge
    };
  }, [o, S, A, b, X, J, i, f, r, c, l, _, C, ie]);
  De(() => {
    ne && (ve(), pt.current && R()), pt.current = ne, mt.current = ve;
  }, [ne, ve, Q]), De(() => {
    z && !g && (ee.current.scrollTop = 0);
  }, [z, g]), De(() => Ae, [Ae]), me(() => {
    let {
      menu: N
    } = ie;
    if (!ne || !N)
      return;
    if (N = N.addEventListener ? N : window, !ie.anchors) {
      ie.anchors = [];
      let H = Qe(P && P.current);
      for (; H && H !== N; )
        ie.anchors.push(H), H = Qe(H);
    }
    let B = I;
    if (ie.anchors.length && B === "initial" && (B = "auto"), B === "initial")
      return;
    const ae = () => {
      B === "auto" ? At(() => ve(!0)) : G(V, {
        reason: Me.SCROLL
      });
    }, re = ie.anchors.concat(I !== "initial" ? N : []);
    return re.forEach((H) => H.addEventListener("scroll", ae)), () => re.forEach((H) => H.removeEventListener("scroll", ae));
  }, [P, ie, ne, V, I, ve]);
  const ht = !!z && z.overflowAmt > 0;
  me(() => {
    if (ht || !ne || !d)
      return;
    const N = () => At(ve), B = d.current;
    return B.addEventListener("scroll", N), () => B.removeEventListener("scroll", N);
  }, [ne, ht, d, ve]), me(() => {
    if (typeof ResizeObserver != "function" || j === "initial")
      return;
    const N = new ResizeObserver(([ae]) => {
      const {
        borderBoxSize: re,
        target: H
      } = ae;
      let be, Ee;
      if (re) {
        const {
          inlineSize: de,
          blockSize: We
        } = re[0] || re;
        be = de, Ee = We;
      } else {
        const de = H.getBoundingClientRect();
        be = de.width, Ee = de.height;
      }
      be === 0 || Ee === 0 || Se(be, Ie.current.width, 1) && Se(Ee, Ie.current.height, 1) || gn(() => {
        mt.current(), R();
      });
    }), B = ee.current;
    return N.observe(B, {
      box: "border-box"
    }), () => N.unobserve(B);
  }, [j]), me(() => {
    if (!ne) {
      te(q.RESET), vt || Z();
      return;
    }
    const {
      position: N,
      alwaysUpdate: B
    } = Y || {}, ae = () => {
      N === xe.FIRST ? te(q.FIRST) : N === xe.LAST ? te(q.LAST) : N >= -1 && te(q.SET_INDEX, void 0, N);
    };
    if (B)
      ae();
    else if (T) {
      const re = setTimeout(() => {
        const H = ee.current;
        H && !H.contains(document.activeElement) && (ye.current.focus(), ae());
      }, yt ? 170 : 100);
      return () => clearTimeout(re);
    }
  }, [ne, yt, vt, T, Y, te]);
  const sn = ce(() => ({
    isParentOpen: ne,
    submenuCtx: s,
    dispatch: te,
    updateItems: Ae
  }), [ne, s, te, Ae]);
  let Ue, He;
  z && (g ? He = z.overflowAmt : Ue = z.height);
  const cn = ce(() => ({
    reposSubmenu: E,
    submenuCtx: s,
    overflow: f,
    overflowAmt: He,
    parentMenuRef: ee,
    parentDir: oe
  }), [E, s, f, He, oe]), an = Ue >= 0 ? {
    maxHeight: Ue,
    overflow: f
  } : void 0, bt = ce(() => ({
    state: w,
    dir: oe
  }), [w, oe]), un = ce(() => ({
    dir: oe
  }), [oe]), fn = $e({
    block: je,
    element: Dn,
    modifiers: un,
    className: a.className
  }), Et = /* @__PURE__ */ qt("ul", {
    role: "menu",
    "aria-label": e,
    ...Ut(u),
    ...Fe({
      onPointerEnter: m == null ? void 0 : m.off,
      onPointerMove: rn,
      onPointerLeave: on,
      onKeyDown: tn,
      onAnimationEnd: nn
    }, L),
    ref: ut(p, ee),
    className: $e({
      block: je,
      modifiers: bt,
      className: t
    }),
    style: {
      ...n,
      ...an,
      margin: 0,
      display: w === "closed" ? "none" : void 0,
      position: et,
      left: W.x,
      top: W.y
    },
    children: [/* @__PURE__ */ F("li", {
      tabIndex: -1,
      style: {
        position: et,
        left: 0,
        top: 0,
        display: "block",
        outline: "none"
      },
      ref: ye,
      ...jt,
      ...y
    }), o && /* @__PURE__ */ F("li", {
      ...jt,
      ...a,
      className: fn,
      style: {
        display: "block",
        position: et,
        left: le.x,
        top: le.y,
        ...a.style
      },
      ref: dt
    }), /* @__PURE__ */ F(Nt.Provider, {
      value: cn,
      children: /* @__PURE__ */ F(Vt.Provider, {
        value: sn,
        children: /* @__PURE__ */ F(Bt.Provider, {
          value: Ye,
          children: G(ue, bt)
        })
      })
    })]
  });
  return h ? /* @__PURE__ */ F(zn, {
    ...h,
    isOpen: ne,
    children: Et
  }) : Et;
}, Jt = /* @__PURE__ */ st(function({
  "aria-label": t,
  className: n,
  containerProps: o,
  initialMounted: a,
  unmountOnClose: r,
  transition: c,
  transitionTimeout: l,
  boundingBoxRef: h,
  boundingBoxPadding: y,
  reposition: p = "auto",
  submenuOpenDelay: d = 300,
  submenuCloseDelay: S = 150,
  viewScroll: b = "initial",
  portal: i,
  theming: f,
  onItemClick: g,
  ...O
}, T) {
  const w = K(null), M = K({}), {
    anchorRef: u,
    state: Y,
    onClose: X
  } = O, J = ce(() => ({
    initialMounted: a,
    unmountOnClose: r,
    transition: c,
    transitionTimeout: l,
    boundingBoxRef: h,
    boundingBoxPadding: y,
    rootMenuRef: w,
    rootAnchorRef: u,
    scrollNodesRef: M,
    reposition: p,
    viewScroll: b,
    submenuOpenDelay: d,
    submenuCloseDelay: S
  }), [a, r, c, l, u, h, y, p, b, d, S]), ue = ce(() => ({
    handleClick(L, W) {
      L.stopPropagation || G(g, L);
      let fe = L.keepOpen;
      fe === void 0 && (fe = W && L.key === se.SPACE), fe || G(X, {
        value: L.value,
        key: L.key,
        reason: Me.CLICK
      });
    },
    handleClose(L) {
      G(X, {
        key: L,
        reason: Me.CLICK
      });
    }
  }), [g, X]);
  if (!Y)
    return null;
  const V = /* @__PURE__ */ F(at.Provider, {
    value: J,
    children: /* @__PURE__ */ F(Kt.Provider, {
      value: ue,
      children: /* @__PURE__ */ F(Xn, {
        ...O,
        ariaLabel: t || "Menu",
        externalRef: T,
        containerRef: w,
        containerProps: {
          className: n,
          containerRef: w,
          containerProps: o,
          theming: f,
          transition: c,
          onClose: X
        }
      })
    })
  });
  return i === !0 && typeof document < "u" ? /* @__PURE__ */ St(V, document.body) : i ? i.target ? /* @__PURE__ */ St(V, i.target) : i.stablePosition ? null : V : V;
});
process.env.NODE_ENV !== "production" && (Jt.propTypes = {
  ...Wt,
  state: /* @__PURE__ */ v.oneOf(/* @__PURE__ */ Rn(Xt)),
  anchorPoint: /* @__PURE__ */ v.exact({
    x: v.number,
    y: v.number
  }),
  anchorRef: v.object,
  captureFocus: v.bool,
  menuItemFocus: /* @__PURE__ */ v.exact({
    position: /* @__PURE__ */ v.oneOfType([v.string, v.number]),
    alwaysUpdate: v.bool
  }),
  onClose: v.func
});
const nt = 0, rt = 1, Le = 2, qe = 3, ze = 4, Gn = 5, Zt = 6, Jn = ["preEnter", "entering", "entered", "preExit", "exiting", "exited", "unmounted"], Qt = (e) => ({
  _s: e,
  status: Jn[e],
  isEnter: e < qe,
  isMounted: e !== Zt,
  isResolved: e === Le || e > ze
}), ot = (e) => e ? Zt : Gn, Zn = (e, t) => {
  switch (e) {
    case rt:
    case nt:
      return Le;
    case ze:
    case qe:
      return ot(t);
  }
}, Qn = (e) => typeof e == "object" ? [e.enter, e.exit] : [e, e], er = (e, t) => setTimeout(() => {
  isNaN(document.body.offsetTop) || e(t + 1);
}, 0), Lt = (e, t, n, o, a) => {
  clearTimeout(o.current);
  const r = Qt(e);
  t(r), n.current = r, a && a({
    current: r
  });
}, tr = ({
  enter: e = !0,
  exit: t = !0,
  preEnter: n,
  preExit: o,
  timeout: a,
  initialEntered: r,
  mountOnEnter: c,
  unmountOnExit: l,
  onStateChange: h
} = {}) => {
  const [y, p] = pe(() => Qt(r ? Le : ot(c))), d = K(y), S = K(), [b, i] = Qn(a), f = we(() => {
    const O = Zn(d.current._s, l);
    O && Lt(O, p, d, S, h);
  }, [h, l]), g = we((O) => {
    const T = (M) => {
      switch (Lt(M, p, d, S, h), M) {
        case rt:
          b >= 0 && (S.current = setTimeout(f, b));
          break;
        case ze:
          i >= 0 && (S.current = setTimeout(f, i));
          break;
        case nt:
        case qe:
          S.current = er(T, M);
          break;
      }
    }, w = d.current.isEnter;
    typeof O != "boolean" && (O = !w), O ? !w && T(e ? n ? nt : rt : Le) : w && T(t ? o ? qe : ze : ot(l));
  }, [f, h, e, t, n, o, b, i, l]);
  return me(() => () => clearTimeout(S.current), []), [y, g, f];
}, nr = ({
  initialOpen: e,
  initialMounted: t,
  unmountOnClose: n,
  transition: o,
  transitionTimeout: a = 500
} = {}) => {
  const [{
    status: r
  }, c, l] = tr({
    initialEntered: e,
    mountOnEnter: !t,
    unmountOnExit: n,
    timeout: a,
    enter: Re(o, "open"),
    exit: Re(o, "close")
  });
  return [{
    state: Xt[r],
    endTransition: l
  }, c];
}, rr = (e) => {
  const [t, n] = nr(e), [o, a] = pe(), r = (c, l) => {
    a({
      position: c,
      alwaysUpdate: l
    }), n(!0);
  };
  return [{
    menuItemFocus: o,
    ...t
  }, n, r];
}, or = (e, t) => {
  if (process.env.NODE_ENV !== "production" && typeof t != "function")
    throw new Error("[React-Menu] useClick/useHover requires a function in the second parameter.");
  const [n] = pe({});
  return {
    onMouseDown: () => {
      n.v = e && e !== "closed";
    },
    onClick: (o) => n.v ? n.v = !1 : t(!0, o)
  };
}, ir = (e, t) => {
  const n = K(t);
  me(() => {
    n.current !== t && G(e, {
      open: t
    }), n.current = t;
  }, [e, t]);
}, ft = /* @__PURE__ */ st(function({
  "aria-label": t,
  captureFocus: n,
  initialOpen: o,
  menuButton: a,
  instanceRef: r,
  onMenuChange: c,
  ...l
}, h) {
  const [y, p, d] = rr(l), {
    state: S
  } = y, b = Yt(S), i = K(null), f = or(S, (u, Y) => d(Y.detail ? void 0 : xe.FIRST)), g = we((u) => {
    p(!1), u.key && i.current.focus();
  }, [p]), O = (u) => {
    switch (u.key) {
      case se.UP:
        d(xe.LAST);
        break;
      case se.DOWN:
        d(xe.FIRST);
        break;
      default:
        return;
    }
    u.preventDefault();
  }, T = G(a, {
    open: b
  });
  if (!T || !T.type)
    throw new Error("Menu requires a menuButton prop.");
  const w = {
    ref: ut(T.ref, i),
    ...Fe({
      onKeyDown: O,
      ...f
    }, T.props)
  };
  In(T.type) === "MenuButton" && (w.isOpen = b);
  const M = /* @__PURE__ */ hn(T, w);
  return ir(c, b), yn(r, () => ({
    openMenu: d,
    closeMenu: () => p(!1)
  })), /* @__PURE__ */ qt(vn, {
    children: [M, /* @__PURE__ */ F(Jt, {
      ...l,
      ...y,
      "aria-label": t || (typeof T.props.children == "string" ? T.props.children : "Menu"),
      anchorRef: i,
      ref: h,
      onClose: g
    })]
  });
});
process.env.NODE_ENV !== "production" && (ft.propTypes = {
  ...Wt,
  ...Nn,
  menuButton: v.oneOfType([v.element, v.func]).isRequired
});
const sr = (e, t) => {
  const n = /* @__PURE__ */ bn(t), o = /* @__PURE__ */ st((a, r) => {
    const c = K(null);
    return /* @__PURE__ */ F(n, {
      ...a,
      itemRef: c,
      externalRef: r,
      isHovering: he(Bt) === c.current
    });
  });
  return o.displayName = `WithHovering(${e})`, o;
}, cr = (e, t, n) => {
  De(() => {
    if (process.env.NODE_ENV !== "production" && !n)
      throw new Error(`[React-Menu] This menu item or submenu should be rendered under a menu: ${t.current.outerHTML}`);
    if (e)
      return;
    const o = t.current;
    return n(o, !0), () => {
      n(o);
    };
  }, [e, t, n]);
}, ar = (e, t, n, o) => {
  const {
    submenuCloseDelay: a
  } = he(at), {
    isParentOpen: r,
    submenuCtx: c,
    dispatch: l,
    updateItems: h
  } = he(Vt), y = () => {
    !n && !o && l(q.SET, e.current);
  }, p = () => {
    !o && l(q.UNSET, e.current);
  }, d = (i) => {
    n && !i.currentTarget.contains(i.relatedTarget) && p();
  }, S = (i) => {
    o || (i.stopPropagation(), c.on(a, y, y));
  }, b = (i, f) => {
    c.off(), !f && p();
  };
  return cr(o, e, h), me(() => {
    n && r && t.current && t.current.focus();
  }, [t, n, r]), {
    setHover: y,
    onBlur: d,
    onPointerMove: S,
    onPointerLeave: b
  };
}, en = /* @__PURE__ */ sr("MenuItem", function({
  className: t,
  value: n,
  href: o,
  type: a,
  checked: r,
  disabled: c,
  children: l,
  onClick: h,
  isHovering: y,
  itemRef: p,
  externalRef: d,
  ...S
}) {
  const b = !!c, {
    setHover: i,
    ...f
  } = ar(p, p, y, b), g = he(Kt), O = he(Ln), T = a === "radio", w = a === "checkbox", M = !!o && !b && !T && !w, u = T ? O.value === n : w ? !!r : !1, Y = (L) => {
    if (b) {
      L.stopPropagation(), L.preventDefault();
      return;
    }
    const W = {
      value: n,
      syntheticEvent: L
    };
    L.key !== void 0 && (W.key = L.key), w && (W.checked = !u), T && (W.name = O.name), G(h, W), T && G(O.onRadioChange, W), g.handleClick(W, w || T);
  }, X = (L) => {
    if (y)
      switch (L.key) {
        case se.ENTER:
          L.preventDefault();
        case se.SPACE:
          M ? p.current.click() : Y(L);
      }
  }, J = ce(() => ({
    type: a,
    disabled: b,
    hover: y,
    checked: u,
    anchor: M
  }), [a, b, y, u, M]), ue = Fe({
    ...f,
    onPointerDown: i,
    onKeyDown: X,
    onClick: Y
  }, S), V = {
    role: T ? "menuitemradio" : w ? "menuitemcheckbox" : Gt,
    "aria-checked": T || w ? u : void 0,
    ...Ut(b, y),
    ...ue,
    ref: ut(d, p),
    className: $e({
      block: je,
      element: $n,
      modifiers: J,
      className: t
    }),
    children: ce(() => G(l, J), [l, J])
  };
  return M ? /* @__PURE__ */ F("li", {
    role: qn,
    children: /* @__PURE__ */ F("a", {
      href: o,
      ...V
    })
  }) : /* @__PURE__ */ F("li", {
    ...V
  });
});
process.env.NODE_ENV !== "production" && (en.propTypes = {
  ...Ht(),
  value: v.any,
  href: v.string,
  type: /* @__PURE__ */ v.oneOf(["checkbox", "radio"]),
  checked: v.bool,
  disabled: v.bool,
  children: /* @__PURE__ */ v.oneOfType([v.node, v.func]),
  onClick: v.func
});
const ur = "_menu__inner_1y02q_1", fr = "_menu__item_1y02q_11", lr = "_menu__action__list_1y02q_19", lt = {
  menu__inner: ur,
  menu__item: fr,
  menu__action__list: lr
}, dr = ({ menuClassName: e, ...t }) => /* @__PURE__ */ F(ft, { menuClassName: it(lt.menu__inner, e), ...t }), pr = ({ className: e, ...t }) => /* @__PURE__ */ F(
  en,
  {
    className: ({ disabled: n, hover: o }) => it(lt.menu__item, e, { "!_text-disabled": n, "!_bg-primary/20": o }),
    ...t
  }
), mr = ({ menuClassName: e, transition: t = !0, ...n }) => /* @__PURE__ */ F(ft, { transition: t, menuClassName: it(lt.menu__action__list, e), ...n }), Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  MenuActionList: mr,
  MenuItem: pr,
  MenuList: dr
}, Symbol.toStringTag, { value: "Module" }));
export {
  dr as M,
  pr as a,
  mr as b,
  Er as i
};
