UNPKG

swipe-list-sdk

Version:

Shared SwipeList React SDK

4,075 lines 125 kB
import * as Xt from "react";
import Ve, { useState as _i, useRef as de, useEffect as Ge, useLayoutEffect as Fn, forwardRef as Mn, useCallback as Nn, useContext as bi, useMemo as nt } from "react";
import { unstable_batchedUpdates as Ln } from "react-dom";
var Nt = { exports: {} }, Re = {};
/**
 * @license React
 * react-jsx-runtime.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 Mr;
function Un() {
  if (Mr) return Re;
  Mr = 1;
  var e = Ve, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, n = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
  function a(u, l, c) {
    var f, p = {}, m = null, y = null;
    c !== void 0 && (m = "" + c), l.key !== void 0 && (m = "" + l.key), l.ref !== void 0 && (y = l.ref);
    for (f in l) i.call(l, f) && !o.hasOwnProperty(f) && (p[f] = l[f]);
    if (u && u.defaultProps) for (f in l = u.defaultProps, l) p[f] === void 0 && (p[f] = l[f]);
    return { $$typeof: t, type: u, key: m, ref: y, props: p, _owner: n.current };
  }
  return Re.Fragment = r, Re.jsx = a, Re.jsxs = a, Re;
}
var ke = {};
/**
 * @license React
 * react-jsx-runtime.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 Nr;
function $n() {
  return Nr || (Nr = 1, process.env.NODE_ENV !== "production" && function() {
    var e = Ve, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), n = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), w = Symbol.iterator, b = "@@iterator";
    function T(s) {
      if (s === null || typeof s != "object")
        return null;
      var d = w && s[w] || s[b];
      return typeof d == "function" ? d : null;
    }
    var v = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
    function _(s) {
      {
        for (var d = arguments.length, g = new Array(d > 1 ? d - 1 : 0), E = 1; E < d; E++)
          g[E - 1] = arguments[E];
        S("error", s, g);
      }
    }
    function S(s, d, g) {
      {
        var E = v.ReactDebugCurrentFrame, I = E.getStackAddendum();
        I !== "" && (d += "%s", g = g.concat([I]));
        var O = g.map(function(R) {
          return String(R);
        });
        O.unshift("Warning: " + d), Function.prototype.apply.call(console[s], console, O);
      }
    }
    var k = !1, V = !1, N = !1, L = !1, me = !1, U;
    U = Symbol.for("react.module.reference");
    function ce(s) {
      return !!(typeof s == "string" || typeof s == "function" || s === i || s === o || me || s === n || s === c || s === f || L || s === y || k || V || N || typeof s == "object" && s !== null && (s.$$typeof === m || s.$$typeof === p || s.$$typeof === a || s.$$typeof === u || s.$$typeof === l || // This needs to include all possible module reference object
      // types supported by any Flight configuration anywhere since
      // we don't know which Flight build this will end up being used
      // with.
      s.$$typeof === U || s.getModuleId !== void 0));
    }
    function K(s, d, g) {
      var E = s.displayName;
      if (E)
        return E;
      var I = d.displayName || d.name || "";
      return I !== "" ? g + "(" + I + ")" : g;
    }
    function re(s) {
      return s.displayName || "Context";
    }
    function $(s) {
      if (s == null)
        return null;
      if (typeof s.tag == "number" && _("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof s == "function")
        return s.displayName || s.name || null;
      if (typeof s == "string")
        return s;
      switch (s) {
        case i:
          return "Fragment";
        case r:
          return "Portal";
        case o:
          return "Profiler";
        case n:
          return "StrictMode";
        case c:
          return "Suspense";
        case f:
          return "SuspenseList";
      }
      if (typeof s == "object")
        switch (s.$$typeof) {
          case u:
            var d = s;
            return re(d) + ".Consumer";
          case a:
            var g = s;
            return re(g._context) + ".Provider";
          case l:
            return K(s, s.render, "ForwardRef");
          case p:
            var E = s.displayName || null;
            return E !== null ? E : $(s.type) || "Memo";
          case m: {
            var I = s, O = I._payload, R = I._init;
            try {
              return $(R(O));
            } catch {
              return null;
            }
          }
        }
      return null;
    }
    var ie = Object.assign, Ae = 0, pr, mr, gr, vr, yr, _r, br;
    function wr() {
    }
    wr.__reactDisabledLog = !0;
    function cn() {
      {
        if (Ae === 0) {
          pr = console.log, mr = console.info, gr = console.warn, vr = console.error, yr = console.group, _r = console.groupCollapsed, br = console.groupEnd;
          var s = {
            configurable: !0,
            enumerable: !0,
            value: wr,
            writable: !0
          };
          Object.defineProperties(console, {
            info: s,
            log: s,
            warn: s,
            error: s,
            group: s,
            groupCollapsed: s,
            groupEnd: s
          });
        }
        Ae++;
      }
    }
    function ln() {
      {
        if (Ae--, Ae === 0) {
          var s = {
            configurable: !0,
            enumerable: !0,
            writable: !0
          };
          Object.defineProperties(console, {
            log: ie({}, s, {
              value: pr
            }),
            info: ie({}, s, {
              value: mr
            }),
            warn: ie({}, s, {
              value: gr
            }),
            error: ie({}, s, {
              value: vr
            }),
            group: ie({}, s, {
              value: yr
            }),
            groupCollapsed: ie({}, s, {
              value: _r
            }),
            groupEnd: ie({}, s, {
              value: br
            })
          });
        }
        Ae < 0 && _("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
      }
    }
    var St = v.ReactCurrentDispatcher, Tt;
    function et(s, d, g) {
      {
        if (Tt === void 0)
          try {
            throw Error();
          } catch (I) {
            var E = I.stack.trim().match(/\n( *(at )?)/);
            Tt = E && E[1] || "";
          }
        return `
` + Tt + s;
      }
    }
    var Pt = !1, tt;
    {
      var fn = typeof WeakMap == "function" ? WeakMap : Map;
      tt = new fn();
    }
    function Er(s, d) {
      if (!s || Pt)
        return "";
      {
        var g = tt.get(s);
        if (g !== void 0)
          return g;
      }
      var E;
      Pt = !0;
      var I = Error.prepareStackTrace;
      Error.prepareStackTrace = void 0;
      var O;
      O = St.current, St.current = null, cn();
      try {
        if (d) {
          var R = function() {
            throw Error();
          };
          if (Object.defineProperty(R.prototype, "props", {
            set: function() {
              throw Error();
            }
          }), typeof Reflect == "object" && Reflect.construct) {
            try {
              Reflect.construct(R, []);
            } catch (Y) {
              E = Y;
            }
            Reflect.construct(s, [], R);
          } else {
            try {
              R.call();
            } catch (Y) {
              E = Y;
            }
            s.call(R.prototype);
          }
        } else {
          try {
            throw Error();
          } catch (Y) {
            E = Y;
          }
          s();
        }
      } catch (Y) {
        if (Y && E && typeof Y.stack == "string") {
          for (var A = Y.stack.split(`
`), B = E.stack.split(`
`), j = A.length - 1, F = B.length - 1; j >= 1 && F >= 0 && A[j] !== B[F]; )
            F--;
          for (; j >= 1 && F >= 0; j--, F--)
            if (A[j] !== B[F]) {
              if (j !== 1 || F !== 1)
                do
                  if (j--, F--, F < 0 || A[j] !== B[F]) {
                    var z = `
` + A[j].replace(" at new ", " at ");
                    return s.displayName && z.includes("<anonymous>") && (z = z.replace("<anonymous>", s.displayName)), typeof s == "function" && tt.set(s, z), z;
                  }
                while (j >= 1 && F >= 0);
              break;
            }
        }
      } finally {
        Pt = !1, St.current = O, ln(), Error.prepareStackTrace = I;
      }
      var ve = s ? s.displayName || s.name : "", le = ve ? et(ve) : "";
      return typeof s == "function" && tt.set(s, le), le;
    }
    function dn(s, d, g) {
      return Er(s, !1);
    }
    function hn(s) {
      var d = s.prototype;
      return !!(d && d.isReactComponent);
    }
    function rt(s, d, g) {
      if (s == null)
        return "";
      if (typeof s == "function")
        return Er(s, hn(s));
      if (typeof s == "string")
        return et(s);
      switch (s) {
        case c:
          return et("Suspense");
        case f:
          return et("SuspenseList");
      }
      if (typeof s == "object")
        switch (s.$$typeof) {
          case l:
            return dn(s.render);
          case p:
            return rt(s.type, d, g);
          case m: {
            var E = s, I = E._payload, O = E._init;
            try {
              return rt(O(I), d, g);
            } catch {
            }
          }
        }
      return "";
    }
    var xe = Object.prototype.hasOwnProperty, Sr = {}, Tr = v.ReactDebugCurrentFrame;
    function it(s) {
      if (s) {
        var d = s._owner, g = rt(s.type, s._source, d ? d.type : null);
        Tr.setExtraStackFrame(g);
      } else
        Tr.setExtraStackFrame(null);
    }
    function pn(s, d, g, E, I) {
      {
        var O = Function.call.bind(xe);
        for (var R in s)
          if (O(s, R)) {
            var A = void 0;
            try {
              if (typeof s[R] != "function") {
                var B = Error((E || "React class") + ": " + g + " type `" + R + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof s[R] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
                throw B.name = "Invariant Violation", B;
              }
              A = s[R](d, R, E, g, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
            } catch (j) {
              A = j;
            }
            A && !(A instanceof Error) && (it(I), _("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", E || "React class", g, R, typeof A), it(null)), A instanceof Error && !(A.message in Sr) && (Sr[A.message] = !0, it(I), _("Failed %s type: %s", g, A.message), it(null));
          }
      }
    }
    var mn = Array.isArray;
    function At(s) {
      return mn(s);
    }
    function gn(s) {
      {
        var d = typeof Symbol == "function" && Symbol.toStringTag, g = d && s[Symbol.toStringTag] || s.constructor.name || "Object";
        return g;
      }
    }
    function vn(s) {
      try {
        return Pr(s), !1;
      } catch {
        return !0;
      }
    }
    function Pr(s) {
      return "" + s;
    }
    function Ar(s) {
      if (vn(s))
        return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", gn(s)), Pr(s);
    }
    var xr = v.ReactCurrentOwner, yn = {
      key: !0,
      ref: !0,
      __self: !0,
      __source: !0
    }, Rr, kr;
    function _n(s) {
      if (xe.call(s, "ref")) {
        var d = Object.getOwnPropertyDescriptor(s, "ref").get;
        if (d && d.isReactWarning)
          return !1;
      }
      return s.ref !== void 0;
    }
    function bn(s) {
      if (xe.call(s, "key")) {
        var d = Object.getOwnPropertyDescriptor(s, "key").get;
        if (d && d.isReactWarning)
          return !1;
      }
      return s.key !== void 0;
    }
    function wn(s, d) {
      typeof s.ref == "string" && xr.current;
    }
    function En(s, d) {
      {
        var g = function() {
          Rr || (Rr = !0, _("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", d));
        };
        g.isReactWarning = !0, Object.defineProperty(s, "key", {
          get: g,
          configurable: !0
        });
      }
    }
    function Sn(s, d) {
      {
        var g = function() {
          kr || (kr = !0, _("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", d));
        };
        g.isReactWarning = !0, Object.defineProperty(s, "ref", {
          get: g,
          configurable: !0
        });
      }
    }
    var Tn = function(s, d, g, E, I, O, R) {
      var A = {
        // This tag allows us to uniquely identify this as a React Element
        $$typeof: t,
        // Built-in properties that belong on the element
        type: s,
        key: d,
        ref: g,
        props: R,
        // Record the component responsible for creating this element.
        _owner: O
      };
      return A._store = {}, Object.defineProperty(A._store, "validated", {
        configurable: !1,
        enumerable: !1,
        writable: !0,
        value: !1
      }), Object.defineProperty(A, "_self", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: E
      }), Object.defineProperty(A, "_source", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: I
      }), Object.freeze && (Object.freeze(A.props), Object.freeze(A)), A;
    };
    function Pn(s, d, g, E, I) {
      {
        var O, R = {}, A = null, B = null;
        g !== void 0 && (Ar(g), A = "" + g), bn(d) && (Ar(d.key), A = "" + d.key), _n(d) && (B = d.ref, wn(d, I));
        for (O in d)
          xe.call(d, O) && !yn.hasOwnProperty(O) && (R[O] = d[O]);
        if (s && s.defaultProps) {
          var j = s.defaultProps;
          for (O in j)
            R[O] === void 0 && (R[O] = j[O]);
        }
        if (A || B) {
          var F = typeof s == "function" ? s.displayName || s.name || "Unknown" : s;
          A && En(R, F), B && Sn(R, F);
        }
        return Tn(s, A, B, I, E, xr.current, R);
      }
    }
    var xt = v.ReactCurrentOwner, Ir = v.ReactDebugCurrentFrame;
    function ge(s) {
      if (s) {
        var d = s._owner, g = rt(s.type, s._source, d ? d.type : null);
        Ir.setExtraStackFrame(g);
      } else
        Ir.setExtraStackFrame(null);
    }
    var Rt;
    Rt = !1;
    function kt(s) {
      return typeof s == "object" && s !== null && s.$$typeof === t;
    }
    function Or() {
      {
        if (xt.current) {
          var s = $(xt.current.type);
          if (s)
            return `

Check the render method of \`` + s + "`.";
        }
        return "";
      }
    }
    function An(s) {
      return "";
    }
    var Cr = {};
    function xn(s) {
      {
        var d = Or();
        if (!d) {
          var g = typeof s == "string" ? s : s.displayName || s.name;
          g && (d = `

Check the top-level render call using <` + g + ">.");
        }
        return d;
      }
    }
    function Dr(s, d) {
      {
        if (!s._store || s._store.validated || s.key != null)
          return;
        s._store.validated = !0;
        var g = xn(d);
        if (Cr[g])
          return;
        Cr[g] = !0;
        var E = "";
        s && s._owner && s._owner !== xt.current && (E = " It was passed a child from " + $(s._owner.type) + "."), ge(s), _('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', g, E), ge(null);
      }
    }
    function Vr(s, d) {
      {
        if (typeof s != "object")
          return;
        if (At(s))
          for (var g = 0; g < s.length; g++) {
            var E = s[g];
            kt(E) && Dr(E, d);
          }
        else if (kt(s))
          s._store && (s._store.validated = !0);
        else if (s) {
          var I = T(s);
          if (typeof I == "function" && I !== s.entries)
            for (var O = I.call(s), R; !(R = O.next()).done; )
              kt(R.value) && Dr(R.value, d);
        }
      }
    }
    function Rn(s) {
      {
        var d = s.type;
        if (d == null || typeof d == "string")
          return;
        var g;
        if (typeof d == "function")
          g = d.propTypes;
        else if (typeof d == "object" && (d.$$typeof === l || // Note: Memo only checks outer props here.
        // Inner props are checked in the reconciler.
        d.$$typeof === p))
          g = d.propTypes;
        else
          return;
        if (g) {
          var E = $(d);
          pn(g, s.props, "prop", E, s);
        } else if (d.PropTypes !== void 0 && !Rt) {
          Rt = !0;
          var I = $(d);
          _("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", I || "Unknown");
        }
        typeof d.getDefaultProps == "function" && !d.getDefaultProps.isReactClassApproved && _("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
      }
    }
    function kn(s) {
      {
        for (var d = Object.keys(s.props), g = 0; g < d.length; g++) {
          var E = d[g];
          if (E !== "children" && E !== "key") {
            ge(s), _("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", E), ge(null);
            break;
          }
        }
        s.ref !== null && (ge(s), _("Invalid attribute `ref` supplied to `React.Fragment`."), ge(null));
      }
    }
    var jr = {};
    function Fr(s, d, g, E, I, O) {
      {
        var R = ce(s);
        if (!R) {
          var A = "";
          (s === void 0 || typeof s == "object" && s !== null && Object.keys(s).length === 0) && (A += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
          var B = An();
          B ? A += B : A += Or();
          var j;
          s === null ? j = "null" : At(s) ? j = "array" : s !== void 0 && s.$$typeof === t ? (j = "<" + ($(s.type) || "Unknown") + " />", A = " Did you accidentally export a JSX literal instead of a component?") : j = typeof s, _("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", j, A);
        }
        var F = Pn(s, d, g, I, O);
        if (F == null)
          return F;
        if (R) {
          var z = d.children;
          if (z !== void 0)
            if (E)
              if (At(z)) {
                for (var ve = 0; ve < z.length; ve++)
                  Vr(z[ve], s);
                Object.freeze && Object.freeze(z);
              } else
                _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
            else
              Vr(z, s);
        }
        if (xe.call(d, "key")) {
          var le = $(s), Y = Object.keys(d).filter(function(jn) {
            return jn !== "key";
          }), It = Y.length > 0 ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}";
          if (!jr[le + It]) {
            var Vn = Y.length > 0 ? "{" + Y.join(": ..., ") + ": ...}" : "{}";
            _(`A props object containing a "key" prop is being spread into JSX:
  let props = %s;
  <%s {...props} />
React keys must be passed directly to JSX without using spread:
  let props = %s;
  <%s key={someKey} {...props} />`, It, le, Vn, le), jr[le + It] = !0;
          }
        }
        return s === i ? kn(F) : Rn(F), F;
      }
    }
    function In(s, d, g) {
      return Fr(s, d, g, !0);
    }
    function On(s, d, g) {
      return Fr(s, d, g, !1);
    }
    var Cn = On, Dn = In;
    ke.Fragment = i, ke.jsx = Cn, ke.jsxs = Dn;
  }()), ke;
}
process.env.NODE_ENV === "production" ? Nt.exports = Un() : Nt.exports = $n();
var Bn = Nt.exports;
const Sa = ({ children: e }) => /* @__PURE__ */ Bn.jsx("div", { className: "swipe-card", children: e });
function Yn(e, t, r) {
  return Math.max(t, Math.min(e, r));
}
const C = {
  toVector(e, t) {
    return e === void 0 && (e = t), Array.isArray(e) ? e : [e, e];
  },
  add(e, t) {
    return [e[0] + t[0], e[1] + t[1]];
  },
  sub(e, t) {
    return [e[0] - t[0], e[1] - t[1]];
  },
  addTo(e, t) {
    e[0] += t[0], e[1] += t[1];
  },
  subTo(e, t) {
    e[0] -= t[0], e[1] -= t[1];
  }
};
function Lr(e, t, r) {
  return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(e, r * 5) : e * t * r / (t + r * e);
}
function Ur(e, t, r, i = 0.15) {
  return i === 0 ? Yn(e, t, r) : e < t ? -Lr(t - e, r - t, i) + t : e > r ? +Lr(e - r, r - t, i) + r : e;
}
function qn(e, [t, r], [i, n]) {
  const [[o, a], [u, l]] = e;
  return [Ur(t, o, a, i), Ur(r, u, l, n)];
}
function Kn(e, t) {
  if (typeof e != "object" || e === null) return e;
  var r = e[Symbol.toPrimitive];
  if (r !== void 0) {
    var i = r.call(e, t);
    if (typeof i != "object") return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (t === "string" ? String : Number)(e);
}
function Wn(e) {
  var t = Kn(e, "string");
  return typeof t == "symbol" ? t : String(t);
}
function M(e, t, r) {
  return t = Wn(t), t in e ? Object.defineProperty(e, t, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = r, e;
}
function $r(e, t) {
  var r = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var i = Object.getOwnPropertySymbols(e);
    t && (i = i.filter(function(n) {
      return Object.getOwnPropertyDescriptor(e, n).enumerable;
    })), r.push.apply(r, i);
  }
  return r;
}
function D(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t] != null ? arguments[t] : {};
    t % 2 ? $r(Object(r), !0).forEach(function(i) {
      M(e, i, r[i]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : $r(Object(r)).forEach(function(i) {
      Object.defineProperty(e, i, Object.getOwnPropertyDescriptor(r, i));
    });
  }
  return e;
}
const wi = {
  pointer: {
    start: "down",
    change: "move",
    end: "up"
  },
  mouse: {
    start: "down",
    change: "move",
    end: "up"
  },
  touch: {
    start: "start",
    change: "move",
    end: "end"
  },
  gesture: {
    start: "start",
    change: "change",
    end: "end"
  }
};
function Br(e) {
  return e ? e[0].toUpperCase() + e.slice(1) : "";
}
const zn = ["enter", "leave"];
function Gn(e = !1, t) {
  return e && !zn.includes(t);
}
function Hn(e, t = "", r = !1) {
  const i = wi[e], n = i && i[t] || t;
  return "on" + Br(e) + Br(n) + (Gn(r, n) ? "Capture" : "");
}
const Qn = ["gotpointercapture", "lostpointercapture"];
function Xn(e) {
  let t = e.substring(2).toLowerCase();
  const r = !!~t.indexOf("passive");
  r && (t = t.replace("passive", ""));
  const i = Qn.includes(t) ? "capturecapture" : "capture", n = !!~t.indexOf(i);
  return n && (t = t.replace("capture", "")), {
    device: t,
    capture: n,
    passive: r
  };
}
function Jn(e, t = "") {
  const r = wi[e], i = r && r[t] || t;
  return e + i;
}
function pt(e) {
  return "touches" in e;
}
function Ei(e) {
  return pt(e) ? "touch" : "pointerType" in e ? e.pointerType : "mouse";
}
function Zn(e) {
  return Array.from(e.touches).filter((t) => {
    var r, i;
    return t.target === e.currentTarget || ((r = e.currentTarget) === null || r === void 0 || (i = r.contains) === null || i === void 0 ? void 0 : i.call(r, t.target));
  });
}
function es(e) {
  return e.type === "touchend" || e.type === "touchcancel" ? e.changedTouches : e.targetTouches;
}
function Si(e) {
  return pt(e) ? es(e)[0] : e;
}
function Lt(e, t) {
  try {
    const r = t.clientX - e.clientX, i = t.clientY - e.clientY, n = (t.clientX + e.clientX) / 2, o = (t.clientY + e.clientY) / 2, a = Math.hypot(r, i);
    return {
      angle: -(Math.atan2(r, i) * 180) / Math.PI,
      distance: a,
      origin: [n, o]
    };
  } catch {
  }
  return null;
}
function ts(e) {
  return Zn(e).map((t) => t.identifier);
}
function Yr(e, t) {
  const [r, i] = Array.from(e.touches).filter((n) => t.includes(n.identifier));
  return Lt(r, i);
}
function Ot(e) {
  const t = Si(e);
  return pt(e) ? t.identifier : t.pointerId;
}
function Se(e) {
  const t = Si(e);
  return [t.clientX, t.clientY];
}
const qr = 40, Kr = 800;
function Ti(e) {
  let {
    deltaX: t,
    deltaY: r,
    deltaMode: i
  } = e;
  return i === 1 ? (t *= qr, r *= qr) : i === 2 && (t *= Kr, r *= Kr), [t, r];
}
function rs(e) {
  var t, r;
  const {
    scrollX: i,
    scrollY: n,
    scrollLeft: o,
    scrollTop: a
  } = e.currentTarget;
  return [(t = i ?? o) !== null && t !== void 0 ? t : 0, (r = n ?? a) !== null && r !== void 0 ? r : 0];
}
function is(e) {
  const t = {};
  if ("buttons" in e && (t.buttons = e.buttons), "shiftKey" in e) {
    const {
      shiftKey: r,
      altKey: i,
      metaKey: n,
      ctrlKey: o
    } = e;
    Object.assign(t, {
      shiftKey: r,
      altKey: i,
      metaKey: n,
      ctrlKey: o
    });
  }
  return t;
}
function ct(e, ...t) {
  return typeof e == "function" ? e(...t) : e;
}
function ns() {
}
function ss(...e) {
  return e.length === 0 ? ns : e.length === 1 ? e[0] : function() {
    let t;
    for (const r of e)
      t = r.apply(this, arguments) || t;
    return t;
  };
}
function Wr(e, t) {
  return Object.assign({}, t, e || {});
}
const os = 32;
class Pi {
  constructor(t, r, i) {
    this.ctrl = t, this.args = r, this.key = i, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
  }
  get state() {
    return this.ctrl.state[this.key];
  }
  set state(t) {
    this.ctrl.state[this.key] = t;
  }
  get shared() {
    return this.ctrl.state.shared;
  }
  get eventStore() {
    return this.ctrl.gestureEventStores[this.key];
  }
  get timeoutStore() {
    return this.ctrl.gestureTimeoutStores[this.key];
  }
  get config() {
    return this.ctrl.config[this.key];
  }
  get sharedConfig() {
    return this.ctrl.config.shared;
  }
  get handler() {
    return this.ctrl.handlers[this.key];
  }
  reset() {
    const {
      state: t,
      shared: r,
      ingKey: i,
      args: n
    } = this;
    r[i] = t._active = t.active = t._blocked = t._force = !1, t._step = [!1, !1], t.intentional = !1, t._movement = [0, 0], t._distance = [0, 0], t._direction = [0, 0], t._delta = [0, 0], t._bounds = [[-1 / 0, 1 / 0], [-1 / 0, 1 / 0]], t.args = n, t.axis = void 0, t.memo = void 0, t.elapsedTime = t.timeDelta = 0, t.direction = [0, 0], t.distance = [0, 0], t.overflow = [0, 0], t._movementBound = [!1, !1], t.velocity = [0, 0], t.movement = [0, 0], t.delta = [0, 0], t.timeStamp = 0;
  }
  start(t) {
    const r = this.state, i = this.config;
    r._active || (this.reset(), this.computeInitial(), r._active = !0, r.target = t.target, r.currentTarget = t.currentTarget, r.lastOffset = i.from ? ct(i.from, r) : r.offset, r.offset = r.lastOffset, r.startTime = r.timeStamp = t.timeStamp);
  }
  computeValues(t) {
    const r = this.state;
    r._values = t, r.values = this.config.transform(t);
  }
  computeInitial() {
    const t = this.state;
    t._initial = t._values, t.initial = t.values;
  }
  compute(t) {
    const {
      state: r,
      config: i,
      shared: n
    } = this;
    r.args = this.args;
    let o = 0;
    if (t && (r.event = t, i.preventDefault && t.cancelable && r.event.preventDefault(), r.type = t.type, n.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, n.locked = !!document.pointerLockElement, Object.assign(n, is(t)), n.down = n.pressed = n.buttons % 2 === 1 || n.touches > 0, o = t.timeStamp - r.timeStamp, r.timeStamp = t.timeStamp, r.elapsedTime = r.timeStamp - r.startTime), r._active) {
      const N = r._delta.map(Math.abs);
      C.addTo(r._distance, N);
    }
    this.axisIntent && this.axisIntent(t);
    const [a, u] = r._movement, [l, c] = i.threshold, {
      _step: f,
      values: p
    } = r;
    if (i.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(a) >= l && p[0]), f[1] === !1 && (f[1] = Math.abs(u) >= c && p[1])) : (f[0] === !1 && (f[0] = Math.abs(a) >= l && Math.sign(a) * l), f[1] === !1 && (f[1] = Math.abs(u) >= c && Math.sign(u) * c)), r.intentional = f[0] !== !1 || f[1] !== !1, !r.intentional) return;
    const m = [0, 0];
    if (i.hasCustomTransform) {
      const [N, L] = p;
      m[0] = f[0] !== !1 ? N - f[0] : 0, m[1] = f[1] !== !1 ? L - f[1] : 0;
    } else
      m[0] = f[0] !== !1 ? a - f[0] : 0, m[1] = f[1] !== !1 ? u - f[1] : 0;
    this.restrictToAxis && !r._blocked && this.restrictToAxis(m);
    const y = r.offset, w = r._active && !r._blocked || r.active;
    w && (r.first = r._active && !r.active, r.last = !r._active && r.active, r.active = n[this.ingKey] = r._active, t && (r.first && ("bounds" in i && (r._bounds = ct(i.bounds, r)), this.setup && this.setup()), r.movement = m, this.computeOffset()));
    const [b, T] = r.offset, [[v, _], [S, k]] = r._bounds;
    r.overflow = [b < v ? -1 : b > _ ? 1 : 0, T < S ? -1 : T > k ? 1 : 0], r._movementBound[0] = r.overflow[0] ? r._movementBound[0] === !1 ? r._movement[0] : r._movementBound[0] : !1, r._movementBound[1] = r.overflow[1] ? r._movementBound[1] === !1 ? r._movement[1] : r._movementBound[1] : !1;
    const V = r._active ? i.rubberband || [0, 0] : [0, 0];
    if (r.offset = qn(r._bounds, r.offset, V), r.delta = C.sub(r.offset, y), this.computeMovement(), w && (!r.last || o > os)) {
      r.delta = C.sub(r.offset, y);
      const N = r.delta.map(Math.abs);
      C.addTo(r.distance, N), r.direction = r.delta.map(Math.sign), r._direction = r._delta.map(Math.sign), !r.first && o > 0 && (r.velocity = [N[0] / o, N[1] / o], r.timeDelta = o);
    }
  }
  emit() {
    const t = this.state, r = this.shared, i = this.config;
    if (t._active || this.clean(), (t._blocked || !t.intentional) && !t._force && !i.triggerAllEvents) return;
    const n = this.handler(D(D(D({}, r), t), {}, {
      [this.aliasKey]: t.values
    }));
    n !== void 0 && (t.memo = n);
  }
  clean() {
    this.eventStore.clean(), this.timeoutStore.clean();
  }
}
function as([e, t], r) {
  const i = Math.abs(e), n = Math.abs(t);
  if (i > n && i > r)
    return "x";
  if (n > i && n > r)
    return "y";
}
class He extends Pi {
  constructor(...t) {
    super(...t), M(this, "aliasKey", "xy");
  }
  reset() {
    super.reset(), this.state.axis = void 0;
  }
  init() {
    this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
  }
  computeOffset() {
    this.state.offset = C.add(this.state.lastOffset, this.state.movement);
  }
  computeMovement() {
    this.state.movement = C.sub(this.state.offset, this.state.lastOffset);
  }
  axisIntent(t) {
    const r = this.state, i = this.config;
    if (!r.axis && t) {
      const n = typeof i.axisThreshold == "object" ? i.axisThreshold[Ei(t)] : i.axisThreshold;
      r.axis = as(r._movement, n);
    }
    r._blocked = (i.lockDirection || !!i.axis) && !r.axis || !!i.axis && i.axis !== r.axis;
  }
  restrictToAxis(t) {
    if (this.config.axis || this.config.lockDirection)
      switch (this.state.axis) {
        case "x":
          t[1] = 0;
          break;
        case "y":
          t[0] = 0;
          break;
      }
  }
}
const zr = (e) => e, Gr = 0.15, Jt = {
  enabled(e = !0) {
    return e;
  },
  eventOptions(e, t, r) {
    return D(D({}, r.shared.eventOptions), e);
  },
  preventDefault(e = !1) {
    return e;
  },
  triggerAllEvents(e = !1) {
    return e;
  },
  rubberband(e = 0) {
    switch (e) {
      case !0:
        return [Gr, Gr];
      case !1:
        return [0, 0];
      default:
        return C.toVector(e);
    }
  },
  from(e) {
    if (typeof e == "function") return e;
    if (e != null) return C.toVector(e);
  },
  transform(e, t, r) {
    const i = e || r.shared.transform;
    if (this.hasCustomTransform = !!i, process.env.NODE_ENV === "development") {
      const n = i || zr;
      return (o) => {
        const a = n(o);
        return (!isFinite(a[0]) || !isFinite(a[1])) && console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`), a;
      };
    }
    return i || zr;
  },
  threshold(e) {
    return C.toVector(e, 0);
  }
};
process.env.NODE_ENV === "development" && Object.assign(Jt, {
  domTarget(e) {
    if (e !== void 0)
      throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
    return NaN;
  },
  lockDirection(e) {
    if (e !== void 0)
      throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");
    return NaN;
  },
  initial(e) {
    if (e !== void 0)
      throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");
    return NaN;
  }
});
const us = 0, pe = D(D({}, Jt), {}, {
  axis(e, t, {
    axis: r
  }) {
    if (this.lockDirection = r === "lock", !this.lockDirection) return r;
  },
  axisThreshold(e = us) {
    return e;
  },
  bounds(e = {}) {
    if (typeof e == "function")
      return (o) => pe.bounds(e(o));
    if ("current" in e)
      return () => e.current;
    if (typeof HTMLElement == "function" && e instanceof HTMLElement)
      return e;
    const {
      left: t = -1 / 0,
      right: r = 1 / 0,
      top: i = -1 / 0,
      bottom: n = 1 / 0
    } = e;
    return [[t, r], [i, n]];
  }
}), Hr = {
  ArrowRight: (e, t = 1) => [e * t, 0],
  ArrowLeft: (e, t = 1) => [-1 * e * t, 0],
  ArrowUp: (e, t = 1) => [0, -1 * e * t],
  ArrowDown: (e, t = 1) => [0, e * t]
};
class cs extends He {
  constructor(...t) {
    super(...t), M(this, "ingKey", "dragging");
  }
  reset() {
    super.reset();
    const t = this.state;
    t._pointerId = void 0, t._pointerActive = !1, t._keyboardActive = !1, t._preventScroll = !1, t._delayed = !1, t.swipe = [0, 0], t.tap = !1, t.canceled = !1, t.cancel = this.cancel.bind(this);
  }
  setup() {
    const t = this.state;
    if (t._bounds instanceof HTMLElement) {
      const r = t._bounds.getBoundingClientRect(), i = t.currentTarget.getBoundingClientRect(), n = {
        left: r.left - i.left + t.offset[0],
        right: r.right - i.right + t.offset[0],
        top: r.top - i.top + t.offset[1],
        bottom: r.bottom - i.bottom + t.offset[1]
      };
      t._bounds = pe.bounds(n);
    }
  }
  cancel() {
    const t = this.state;
    t.canceled || (t.canceled = !0, t._active = !1, setTimeout(() => {
      this.compute(), this.emit();
    }, 0));
  }
  setActive() {
    this.state._active = this.state._pointerActive || this.state._keyboardActive;
  }
  clean() {
    this.pointerClean(), this.state._pointerActive = !1, this.state._keyboardActive = !1, super.clean();
  }
  pointerDown(t) {
    const r = this.config, i = this.state;
    if (t.buttons != null && (Array.isArray(r.pointerButtons) ? !r.pointerButtons.includes(t.buttons) : r.pointerButtons !== -1 && r.pointerButtons !== t.buttons)) return;
    const n = this.ctrl.setEventIds(t);
    r.pointerCapture && t.target.setPointerCapture(t.pointerId), !(n && n.size > 1 && i._pointerActive) && (this.start(t), this.setupPointer(t), i._pointerId = Ot(t), i._pointerActive = !0, this.computeValues(Se(t)), this.computeInitial(), r.preventScrollAxis && Ei(t) !== "mouse" ? (i._active = !1, this.setupScrollPrevention(t)) : r.delay > 0 ? (this.setupDelayTrigger(t), r.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
  }
  startPointerDrag(t) {
    const r = this.state;
    r._active = !0, r._preventScroll = !0, r._delayed = !1, this.compute(t), this.emit();
  }
  pointerMove(t) {
    const r = this.state, i = this.config;
    if (!r._pointerActive) return;
    const n = Ot(t);
    if (r._pointerId !== void 0 && n !== r._pointerId) return;
    const o = Se(t);
    if (document.pointerLockElement === t.target ? r._delta = [t.movementX, t.movementY] : (r._delta = C.sub(o, r._values), this.computeValues(o)), C.addTo(r._movement, r._delta), this.compute(t), r._delayed && r.intentional) {
      this.timeoutStore.remove("dragDelay"), r.active = !1, this.startPointerDrag(t);
      return;
    }
    if (i.preventScrollAxis && !r._preventScroll)
      if (r.axis)
        if (r.axis === i.preventScrollAxis || i.preventScrollAxis === "xy") {
          r._active = !1, this.clean();
          return;
        } else {
          this.timeoutStore.remove("startPointerDrag"), this.startPointerDrag(t);
          return;
        }
      else
        return;
    this.emit();
  }
  pointerUp(t) {
    this.ctrl.setEventIds(t);
    try {
      this.config.pointerCapture && t.target.hasPointerCapture(t.pointerId) && t.target.releasePointerCapture(t.pointerId);
    } catch {
      process.env.NODE_ENV === "development" && console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.");
    }
    const r = this.state, i = this.config;
    if (!r._active || !r._pointerActive) return;
    const n = Ot(t);
    if (r._pointerId !== void 0 && n !== r._pointerId) return;
    this.state._pointerActive = !1, this.setActive(), this.compute(t);
    const [o, a] = r._distance;
    if (r.tap = o <= i.tapsThreshold && a <= i.tapsThreshold, r.tap && i.filterTaps)
      r._force = !0;
    else {
      const [u, l] = r._delta, [c, f] = r._movement, [p, m] = i.swipe.velocity, [y, w] = i.swipe.distance, b = i.swipe.duration;
      if (r.elapsedTime < b) {
        const T = Math.abs(u / r.timeDelta), v = Math.abs(l / r.timeDelta);
        T > p && Math.abs(c) > y && (r.swipe[0] = Math.sign(u)), v > m && Math.abs(f) > w && (r.swipe[1] = Math.sign(l));
      }
    }
    this.emit();
  }
  pointerClick(t) {
    !this.state.tap && t.detail > 0 && (t.preventDefault(), t.stopPropagation());
  }
  setupPointer(t) {
    const r = this.config, i = r.device;
    if (process.env.NODE_ENV === "development")
      try {
        if (i === "pointer" && r.preventScrollDelay === void 0) {
          const n = "uv" in t ? t.sourceEvent.currentTarget : t.currentTarget;
          window.getComputedStyle(n).touchAction === "auto" && console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.", n);
        }
      } catch {
      }
    r.pointerLock && t.currentTarget.requestPointerLock(), r.pointerCapture || (this.eventStore.add(this.sharedConfig.window, i, "change", this.pointerMove.bind(this)), this.eventStore.add(this.sharedConfig.window, i, "end", this.pointerUp.bind(this)), this.eventStore.add(this.sharedConfig.window, i, "cancel", this.pointerUp.bind(this)));
  }
  pointerClean() {
    this.config.pointerLock && document.pointerLockElement === this.state.currentTarget && document.exitPointerLock();
  }
  preventScroll(t) {
    this.state._preventScroll && t.cancelable && t.preventDefault();
  }
  setupScrollPrevention(t) {
    this.state._preventScroll = !1, ls(t);
    const r = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
      passive: !1
    });
    this.eventStore.add(this.sharedConfig.window, "touch", "end", r), this.eventStore.add(this.sharedConfig.window, "touch", "cancel", r), this.timeoutStore.add("startPointerDrag", this.startPointerDrag.bind(this), this.config.preventScrollDelay, t);
  }
  setupDelayTrigger(t) {
    this.state._delayed = !0, this.timeoutStore.add("dragDelay", () => {
      this.state._step = [0, 0], this.startPointerDrag(t);
    }, this.config.delay);
  }
  keyDown(t) {
    const r = Hr[t.key];
    if (r) {
      const i = this.state, n = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
      this.start(t), i._delta = r(this.config.keyboardDisplacement, n), i._keyboardActive = !0, C.addTo(i._movement, i._delta), this.compute(t), this.emit();
    }
  }
  keyUp(t) {
    t.key in Hr && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
  }
  bind(t) {
    const r = this.config.device;
    t(r, "start", this.pointerDown.bind(this)), this.config.pointerCapture && (t(r, "change", this.pointerMove.bind(this)), t(r, "end", this.pointerUp.bind(this)), t(r, "cancel", this.pointerUp.bind(this)), t("lostPointerCapture", "", this.pointerUp.bind(this))), this.config.keys && (t("key", "down", this.keyDown.bind(this)), t("key", "up", this.keyUp.bind(this))), this.config.filterTaps && t("click", "", this.pointerClick.bind(this), {
      capture: !0,
      passive: !1
    });
  }
}
function ls(e) {
  "persist" in e && typeof e.persist == "function" && e.persist();
}
const Qe = typeof window < "u" && window.document && window.document.createElement;
function Ai() {
  return Qe && "ontouchstart" in window;
}
function fs() {
  return Ai() || Qe && window.navigator.maxTouchPoints > 1;
}
function ds() {
  return Qe && "onpointerdown" in window;
}
function hs() {
  return Qe && "exitPointerLock" in window.document;
}
function ps() {
  try {
    return "constructor" in GestureEvent;
  } catch {
    return !1;
  }
}
const G = {
  isBrowser: Qe,
  gesture: ps(),
  touch: Ai(),
  touchscreen: fs(),
  pointer: ds(),
  pointerLock: hs()
}, ms = 250, gs = 180, vs = 0.5, ys = 50, _s = 250, bs = 10, Qr = {
  mouse: 0,
  touch: 0,
  pen: 8
}, xi = D(D({}, pe), {}, {
  device(e, t, {
    pointer: {
      touch: r = !1,
      lock: i = !1,
      mouse: n = !1
    } = {}
  }) {
    return this.pointerLock = i && G.pointerLock, G.touch && r ? "touch" : this.pointerLock ? "mouse" : G.pointer && !n ? "pointer" : G.touch ? "touch" : "mouse";
  },
  preventScrollAxis(e, t, {
    preventScroll: r
  }) {
    if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && e ? ms : void 0, !(!G.touchscreen || r === !1))
      return e || (r !== void 0 ? "y" : void 0);
  },
  pointerCapture(e, t, {
    pointer: {
      capture: r = !0,
      buttons: i = 1,
      keys: n = !0
    } = {}
  }) {
    return this.pointerButtons = i, this.keys = n, !this.pointerLock && this.device === "pointer" && r;
  },
  threshold(e, t, {
    filterTaps: r = !1,
    tapsThreshold: i = 3,
    axis: n = void 0
  }) {
    const o = C.toVector(e, r ? i : n ? 1 : 0);
    return this.filterTaps = r, this.tapsThreshold = i, o;
  },
  swipe({
    velocity: e = vs,
    distance: t = ys,
    duration: r = _s
  } = {}) {
    return {
      velocity: this.transform(C.toVector(e)),
      distance: this.transform(C.toVector(t)),
      duration: r
    };
  },
  delay(e = 0) {
    switch (e) {
      case !0:
        return gs;
      case !1:
        return 0;
      default:
        return e;
    }
  },
  axisThreshold(e) {
    return e ? D(D({}, Qr), e) : Qr;
  },
  keyboardDisplacement(e = bs) {
    return e;
  }
});
process.env.NODE_ENV === "development" && Object.assign(xi, {
  useTouch(e) {
    if (e !== void 0)
      throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");
    return NaN;
  },
  experimental_preventWindowScrollY(e) {
    if (e !== void 0)
      throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");
    return NaN;
  },
  swipeVelocity(e) {
    if (e !== void 0)
      throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");
    return NaN;
  },
  swipeDistance(e) {
    if (e !== void 0)
      throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");
    return NaN;
  },
  swipeDuration(e) {
    if (e !== void 0)
      throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");
    return NaN;
  }
});
function Ri(e) {
  const [t, r] = e.overflow, [i, n] = e._delta, [o, a] = e._direction;
  (t < 0 && i > 0 && o < 0 || t > 0 && i < 0 && o > 0) && (e._movement[0] = e._movementBound[0]), (r < 0 && n > 0 && a < 0 || r > 0 && n < 0 && a > 0) && (e._movement[1] = e._movementBound[1]);
}
const ws = 30, Es = 100;
class Ss extends Pi {
  constructor(...t) {
    super(...t), M(this, "ingKey", "pinching"), M(this, "aliasKey", "da");
  }
  init() {
    this.state.offset = [1, 0], this.state.lastOffset = [1, 0], this.state._pointerEvents = /* @__PURE__ */ new Map();
  }
  reset() {
    super.reset();
    const t = this.state;
    t._touchIds = [], t.canceled = !1, t.cancel = this.cancel.bind(this), t.turns = 0;
  }
  computeOffset() {
    const {
      type: t,
      movement: r,
      lastOffset: i
    } = this.state;
    t === "wheel" ? this.state.offset = C.add(r, i) : this.state.offset = [(1 + r[0]) * i[0], r[1] + i[1]];
  }
  computeMovement() {
    const {
      offset: t,
      lastOffset: r
    } = this.state;
    this.state.movement = [t[0] / r[0], t[1] - r[1]];
  }
  axisIntent() {
    const t = this.state, [r, i] = t._movement;
    if (!t.axis) {
      const n = Math.abs(r) * ws - Math.abs(i);
      n < 0 ? t.axis = "angle" : n > 0 && (t.axis = "scale");
    }
  }
  restrictToAxis(t) {
    this.config.lockDirection && (this.state.axis === "scale" ? t[1] = 0 : this.state.axis === "angle" && (t[0] = 0));
  }
  cancel() {
    const t = this.state;
    t.canceled || setTimeout(() => {
      t.canceled = !0, t._active = !1, this.compute(), this.emit();
    }, 0);
  }
  touchStart(t) {
    this.ctrl.setEventIds(t);
    const r = this.state, i = this.ctrl.touchIds;
    if (r._active && r._touchIds.every((o) => i.has(o)) || i.size < 2) return;
    this.start(t), r._touchIds = Array.from(i).slice(0, 2);
    const n = Yr(t, r._touchIds);
    n && this.pinchStart(t, n);
  }
  pointerStart(t) {
    if (t.buttons != null && t.buttons % 2 !== 1) return;
    this.ctrl.setEventIds(t), t.target.setPointerCapture(t.pointerId);
    const r = this.state, i = r._pointerEvents, n = this.ctrl.pointerIds;
    if (r._active && Array.from(i.keys()).every((a) => n.has(a)) || (i.size < 2 && i.set(t.pointerId, t), r._pointerEvents.size < 2)) return;
    this.start(t);
    const o = Lt(...Array.from(i.values()));
    o && this.pinchStart(t, o);
  }
  pinchStart(t, r) {
    const i = this.state;
    i.origin = r.origin, this.computeValues([r.distance, r.angle]), this.computeInitial(), this.compute(t), this.emit();
  }
  touchMove(t) {
    if (!this.state._active) return;
    const r = Yr(t, this.state._touchIds);
    r && this.pinchMove(t, r);
  }
  pointerMove(t) {
    const r = this.state._pointerEvents;
    if (r.has(t.pointerId) && r.set(t.pointerId, t), !this.state._active) return;
    const i = Lt(...Array.from(r.values()));
    i && this.pinchMove(t, i);
  }
  pinchMove(t, r) {
    const i = this.state, n = i._values[1], o = r.angle - n;
    let a = 0;
    Math.abs(o) > 270 && (a += Math.sign(o)), this.computeValues([r.distance, r.angle - 360 * a]), i.origin = r.origin, i.turns = a, i._movement = [i._values[0] / i._initial[0] - 1, i._values[1] - i._initial[1]], this.compute(t), this.emit();
  }
  touchEnd(t) {
    this.ctrl.setEventIds(t), this.state._active && this.state._touchIds.some((r) => !this.ctrl.touchIds.has(r)) && (this.state._active = !1, this.compute(t), this.emit());
  }
  pointerEnd(t) {
    const r = this.state;
    this.ctrl.setEventIds(t);
    try {
      t.target.releasePointerCapture(t.pointerId);
    } catch {
    }
    r._pointerEvents.has(t.pointerId) && r._pointerEvents.delete(t.pointerId), r._active && r._pointerEvents.size < 2 && (r._active = !1, this.compute(t), this.emit());
  }
  gestureStart(t) {
    t.cancelable && t.preventDefault();
    const r = this.state;
    r._active || (this.start(t), this.computeValues([t.scale, t.rotation]), r.origin = [t.clientX, t.clientY], this.compute(t), this.emit());
  }
  gestureMove(t) {
    if (t.cancelable && t.preventDefault(), !this.state._active) return;
    const r = this.state;
    this.computeValues([t.scale, t.rotation]), r.origin = [t.clientX, t.clientY];
    const i = r._movement;
    r._movement = [t.scale - 1, t.rotation], r._delta = C.sub(r._movement, i), this.compute(t), this.emit();
  }
  gestureEnd(t) {
    this.state._active && (this.state._active = !1, this.compute(t), this.emit());
  }
  wheel(t) {
    const r = this.config.modifierKey;
    r && (Array.isArray(r) ? !r.find((i) => t[i]) : !t[r]) || (this.state._active ? this.wheelChange(t) : this.wheelStart(t), this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this)));
  }
  wheelStart(t) {
    this.start(t), this.wheelChange(t);
  }
  wheelChange(t) {
    "uv" in t || (t.cancelable && t.preventDefault(), process.env.NODE_ENV === "development" && !t.defaultPrevented && console.warn("[@use-gesture]: To properly support zoom on trackpads, try using the `target` option.\n\nThis message will only appear in development mode."));
    const i = this.state;
    i._delta = [-Ti(t)[1] / Es * i.offset[0], 0], C.addTo(i._movement, i._delta), Ri(i), this.state.origin = [t.clientX, t.clientY], this.compute(t), this.emit();
  }
  wheelEnd() {
    this.state._active && (this.state._active = !1, this.compute(), this.emit());
  }
  bind(t) {
    const r = this.config.device;
    r && (t(r, "start", this[r + "Start"].bind(this)), t(r, "change", this[r + "Move"].bind(this)), t(r, "end", this[r + "End"].bind(this)), t(r, "cancel", this[r + "End"].bind(this)), t("lostPointerCapture", "", this[r + "End"].bind(this))), this.config.pinchOnWheel && t("wheel", "", this.wheel.bind(this), {
      passive: !1
    });
  }
}
const Ts = D(D({}, Jt), {}, {
  device(e, t, {
    shared: r,
    pointer: {
      touch: i = !1
    } = {}
  }) {
    if (r.target && !G.touch && G.gesture) return "gesture";
    if (G.touch && i) return "touch";
    if (G.touchscreen) {
      if (G.pointer) return "pointer";
      if (G.touch) return "touch";
    }
  },
  bounds(e, t, {
    scaleBounds: r = {},
    angleBounds: i = {}
  }) {
    const n = (a) => {
      const u = Wr(ct(r, a), {
        min: -1 / 0,
        max: 1 / 0
      });
      return [u.min, u.max];
    }, o = (a) => {
      const u = Wr(ct(i, a), {
        min: -1 / 0,
        max: 1 / 0
      });
      return [u.min, u.max];
    };
    return typeof r != "function" && typeof i != "function" ? [n(), o()] : (a) => [n(a), o(a)];
  },
  threshold(e, t, r) {
    return this.lockDirection = r.axis === "lock", C.toVector(e, this.lockDirection ? [0.1, 3] : 0);
  },
  modifierKey(e) {
    return e === void 0 ? "ctrlKey" : e;
  },
  pinchOnWheel(e = !0) {
    return e;
  }
});
class Ps extends He {
  constructor(...t) {
    super(...t), M(this, "ingKey", "moving");
  }
  move(t) {
    this.config.mouseOnly && t.pointerType !== "mouse" || (this.state._active ? this.moveChange(t) : this.moveStart(t), this.timeoutStore.add("moveEnd", this.moveEnd.bind(this)));
  }
  moveStart(t) {
    this.start(t), this.computeValues(Se(t)), this.compute(t), this.computeInitial(), this.emit();
  }
  moveChange(t) {
    if (!this.state._active) return;
    const r = Se(t), i = this.state;
    i._delta = C.sub(r, i._values), C.addTo(i._movement, i._delta), this.computeValues(r), this.compute(t), this.emit();
  }
  moveEnd(t) {
    this.state._active && (this.state._active = !1, this.compute(t), this.emit());
  }
  bind(t) {
    t("pointer", "change", this.move.bind(this)), t("pointer", "leave", this.moveEnd.bind(this));
  }
}
const As = D(D({}, pe), {}, {
  mouseOnly: (e = !0) => e
});
class xs extends He {
  constructor(...t) {
    super(...t), M(this, "ingKey", "scrolling");
  }
  scroll(t) {
    this.state._active || this.start(t), this.scrollChange(t), this.timeoutStore.add("scrollEnd", this.scrollEnd.bind(this));
  }
  scrollChange(t) {
    t.cancelable && t.preventDefault();
    const r = this.state, i = rs(t);
    r._delta = C.sub(i, r._values), C.addTo(r._movement, r._delta), this.computeValues(i), this.compute(t), this.emit();
  }
  scrollEnd() {
    this.state._active && (this.state._active = !1, this.compute(), this.emit());
  }
  bind(t) {
    t("scroll", "", this.scroll.bind(this));
  }
}
const Rs = pe;
class ks extends He {
  constructor(...t) {
    super(...t), M(this, "ingKey", "wheeling");
  }
  wheel(t) {
    this.state._active || this.start(t), this.wheelChange(t), this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this));
  }
  wheelChange(t) {
    const r = this.state;
    r._delta = Ti(t), C.addTo(r._movement, r._delta), Ri(r), this.compute(t), this.emit();
  }
  wheelEnd() {
    this.state._active && (this.state._active = !1, this.compute(), this.emit());
  }
  bind(t) {
    t("wheel", "", this.wheel.bind(this));
  }
}
const Is = pe;
class Os extends He {
  constructor(...t) {
    super(...t), M(this, "ingKey", "hovering");
  }
  enter(t) {
    this.config.mouseOnly && t.pointerType !== "mouse" || (this.start(t), this.computeValues(Se(t)), this.compute(t), this.emit());
  }
  leave(t) {
    if (this.config.mouseOnly && t.pointerType !== "mouse") return;
    const r = this.state;
    if (!r._active) return;
    r._active = !1;
    const i = Se(t);
    r._movement = r._delta = C.sub(i, r._values), this.computeValues(i), this.compute(t), r.delta = r.movement, this.emit();
  }
  bind(t) {
    t("pointer", "enter", this.enter.bind(this)), t("pointer", "leave", this.leave.bind(this));
  }
}
const Cs = D(D({}, pe), {}, {
  mouseOnly: (e = !0) => e
}), Zt = /* @__PURE__ */ new Map(), Ut = /* @__PURE__ */ new Map();
function Ds(e) {
  Zt.set(e.key, e.engine), Ut.set(e.key, e.resolver);
}
const Vs = {
  key: "drag",
  engine: cs,
  resolver: xi
}, js = {
  key: "hover",
  engine: Os,
  resolver: Cs
}, Fs = {
  key: "move",
  engine: Ps,
  resolver: As
}, Ms = {
  key: "pinch",
  engine: Ss,
  resolver: Ts
}, Ns = {
  key: "scroll",
  engine: xs,
  resolver: Rs
}, Ls = {
  key: "wheel",
  engine: ks,
  resolver: Is
};
function Us(e, t) {
  if (e == null) return {};
  var r = {}, i = Object.keys(e), n, o;
  for (o = 0; o < i.length; o++)
    n = i[o], !(t.indexOf(n) >= 0) && (r[n] = e[n]);
  return r;
}
function $s(e, t) {
  if (e == null) return {};
  var r = Us(e, t), i, n;
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(e);
    for (n = 0; n < o.length; n++)
      i = o[n], !(t.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(e, i) && (r[i] = e[i]);
  }
  return r;
}
const Bs = {
  target(e) {
    if (e)
      return () => "current" in e ? e.current : e;
  },
  enabled(e = !0) {
    return e;
  },
  window(e = G.isBrowser ? window : void 0) {
    return e;
  },
  eventOptions({
    passive: e = !0,
    capture: t = !1
  } = {}) {
    return {
      passive: e,
      capture: t
    };
  },
  transform(e) {
    return e;
  }
}, Ys = ["target", "eventOptions", "window", "enabled", "transform"];
function ot(e = {}, t) {
  const r = {};
  for (const [i, n] of Object.entries(t))
    switch (typeof n) {
      case "function":
        if (process.env.NODE_ENV === "development") {
          const o = n.call(r, e[i], i, e);
          Number.isNaN(o) || (r[i] = o);
        } else
          r[i] = n.call(r, e[i], i, e);
        break;
      case "object":
        r[i] = ot(e[i], n);
        break;
      case "boolean":
        n && (r[i] = e[i]);
        break;
    }
  return r;
}
function qs(e, t, r = {}) {
  const i = e, {
    target: n,
    eventOptions: o,
    window: a,
    enabled: u,
    transform: l
  } = i, c = $s(i, Ys);
  if (r.shared = ot({
    target: n,
    eventOptions: o,
    window: a,
    enabled: u,
    transform: l
  }, Bs), t) {
    const f = Ut.get(t);
    r[t] = ot(D({
      shared: r.shared
    }, c), f);
  } else
    for (const f in c) {
      const p = Ut.get(f);
      if (p)
        r[f] = ot(D({
          shared: r.shared
        }, c[f]), p);
      else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(f)) {
        if (f === "domTarget")
          throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
        console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`);
      }
    }
  return r;
}
class ki {
  constructor(t, r) {
    M(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = r;
  }
  add(t, r, i, n, o) {
    const a = this._listeners, u = Jn(r, i), l = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, c = D(D({}, l), o);
    t.addEventListener(u, n, c);
    const f = () => {
      t.removeEventListener(u, n, c), a.delete(f);
    };
    return a.add(f), f;
  }
  clean() {
    this._listeners.forEach((t) => t()), this._listeners.clear();
  }
}
class Ks {
  constructor() {
    M(this, "_timeouts", /* @__PURE__ */ new Map());
  }
  add(t, r, i = 140, ...n) {
    this.remove(t), this._timeouts.set(t, window.setTimeout(r, i, ...n));
  }
  remove(t) {
    const r = this._timeouts.get(t);
    r && window.clearTimeout(r);
  }
  clean() {
    this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
  }
}
let Ws = class {
  constructor(t) {
    M(this, "gestures", /* @__PURE__ */ new Set()), M(this, "_targetEventStore", new ki(this)), M(this, "gestureEventStores", {}), M(this, "gestureTimeoutStores", {}), M(this, "handlers", {}), M(this, "config", {}), M(this, "pointerIds", /* @__PURE__ */ new Set()), M(this, "touchIds", /* @__PURE__ */ new Set()), M(this, "state", {
      shared: {
        shiftKey: !1,
        metaKey: !1,
        ctrlKey: !1,
        altKey: !1
      }
    }), zs(this, t);
  }
  setEventIds(t) {
    if (pt(t))
      return this.touchIds = new Set(ts(t)), this.touchIds;
    if ("pointerId" in t)
      return t.type === "pointerup" || t.type === "pointercancel" ? this.pointerIds.delete(t.pointerId) : t.type === "pointerdown" && this.pointerIds.add(t.pointerId), this.pointerIds;
  }
  applyHandlers(t, r) {
    this.handlers = t, this.nativeHandlers = r;
  }
  applyConfig(t, r) {
    this.config = qs(t, r, this.config);
  }
  clean() {
    this._targetEventStore.clean();
    for (const t of this.gestures)
      this.gestureEventStores[t].clean(), this.gestureTimeoutStores[t].clean();
  }
  effect() {
    return this.config.shared.target && this.bind(), () => this._targetEventStore.clean();
  }
  bind(...t) {
    const r = this.config.shared, i = {};
    let n;
    if (!(r.target && (n = r.target(), !n))) {
      if (r.enabled) {
        for (const a of this.gestures) {
          const u = this.config[a], l = Xr(i, u.eventOptions, !!n);
          if (u.enabled) {
            const c = Zt.get(a);
            new c(this, t, a).bind(l);
          }
        }
        const o = Xr(i, r.eventOptions, !!n);
        for (const a in this.nativeHandlers)
          o(a, "", (u) => this.nativeHandlers[a](D(D({}, this.state.shared), {}, {
            event: u,
            args: t
          })), void 0, !0);
      }
      for (const o in i)
        i[o] = ss(...i[o]);
      if (!n) return i;
      for (const o in i) {
        const {
          device: a,
          capture: u,
          passive: l
        } = Xn(o);
        this._targetEventStore.add(n, a, "", i[o], {
          capture: u,
          passive: l
        });
      }
    }
  }
};
function ye(e, t) {
  e.gestures.add(t), e.gestureEventStores[t] = new ki(e, t), e.gestureTimeoutStores[t] = new Ks();
}
function zs(e, t) {
  t.drag && ye(e, "drag"), t.wheel && ye(e, "wheel"), t.scroll && ye(e, "scroll"), t.move && ye(e, "move"), t.pinch && ye(e, "pinch"), t.hover && ye(e, "hover");
}
const Xr = (e, t, r) => (i, n, o, a = {}, u = !1) => {
  var l, c;
  const f = (l = a.capture) !== null && l !== void 0 ? l : t.capture, p = (c = a.passive) !== null && c !== void 0 ? c : t.passive;
  let m = u ? i : Hn(i, n, f);
  r && p && (m += "Passive"), e[m] = e[m] || [], e[m].push(o);
}, Gs = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;
function Hs(e) {
  const t = {}, r = {}, i = /* @__PURE__ */ new Set();
  for (let n in e)
    Gs.test(n) ? (i.add(RegExp.lastMatch), r[n] = e[n]) : t[n] = e[n];
  return [r, t, i];
}
function _e(e, t, r, i, n, o) {
  if (!e.has(r)) return;
  if (!Zt.has(i)) {
    process.env.NODE_ENV === "development" && console.warn(`[@use-gesture]: You've created a custom handler that that uses the \`${i}\` gesture but isn't properly configured.

Please add \`${i}Action\` when creating your handler.`);
    return;
  }
  const a = r + "Start", u = r + "End", l = (c) => {
    let f;
    return c.first && a in t && t[a](c), r in t && (f = t[r](c)), c.last && u in t && t[u](c), f;
  };
  n[i] = l, o[i] = o[i] || {};
}
function Qs(e, t) {
  const [r, i, n] = Hs(e), o = {};
  return _e(n, r, "onDrag", "drag", o, t), _e(n, r, "onWheel", "wheel", o, t), _e(n, r, "onScroll", "scroll", o, t), _e(n, r, "onPinch", "pinch", o, t), _e(n, r, "onMove", "move", o, t), _e(n, r, "onHover", "hover", o, t), {
    handlers: o,
    config: t,
    nativeHandlers: i
  };
}
function Xs(e, t = {}, r, i) {
  const n = Ve.useMemo(() => new Ws(e), []);
  if (n.applyHandlers(e, i), n.applyConfig(t, r), Ve.useEffect(n.effect.bind(n)), Ve.useEffect(() => n.clean.bind(n), []), t.target === void 0)
    return n.bind.bind(n);
}
function Js(e) {
  return e.forEach(Ds), function(r, i) {
    const {
      handlers: n,
      nativeHandlers: o,
      config: a
    } = Qs(r, i || {});
    return Xs(n, a, void 0, o);
  };
}
function Zs(e, t) {
  return Js([Vs, Ms, Ns, Ls, Fs, js])(e, {});
}
var er = Je(), P = (e) => Xe(e, er), tr = Je();
P.write = (e) => Xe(e, tr);
var mt = Je();
P.onStart = (e) => Xe(e, mt);
var rr = Je();
P.onFrame = (e) => Xe(e, rr);
var ir = Je();
P.onFinish = (e) => Xe(e, ir);
var we = [];
P.setTimeout = (e, t) => {
  const r = P.now() + t, i = () => {
    const o = we.findIndex((a) => a.cancel == i);
    ~o && we.splice(o, 1), ae -= ~o ? 1 : 0;
  }, n = { time: r, handler: e, cancel: i };
  return we.splice(Ii(r), 0, n), ae += 1, Oi(), n;
};
var Ii = (e) => ~(~we.findIndex((t) => t.time > e) || ~we.length);
P.cancel = (e) => {
  mt.delete(e), rr.delete(e), ir.delete(e), er.delete(e), tr.delete(e);
};
P.sync = (e) => {
  $t = !0, P.batchedUpdates(e), $t = !1;
};
P.throttle = (e) => {
  let t;
  function r() {
    try {
      e(...t);
    } finally {
      t = null;
    }
  }
  function i(...n) {
    t = n, P.onStart(r);
  }
  return i.handler = e, i.cancel = () => {
    mt.delete(r), t = null;
  }, i;
};
var nr = typeof window < "u" ? window.requestAnimationFrame : (
  // eslint-disable-next-line @typescript-eslint/no-empty-function
  () => {
  }
);
P.use = (e) => nr = e;
P.now = typeof performance < "u" ? () => performance.now() : Date.now;
P.batchedUpdates = (e) => e();
P.catch = console.error;
P.frameLoop = "always";
P.advance = () => {
  P.frameLoop !== "demand" ? console.warn(
    "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"
  ) : Di();
};
var oe = -1, ae = 0, $t = !1;
function Xe(e, t) {
  $t ? (t.delete(e), e(0)) : (t.add(e), Oi());
}
function Oi() {
  oe < 0 && (oe = 0, P.frameLoop !== "demand" && nr(Ci));
}
function eo() {
  oe = -1;
}
function Ci() {
  ~oe && (nr(Ci), P.batchedUpdates(Di));
}
function Di() {
  const e = oe;
  oe = P.now();
  const t = Ii(oe);
  if (t && (Vi(we.splice(0, t), (r) => r.handler()), ae -= t), !ae) {
    eo();
    return;
  }
  mt.flush(), er.flush(e ? Math.min(64, oe - e) : 16.667), rr.flush(), tr.flush(), ir.flush();
}
function Je() {
  let e = /* @__PURE__ */ new Set(), t = e;
  return {
    add(r) {
      ae += t == e && !e.has(r) ? 1 : 0, e.add(r);
    },
    delete(r) {
      return ae -= t == e && e.has(r) ? 1 : 0, e.delete(r);
    },
    flush(r) {
      t.size && (e = /* @__PURE__ */ new Set(), ae -= t.size, Vi(t, (i) => i(r) && e.add(i)), ae += e.size, t = e);
    }
  };
}
function Vi(e, t) {
  e.forEach((r) => {
    try {
      t(r);
    } catch (i) {
      P.catch(i);
    }
  });
}
var to = Object.defineProperty, ro = (e, t) => {
  for (var r in t)
    to(e, r, { get: t[r], enumerable: !0 });
}, Z = {};
ro(Z, {
  assign: () => no,
  colors: () => ue,
  createStringInterpolator: () => or,
  skipAnimation: () => Fi,
  to: () => ji,
  willAdvance: () => ar
});
function Bt() {
}
var io = (e, t, r) => Object.defineProperty(e, t, { value: r, writable: !0, configurable: !0 }), h = {
  arr: Array.isArray,
  obj: (e) => !!e && e.constructor.name === "Object",
  fun: (e) => typeof e == "function",
  str: (e) => typeof e == "string",
  num: (e) => typeof e == "number",
  und: (e) => e === void 0
};
function ne(e, t) {
  if (h.arr(e)) {
    if (!h.arr(t) || e.length !== t.length)
      return !1;
    for (let r = 0; r < e.length; r++)
      if (e[r] !== t[r])
        return !1;
    return !0;
  }
  return e === t;
}
var x = (e, t) => e.forEach(t);
function te(e, t, r) {
  if (h.arr(e)) {
    for (let i = 0; i < e.length; i++)
      t.call(r, e[i], `${i}`);
    return;
  }
  for (const i in e)
    e.hasOwnProperty(i) && t.call(r, e[i], i);
}
var W = (e) => h.und(e) ? [] : h.arr(e) ? e : [e];
function je(e, t) {
  if (e.size) {
    const r = Array.from(e);
    e.clear(), x(r, t);
  }
}
var De = (e, ...t) => je(e, (r) => r(...t)), sr = () => typeof window > "u" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent), or, ji, ue = null, Fi = !1, ar = Bt, no = (e) => {
  e.to && (ji = e.to), e.now && (P.now = e.now), e.colors !== void 0 && (ue = e.colors), e.skipAnimation != null && (Fi = e.skipAnimation), e.createStringInterpolator && (or = e.createStringInterpolator), e.requestAnimationFrame && P.use(e.requestAnimationFrame), e.batchedUpdates && (P.batchedUpdates = e.batchedUpdates), e.willAdvance && (ar = e.willAdvance), e.frameLoop && (P.frameLoop = e.frameLoop);
}, Fe = /* @__PURE__ */ new Set(), Q = [], Ct = [], lt = 0, gt = {
  get idle() {
    return !Fe.size && !Q.length;
  },
  /** Advance the given animation on every frame until idle. */
  start(e) {
    lt > e.priority ? (Fe.add(e), P.onStart(so)) : (Mi(e), P(Yt));
  },
  /** Advance all animations by the given time. */
  advance: Yt,
  /** Call this when an animation's priority changes. */
  sort(e) {
    if (lt)
      P.onFrame(() => gt.sort(e));
    else {
      const t = Q.indexOf(e);
      ~t && (Q.splice(t, 1), Ni(e));
    }
  },
  /**
   * Clear all animations. For testing purposes.
   *
   * ☠️ Never call this from within the frameloop.
   */
  clear() {
    Q = [], Fe.clear();
  }
};
function so() {
  Fe.forEach(Mi), Fe.clear(), P(Yt);
}
function Mi(e) {
  Q.includes(e) || Ni(e);
}
function Ni(e) {
  Q.splice(
    oo(Q, (t) => t.priority > e.priority),
    0,
    e
  );
}
function Yt(e) {
  const t = Ct;
  for (let r = 0; r < Q.length; r++) {
    const i = Q[r];
    lt = i.priority, i.idle || (ar(i), i.advance(e), i.idle || t.push(i));
  }
  return lt = 0, Ct = Q, Ct.length = 0, Q = t, Q.length > 0;
}
function oo(e, t) {
  const r = e.findIndex(t);
  return r < 0 ? e.length : r;
}
var ao = {
  transparent: 0,
  aliceblue: 4042850303,
  antiquewhite: 4209760255,
  aqua: 16777215,
  aquamarine: 2147472639,
  azure: 4043309055,
  beige: 4126530815,
  bisque: 4293182719,
  black: 255,
  blanchedalmond: 4293643775,
  blue: 65535,
  blueviolet: 2318131967,
  brown: 2771004159,
  burlywood: 3736635391,
  burntsienna: 3934150143,
  cadetblue: 1604231423,
  chartreuse: 2147418367,
  chocolate: 3530104575,
  coral: 4286533887,
  cornflowerblue: 1687547391,
  cornsilk: 4294499583,
  crimson: 3692313855,
  cyan: 16777215,
  darkblue: 35839,
  darkcyan: 9145343,
  darkgoldenrod: 3095792639,
  darkgray: 2846468607,
  darkgreen: 6553855,
  darkgrey: 2846468607,
  darkkhaki: 3182914559,
  darkmagenta: 2332068863,
  darkolivegreen: 1433087999,
  darkorange: 4287365375,
  darkorchid: 2570243327,
  darkred: 2332033279,
  darksalmon: 3918953215,
  darkseagreen: 2411499519,
  darkslateblue: 1211993087,
  darkslategray: 793726975,
  darkslategrey: 793726975,
  darkturquoise: 13554175,
  darkviolet: 2483082239,
  deeppink: 4279538687,
  deepskyblue: 12582911,
  dimgray: 1768516095,
  dimgrey: 1768516095,
  dodgerblue: 512819199,
  firebrick: 2988581631,
  floralwhite: 4294635775,
  forestgreen: 579543807,
  fuchsia: 4278255615,
  gainsboro: 3705462015,
  ghostwhite: 4177068031,
  gold: 4292280575,
  goldenrod: 3668254975,
  gray: 2155905279,
  green: 8388863,
  greenyellow: 2919182335,
  grey: 2155905279,
  honeydew: 4043305215,
  hotpink: 4285117695,
  indianred: 3445382399,
  indigo: 1258324735,
  ivory: 4294963455,
  khaki: 4041641215,
  lavender: 3873897215,
  lavenderblush: 4293981695,
  lawngreen: 2096890111,
  lemonchiffon: 4294626815,
  lightblue: 2916673279,
  lightcoral: 4034953471,
  lightcyan: 3774873599,
  lightgoldenrodyellow: 4210742015,
  lightgray: 3553874943,
  lightgreen: 2431553791,
  lightgrey: 3553874943,
  lightpink: 4290167295,
  lightsalmon: 4288707327,
  lightseagreen: 548580095,
  lightskyblue: 2278488831,
  lightslategray: 2005441023,
  lightslategrey: 2005441023,
  lightsteelblue: 2965692159,
  lightyellow: 4294959359,
  lime: 16711935,
  limegreen: 852308735,
  linen: 4210091775,
  magenta: 4278255615,
  maroon: 2147483903,
  mediumaquamarine: 1724754687,
  mediumblue: 52735,
  mediumorchid: 3126187007,
  mediumpurple: 2473647103,
  mediumseagreen: 1018393087,
  mediumslateblue: 2070474495,
  mediumspringgreen: 16423679,
  mediumturquoise: 1221709055,
  mediumvioletred: 3340076543,
  midnightblue: 421097727,
  mintcream: 4127193855,
  mistyrose: 4293190143,
  moccasin: 4293178879,
  navajowhite: 4292783615,
  navy: 33023,
  oldlace: 4260751103,
  olive: 2155872511,
  olivedrab: 1804477439,
  orange: 4289003775,
  orangered: 4282712319,
  orchid: 3664828159,
  palegoldenrod: 4008225535,
  palegreen: 2566625535,
  paleturquoise: 2951671551,
  palevioletred: 3681588223,
  papayawhip: 4293907967,
  peachpuff: 4292524543,
  peru: 3448061951,
  pink: 4290825215,
  plum: 3718307327,
  powderblue: 2967529215,
  purple: 2147516671,
  rebeccapurple: 1714657791,
  red: 4278190335,
  rosybrown: 3163525119,
  royalblue: 1097458175,
  saddlebrown: 2336560127,
  salmon: 4202722047,
  sandybrown: 4104413439,
  seagreen: 780883967,
  seashell: 4294307583,
  sienna: 2689740287,
  silver: 3233857791,
  skyblue: 2278484991,
  slateblue: 1784335871,
  slategray: 1887473919,
  slategrey: 1887473919,
  snow: 4294638335,
  springgreen: 16744447,
  steelblue: 1182971135,
  tan: 3535047935,
  teal: 8421631,
  thistle: 3636451583,
  tomato: 4284696575,
  turquoise: 1088475391,
  violet: 4001558271,
  wheat: 4125012991,
  white: 4294967295,
  whitesmoke: 4126537215,
  yellow: 4294902015,
  yellowgreen: 2597139199
}, J = "[-+]?\\d*\\.?\\d+", ft = J + "%";
function vt(...e) {
  return "\\(\\s*(" + e.join(")\\s*,\\s*(") + ")\\s*\\)";
}
var uo = new RegExp("rgb" + vt(J, J, J)), co = new RegExp("rgba" + vt(J, J, J, J)), lo = new RegExp("hsl" + vt(J, ft, ft)), fo = new RegExp(
  "hsla" + vt(J, ft, ft, J)
), ho = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, po = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, mo = /^#([0-9a-fA-F]{6})$/, go = /^#([0-9a-fA-F]{8})$/;
function vo(e) {
  let t;
  return typeof e == "number" ? e >>> 0 === e && e >= 0 && e <= 4294967295 ? e : null : (t = mo.exec(e)) ? parseInt(t[1] + "ff", 16) >>> 0 : ue && ue[e] !== void 0 ? ue[e] : (t = uo.exec(e)) ? (be(t[1]) << 24 | // r
  be(t[2]) << 16 | // g
  be(t[3]) << 8 | // b
  255) >>> // a
  0 : (t = co.exec(e)) ? (be(t[1]) << 24 | // r
  be(t[2]) << 16 | // g
  be(t[3]) << 8 | // b
  ei(t[4])) >>> // a
  0 : (t = ho.exec(e)) ? parseInt(
    t[1] + t[1] + // r
    t[2] + t[2] + // g
    t[3] + t[3] + // b
    "ff",
    // a
    16
  ) >>> 0 : (t = go.exec(e)) ? parseInt(t[1], 16) >>> 0 : (t = po.exec(e)) ? parseInt(
    t[1] + t[1] + // r
    t[2] + t[2] + // g
    t[3] + t[3] + // b
    t[4] + t[4],
    // a
    16
  ) >>> 0 : (t = lo.exec(e)) ? (Jr(
    Zr(t[1]),
    // h
    st(t[2]),
    // s
    st(t[3])
    // l
  ) | 255) >>> // a
  0 : (t = fo.exec(e)) ? (Jr(
    Zr(t[1]),
    // h
    st(t[2]),
    // s
    st(t[3])
    // l
  ) | ei(t[4])) >>> // a
  0 : null;
}
function Dt(e, t, r) {
  return r < 0 && (r += 1), r > 1 && (r -= 1), r < 1 / 6 ? e + (t - e) * 6 * r : r < 1 / 2 ? t : r < 2 / 3 ? e + (t - e) * (2 / 3 - r) * 6 : e;
}
function Jr(e, t, r) {
  const i = r < 0.5 ? r * (1 + t) : r + t - r * t, n = 2 * r - i, o = Dt(n, i, e + 1 / 3), a = Dt(n, i, e), u = Dt(n, i, e - 1 / 3);
  return Math.round(o * 255) << 24 | Math.round(a * 255) << 16 | Math.round(u * 255) << 8;
}
function be(e) {
  const t = parseInt(e, 10);
  return t < 0 ? 0 : t > 255 ? 255 : t;
}
function Zr(e) {
  return (parseFloat(e) % 360 + 360) % 360 / 360;
}
function ei(e) {
  const t = parseFloat(e);
  return t < 0 ? 0 : t > 1 ? 255 : Math.round(t * 255);
}
function st(e) {
  const t = parseFloat(e);
  return t < 0 ? 0 : t > 100 ? 1 : t / 100;
}
function ti(e) {
  let t = vo(e);
  if (t === null)
    return e;
  t = t || 0;
  const r = (t & 4278190080) >>> 24, i = (t & 16711680) >>> 16, n = (t & 65280) >>> 8, o = (t & 255) / 255;
  return `rgba(${r}, ${i}, ${n}, ${o})`;
}
var Le = (e, t, r) => {
  if (h.fun(e))
    return e;
  if (h.arr(e))
    return Le({
      range: e,
      output: t,
      extrapolate: r
    });
  if (h.str(e.output[0]))
    return or(e);
  const i = e, n = i.output, o = i.range || [0, 1], a = i.extrapolateLeft || i.extrapolate || "extend", u = i.extrapolateRight || i.extrapolate || "extend", l = i.easing || ((c) => c);
  return (c) => {
    const f = _o(c, o);
    return yo(
      c,
      o[f],
      o[f + 1],
      n[f],
      n[f + 1],
      l,
      a,
      u,
      i.map
    );
  };
};
function yo(e, t, r, i, n, o, a, u, l) {
  let c = l ? l(e) : e;
  if (c < t) {
    if (a === "identity")
      return c;
    a === "clamp" && (c = t);
  }
  if (c > r) {
    if (u === "identity")
      return c;
    u === "clamp" && (c = r);
  }
  return i === n ? i : t === r ? e <= t ? i : n : (t === -1 / 0 ? c = -c : r === 1 / 0 ? c = c - t : c = (c - t) / (r - t), c = o(c), i === -1 / 0 ? c = -c : n === 1 / 0 ? c = c + i : c = c * (n - i) + i, c);
}
function _o(e, t) {
  for (var r = 1; r < t.length - 1 && !(t[r] >= e); ++r)
    ;
  return r - 1;
}
var bo = {
  linear: (e) => e
}, Ue = Symbol.for("FluidValue.get"), Te = Symbol.for("FluidValue.observers"), H = (e) => !!(e && e[Ue]), q = (e) => e && e[Ue] ? e[Ue]() : e, ri = (e) => e[Te] || null;
function wo(e, t) {
  e.eventObserved ? e.eventObserved(t) : e(t);
}
function $e(e, t) {
  const r = e[Te];
  r && r.forEach((i) => {
    wo(i, t);
  });
}
var Li = class {
  constructor(e) {
    if (!e && !(e = this.get))
      throw Error("Unknown getter");
    Eo(this, e);
  }
}, Eo = (e, t) => Ui(e, Ue, t);
function Pe(e, t) {
  if (e[Ue]) {
    let r = e[Te];
    r || Ui(e, Te, r = /* @__PURE__ */ new Set()), r.has(t) || (r.add(t), e.observerAdded && e.observerAdded(r.size, t));
  }
  return t;
}
function Be(e, t) {
  const r = e[Te];
  if (r && r.has(t)) {
    const i = r.size - 1;
    i ? r.delete(t) : e[Te] = null, e.observerRemoved && e.observerRemoved(i, t);
  }
}
var Ui = (e, t, r) => Object.defineProperty(e, t, {
  value: r,
  writable: !0,
  configurable: !0
}), at = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, So = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi, ii = new RegExp(`(${at.source})(%|[a-z]+)`, "i"), To = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi, yt = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/, $i = (e) => {
  const [t, r] = Po(e);
  if (!t || sr())
    return e;
  const i = window.getComputedStyle(document.documentElement).getPropertyValue(t);
  if (i)
    return i.trim();
  if (r && r.startsWith("--")) {
    const n = window.getComputedStyle(document.documentElement).getPropertyValue(r);
    return n || e;
  } else {
    if (r && yt.test(r))
      return $i(r);
    if (r)
      return r;
  }
  return e;
}, Po = (e) => {
  const t = yt.exec(e);
  if (!t)
    return [,];
  const [, r, i] = t;
  return [r, i];
}, Vt, Ao = (e, t, r, i, n) => `rgba(${Math.round(t)}, ${Math.round(r)}, ${Math.round(i)}, ${n})`, Bi = (e) => {
  Vt || (Vt = ue ? (
    // match color names, ignore partial matches
    new RegExp(`(${Object.keys(ue).join("|")})(?!\\w)`, "g")
  ) : (
    // never match
    /^\b$/
  ));
  const t = e.output.map((o) => q(o).replace(yt, $i).replace(So, ti).replace(Vt, ti)), r = t.map((o) => o.match(at).map(Number)), n = r[0].map(
    (o, a) => r.map((u) => {
      if (!(a in u))
        throw Error('The arity of each "output" value must be equal');
      return u[a];
    })
  ).map(
    (o) => Le({ ...e, output: o })
  );
  return (o) => {
    var l;
    const a = !ii.test(t[0]) && ((l = t.find((c) => ii.test(c))) == null ? void 0 : l.replace(at, ""));
    let u = 0;
    return t[0].replace(
      at,
      () => `${n[u++](o)}${a || ""}`
    ).replace(To, Ao);
  };
}, ur = "react-spring: ", Yi = (e) => {
  const t = e;
  let r = !1;
  if (typeof t != "function")
    throw new TypeError(`${ur}once requires a function parameter`);
  return (...i) => {
    r || (t(...i), r = !0);
  };
}, xo = Yi(console.warn);
function Ro() {
  xo(
    `${ur}The "interpolate" function is deprecated in v9 (use "to" instead)`
  );
}
var ko = Yi(console.warn);
function Io() {
  ko(
    `${ur}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`
  );
}
function _t(e) {
  return h.str(e) && (e[0] == "#" || /\d/.test(e) || // Do not identify a CSS variable as an AnimatedString if its SSR
  !sr() && yt.test(e) || e in (ue || {}));
}
var cr = sr() ? Ge : Fn, Oo = () => {
  const e = de(!1);
  return cr(() => (e.current = !0, () => {
    e.current = !1;
  }), []), e;
};
function qi() {
  const e = _i()[1], t = Oo();
  return () => {
    t.current && e(Math.random());
  };
}
function Co(e, t) {
  const [r] = _i(
    () => ({
      inputs: t,
      result: e()
    })
  ), i = de(), n = i.current;
  let o = n;
  return o ? t && o.inputs && Do(t, o.inputs) || (o = {
    inputs: t,
    result: e()
  }) : o = r, Ge(() => {
    i.current = o, n == r && (r.inputs = r.result = void 0);
  }, [o]), o.result;
}
function Do(e, t) {
  if (e.length !== t.length)
    return !1;
  for (let r = 0; r < e.length; r++)
    if (e[r] !== t[r])
      return !1;
  return !0;
}
var Ki = (e) => Ge(e, Vo), Vo = [];
function ni(e) {
  const t = de();
  return Ge(() => {
    t.current = e;
  }), t.current;
}
var Ye = Symbol.for("Animated:node"), jo = (e) => !!e && e[Ye] === e, ee = (e) => e && e[Ye], lr = (e, t) => io(e, Ye, t), bt = (e) => e && e[Ye] && e[Ye].getPayload(), Wi = class {
  constructor() {
    lr(this, this);
  }
  /** Get every `AnimatedValue` used by this node. */
  getPayload() {
    return this.payload || [];
  }
}, Ze = class extends Wi {
  constructor(e) {
    super(), this._value = e, this.done = !0, this.durationProgress = 0, h.num(this._value) && (this.lastPosition = this._value);
  }
  /** @internal */
  static create(e) {
    return new Ze(e);
  }
  getPayload() {
    return [this];
  }
  getValue() {
    return this._value;
  }
  setValue(e, t) {
    return h.num(e) && (this.lastPosition = e, t && (e = Math.round(e / t) * t, this.done && (this.lastPosition = e))), this._value === e ? !1 : (this._value = e, !0);
  }
  reset() {
    const { done: e } = this;
    this.done = !1, h.num(this._value) && (this.elapsedTime = 0, this.durationProgress = 0, this.lastPosition = this._value, e && (this.lastVelocity = null), this.v0 = null);
  }
}, qe = class extends Ze {
  constructor(e) {
    super(0), this._string = null, this._toString = Le({
      output: [e, e]
    });
  }
  /** @internal */
  static create(e) {
    return new qe(e);
  }
  getValue() {
    const e = this._string;
    return e ?? (this._string = this._toString(this._value));
  }
  setValue(e) {
    if (h.str(e)) {
      if (e == this._string)
        return !1;
      this._string = e, this._value = 1;
    } else if (super.setValue(e))
      this._string = null;
    else
      return !1;
    return !0;
  }
  reset(e) {
    e && (this._toString = Le({
      output: [this.getValue(), e]
    })), this._value = 0, super.reset();
  }
}, dt = { dependencies: null }, wt = class extends Wi {
  constructor(e) {
    super(), this.source = e, this.setValue(e);
  }
  getValue(e) {
    const t = {};
    return te(this.source, (r, i) => {
      jo(r) ? t[i] = r.getValue(e) : H(r) ? t[i] = q(r) : e || (t[i] = r);
    }), t;
  }
  /** Replace the raw object data */
  setValue(e) {
    this.source = e, this.payload = this._makePayload(e);
  }
  reset() {
    this.payload && x(this.payload, (e) => e.reset());
  }
  /** Create a payload set. */
  _makePayload(e) {
    if (e) {
      const t = /* @__PURE__ */ new Set();
      return te(e, this._addToPayload, t), Array.from(t);
    }
  }
  /** Add to a payload set. */
  _addToPayload(e) {
    dt.dependencies && H(e) && dt.dependencies.add(e);
    const t = bt(e);
    t && x(t, (r) => this.add(r));
  }
}, zi = class extends wt {
  constructor(e) {
    super(e);
  }
  /** @internal */
  static create(e) {
    return new zi(e);
  }
  getValue() {
    return this.source.map((e) => e.getValue());
  }
  setValue(e) {
    const t = this.getPayload();
    return e.length == t.length ? t.map((r, i) => r.setValue(e[i])).some(Boolean) : (super.setValue(e.map(Fo)), !0);
  }
};
function Fo(e) {
  return (_t(e) ? qe : Ze).create(e);
}
function qt(e) {
  const t = ee(e);
  return t ? t.constructor : h.arr(e) ? zi : _t(e) ? qe : Ze;
}
var si = (e, t) => {
  const r = (
    // Function components must use "forwardRef" to avoid being
    // re-rendered on every animation frame.
    !h.fun(e) || e.prototype && e.prototype.isReactComponent
  );
  return Mn((i, n) => {
    const o = de(null), a = r && // eslint-disable-next-line react-hooks/rules-of-hooks
    Nn(
      (w) => {
        o.current = Lo(n, w);
      },
      [n]
    ), [u, l] = No(i, t), c = qi(), f = () => {
      const w = o.current;
      if (r && !w)
        return;
      (w ? t.applyAnimatedValues(w, u.getValue(!0)) : !1) === !1 && c();
    }, p = new Mo(f, l), m = de();
    cr(() => (m.current = p, x(l, (w) => Pe(w, p)), () => {
      m.current && (x(
        m.current.deps,
        (w) => Be(w, m.current)
      ), P.cancel(m.current.update));
    })), Ge(f, []), Ki(() => () => {
      const w = m.current;
      x(w.deps, (b) => Be(b, w));
    });
    const y = t.getComponentProps(u.getValue());
    return /* @__PURE__ */ Xt.createElement(e, { ...y, ref: a });
  });
}, Mo = class {
  constructor(e, t) {
    this.update = e, this.deps = t;
  }
  eventObserved(e) {
    e.type == "change" && P.write(this.update);
  }
};
function No(e, t) {
  const r = /* @__PURE__ */ new Set();
  return dt.dependencies = r, e.style && (e = {
    ...e,
    style: t.createAnimatedStyle(e.style)
  }), e = new wt(e), dt.dependencies = null, [e, r];
}
function Lo(e, t) {
  return e && (h.fun(e) ? e(t) : e.current = t), t;
}
var oi = Symbol.for("AnimatedComponent"), Uo = (e, {
  applyAnimatedValues: t = () => !1,
  createAnimatedStyle: r = (n) => new wt(n),
  getComponentProps: i = (n) => n
} = {}) => {
  const n = {
    applyAnimatedValues: t,
    createAnimatedStyle: r,
    getComponentProps: i
  }, o = (a) => {
    const u = ai(a) || "Anonymous";
    return h.str(a) ? a = o[a] || (o[a] = si(a, n)) : a = a[oi] || (a[oi] = si(a, n)), a.displayName = `Animated(${u})`, a;
  };
  return te(e, (a, u) => {
    h.arr(e) && (u = ai(a)), o[u] = o(a);
  }), {
    animated: o
  };
}, ai = (e) => h.str(e) ? e : e && h.str(e.displayName) ? e.displayName : h.fun(e) && e.name || null;
function fe(e, ...t) {
  return h.fun(e) ? e(...t) : e;
}
var Me = (e, t) => e === !0 || !!(t && e && (h.fun(e) ? e(t) : W(e).includes(t))), Gi = (e, t) => h.obj(e) ? t && e[t] : e, Hi = (e, t) => e.default === !0 ? e[t] : e.default ? e.default[t] : void 0, $o = (e) => e, fr = (e, t = $o) => {
  let r = Bo;
  e.default && e.default !== !0 && (e = e.default, r = Object.keys(e));
  const i = {};
  for (const n of r) {
    const o = t(e[n], n);
    h.und(o) || (i[n] = o);
  }
  return i;
}, Bo = [
  "config",
  "onProps",
  "onStart",
  "onChange",
  "onPause",
  "onResume",
  "onRest"
], Yo = {
  config: 1,
  from: 1,
  to: 1,
  ref: 1,
  loop: 1,
  reset: 1,
  pause: 1,
  cancel: 1,
  reverse: 1,
  immediate: 1,
  default: 1,
  delay: 1,
  onProps: 1,
  onStart: 1,
  onChange: 1,
  onPause: 1,
  onResume: 1,
  onRest: 1,
  onResolve: 1,
  // Transition props
  items: 1,
  trail: 1,
  sort: 1,
  expires: 1,
  initial: 1,
  enter: 1,
  update: 1,
  leave: 1,
  children: 1,
  onDestroyed: 1,
  // Internal props
  keys: 1,
  callId: 1,
  parentId: 1
};
function qo(e) {
  const t = {};
  let r = 0;
  if (te(e, (i, n) => {
    Yo[n] || (t[n] = i, r++);
  }), r)
    return t;
}
function Qi(e) {
  const t = qo(e);
  if (t) {
    const r = { to: t };
    return te(e, (i, n) => n in t || (r[n] = i)), r;
  }
  return { ...e };
}
function Ke(e) {
  return e = q(e), h.arr(e) ? e.map(Ke) : _t(e) ? Z.createStringInterpolator({
    range: [0, 1],
    output: [e, e]
  })(1) : e;
}
function Ko(e) {
  for (const t in e)
    return !0;
  return !1;
}
function Kt(e) {
  return h.fun(e) || h.arr(e) && h.obj(e[0]);
}
function Wo(e, t) {
  var r;
  (r = e.ref) == null || r.delete(e), t == null || t.delete(e);
}
function zo(e, t) {
  var r;
  t && e.ref !== t && ((r = e.ref) == null || r.delete(e), t.add(e), e.ref = t);
}
var Go = {
  default: { tension: 170, friction: 26 }
}, Wt = {
  ...Go.default,
  mass: 1,
  damping: 1,
  easing: bo.linear,
  clamp: !1
}, Ho = class {
  constructor() {
    this.velocity = 0, Object.assign(this, Wt);
  }
};
function Qo(e, t, r) {
  r && (r = { ...r }, ui(r, t), t = { ...r, ...t }), ui(e, t), Object.assign(e, t);
  for (const a in Wt)
    e[a] == null && (e[a] = Wt[a]);
  let { frequency: i, damping: n } = e;
  const { mass: o } = e;
  return h.und(i) || (i < 0.01 && (i = 0.01), n < 0 && (n = 0), e.tension = Math.pow(2 * Math.PI / i, 2) * o, e.friction = 4 * Math.PI * n * o / i), e;
}
function ui(e, t) {
  if (!h.und(t.decay))
    e.duration = void 0;
  else {
    const r = !h.und(t.tension) || !h.und(t.friction);
    (r || !h.und(t.frequency) || !h.und(t.damping) || !h.und(t.mass)) && (e.duration = void 0, e.decay = void 0), r && (e.frequency = void 0);
  }
}
var ci = [], Xo = class {
  constructor() {
    this.changed = !1, this.values = ci, this.toValues = null, this.fromValues = ci, this.config = new Ho(), this.immediate = !1;
  }
};
function Xi(e, { key: t, props: r, defaultProps: i, state: n, actions: o }) {
  return new Promise((a, u) => {
    let l, c, f = Me(r.cancel ?? (i == null ? void 0 : i.cancel), t);
    if (f)
      y();
    else {
      h.und(r.pause) || (n.paused = Me(r.pause, t));
      let w = i == null ? void 0 : i.pause;
      w !== !0 && (w = n.paused || Me(w, t)), l = fe(r.delay || 0, t), w ? (n.resumeQueue.add(m), o.pause()) : (o.resume(), m());
    }
    function p() {
      n.resumeQueue.add(m), n.timeouts.delete(c), c.cancel(), l = c.time - P.now();
    }
    function m() {
      l > 0 && !Z.skipAnimation ? (n.delayed = !0, c = P.setTimeout(y, l), n.pauseQueue.add(p), n.timeouts.add(c)) : y();
    }
    function y() {
      n.delayed && (n.delayed = !1), n.pauseQueue.delete(p), n.timeouts.delete(c), e <= (n.cancelId || 0) && (f = !0);
      try {
        o.start({ ...r, callId: e, cancel: f }, a);
      } catch (w) {
        u(w);
      }
    }
  });
}
var dr = (e, t) => t.length == 1 ? t[0] : t.some((r) => r.cancelled) ? Ee(e.get()) : t.every((r) => r.noop) ? Ji(e.get()) : X(
  e.get(),
  t.every((r) => r.finished)
), Ji = (e) => ({
  value: e,
  noop: !0,
  finished: !0,
  cancelled: !1
}), X = (e, t, r = !1) => ({
  value: e,
  finished: t,
  cancelled: r
}), Ee = (e) => ({
  value: e,
  cancelled: !0,
  finished: !1
});
function Zi(e, t, r, i) {
  const { callId: n, parentId: o, onRest: a } = t, { asyncTo: u, promise: l } = r;
  return !o && e === u && !t.reset ? l : r.promise = (async () => {
    r.asyncId = n, r.asyncTo = e;
    const c = fr(
      t,
      (T, v) => (
        // The `onRest` prop is only called when the `runAsync` promise is resolved.
        v === "onRest" ? void 0 : T
      )
    );
    let f, p;
    const m = new Promise(
      (T, v) => (f = T, p = v)
    ), y = (T) => {
      const v = (
        // The `cancel` prop or `stop` method was used.
        n <= (r.cancelId || 0) && Ee(i) || // The async `to` prop was replaced.
        n !== r.asyncId && X(i, !1)
      );
      if (v)
        throw T.result = v, p(T), T;
    }, w = (T, v) => {
      const _ = new li(), S = new fi();
      return (async () => {
        if (Z.skipAnimation)
          throw We(r), S.result = X(i, !1), p(S), S;
        y(_);
        const k = h.obj(T) ? { ...T } : { ...v, to: T };
        k.parentId = n, te(c, (N, L) => {
          h.und(k[L]) && (k[L] = N);
        });
        const V = await i.start(k);
        return y(_), r.paused && await new Promise((N) => {
          r.resumeQueue.add(N);
        }), V;
      })();
    };
    let b;
    if (Z.skipAnimation)
      return We(r), X(i, !1);
    try {
      let T;
      h.arr(e) ? T = (async (v) => {
        for (const _ of v)
          await w(_);
      })(e) : T = Promise.resolve(e(w, i.stop.bind(i))), await Promise.all([T.then(f), m]), b = X(i.get(), !0, !1);
    } catch (T) {
      if (T instanceof li)
        b = T.result;
      else if (T instanceof fi)
        b = T.result;
      else
        throw T;
    } finally {
      n == r.asyncId && (r.asyncId = o, r.asyncTo = o ? u : void 0, r.promise = o ? l : void 0);
    }
    return h.fun(a) && P.batchedUpdates(() => {
      a(b, i, i.item);
    }), b;
  })();
}
function We(e, t) {
  je(e.timeouts, (r) => r.cancel()), e.pauseQueue.clear(), e.resumeQueue.clear(), e.asyncId = e.asyncTo = e.promise = void 0, t && (e.cancelId = t);
}
var li = class extends Error {
  constructor() {
    super(
      "An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."
    );
  }
}, fi = class extends Error {
  constructor() {
    super("SkipAnimationSignal");
  }
}, zt = (e) => e instanceof hr, Jo = 1, hr = class extends Li {
  constructor() {
    super(...arguments), this.id = Jo++, this._priority = 0;
  }
  get priority() {
    return this._priority;
  }
  set priority(e) {
    this._priority != e && (this._priority = e, this._onPriorityChange(e));
  }
  /** Get the current value */
  get() {
    const e = ee(this);
    return e && e.getValue();
  }
  /** Create a spring that maps our value to another value */
  to(...e) {
    return Z.to(this, e);
  }
  /** @deprecated Use the `to` method instead. */
  interpolate(...e) {
    return Ro(), Z.to(this, e);
  }
  toJSON() {
    return this.get();
  }
  observerAdded(e) {
    e == 1 && this._attach();
  }
  observerRemoved(e) {
    e == 0 && this._detach();
  }
  /** Called when the first child is added. */
  _attach() {
  }
  /** Called when the last child is removed. */
  _detach() {
  }
  /** Tell our children about our new value */
  _onChange(e, t = !1) {
    $e(this, {
      type: "change",
      parent: this,
      value: e,
      idle: t
    });
  }
  /** Tell our children about our new priority */
  _onPriorityChange(e) {
    this.idle || gt.sort(this), $e(this, {
      type: "priority",
      parent: this,
      priority: e
    });
  }
}, he = Symbol.for("SpringPhase"), en = 1, Gt = 2, Ht = 4, jt = (e) => (e[he] & en) > 0, se = (e) => (e[he] & Gt) > 0, Ie = (e) => (e[he] & Ht) > 0, di = (e, t) => t ? e[he] |= Gt | en : e[he] &= ~Gt, hi = (e, t) => t ? e[he] |= Ht : e[he] &= ~Ht, Zo = class extends hr {
  constructor(e, t) {
    if (super(), this.animation = new Xo(), this.defaultProps = {}, this._state = {
      paused: !1,
      delayed: !1,
      pauseQueue: /* @__PURE__ */ new Set(),
      resumeQueue: /* @__PURE__ */ new Set(),
      timeouts: /* @__PURE__ */ new Set()
    }, this._pendingCalls = /* @__PURE__ */ new Set(), this._lastCallId = 0, this._lastToId = 0, this._memoizedDuration = 0, !h.und(e) || !h.und(t)) {
      const r = h.obj(e) ? { ...e } : { ...t, from: e };
      h.und(r.default) && (r.default = !0), this.start(r);
    }
  }
  /** Equals true when not advancing on each frame. */
  get idle() {
    return !(se(this) || this._state.asyncTo) || Ie(this);
  }
  get goal() {
    return q(this.animation.to);
  }
  get velocity() {
    const e = ee(this);
    return e instanceof Ze ? e.lastVelocity || 0 : e.getPayload().map((t) => t.lastVelocity || 0);
  }
  /**
   * When true, this value has been animated at least once.
   */
  get hasAnimated() {
    return jt(this);
  }
  /**
   * When true, this value has an unfinished animation,
   * which is either active or paused.
   */
  get isAnimating() {
    return se(this);
  }
  /**
   * When true, all current and future animations are paused.
   */
  get isPaused() {
    return Ie(this);
  }
  /**
   *
   *
   */
  get isDelayed() {
    return this._state.delayed;
  }
  /** Advance the current animation by a number of milliseconds */
  advance(e) {
    let t = !0, r = !1;
    const i = this.animation;
    let { toValues: n } = i;
    const { config: o } = i, a = bt(i.to);
    !a && H(i.to) && (n = W(q(i.to))), i.values.forEach((c, f) => {
      if (c.done)
        return;
      const p = (
        // Animated strings always go from 0 to 1.
        c.constructor == qe ? 1 : a ? a[f].lastPosition : n[f]
      );
      let m = i.immediate, y = p;
      if (!m) {
        if (y = c.lastPosition, o.tension <= 0) {
          c.done = !0;
          return;
        }
        let w = c.elapsedTime += e;
        const b = i.fromValues[f], T = c.v0 != null ? c.v0 : c.v0 = h.arr(o.velocity) ? o.velocity[f] : o.velocity;
        let v;
        const _ = o.precision || (b == p ? 5e-3 : Math.min(1, Math.abs(p - b) * 1e-3));
        if (h.und(o.duration))
          if (o.decay) {
            const S = o.decay === !0 ? 0.998 : o.decay, k = Math.exp(-(1 - S) * w);
            y = b + T / (1 - S) * (1 - k), m = Math.abs(c.lastPosition - y) <= _, v = T * k;
          } else {
            v = c.lastVelocity == null ? T : c.lastVelocity;
            const S = o.restVelocity || _ / 10, k = o.clamp ? 0 : o.bounce, V = !h.und(k), N = b == p ? c.v0 > 0 : b < p;
            let L, me = !1;
            const U = 1, ce = Math.ceil(e / U);
            for (let K = 0; K < ce && (L = Math.abs(v) > S, !(!L && (m = Math.abs(p - y) <= _, m))); ++K) {
              V && (me = y == p || y > p == N, me && (v = -v * k, y = p));
              const re = -o.tension * 1e-6 * (y - p), $ = -o.friction * 1e-3 * v, ie = (re + $) / o.mass;
              v = v + ie * U, y = y + v * U;
            }
          }
        else {
          let S = 1;
          o.duration > 0 && (this._memoizedDuration !== o.duration && (this._memoizedDuration = o.duration, c.durationProgress > 0 && (c.elapsedTime = o.duration * c.durationProgress, w = c.elapsedTime += e)), S = (o.progress || 0) + w / this._memoizedDuration, S = S > 1 ? 1 : S < 0 ? 0 : S, c.durationProgress = S), y = b + o.easing(S) * (p - b), v = (y - c.lastPosition) / e, m = S == 1;
        }
        c.lastVelocity = v, Number.isNaN(y) && (console.warn("Got NaN while animating:", this), m = !0);
      }
      a && !a[f].done && (m = !1), m ? c.done = !0 : t = !1, c.setValue(y, o.round) && (r = !0);
    });
    const u = ee(this), l = u.getValue();
    if (t) {
      const c = q(i.to);
      (l !== c || r) && !o.decay ? (u.setValue(c), this._onChange(c)) : r && o.decay && this._onChange(l), this._stop();
    } else r && this._onChange(l);
  }
  /** Set the current value, while stopping the current animation */
  set(e) {
    return P.batchedUpdates(() => {
      this._stop(), this._focus(e), this._set(e);
    }), this;
  }
  /**
   * Freeze the active animation in time, as well as any updates merged
   * before `resume` is called.
   */
  pause() {
    this._update({ pause: !0 });
  }
  /** Resume the animation if paused. */
  resume() {
    this._update({ pause: !1 });
  }
  /** Skip to the end of the current animation. */
  finish() {
    if (se(this)) {
      const { to: e, config: t } = this.animation;
      P.batchedUpdates(() => {
        this._onStart(), t.decay || this._set(e, !1), this._stop();
      });
    }
    return this;
  }
  /** Push props into the pending queue. */
  update(e) {
    return (this.queue || (this.queue = [])).push(e), this;
  }
  start(e, t) {
    let r;
    return h.und(e) ? (r = this.queue || [], this.queue = []) : r = [h.obj(e) ? e : { ...t, to: e }], Promise.all(
      r.map((i) => this._update(i))
    ).then((i) => dr(this, i));
  }
  /**
   * Stop the current animation, and cancel any delayed updates.
   *
   * Pass `true` to call `onRest` with `cancelled: true`.
   */
  stop(e) {
    const { to: t } = this.animation;
    return this._focus(this.get()), We(this._state, e && this._lastCallId), P.batchedUpdates(() => this._stop(t, e)), this;
  }
  /** Restart the animation. */
  reset() {
    this._update({ reset: !0 });
  }
  /** @internal */
  eventObserved(e) {
    e.type == "change" ? this._start() : e.type == "priority" && (this.priority = e.priority + 1);
  }
  /**
   * Parse the `to` and `from` range from the given `props` object.
   *
   * This also ensures the initial value is available to animated components
   * during the render phase.
   */
  _prepareNode(e) {
    const t = this.key || "";
    let { to: r, from: i } = e;
    r = h.obj(r) ? r[t] : r, (r == null || Kt(r)) && (r = void 0), i = h.obj(i) ? i[t] : i, i == null && (i = void 0);
    const n = { to: r, from: i };
    return jt(this) || (e.reverse && ([r, i] = [i, r]), i = q(i), h.und(i) ? ee(this) || this._set(r) : this._set(i)), n;
  }
  /** Every update is processed by this method before merging. */
  _update({ ...e }, t) {
    const { key: r, defaultProps: i } = this;
    e.default && Object.assign(
      i,
      fr(
        e,
        (a, u) => /^on/.test(u) ? Gi(a, r) : a
      )
    ), mi(this, e, "onProps"), Ce(this, "onProps", e, this);
    const n = this._prepareNode(e);
    if (Object.isFrozen(this))
      throw Error(
        "Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?"
      );
    const o = this._state;
    return Xi(++this._lastCallId, {
      key: r,
      props: e,
      defaultProps: i,
      state: o,
      actions: {
        pause: () => {
          Ie(this) || (hi(this, !0), De(o.pauseQueue), Ce(
            this,
            "onPause",
            X(this, Oe(this, this.animation.to)),
            this
          ));
        },
        resume: () => {
          Ie(this) && (hi(this, !1), se(this) && this._resume(), De(o.resumeQueue), Ce(
            this,
            "onResume",
            X(this, Oe(this, this.animation.to)),
            this
          ));
        },
        start: this._merge.bind(this, n)
      }
    }).then((a) => {
      if (e.loop && a.finished && !(t && a.noop)) {
        const u = tn(e);
        if (u)
          return this._update(u, !0);
      }
      return a;
    });
  }
  /** Merge props into the current animation */
  _merge(e, t, r) {
    if (t.cancel)
      return this.stop(!0), r(Ee(this));
    const i = !h.und(e.to), n = !h.und(e.from);
    if (i || n)
      if (t.callId > this._lastToId)
        this._lastToId = t.callId;
      else
        return r(Ee(this));
    const { key: o, defaultProps: a, animation: u } = this, { to: l, from: c } = u;
    let { to: f = l, from: p = c } = e;
    n && !i && (!t.default || h.und(f)) && (f = p), t.reverse && ([f, p] = [p, f]);
    const m = !ne(p, c);
    m && (u.from = p), p = q(p);
    const y = !ne(f, l);
    y && this._focus(f);
    const w = Kt(t.to), { config: b } = u, { decay: T, velocity: v } = b;
    (i || n) && (b.velocity = 0), t.config && !w && Qo(
      b,
      fe(t.config, o),
      // Avoid calling the same "config" prop twice.
      t.config !== a.config ? fe(a.config, o) : void 0
    );
    let _ = ee(this);
    if (!_ || h.und(f))
      return r(X(this, !0));
    const S = (
      // When `reset` is undefined, the `from` prop implies `reset: true`,
      // except for declarative updates. When `reset` is defined, there
      // must exist a value to animate from.
      h.und(t.reset) ? n && !t.default : !h.und(p) && Me(t.reset, o)
    ), k = S ? p : this.get(), V = Ke(f), N = h.num(V) || h.arr(V) || _t(V), L = !w && (!N || Me(a.immediate || t.immediate, o));
    if (y) {
      const K = qt(f);
      if (K !== _.constructor)
        if (L)
          _ = this._set(V);
        else
          throw Error(
            `Cannot animate between ${_.constructor.name} and ${K.name}, as the "to" prop suggests`
          );
    }
    const me = _.constructor;
    let U = H(f), ce = !1;
    if (!U) {
      const K = S || !jt(this) && m;
      (y || K) && (ce = ne(Ke(k), V), U = !ce), (!ne(u.immediate, L) && !L || !ne(b.decay, T) || !ne(b.velocity, v)) && (U = !0);
    }
    if (ce && se(this) && (u.changed && !S ? U = !0 : U || this._stop(l)), !w && ((U || H(l)) && (u.values = _.getPayload(), u.toValues = H(f) ? null : me == qe ? [1] : W(V)), u.immediate != L && (u.immediate = L, !L && !S && this._set(l)), U)) {
      const { onRest: K } = u;
      x(ta, ($) => mi(this, t, $));
      const re = X(this, Oe(this, l));
      De(this._pendingCalls, re), this._pendingCalls.add(r), u.changed && P.batchedUpdates(() => {
        var $;
        u.changed = !S, K == null || K(re, this), S ? fe(a.onRest, re) : ($ = u.onStart) == null || $.call(u, re, this);
      });
    }
    S && this._set(k), w ? r(Zi(t.to, t, this._state, this)) : U ? this._start() : se(this) && !y ? this._pendingCalls.add(r) : r(Ji(k));
  }
  /** Update the `animation.to` value, which might be a `FluidValue` */
  _focus(e) {
    const t = this.animation;
    e !== t.to && (ri(this) && this._detach(), t.to = e, ri(this) && this._attach());
  }
  _attach() {
    let e = 0;
    const { to: t } = this.animation;
    H(t) && (Pe(t, this), zt(t) && (e = t.priority + 1)), this.priority = e;
  }
  _detach() {
    const { to: e } = this.animation;
    H(e) && Be(e, this);
  }
  /**
   * Update the current value from outside the frameloop,
   * and return the `Animated` node.
   */
  _set(e, t = !0) {
    const r = q(e);
    if (!h.und(r)) {
      const i = ee(this);
      if (!i || !ne(r, i.getValue())) {
        const n = qt(r);
        !i || i.constructor != n ? lr(this, n.create(r)) : i.setValue(r), i && P.batchedUpdates(() => {
          this._onChange(r, t);
        });
      }
    }
    return ee(this);
  }
  _onStart() {
    const e = this.animation;
    e.changed || (e.changed = !0, Ce(
      this,
      "onStart",
      X(this, Oe(this, e.to)),
      this
    ));
  }
  _onChange(e, t) {
    t || (this._onStart(), fe(this.animation.onChange, e, this)), fe(this.defaultProps.onChange, e, this), super._onChange(e, t);
  }
  // This method resets the animation state (even if already animating) to
  // ensure the latest from/to range is used, and it also ensures this spring
  // is added to the frameloop.
  _start() {
    const e = this.animation;
    ee(this).reset(q(e.to)), e.immediate || (e.fromValues = e.values.map((t) => t.lastPosition)), se(this) || (di(this, !0), Ie(this) || this._resume());
  }
  _resume() {
    Z.skipAnimation ? this.finish() : gt.start(this);
  }
  /**
   * Exit the frameloop and notify `onRest` listeners.
   *
   * Always wrap `_stop` calls with `batchedUpdates`.
   */
  _stop(e, t) {
    if (se(this)) {
      di(this, !1);
      const r = this.animation;
      x(r.values, (n) => {
        n.done = !0;
      }), r.toValues && (r.onChange = r.onPause = r.onResume = void 0), $e(this, {
        type: "idle",
        parent: this
      });
      const i = t ? Ee(this.get()) : X(this.get(), Oe(this, e ?? r.to));
      De(this._pendingCalls, i), r.changed && (r.changed = !1, Ce(this, "onRest", i, this));
    }
  }
};
function Oe(e, t) {
  const r = Ke(t), i = Ke(e.get());
  return ne(i, r);
}
function tn(e, t = e.loop, r = e.to) {
  const i = fe(t);
  if (i) {
    const n = i !== !0 && Qi(i), o = (n || e).reverse, a = !n || n.reset;
    return ze({
      ...e,
      loop: t,
      // Avoid updating default props when looping.
      default: !1,
      // Never loop the `pause` prop.
      pause: void 0,
      // For the "reverse" prop to loop as expected, the "to" prop
      // must be undefined. The "reverse" prop is ignored when the
      // "to" prop is an array or function.
      to: !o || Kt(r) ? r : void 0,
      // Ignore the "from" prop except on reset.
      from: a ? e.from : void 0,
      reset: a,
      // The "loop" prop can return a "useSpring" props object to
      // override any of the original props.
      ...n
    });
  }
}
function ze(e) {
  const { to: t, from: r } = e = Qi(e), i = /* @__PURE__ */ new Set();
  return h.obj(t) && pi(t, i), h.obj(r) && pi(r, i), e.keys = i.size ? Array.from(i) : null, e;
}
function ea(e) {
  const t = ze(e);
  return h.und(t.default) && (t.default = fr(t)), t;
}
function pi(e, t) {
  te(e, (r, i) => r != null && t.add(i));
}
var ta = [
  "onStart",
  "onRest",
  "onChange",
  "onPause",
  "onResume"
];
function mi(e, t, r) {
  e.animation[r] = t[r] !== Hi(t, r) ? Gi(t[r], e.key) : void 0;
}
function Ce(e, t, ...r) {
  var i, n, o, a;
  (n = (i = e.animation)[t]) == null || n.call(i, ...r), (a = (o = e.defaultProps)[t]) == null || a.call(o, ...r);
}
var ra = ["onStart", "onChange", "onRest"], ia = 1, na = class {
  constructor(e, t) {
    this.id = ia++, this.springs = {}, this.queue = [], this._lastAsyncId = 0, this._active = /* @__PURE__ */ new Set(), this._changed = /* @__PURE__ */ new Set(), this._started = !1, this._state = {
      paused: !1,
      pauseQueue: /* @__PURE__ */ new Set(),
      resumeQueue: /* @__PURE__ */ new Set(),
      timeouts: /* @__PURE__ */ new Set()
    }, this._events = {
      onStart: /* @__PURE__ */ new Map(),
      onChange: /* @__PURE__ */ new Map(),
      onRest: /* @__PURE__ */ new Map()
    }, this._onFrame = this._onFrame.bind(this), t && (this._flush = t), e && this.start({ default: !0, ...e });
  }
  /**
   * Equals `true` when no spring values are in the frameloop, and
   * no async animation is currently active.
   */
  get idle() {
    return !this._state.asyncTo && Object.values(this.springs).every((e) => e.idle && !e.isDelayed && !e.isPaused);
  }
  get item() {
    return this._item;
  }
  set item(e) {
    this._item = e;
  }
  /** Get the current values of our springs */
  get() {
    const e = {};
    return this.each((t, r) => e[r] = t.get()), e;
  }
  /** Set the current values without animating. */
  set(e) {
    for (const t in e) {
      const r = e[t];
      h.und(r) || this.springs[t].set(r);
    }
  }
  /** Push an update onto the queue of each value. */
  update(e) {
    return e && this.queue.push(ze(e)), this;
  }
  /**
   * Start the queued animations for every spring, and resolve the returned
   * promise once all queued animations have finished or been cancelled.
   *
   * When you pass a queue (instead of nothing), that queue is used instead of
   * the queued animations added with the `update` method, which are left alone.
   */
  start(e) {
    let { queue: t } = this;
    return e ? t = W(e).map(ze) : this.queue = [], this._flush ? this._flush(this, t) : (an(this, t), Qt(this, t));
  }
  /** @internal */
  stop(e, t) {
    if (e !== !!e && (t = e), t) {
      const r = this.springs;
      x(W(t), (i) => r[i].stop(!!e));
    } else
      We(this._state, this._lastAsyncId), this.each((r) => r.stop(!!e));
    return this;
  }
  /** Freeze the active animation in time */
  pause(e) {
    if (h.und(e))
      this.start({ pause: !0 });
    else {
      const t = this.springs;
      x(W(e), (r) => t[r].pause());
    }
    return this;
  }
  /** Resume the animation if paused. */
  resume(e) {
    if (h.und(e))
      this.start({ pause: !1 });
    else {
      const t = this.springs;
      x(W(e), (r) => t[r].resume());
    }
    return this;
  }
  /** Call a function once per spring value */
  each(e) {
    te(this.springs, e);
  }
  /** @internal Called at the end of every animation frame */
  _onFrame() {
    const { onStart: e, onChange: t, onRest: r } = this._events, i = this._active.size > 0, n = this._changed.size > 0;
    (i && !this._started || n && !this._started) && (this._started = !0, je(e, ([u, l]) => {
      l.value = this.get(), u(l, this, this._item);
    }));
    const o = !i && this._started, a = n || o && r.size ? this.get() : null;
    n && t.size && je(t, ([u, l]) => {
      l.value = a, u(l, this, this._item);
    }), o && (this._started = !1, je(r, ([u, l]) => {
      l.value = a, u(l, this, this._item);
    }));
  }
  /** @internal */
  eventObserved(e) {
    if (e.type == "change")
      this._changed.add(e.parent), e.idle || this._active.add(e.parent);
    else if (e.type == "idle")
      this._active.delete(e.parent);
    else
      return;
    P.onFrame(this._onFrame);
  }
};
function Qt(e, t) {
  return Promise.all(t.map((r) => rn(e, r))).then(
    (r) => dr(e, r)
  );
}
async function rn(e, t, r) {
  const { keys: i, to: n, from: o, loop: a, onRest: u, onResolve: l } = t, c = h.obj(t.default) && t.default;
  a && (t.loop = !1), n === !1 && (t.to = null), o === !1 && (t.from = null);
  const f = h.arr(n) || h.fun(n) ? n : void 0;
  f ? (t.to = void 0, t.onRest = void 0, c && (c.onRest = void 0)) : x(ra, (b) => {
    const T = t[b];
    if (h.fun(T)) {
      const v = e._events[b];
      t[b] = ({ finished: _, cancelled: S }) => {
        const k = v.get(T);
        k ? (_ || (k.finished = !1), S && (k.cancelled = !0)) : v.set(T, {
          value: null,
          finished: _ || !1,
          cancelled: S || !1
        });
      }, c && (c[b] = t[b]);
    }
  });
  const p = e._state;
  t.pause === !p.paused ? (p.paused = t.pause, De(t.pause ? p.pauseQueue : p.resumeQueue)) : p.paused && (t.pause = !0);
  const m = (i || Object.keys(e.springs)).map(
    (b) => e.springs[b].start(t)
  ), y = t.cancel === !0 || Hi(t, "cancel") === !0;
  (f || y && p.asyncId) && m.push(
    Xi(++e._lastAsyncId, {
      props: t,
      state: p,
      actions: {
        pause: Bt,
        resume: Bt,
        start(b, T) {
          y ? (We(p, e._lastAsyncId), T(Ee(e))) : (b.onRest = u, T(
            Zi(
              f,
              b,
              p,
              e
            )
          ));
        }
      }
    })
  ), p.paused && await new Promise((b) => {
    p.resumeQueue.add(b);
  });
  const w = dr(e, await Promise.all(m));
  if (a && w.finished && !(r && w.noop)) {
    const b = tn(t, a, n);
    if (b)
      return an(e, [b]), rn(e, b, !0);
  }
  return l && P.batchedUpdates(() => l(w, e, e.item)), w;
}
function gi(e, t) {
  const r = { ...e.springs };
  return t && x(W(t), (i) => {
    h.und(i.keys) && (i = ze(i)), h.obj(i.to) || (i = { ...i, to: void 0 }), on(r, i, (n) => sn(n));
  }), nn(e, r), r;
}
function nn(e, t) {
  te(t, (r, i) => {
    e.springs[i] || (e.springs[i] = r, Pe(r, e));
  });
}
function sn(e, t) {
  const r = new Zo();
  return r.key = e, t && Pe(r, t), r;
}
function on(e, t, r) {
  t.keys && x(t.keys, (i) => {
    (e[i] || (e[i] = r(i)))._prepareNode(t);
  });
}
function an(e, t) {
  x(t, (r) => {
    on(e.springs, r, (i) => sn(i, e));
  });
}
var Et = ({
  children: e,
  ...t
}) => {
  const r = bi(ht), i = t.pause || !!r.pause, n = t.immediate || !!r.immediate;
  t = Co(() => ({ pause: i, immediate: n }), [i, n]);
  const { Provider: o } = ht;
  return /* @__PURE__ */ Xt.createElement(o, { value: t }, e);
}, ht = sa(Et, {});
Et.Provider = ht.Provider;
Et.Consumer = ht.Consumer;
function sa(e, t) {
  return Object.assign(e, Xt.createContext(t)), e.Provider._context = e, e.Consumer._context = e, e;
}
var oa = () => {
  const e = [], t = function(i) {
    Io();
    const n = [];
    return x(e, (o, a) => {
      if (h.und(i))
        n.push(o.start());
      else {
        const u = r(i, o, a);
        u && n.push(o.start(u));
      }
    }), n;
  };
  t.current = e, t.add = function(i) {
    e.includes(i) || e.push(i);
  }, t.delete = function(i) {
    const n = e.indexOf(i);
    ~n && e.splice(n, 1);
  }, t.pause = function() {
    return x(e, (i) => i.pause(...arguments)), this;
  }, t.resume = function() {
    return x(e, (i) => i.resume(...arguments)), this;
  }, t.set = function(i) {
    x(e, (n, o) => {
      const a = h.fun(i) ? i(o, n) : i;
      a && n.set(a);
    });
  }, t.start = function(i) {
    const n = [];
    return x(e, (o, a) => {
      if (h.und(i))
        n.push(o.start());
      else {
        const u = this._getProps(i, o, a);
        u && n.push(o.start(u));
      }
    }), n;
  }, t.stop = function() {
    return x(e, (i) => i.stop(...arguments)), this;
  }, t.update = function(i) {
    return x(e, (n, o) => n.update(this._getProps(i, n, o))), this;
  };
  const r = function(i, n, o) {
    return h.fun(i) ? i(o, n) : i;
  };
  return t._getProps = r, t;
};
function aa(e, t, r) {
  const i = h.fun(t) && t;
  i && !r && (r = []);
  const n = nt(
    () => i || arguments.length == 3 ? oa() : void 0,
    []
  ), o = de(0), a = qi(), u = nt(
    () => ({
      ctrls: [],
      queue: [],
      flush(v, _) {
        const S = gi(v, _);
        return o.current > 0 && !u.queue.length && !Object.keys(S).some((V) => !v.springs[V]) ? Qt(v, _) : new Promise((V) => {
          nn(v, S), u.queue.push(() => {
            V(Qt(v, _));
          }), a();
        });
      }
    }),
    []
  ), l = de([...u.ctrls]), c = [], f = ni(e) || 0;
  nt(() => {
    x(l.current.slice(e, f), (v) => {
      Wo(v, n), v.stop(!0);
    }), l.current.length = e, p(f, e);
  }, [e]), nt(() => {
    p(0, Math.min(f, e));
  }, r);
  function p(v, _) {
    for (let S = v; S < _; S++) {
      const k = l.current[S] || (l.current[S] = new na(null, u.flush)), V = i ? i(S, k) : t[S];
      V && (c[S] = ea(V));
    }
  }
  const m = l.current.map((v, _) => gi(v, c[_])), y = bi(Et), w = ni(y), b = y !== w && Ko(y);
  cr(() => {
    o.current++, u.ctrls = l.current;
    const { queue: v } = u;
    v.length && (u.queue = [], x(v, (_) => _())), x(l.current, (_, S) => {
      n == null || n.add(_), b && _.start({ default: y });
      const k = c[S];
      k && (zo(_, k.ref), _.ref ? _.queue.push(k) : _.start(k));
    });
  }), Ki(() => () => {
    x(u.ctrls, (v) => v.stop(!0));
  });
  const T = m.map((v) => ({ ...v }));
  return n ? [T, n] : T;
}
function ua(e, t) {
  const r = h.fun(e), [[i], n] = aa(
    1,
    r ? e : [e],
    r ? [] : t
  );
  return r || arguments.length == 2 ? [i, n] : i;
}
var ca = class extends hr {
  constructor(e, t) {
    super(), this.source = e, this.idle = !0, this._active = /* @__PURE__ */ new Set(), this.calc = Le(...t);
    const r = this._get(), i = qt(r);
    lr(this, i.create(r));
  }
  advance(e) {
    const t = this._get(), r = this.get();
    ne(t, r) || (ee(this).setValue(t), this._onChange(t, this.idle)), !this.idle && vi(this._active) && Ft(this);
  }
  _get() {
    const e = h.arr(this.source) ? this.source.map(q) : W(q(this.source));
    return this.calc(...e);
  }
  _start() {
    this.idle && !vi(this._active) && (this.idle = !1, x(bt(this), (e) => {
      e.done = !1;
    }), Z.skipAnimation ? (P.batchedUpdates(() => this.advance()), Ft(this)) : gt.start(this));
  }
  // Observe our sources only when we're observed.
  _attach() {
    let e = 1;
    x(W(this.source), (t) => {
      H(t) && Pe(t, this), zt(t) && (t.idle || this._active.add(t), e = Math.max(e, t.priority + 1));
    }), this.priority = e, this._start();
  }
  // Stop observing our sources once we have no observers.
  _detach() {
    x(W(this.source), (e) => {
      H(e) && Be(e, this);
    }), this._active.clear(), Ft(this);
  }
  /** @internal */
  eventObserved(e) {
    e.type == "change" ? e.idle ? this.advance() : (this._active.add(e.parent), this._start()) : e.type == "idle" ? this._active.delete(e.parent) : e.type == "priority" && (this.priority = W(this.source).reduce(
      (t, r) => Math.max(t, (zt(r) ? r.priority : 0) + 1),
      0
    ));
  }
};
function la(e) {
  return e.idle !== !1;
}
function vi(e) {
  return !e.size || Array.from(e).every(la);
}
function Ft(e) {
  e.idle || (e.idle = !0, x(bt(e), (t) => {
    t.done = !0;
  }), $e(e, {
    type: "idle",
    parent: e
  }));
}
Z.assign({
  createStringInterpolator: Bi,
  to: (e, t) => new ca(e, t)
});
var un = /^--/;
function fa(e, t) {
  return t == null || typeof t == "boolean" || t === "" ? "" : typeof t == "number" && t !== 0 && !un.test(e) && !(Ne.hasOwnProperty(e) && Ne[e]) ? t + "px" : ("" + t).trim();
}
var yi = {};
function da(e, t) {
  if (!e.nodeType || !e.setAttribute)
    return !1;
  const r = e.nodeName === "filter" || e.parentNode && e.parentNode.nodeName === "filter", {
    className: i,
    style: n,
    children: o,
    scrollTop: a,
    scrollLeft: u,
    viewBox: l,
    ...c
  } = t, f = Object.values(c), p = Object.keys(c).map(
    (m) => r || e.hasAttribute(m) ? m : yi[m] || (yi[m] = m.replace(
      /([A-Z])/g,
      // Attributes are written in dash case
      (y) => "-" + y.toLowerCase()
    ))
  );
  o !== void 0 && (e.textContent = o);
  for (const m in n)
    if (n.hasOwnProperty(m)) {
      const y = fa(m, n[m]);
      un.test(m) ? e.style.setProperty(m, y) : e.style[m] = y;
    }
  p.forEach((m, y) => {
    e.setAttribute(m, f[y]);
  }), i !== void 0 && (e.className = i), a !== void 0 && (e.scrollTop = a), u !== void 0 && (e.scrollLeft = u), l !== void 0 && e.setAttribute("viewBox", l);
}
var Ne = {
  animationIterationCount: !0,
  borderImageOutset: !0,
  borderImageSlice: !0,
  borderImageWidth: !0,
  boxFlex: !0,
  boxFlexGroup: !0,
  boxOrdinalGroup: !0,
  columnCount: !0,
  columns: !0,
  flex: !0,
  flexGrow: !0,
  flexPositive: !0,
  flexShrink: !0,
  flexNegative: !0,
  flexOrder: !0,
  gridRow: !0,
  gridRowEnd: !0,
  gridRowSpan: !0,
  gridRowStart: !0,
  gridColumn: !0,
  gridColumnEnd: !0,
  gridColumnSpan: !0,
  gridColumnStart: !0,
  fontWeight: !0,
  lineClamp: !0,
  lineHeight: !0,
  opacity: !0,
  order: !0,
  orphans: !0,
  tabSize: !0,
  widows: !0,
  zIndex: !0,
  zoom: !0,
  // SVG-related properties
  fillOpacity: !0,
  floodOpacity: !0,
  stopOpacity: !0,
  strokeDasharray: !0,
  strokeDashoffset: !0,
  strokeMiterlimit: !0,
  strokeOpacity: !0,
  strokeWidth: !0
}, ha = (e, t) => e + t.charAt(0).toUpperCase() + t.substring(1), pa = ["Webkit", "Ms", "Moz", "O"];
Ne = Object.keys(Ne).reduce((e, t) => (pa.forEach((r) => e[ha(r, t)] = e[t]), e), Ne);
var ma = /^(matrix|translate|scale|rotate|skew)/, ga = /^(translate)/, va = /^(rotate|skew)/, Mt = (e, t) => h.num(e) && e !== 0 ? e + t : e, ut = (e, t) => h.arr(e) ? e.every((r) => ut(r, t)) : h.num(e) ? e === t : parseFloat(e) === t, ya = class extends wt {
  constructor({ x: e, y: t, z: r, ...i }) {
    const n = [], o = [];
    (e || t || r) && (n.push([e || 0, t || 0, r || 0]), o.push((a) => [
      `translate3d(${a.map((u) => Mt(u, "px")).join(",")})`,
      // prettier-ignore
      ut(a, 0)
    ])), te(i, (a, u) => {
      if (u === "transform")
        n.push([a || ""]), o.push((l) => [l, l === ""]);
      else if (ma.test(u)) {
        if (delete i[u], h.und(a))
          return;
        const l = ga.test(u) ? "px" : va.test(u) ? "deg" : "";
        n.push(W(a)), o.push(
          u === "rotate3d" ? ([c, f, p, m]) => [
            `rotate3d(${c},${f},${p},${Mt(m, l)})`,
            ut(m, 0)
          ] : (c) => [
            `${u}(${c.map((f) => Mt(f, l)).join(",")})`,
            ut(c, u.startsWith("scale") ? 1 : 0)
          ]
        );
      }
    }), n.length && (i.transform = new _a(n, o)), super(i);
  }
}, _a = class extends Li {
  constructor(e, t) {
    super(), this.inputs = e, this.transforms = t, this._value = null;
  }
  get() {
    return this._value || (this._value = this._get());
  }
  _get() {
    let e = "", t = !0;
    return x(this.inputs, (r, i) => {
      const n = q(r[0]), [o, a] = this.transforms[i](
        h.arr(n) ? n : r.map(q)
      );
      e += " " + o, t = t && a;
    }), t ? "none" : e;
  }
  // Start observing our inputs once we have an observer.
  observerAdded(e) {
    e == 1 && x(
      this.inputs,
      (t) => x(
        t,
        (r) => H(r) && Pe(r, this)
      )
    );
  }
  // Stop observing our inputs once we have no observers.
  observerRemoved(e) {
    e == 0 && x(
      this.inputs,
      (t) => x(
        t,
        (r) => H(r) && Be(r, this)
      )
    );
  }
  eventObserved(e) {
    e.type == "change" && (this._value = null), $e(this, e);
  }
}, ba = [
  "a",
  "abbr",
  "address",
  "area",
  "article",
  "aside",
  "audio",
  "b",
  "base",
  "bdi",
  "bdo",
  "big",
  "blockquote",
  "body",
  "br",
  "button",
  "canvas",
  "caption",
  "cite",
  "code",
  "col",
  "colgroup",
  "data",
  "datalist",
  "dd",
  "del",
  "details",
  "dfn",
  "dialog",
  "div",
  "dl",
  "dt",
  "em",
  "embed",
  "fieldset",
  "figcaption",
  "figure",
  "footer",
  "form",
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6",
  "head",
  "header",
  "hgroup",
  "hr",
  "html",
  "i",
  "iframe",
  "img",
  "input",
  "ins",
  "kbd",
  "keygen",
  "label",
  "legend",
  "li",
  "link",
  "main",
  "map",
  "mark",
  "menu",
  "menuitem",
  "meta",
  "meter",
  "nav",
  "noscript",
  "object",
  "ol",
  "optgroup",
  "option",
  "output",
  "p",
  "param",
  "picture",
  "pre",
  "progress",
  "q",
  "rp",
  "rt",
  "ruby",
  "s",
  "samp",
  "script",
  "section",
  "select",
  "small",
  "source",
  "span",
  "strong",
  "style",
  "sub",
  "summary",
  "sup",
  "table",
  "tbody",
  "td",
  "textarea",
  "tfoot",
  "th",
  "thead",
  "time",
  "title",
  "tr",
  "track",
  "u",
  "ul",
  "var",
  "video",
  "wbr",
  // SVG
  "circle",
  "clipPath",
  "defs",
  "ellipse",
  "foreignObject",
  "g",
  "image",
  "line",
  "linearGradient",
  "mask",
  "path",
  "pattern",
  "polygon",
  "polyline",
  "radialGradient",
  "rect",
  "stop",
  "svg",
  "text",
  "tspan"
];
Z.assign({
  batchedUpdates: Ln,
  createStringInterpolator: Bi,
  colors: ao
});
Uo(ba, {
  applyAnimatedValues: da,
  createAnimatedStyle: (e) => new ya(e),
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  getComponentProps: ({ scrollTop: e, scrollLeft: t, ...r }) => r
});
function Pa(e, t) {
  const [{ x: r }, i] = ua(() => ({ x: 0 }));
  return { bind: Zs({
    onDrag: ({ down: o, movement: [a], direction: [u], velocity: l }) => {
      !o && l > 0.2 ? (u > 0 ? t() : e(), i.start({ x: 0 })) : i.start({ x: o ? a : 0 });
    }
  }), style: { x: r } };
}
export {
  Sa as SwipeCard,
  Pa as useSwipe
};