@telegraph/modal 0.0.84 → 0.0.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,91 +1,90 @@
1
- import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
- import * as v from "@radix-ui/react-dialog";
3
- import * as i from "react";
4
- import g from "react";
5
- import * as H from "react-dom";
6
- import { FocusScope as Z } from "@radix-ui/react-focus-scope";
7
- import * as q from "@radix-ui/react-portal";
8
- import * as G from "@radix-ui/react-visually-hidden";
9
- import { Button as J } from "@telegraph/button";
10
- import { RefToTgphRef as Q } from "@telegraph/helpers";
11
- import { Lucide as ee } from "@telegraph/icon";
12
- import { Stack as E, Box as te } from "@telegraph/layout";
13
- import { AnimatePresence as ne, motion as T } from "framer-motion";
14
- function O(e, t, { checkForDefaultPrevented: r = !0 } = {}) {
15
- return function(n) {
16
- if (e == null || e(n), r === !1 || !n.defaultPrevented)
17
- return t == null ? void 0 : t(n);
18
- };
19
- }
20
- function F(e, t) {
1
+ import { jsx as M, jsxs as Ve } from "react/jsx-runtime";
2
+ import * as J from "@radix-ui/react-dialog";
3
+ import * as v from "react";
4
+ import ne, { createContext as se, useRef as de, useLayoutEffect as Us, useEffect as dt, useState as zs, useContext as I, useMemo as Fe, useCallback as Gs, useInsertionEffect as Hs, forwardRef as Ys, Fragment as Tn, createElement as Xs } from "react";
5
+ import * as qs from "react-dom";
6
+ import { FocusScope as Zs } from "@radix-ui/react-focus-scope";
7
+ import * as Js from "@radix-ui/react-portal";
8
+ import * as Qs from "@radix-ui/react-visually-hidden";
9
+ import { Button as ei } from "@telegraph/button";
10
+ import { RefToTgphRef as ti } from "@telegraph/helpers";
11
+ import { Stack as ee, Box as ni } from "@telegraph/layout";
12
+ import { X as si } from "lucide-react";
13
+ function Ke(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
14
+ return function(i) {
15
+ if (e == null || e(i), n === !1 || !i.defaultPrevented)
16
+ return t == null ? void 0 : t(i);
17
+ };
18
+ }
19
+ function Kt(e, t) {
21
20
  if (typeof e == "function")
22
21
  return e(t);
23
22
  e != null && (e.current = t);
24
23
  }
25
- function $(...e) {
24
+ function wn(...e) {
26
25
  return (t) => {
27
- let r = !1;
28
- const o = e.map((n) => {
29
- const s = F(n, t);
30
- return !r && typeof s == "function" && (r = !0), s;
26
+ let n = !1;
27
+ const s = e.map((i) => {
28
+ const r = Kt(i, t);
29
+ return !n && typeof r == "function" && (n = !0), r;
31
30
  });
32
- if (r)
31
+ if (n)
33
32
  return () => {
34
- for (let n = 0; n < o.length; n++) {
35
- const s = o[n];
36
- typeof s == "function" ? s() : F(e[n], null);
33
+ for (let i = 0; i < s.length; i++) {
34
+ const r = s[i];
35
+ typeof r == "function" ? r() : Kt(e[i], null);
37
36
  }
38
37
  };
39
38
  };
40
39
  }
41
- function M(...e) {
42
- return i.useCallback($(...e), e);
40
+ function Sn(...e) {
41
+ return v.useCallback(wn(...e), e);
43
42
  }
44
43
  // @__NO_SIDE_EFFECTS__
45
- function re(e) {
46
- const t = /* @__PURE__ */ oe(e), r = i.forwardRef((o, n) => {
47
- const { children: s, ...l } = o, a = i.Children.toArray(s), f = a.find(ie);
48
- if (f) {
49
- const u = f.props.children, c = a.map((y) => y === f ? i.Children.count(u) > 1 ? i.Children.only(null) : i.isValidElement(u) ? u.props.children : null : y);
50
- return /* @__PURE__ */ d(t, { ...l, ref: n, children: i.isValidElement(u) ? i.cloneElement(u, void 0, c) : null });
51
- }
52
- return /* @__PURE__ */ d(t, { ...l, ref: n, children: s });
44
+ function ii(e) {
45
+ const t = /* @__PURE__ */ ri(e), n = v.forwardRef((s, i) => {
46
+ const { children: r, ...o } = s, a = v.Children.toArray(r), l = a.find(ai);
47
+ if (l) {
48
+ const u = l.props.children, c = a.map((d) => d === l ? v.Children.count(u) > 1 ? v.Children.only(null) : v.isValidElement(u) ? u.props.children : null : d);
49
+ return /* @__PURE__ */ M(t, { ...o, ref: i, children: v.isValidElement(u) ? v.cloneElement(u, void 0, c) : null });
50
+ }
51
+ return /* @__PURE__ */ M(t, { ...o, ref: i, children: r });
53
52
  });
54
- return r.displayName = `${e}.Slot`, r;
53
+ return n.displayName = `${e}.Slot`, n;
55
54
  }
56
55
  // @__NO_SIDE_EFFECTS__
57
- function oe(e) {
58
- const t = i.forwardRef((r, o) => {
59
- const { children: n, ...s } = r;
60
- if (i.isValidElement(n)) {
61
- const l = ce(n), a = ae(s, n.props);
62
- return n.type !== i.Fragment && (a.ref = o ? $(o, l) : l), i.cloneElement(n, a);
63
- }
64
- return i.Children.count(n) > 1 ? i.Children.only(null) : null;
56
+ function ri(e) {
57
+ const t = v.forwardRef((n, s) => {
58
+ const { children: i, ...r } = n;
59
+ if (v.isValidElement(i)) {
60
+ const o = ui(i), a = ci(r, i.props);
61
+ return i.type !== v.Fragment && (a.ref = s ? wn(s, o) : o), v.cloneElement(i, a);
62
+ }
63
+ return v.Children.count(i) > 1 ? v.Children.only(null) : null;
65
64
  });
66
65
  return t.displayName = `${e}.SlotClone`, t;
67
66
  }
68
- var se = Symbol("radix.slottable");
69
- function ie(e) {
70
- return i.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === se;
67
+ var oi = Symbol("radix.slottable");
68
+ function ai(e) {
69
+ return v.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === oi;
71
70
  }
72
- function ae(e, t) {
73
- const r = { ...t };
74
- for (const o in t) {
75
- const n = e[o], s = t[o];
76
- /^on[A-Z]/.test(o) ? n && s ? r[o] = (...a) => {
77
- const f = s(...a);
78
- return n(...a), f;
79
- } : n && (r[o] = n) : o === "style" ? r[o] = { ...n, ...s } : o === "className" && (r[o] = [n, s].filter(Boolean).join(" "));
71
+ function ci(e, t) {
72
+ const n = { ...t };
73
+ for (const s in t) {
74
+ const i = e[s], r = t[s];
75
+ /^on[A-Z]/.test(s) ? i && r ? n[s] = (...a) => {
76
+ const l = r(...a);
77
+ return i(...a), l;
78
+ } : i && (n[s] = i) : s === "style" ? n[s] = { ...i, ...r } : s === "className" && (n[s] = [i, r].filter(Boolean).join(" "));
80
79
  }
81
- return { ...e, ...r };
80
+ return { ...e, ...n };
82
81
  }
83
- function ce(e) {
84
- var o, n;
85
- let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, r = t && "isReactWarning" in t && t.isReactWarning;
86
- return r ? e.ref : (t = (n = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : n.get, r = t && "isReactWarning" in t && t.isReactWarning, r ? e.props.ref : e.props.ref || e.ref);
82
+ function ui(e) {
83
+ var s, i;
84
+ let t = (s = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : s.get, n = t && "isReactWarning" in t && t.isReactWarning;
85
+ return n ? e.ref : (t = (i = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : i.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
87
86
  }
88
- var le = [
87
+ var li = [
89
88
  "a",
90
89
  "button",
91
90
  "div",
@@ -103,354 +102,3615 @@ var le = [
103
102
  "span",
104
103
  "svg",
105
104
  "ul"
106
- ], j = le.reduce((e, t) => {
107
- const r = /* @__PURE__ */ re(`Primitive.${t}`), o = i.forwardRef((n, s) => {
108
- const { asChild: l, ...a } = n, f = l ? r : t;
109
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ d(f, { ...a, ref: s });
105
+ ], xn = li.reduce((e, t) => {
106
+ const n = /* @__PURE__ */ ii(`Primitive.${t}`), s = v.forwardRef((i, r) => {
107
+ const { asChild: o, ...a } = i, l = o ? n : t;
108
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ M(l, { ...a, ref: r });
110
109
  });
111
- return o.displayName = `Primitive.${t}`, { ...e, [t]: o };
110
+ return s.displayName = `Primitive.${t}`, { ...e, [t]: s };
112
111
  }, {});
113
- function ue(e, t) {
114
- e && H.flushSync(() => e.dispatchEvent(t));
112
+ function fi(e, t) {
113
+ e && qs.flushSync(() => e.dispatchEvent(t));
115
114
  }
116
- function I(e) {
117
- const t = i.useRef(e);
118
- return i.useEffect(() => {
115
+ function ht(e) {
116
+ const t = v.useRef(e);
117
+ return v.useEffect(() => {
119
118
  t.current = e;
120
- }), i.useMemo(() => (...r) => {
121
- var o;
122
- return (o = t.current) == null ? void 0 : o.call(t, ...r);
119
+ }), v.useMemo(() => (...n) => {
120
+ var s;
121
+ return (s = t.current) == null ? void 0 : s.call(t, ...n);
123
122
  }, []);
124
123
  }
125
- function de(e, t = globalThis == null ? void 0 : globalThis.document) {
126
- const r = I(e);
127
- i.useEffect(() => {
128
- const o = (n) => {
129
- n.key === "Escape" && r(n);
124
+ function di(e, t = globalThis == null ? void 0 : globalThis.document) {
125
+ const n = ht(e);
126
+ v.useEffect(() => {
127
+ const s = (i) => {
128
+ i.key === "Escape" && n(i);
130
129
  };
131
- return t.addEventListener("keydown", o, { capture: !0 }), () => t.removeEventListener("keydown", o, { capture: !0 });
132
- }, [r, t]);
130
+ return t.addEventListener("keydown", s, { capture: !0 }), () => t.removeEventListener("keydown", s, { capture: !0 });
131
+ }, [n, t]);
133
132
  }
134
- var fe = "DismissableLayer", B = "dismissableLayer.update", pe = "dismissableLayer.pointerDownOutside", ye = "dismissableLayer.focusOutside", A, U = i.createContext({
133
+ var hi = "DismissableLayer", Ge = "dismissableLayer.update", pi = "dismissableLayer.pointerDownOutside", mi = "dismissableLayer.focusOutside", Wt, Vn = v.createContext({
135
134
  layers: /* @__PURE__ */ new Set(),
136
135
  layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
137
136
  branches: /* @__PURE__ */ new Set()
138
- }), z = i.forwardRef(
137
+ }), An = v.forwardRef(
139
138
  (e, t) => {
140
139
  const {
141
- disableOutsidePointerEvents: r = !1,
142
- onEscapeKeyDown: o,
143
- onPointerDownOutside: n,
144
- onFocusOutside: s,
145
- onInteractOutside: l,
140
+ disableOutsidePointerEvents: n = !1,
141
+ onEscapeKeyDown: s,
142
+ onPointerDownOutside: i,
143
+ onFocusOutside: r,
144
+ onInteractOutside: o,
146
145
  onDismiss: a,
147
- ...f
148
- } = e, u = i.useContext(U), [c, y] = i.useState(null), m = (c == null ? void 0 : c.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, L] = i.useState({}), b = M(t, (p) => y(p)), C = Array.from(u.layers), [P] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), h = C.indexOf(P), x = c ? C.indexOf(c) : -1, w = u.layersWithOutsidePointerEventsDisabled.size > 0, W = x >= h, Y = ve((p) => {
149
- const R = p.target, k = [...u.branches].some((D) => D.contains(R));
150
- !W || k || (n == null || n(p), l == null || l(p), p.defaultPrevented || a == null || a());
151
- }, m), N = Ee((p) => {
152
- const R = p.target;
153
- [...u.branches].some((D) => D.contains(R)) || (s == null || s(p), l == null || l(p), p.defaultPrevented || a == null || a());
154
- }, m);
155
- return de((p) => {
156
- x === u.layers.size - 1 && (o == null || o(p), !p.defaultPrevented && a && (p.preventDefault(), a()));
157
- }, m), i.useEffect(() => {
146
+ ...l
147
+ } = e, u = v.useContext(Vn), [c, d] = v.useState(null), f = (c == null ? void 0 : c.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, h] = v.useState({}), g = Sn(t, (x) => d(x)), y = Array.from(u.layers), [T] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), p = y.indexOf(T), V = c ? y.indexOf(c) : -1, m = u.layersWithOutsidePointerEventsDisabled.size > 0, C = V >= p, w = bi((x) => {
148
+ const S = x.target, D = [...u.branches].some((F) => F.contains(S));
149
+ !C || D || (i == null || i(x), o == null || o(x), x.defaultPrevented || a == null || a());
150
+ }, f), A = vi((x) => {
151
+ const S = x.target;
152
+ [...u.branches].some((F) => F.contains(S)) || (r == null || r(x), o == null || o(x), x.defaultPrevented || a == null || a());
153
+ }, f);
154
+ return di((x) => {
155
+ V === u.layers.size - 1 && (s == null || s(x), !x.defaultPrevented && a && (x.preventDefault(), a()));
156
+ }, f), v.useEffect(() => {
158
157
  if (c)
159
- return r && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (A = m.body.style.pointerEvents, m.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(c)), u.layers.add(c), _(), () => {
160
- r && u.layersWithOutsidePointerEventsDisabled.size === 1 && (m.body.style.pointerEvents = A);
158
+ return n && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (Wt = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(c)), u.layers.add(c), $t(), () => {
159
+ n && u.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = Wt);
161
160
  };
162
- }, [c, m, r, u]), i.useEffect(() => () => {
163
- c && (u.layers.delete(c), u.layersWithOutsidePointerEventsDisabled.delete(c), _());
164
- }, [c, u]), i.useEffect(() => {
165
- const p = () => L({});
166
- return document.addEventListener(B, p), () => document.removeEventListener(B, p);
167
- }, []), /* @__PURE__ */ d(
168
- j.div,
161
+ }, [c, f, n, u]), v.useEffect(() => () => {
162
+ c && (u.layers.delete(c), u.layersWithOutsidePointerEventsDisabled.delete(c), $t());
163
+ }, [c, u]), v.useEffect(() => {
164
+ const x = () => h({});
165
+ return document.addEventListener(Ge, x), () => document.removeEventListener(Ge, x);
166
+ }, []), /* @__PURE__ */ M(
167
+ xn.div,
169
168
  {
170
- ...f,
171
- ref: b,
169
+ ...l,
170
+ ref: g,
172
171
  style: {
173
- pointerEvents: w ? W ? "auto" : "none" : void 0,
172
+ pointerEvents: m ? C ? "auto" : "none" : void 0,
174
173
  ...e.style
175
174
  },
176
- onFocusCapture: O(e.onFocusCapture, N.onFocusCapture),
177
- onBlurCapture: O(e.onBlurCapture, N.onBlurCapture),
178
- onPointerDownCapture: O(
175
+ onFocusCapture: Ke(e.onFocusCapture, A.onFocusCapture),
176
+ onBlurCapture: Ke(e.onBlurCapture, A.onBlurCapture),
177
+ onPointerDownCapture: Ke(
179
178
  e.onPointerDownCapture,
180
- Y.onPointerDownCapture
179
+ w.onPointerDownCapture
181
180
  )
182
181
  }
183
182
  );
184
183
  }
185
184
  );
186
- z.displayName = fe;
187
- var me = "DismissableLayerBranch", he = i.forwardRef((e, t) => {
188
- const r = i.useContext(U), o = i.useRef(null), n = M(t, o);
189
- return i.useEffect(() => {
190
- const s = o.current;
191
- if (s)
192
- return r.branches.add(s), () => {
193
- r.branches.delete(s);
185
+ An.displayName = hi;
186
+ var gi = "DismissableLayerBranch", yi = v.forwardRef((e, t) => {
187
+ const n = v.useContext(Vn), s = v.useRef(null), i = Sn(t, s);
188
+ return v.useEffect(() => {
189
+ const r = s.current;
190
+ if (r)
191
+ return n.branches.add(r), () => {
192
+ n.branches.delete(r);
194
193
  };
195
- }, [r.branches]), /* @__PURE__ */ d(j.div, { ...e, ref: n });
194
+ }, [n.branches]), /* @__PURE__ */ M(xn.div, { ...e, ref: i });
196
195
  });
197
- he.displayName = me;
198
- function ve(e, t = globalThis == null ? void 0 : globalThis.document) {
199
- const r = I(e), o = i.useRef(!1), n = i.useRef(() => {
196
+ yi.displayName = gi;
197
+ function bi(e, t = globalThis == null ? void 0 : globalThis.document) {
198
+ const n = ht(e), s = v.useRef(!1), i = v.useRef(() => {
200
199
  });
201
- return i.useEffect(() => {
202
- const s = (a) => {
203
- if (a.target && !o.current) {
204
- let f = function() {
205
- V(
206
- pe,
207
- r,
200
+ return v.useEffect(() => {
201
+ const r = (a) => {
202
+ if (a.target && !s.current) {
203
+ let l = function() {
204
+ Cn(
205
+ pi,
206
+ n,
208
207
  u,
209
208
  { discrete: !0 }
210
209
  );
211
210
  };
212
211
  const u = { originalEvent: a };
213
- a.pointerType === "touch" ? (t.removeEventListener("click", n.current), n.current = f, t.addEventListener("click", n.current, { once: !0 })) : f();
212
+ a.pointerType === "touch" ? (t.removeEventListener("click", i.current), i.current = l, t.addEventListener("click", i.current, { once: !0 })) : l();
214
213
  } else
215
- t.removeEventListener("click", n.current);
216
- o.current = !1;
217
- }, l = window.setTimeout(() => {
218
- t.addEventListener("pointerdown", s);
214
+ t.removeEventListener("click", i.current);
215
+ s.current = !1;
216
+ }, o = window.setTimeout(() => {
217
+ t.addEventListener("pointerdown", r);
219
218
  }, 0);
220
219
  return () => {
221
- window.clearTimeout(l), t.removeEventListener("pointerdown", s), t.removeEventListener("click", n.current);
220
+ window.clearTimeout(o), t.removeEventListener("pointerdown", r), t.removeEventListener("click", i.current);
222
221
  };
223
- }, [t, r]), {
222
+ }, [t, n]), {
224
223
  // ensures we check React component tree (not just DOM tree)
225
- onPointerDownCapture: () => o.current = !0
224
+ onPointerDownCapture: () => s.current = !0
226
225
  };
227
226
  }
228
- function Ee(e, t = globalThis == null ? void 0 : globalThis.document) {
229
- const r = I(e), o = i.useRef(!1);
230
- return i.useEffect(() => {
231
- const n = (s) => {
232
- s.target && !o.current && V(ye, r, { originalEvent: s }, {
227
+ function vi(e, t = globalThis == null ? void 0 : globalThis.document) {
228
+ const n = ht(e), s = v.useRef(!1);
229
+ return v.useEffect(() => {
230
+ const i = (r) => {
231
+ r.target && !s.current && Cn(mi, n, { originalEvent: r }, {
233
232
  discrete: !1
234
233
  });
235
234
  };
236
- return t.addEventListener("focusin", n), () => t.removeEventListener("focusin", n);
237
- }, [t, r]), {
238
- onFocusCapture: () => o.current = !0,
239
- onBlurCapture: () => o.current = !1
235
+ return t.addEventListener("focusin", i), () => t.removeEventListener("focusin", i);
236
+ }, [t, n]), {
237
+ onFocusCapture: () => s.current = !0,
238
+ onBlurCapture: () => s.current = !1
240
239
  };
241
240
  }
242
- function _() {
243
- const e = new CustomEvent(B);
241
+ function $t() {
242
+ const e = new CustomEvent(Ge);
244
243
  document.dispatchEvent(e);
245
244
  }
246
- function V(e, t, r, { discrete: o }) {
247
- const n = r.originalEvent.target, s = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: r });
248
- t && n.addEventListener(e, t, { once: !0 }), o ? ue(n, s) : n.dispatchEvent(s);
245
+ function Cn(e, t, n, { discrete: s }) {
246
+ const i = n.originalEvent.target, r = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
247
+ t && i.addEventListener(e, t, { once: !0 }), s ? fi(i, r) : i.dispatchEvent(r);
249
248
  }
250
- var ge = globalThis != null && globalThis.document ? i.useLayoutEffect : () => {
251
- }, be = i[" useInsertionEffect ".trim().toString()] || ge;
252
- function Ce({
249
+ var Ti = globalThis != null && globalThis.document ? v.useLayoutEffect : () => {
250
+ }, wi = v[" useInsertionEffect ".trim().toString()] || Ti;
251
+ function Si({
253
252
  prop: e,
254
253
  defaultProp: t,
255
- onChange: r = () => {
254
+ onChange: n = () => {
256
255
  },
257
- caller: o
256
+ caller: s
258
257
  }) {
259
- const [n, s, l] = Le({
258
+ const [i, r, o] = xi({
260
259
  defaultProp: t,
261
- onChange: r
262
- }), a = e !== void 0, f = a ? e : n;
260
+ onChange: n
261
+ }), a = e !== void 0, l = a ? e : i;
263
262
  {
264
- const c = i.useRef(e !== void 0);
265
- i.useEffect(() => {
266
- const y = c.current;
267
- y !== a && console.warn(
268
- `${o} is changing from ${y ? "controlled" : "uncontrolled"} to ${a ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
263
+ const c = v.useRef(e !== void 0);
264
+ v.useEffect(() => {
265
+ const d = c.current;
266
+ d !== a && console.warn(
267
+ `${s} is changing from ${d ? "controlled" : "uncontrolled"} to ${a ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
269
268
  ), c.current = a;
270
- }, [a, o]);
269
+ }, [a, s]);
271
270
  }
272
- const u = i.useCallback(
271
+ const u = v.useCallback(
273
272
  (c) => {
274
- var y;
273
+ var d;
275
274
  if (a) {
276
- const m = Pe(c) ? c(e) : c;
277
- m !== e && ((y = l.current) == null || y.call(l, m));
275
+ const f = Vi(c) ? c(e) : c;
276
+ f !== e && ((d = o.current) == null || d.call(o, f));
278
277
  } else
279
- s(c);
278
+ r(c);
280
279
  },
281
- [a, e, s, l]
280
+ [a, e, r, o]
282
281
  );
283
- return [f, u];
282
+ return [l, u];
284
283
  }
285
- function Le({
284
+ function xi({
286
285
  defaultProp: e,
287
286
  onChange: t
288
287
  }) {
289
- const [r, o] = i.useState(e), n = i.useRef(r), s = i.useRef(t);
290
- return be(() => {
291
- s.current = t;
292
- }, [t]), i.useEffect(() => {
293
- var l;
294
- n.current !== r && ((l = s.current) == null || l.call(s, r), n.current = r);
295
- }, [r, n]), [r, o, s];
296
- }
297
- function Pe(e) {
288
+ const [n, s] = v.useState(e), i = v.useRef(n), r = v.useRef(t);
289
+ return wi(() => {
290
+ r.current = t;
291
+ }, [t]), v.useEffect(() => {
292
+ var o;
293
+ i.current !== n && ((o = r.current) == null || o.call(r, n), i.current = n);
294
+ }, [n, i]), [n, s, r];
295
+ }
296
+ function Vi(e) {
298
297
  return typeof e == "function";
299
298
  }
300
- const K = g.createContext({
301
- layers: [],
302
- setLayers: () => {
303
- },
304
- addLayer: () => {
299
+ const Ai = se({});
300
+ function Ci(e) {
301
+ const t = de(null);
302
+ return t.current === null && (t.current = e()), t.current;
303
+ }
304
+ const pt = typeof window < "u", Mi = pt ? Us : dt, Mn = /* @__PURE__ */ se(null);
305
+ function Pi(e, t) {
306
+ e.indexOf(t) === -1 && e.push(t);
307
+ }
308
+ function Ei(e, t) {
309
+ const n = e.indexOf(t);
310
+ n > -1 && e.splice(n, 1);
311
+ }
312
+ const Y = (e, t, n) => n > t ? t : n < e ? e : n;
313
+ let ie = () => {
314
+ }, _ = () => {
315
+ };
316
+ process.env.NODE_ENV !== "production" && (ie = (e, t) => {
317
+ !e && typeof console < "u" && console.warn(t);
318
+ }, _ = (e, t) => {
319
+ if (!e)
320
+ throw new Error(t);
321
+ });
322
+ const W = {}, Pn = (e) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);
323
+ function Di(e) {
324
+ return typeof e == "object" && e !== null;
325
+ }
326
+ const En = (e) => /^0[^.\s]+$/u.test(e);
327
+ // @__NO_SIDE_EFFECTS__
328
+ function mt(e) {
329
+ let t;
330
+ return () => (t === void 0 && (t = e()), t);
331
+ }
332
+ const re = /* @__NO_SIDE_EFFECTS__ */ (e) => e, Fi = (e, t) => (n) => t(e(n)), Re = (...e) => e.reduce(Fi), Dn = /* @__NO_SIDE_EFFECTS__ */ (e, t, n) => {
333
+ const s = t - e;
334
+ return s === 0 ? 1 : (n - e) / s;
335
+ };
336
+ class Fn {
337
+ constructor() {
338
+ this.subscriptions = [];
339
+ }
340
+ add(t) {
341
+ return Pi(this.subscriptions, t), () => Ei(this.subscriptions, t);
342
+ }
343
+ notify(t, n, s) {
344
+ const i = this.subscriptions.length;
345
+ if (i)
346
+ if (i === 1)
347
+ this.subscriptions[0](t, n, s);
348
+ else
349
+ for (let r = 0; r < i; r++) {
350
+ const o = this.subscriptions[r];
351
+ o && o(t, n, s);
352
+ }
353
+ }
354
+ getSize() {
355
+ return this.subscriptions.length;
356
+ }
357
+ clear() {
358
+ this.subscriptions.length = 0;
359
+ }
360
+ }
361
+ const N = /* @__NO_SIDE_EFFECTS__ */ (e) => e * 1e3, K = /* @__NO_SIDE_EFFECTS__ */ (e) => e / 1e3;
362
+ function Rn(e, t) {
363
+ return t ? e * (1e3 / t) : 0;
364
+ }
365
+ const _t = /* @__PURE__ */ new Set();
366
+ function On(e, t, n) {
367
+ e || _t.has(t) || (console.warn(t), _t.add(t));
368
+ }
369
+ const Ln = (e, t, n) => (((1 - 3 * n + 3 * t) * e + (3 * n - 6 * t)) * e + 3 * t) * e, Ri = 1e-7, Oi = 12;
370
+ function Li(e, t, n, s, i) {
371
+ let r, o, a = 0;
372
+ do
373
+ o = t + (n - t) / 2, r = Ln(o, s, i) - e, r > 0 ? n = o : t = o;
374
+ while (Math.abs(r) > Ri && ++a < Oi);
375
+ return o;
376
+ }
377
+ function be(e, t, n, s) {
378
+ if (e === t && n === s)
379
+ return re;
380
+ const i = (r) => Li(r, 0, 1, e, n);
381
+ return (r) => r === 0 || r === 1 ? r : Ln(i(r), t, s);
382
+ }
383
+ const In = (e) => (t) => t <= 0.5 ? e(2 * t) / 2 : (2 - e(2 * (1 - t))) / 2, kn = (e) => (t) => 1 - e(1 - t), Nn = /* @__PURE__ */ be(0.33, 1.53, 0.69, 0.99), gt = /* @__PURE__ */ kn(Nn), Bn = /* @__PURE__ */ In(gt), Kn = (e) => (e *= 2) < 1 ? 0.5 * gt(e) : 0.5 * (2 - Math.pow(2, -10 * (e - 1))), yt = (e) => 1 - Math.sin(Math.acos(e)), Ii = kn(yt), Wn = In(yt), ki = /* @__PURE__ */ be(0.42, 0, 1, 1), Ni = /* @__PURE__ */ be(0, 0, 0.58, 1), $n = /* @__PURE__ */ be(0.42, 0, 0.58, 1), Bi = (e) => Array.isArray(e) && typeof e[0] != "number", _n = (e) => Array.isArray(e) && typeof e[0] == "number", jt = {
384
+ linear: re,
385
+ easeIn: ki,
386
+ easeInOut: $n,
387
+ easeOut: Ni,
388
+ circIn: yt,
389
+ circInOut: Wn,
390
+ circOut: Ii,
391
+ backIn: gt,
392
+ backInOut: Bn,
393
+ backOut: Nn,
394
+ anticipate: Kn
395
+ }, Ki = (e) => typeof e == "string", Ut = (e) => {
396
+ if (_n(e)) {
397
+ _(e.length === 4, "Cubic bezier arrays must contain four numerical values.");
398
+ const [t, n, s, i] = e;
399
+ return be(t, n, s, i);
400
+ } else if (Ki(e))
401
+ return _(jt[e] !== void 0, `Invalid easing type '${e}'`), jt[e];
402
+ return e;
403
+ }, Te = [
404
+ "setup",
405
+ // Compute
406
+ "read",
407
+ // Read
408
+ "resolveKeyframes",
409
+ // Write/Read/Write/Read
410
+ "preUpdate",
411
+ // Compute
412
+ "update",
413
+ // Compute
414
+ "preRender",
415
+ // Compute
416
+ "render",
417
+ // Write
418
+ "postRender"
419
+ // Compute
420
+ ];
421
+ function Wi(e, t) {
422
+ let n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = !1, r = !1;
423
+ const o = /* @__PURE__ */ new WeakSet();
424
+ let a = {
425
+ delta: 0,
426
+ timestamp: 0,
427
+ isProcessing: !1
428
+ };
429
+ function l(c) {
430
+ o.has(c) && (u.schedule(c), e()), c(a);
431
+ }
432
+ const u = {
433
+ /**
434
+ * Schedule a process to run on the next frame.
435
+ */
436
+ schedule: (c, d = !1, f = !1) => {
437
+ const g = f && i ? n : s;
438
+ return d && o.add(c), g.has(c) || g.add(c), c;
439
+ },
440
+ /**
441
+ * Cancel the provided callback from running on the next frame.
442
+ */
443
+ cancel: (c) => {
444
+ s.delete(c), o.delete(c);
445
+ },
446
+ /**
447
+ * Execute all schedule callbacks.
448
+ */
449
+ process: (c) => {
450
+ if (a = c, i) {
451
+ r = !0;
452
+ return;
453
+ }
454
+ i = !0, [n, s] = [s, n], n.forEach(l), n.clear(), i = !1, r && (r = !1, u.process(c));
455
+ }
456
+ };
457
+ return u;
458
+ }
459
+ const $i = 40;
460
+ function jn(e, t) {
461
+ let n = !1, s = !0;
462
+ const i = {
463
+ delta: 0,
464
+ timestamp: 0,
465
+ isProcessing: !1
466
+ }, r = () => n = !0, o = Te.reduce((m, C) => (m[C] = Wi(r), m), {}), { setup: a, read: l, resolveKeyframes: u, preUpdate: c, update: d, preRender: f, render: h, postRender: g } = o, y = () => {
467
+ const m = W.useManualTiming ? i.timestamp : performance.now();
468
+ n = !1, W.useManualTiming || (i.delta = s ? 1e3 / 60 : Math.max(Math.min(m - i.timestamp, $i), 1)), i.timestamp = m, i.isProcessing = !0, a.process(i), l.process(i), u.process(i), c.process(i), d.process(i), f.process(i), h.process(i), g.process(i), i.isProcessing = !1, n && t && (s = !1, e(y));
469
+ }, T = () => {
470
+ n = !0, s = !0, i.isProcessing || e(y);
471
+ };
472
+ return { schedule: Te.reduce((m, C) => {
473
+ const w = o[C];
474
+ return m[C] = (A, x = !1, S = !1) => (n || T(), w.schedule(A, x, S)), m;
475
+ }, {}), cancel: (m) => {
476
+ for (let C = 0; C < Te.length; C++)
477
+ o[Te[C]].cancel(m);
478
+ }, state: i, steps: o };
479
+ }
480
+ const { schedule: k, cancel: He, state: Ae, steps: Dc } = /* @__PURE__ */ jn(typeof requestAnimationFrame < "u" ? requestAnimationFrame : re, !0);
481
+ let Se;
482
+ function _i() {
483
+ Se = void 0;
484
+ }
485
+ const L = {
486
+ now: () => (Se === void 0 && L.set(Ae.isProcessing || W.useManualTiming ? Ae.timestamp : performance.now()), Se),
487
+ set: (e) => {
488
+ Se = e, queueMicrotask(_i);
489
+ }
490
+ }, Un = (e) => (t) => typeof t == "string" && t.startsWith(e), zn = /* @__PURE__ */ Un("--"), ji = /* @__PURE__ */ Un("var(--"), bt = (e) => ji(e) ? Ui.test(e.split("/*")[0].trim()) : !1, Ui = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu, oe = {
491
+ test: (e) => typeof e == "number",
492
+ parse: parseFloat,
493
+ transform: (e) => e
494
+ }, pe = {
495
+ ...oe,
496
+ transform: (e) => Y(0, 1, e)
497
+ }, we = {
498
+ ...oe,
499
+ default: 1
500
+ }, he = (e) => Math.round(e * 1e5) / 1e5, vt = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
501
+ function zi(e) {
502
+ return e == null;
503
+ }
504
+ const Gi = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, Tt = (e, t) => (n) => !!(typeof n == "string" && Gi.test(n) && n.startsWith(e) || t && !zi(n) && Object.prototype.hasOwnProperty.call(n, t)), Gn = (e, t, n) => (s) => {
505
+ if (typeof s != "string")
506
+ return s;
507
+ const [i, r, o, a] = s.match(vt);
508
+ return {
509
+ [e]: parseFloat(i),
510
+ [t]: parseFloat(r),
511
+ [n]: parseFloat(o),
512
+ alpha: a !== void 0 ? parseFloat(a) : 1
513
+ };
514
+ }, Hi = (e) => Y(0, 255, e), We = {
515
+ ...oe,
516
+ transform: (e) => Math.round(Hi(e))
517
+ }, U = {
518
+ test: /* @__PURE__ */ Tt("rgb", "red"),
519
+ parse: /* @__PURE__ */ Gn("red", "green", "blue"),
520
+ transform: ({ red: e, green: t, blue: n, alpha: s = 1 }) => "rgba(" + We.transform(e) + ", " + We.transform(t) + ", " + We.transform(n) + ", " + he(pe.transform(s)) + ")"
521
+ };
522
+ function Yi(e) {
523
+ let t = "", n = "", s = "", i = "";
524
+ return e.length > 5 ? (t = e.substring(1, 3), n = e.substring(3, 5), s = e.substring(5, 7), i = e.substring(7, 9)) : (t = e.substring(1, 2), n = e.substring(2, 3), s = e.substring(3, 4), i = e.substring(4, 5), t += t, n += n, s += s, i += i), {
525
+ red: parseInt(t, 16),
526
+ green: parseInt(n, 16),
527
+ blue: parseInt(s, 16),
528
+ alpha: i ? parseInt(i, 16) / 255 : 1
529
+ };
530
+ }
531
+ const Ye = {
532
+ test: /* @__PURE__ */ Tt("#"),
533
+ parse: Yi,
534
+ transform: U.transform
535
+ }, ve = /* @__NO_SIDE_EFFECTS__ */ (e) => ({
536
+ test: (t) => typeof t == "string" && t.endsWith(e) && t.split(" ").length === 1,
537
+ parse: parseFloat,
538
+ transform: (t) => `${t}${e}`
539
+ }), $ = /* @__PURE__ */ ve("deg"), Q = /* @__PURE__ */ ve("%"), b = /* @__PURE__ */ ve("px"), Xi = /* @__PURE__ */ ve("vh"), qi = /* @__PURE__ */ ve("vw"), zt = {
540
+ ...Q,
541
+ parse: (e) => Q.parse(e) / 100,
542
+ transform: (e) => Q.transform(e * 100)
543
+ }, q = {
544
+ test: /* @__PURE__ */ Tt("hsl", "hue"),
545
+ parse: /* @__PURE__ */ Gn("hue", "saturation", "lightness"),
546
+ transform: ({ hue: e, saturation: t, lightness: n, alpha: s = 1 }) => "hsla(" + Math.round(e) + ", " + Q.transform(he(t)) + ", " + Q.transform(he(n)) + ", " + he(pe.transform(s)) + ")"
547
+ }, E = {
548
+ test: (e) => U.test(e) || Ye.test(e) || q.test(e),
549
+ parse: (e) => U.test(e) ? U.parse(e) : q.test(e) ? q.parse(e) : Ye.parse(e),
550
+ transform: (e) => typeof e == "string" ? e : e.hasOwnProperty("red") ? U.transform(e) : q.transform(e),
551
+ getAnimatableNone: (e) => {
552
+ const t = E.parse(e);
553
+ return t.alpha = 0, E.transform(t);
554
+ }
555
+ }, Zi = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
556
+ function Ji(e) {
557
+ var t, n;
558
+ return isNaN(e) && typeof e == "string" && (((t = e.match(vt)) == null ? void 0 : t.length) || 0) + (((n = e.match(Zi)) == null ? void 0 : n.length) || 0) > 0;
559
+ }
560
+ const Hn = "number", Yn = "color", Qi = "var", er = "var(", Gt = "${}", tr = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;
561
+ function me(e) {
562
+ const t = e.toString(), n = [], s = {
563
+ color: [],
564
+ number: [],
565
+ var: []
566
+ }, i = [];
567
+ let r = 0;
568
+ const a = t.replace(tr, (l) => (E.test(l) ? (s.color.push(r), i.push(Yn), n.push(E.parse(l))) : l.startsWith(er) ? (s.var.push(r), i.push(Qi), n.push(l)) : (s.number.push(r), i.push(Hn), n.push(parseFloat(l))), ++r, Gt)).split(Gt);
569
+ return { values: n, split: a, indexes: s, types: i };
570
+ }
571
+ function Xn(e) {
572
+ return me(e).values;
573
+ }
574
+ function qn(e) {
575
+ const { split: t, types: n } = me(e), s = t.length;
576
+ return (i) => {
577
+ let r = "";
578
+ for (let o = 0; o < s; o++)
579
+ if (r += t[o], i[o] !== void 0) {
580
+ const a = n[o];
581
+ a === Hn ? r += he(i[o]) : a === Yn ? r += E.transform(i[o]) : r += i[o];
582
+ }
583
+ return r;
584
+ };
585
+ }
586
+ const nr = (e) => typeof e == "number" ? 0 : E.test(e) ? E.getAnimatableNone(e) : e;
587
+ function sr(e) {
588
+ const t = Xn(e);
589
+ return qn(e)(t.map(nr));
590
+ }
591
+ const ae = {
592
+ test: Ji,
593
+ parse: Xn,
594
+ createTransformer: qn,
595
+ getAnimatableNone: sr
596
+ };
597
+ function $e(e, t, n) {
598
+ return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? e + (t - e) * 6 * n : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * (2 / 3 - n) * 6 : e;
599
+ }
600
+ function ir({ hue: e, saturation: t, lightness: n, alpha: s }) {
601
+ e /= 360, t /= 100, n /= 100;
602
+ let i = 0, r = 0, o = 0;
603
+ if (!t)
604
+ i = r = o = n;
605
+ else {
606
+ const a = n < 0.5 ? n * (1 + t) : n + t - n * t, l = 2 * n - a;
607
+ i = $e(l, a, e + 1 / 3), r = $e(l, a, e), o = $e(l, a, e - 1 / 3);
608
+ }
609
+ return {
610
+ red: Math.round(i * 255),
611
+ green: Math.round(r * 255),
612
+ blue: Math.round(o * 255),
613
+ alpha: s
614
+ };
615
+ }
616
+ function Ce(e, t) {
617
+ return (n) => n > 0 ? t : e;
618
+ }
619
+ const Oe = (e, t, n) => e + (t - e) * n, _e = (e, t, n) => {
620
+ const s = e * e, i = n * (t * t - s) + s;
621
+ return i < 0 ? 0 : Math.sqrt(i);
622
+ }, rr = [Ye, U, q], or = (e) => rr.find((t) => t.test(e));
623
+ function Ht(e) {
624
+ const t = or(e);
625
+ if (ie(!!t, `'${e}' is not an animatable color. Use the equivalent color code instead.`), !t)
626
+ return !1;
627
+ let n = t.parse(e);
628
+ return t === q && (n = ir(n)), n;
629
+ }
630
+ const Yt = (e, t) => {
631
+ const n = Ht(e), s = Ht(t);
632
+ if (!n || !s)
633
+ return Ce(e, t);
634
+ const i = { ...n };
635
+ return (r) => (i.red = _e(n.red, s.red, r), i.green = _e(n.green, s.green, r), i.blue = _e(n.blue, s.blue, r), i.alpha = Oe(n.alpha, s.alpha, r), U.transform(i));
636
+ }, Xe = /* @__PURE__ */ new Set(["none", "hidden"]);
637
+ function ar(e, t) {
638
+ return Xe.has(e) ? (n) => n <= 0 ? e : t : (n) => n >= 1 ? t : e;
639
+ }
640
+ function cr(e, t) {
641
+ return (n) => Oe(e, t, n);
642
+ }
643
+ function wt(e) {
644
+ return typeof e == "number" ? cr : typeof e == "string" ? bt(e) ? Ce : E.test(e) ? Yt : fr : Array.isArray(e) ? Zn : typeof e == "object" ? E.test(e) ? Yt : ur : Ce;
645
+ }
646
+ function Zn(e, t) {
647
+ const n = [...e], s = n.length, i = e.map((r, o) => wt(r)(r, t[o]));
648
+ return (r) => {
649
+ for (let o = 0; o < s; o++)
650
+ n[o] = i[o](r);
651
+ return n;
652
+ };
653
+ }
654
+ function ur(e, t) {
655
+ const n = { ...e, ...t }, s = {};
656
+ for (const i in n)
657
+ e[i] !== void 0 && t[i] !== void 0 && (s[i] = wt(e[i])(e[i], t[i]));
658
+ return (i) => {
659
+ for (const r in s)
660
+ n[r] = s[r](i);
661
+ return n;
662
+ };
663
+ }
664
+ function lr(e, t) {
665
+ const n = [], s = { color: 0, var: 0, number: 0 };
666
+ for (let i = 0; i < t.values.length; i++) {
667
+ const r = t.types[i], o = e.indexes[r][s[r]], a = e.values[o] ?? 0;
668
+ n[i] = a, s[r]++;
669
+ }
670
+ return n;
671
+ }
672
+ const fr = (e, t) => {
673
+ const n = ae.createTransformer(t), s = me(e), i = me(t);
674
+ return s.indexes.var.length === i.indexes.var.length && s.indexes.color.length === i.indexes.color.length && s.indexes.number.length >= i.indexes.number.length ? Xe.has(e) && !i.values.length || Xe.has(t) && !s.values.length ? ar(e, t) : Re(Zn(lr(s, i), i.values), n) : (ie(!0, `Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`), Ce(e, t));
675
+ };
676
+ function Jn(e, t, n) {
677
+ return typeof e == "number" && typeof t == "number" && typeof n == "number" ? Oe(e, t, n) : wt(e)(e, t);
678
+ }
679
+ const dr = (e) => {
680
+ const t = ({ timestamp: n }) => e(n);
681
+ return {
682
+ start: (n = !0) => k.update(t, n),
683
+ stop: () => He(t),
684
+ /**
685
+ * If we're processing this frame we can use the
686
+ * framelocked timestamp to keep things in sync.
687
+ */
688
+ now: () => Ae.isProcessing ? Ae.timestamp : L.now()
689
+ };
690
+ }, Qn = (e, t, n = 10) => {
691
+ let s = "";
692
+ const i = Math.max(Math.round(t / n), 2);
693
+ for (let r = 0; r < i; r++)
694
+ s += Math.round(e(r / (i - 1)) * 1e4) / 1e4 + ", ";
695
+ return `linear(${s.substring(0, s.length - 2)})`;
696
+ }, Me = 2e4;
697
+ function St(e) {
698
+ let t = 0;
699
+ const n = 50;
700
+ let s = e.next(t);
701
+ for (; !s.done && t < Me; )
702
+ t += n, s = e.next(t);
703
+ return t >= Me ? 1 / 0 : t;
704
+ }
705
+ function hr(e, t = 100, n) {
706
+ const s = n({ ...e, keyframes: [0, t] }), i = Math.min(St(s), Me);
707
+ return {
708
+ type: "keyframes",
709
+ ease: (r) => s.next(i * r).value / t,
710
+ duration: /* @__PURE__ */ K(i)
711
+ };
712
+ }
713
+ const pr = 5;
714
+ function es(e, t, n) {
715
+ const s = Math.max(t - pr, 0);
716
+ return Rn(n - e(s), t - s);
717
+ }
718
+ const P = {
719
+ // Default spring physics
720
+ stiffness: 100,
721
+ damping: 10,
722
+ mass: 1,
723
+ velocity: 0,
724
+ // Default duration/bounce-based options
725
+ duration: 800,
726
+ // in ms
727
+ bounce: 0.3,
728
+ visualDuration: 0.3,
729
+ // in seconds
730
+ // Rest thresholds
731
+ restSpeed: {
732
+ granular: 0.01,
733
+ default: 2
305
734
  },
306
- removeLayer: () => {
735
+ restDelta: {
736
+ granular: 5e-3,
737
+ default: 0.5
307
738
  },
308
- removeTopLayer: () => {
739
+ // Limits
740
+ minDuration: 0.01,
741
+ // in seconds
742
+ maxDuration: 10,
743
+ // in seconds
744
+ minDamping: 0.05,
745
+ maxDamping: 1
746
+ }, Xt = 1e-3;
747
+ function mr({ duration: e = P.duration, bounce: t = P.bounce, velocity: n = P.velocity, mass: s = P.mass }) {
748
+ let i, r;
749
+ ie(e <= /* @__PURE__ */ N(P.maxDuration), "Spring duration must be 10 seconds or less");
750
+ let o = 1 - t;
751
+ o = Y(P.minDamping, P.maxDamping, o), e = Y(P.minDuration, P.maxDuration, /* @__PURE__ */ K(e)), o < 1 ? (i = (u) => {
752
+ const c = u * o, d = c * e, f = c - n, h = qe(u, o), g = Math.exp(-d);
753
+ return Xt - f / h * g;
754
+ }, r = (u) => {
755
+ const d = u * o * e, f = d * n + n, h = Math.pow(o, 2) * Math.pow(u, 2) * e, g = Math.exp(-d), y = qe(Math.pow(u, 2), o);
756
+ return (-i(u) + Xt > 0 ? -1 : 1) * ((f - h) * g) / y;
757
+ }) : (i = (u) => {
758
+ const c = Math.exp(-u * e), d = (u - n) * e + 1;
759
+ return -1e-3 + c * d;
760
+ }, r = (u) => {
761
+ const c = Math.exp(-u * e), d = (n - u) * (e * e);
762
+ return c * d;
763
+ });
764
+ const a = 5 / e, l = yr(i, r, a);
765
+ if (e = /* @__PURE__ */ N(e), isNaN(l))
766
+ return {
767
+ stiffness: P.stiffness,
768
+ damping: P.damping,
769
+ duration: e
770
+ };
771
+ {
772
+ const u = Math.pow(l, 2) * s;
773
+ return {
774
+ stiffness: u,
775
+ damping: o * 2 * Math.sqrt(s * u),
776
+ duration: e
777
+ };
309
778
  }
310
- }), je = ({ children: e }) => {
311
- const [t, r] = g.useState([]), o = (l) => {
312
- r((a) => [...a, l]);
313
- }, n = (l) => {
314
- r(t.filter((a) => a !== l));
315
- }, s = () => {
316
- const l = t[t.length - 1];
317
- l && n(l);
318
- };
319
- return /* @__PURE__ */ d(
320
- K.Provider,
321
- {
322
- value: { layers: t, setLayers: r, addLayer: o, removeLayer: n, removeTopLayer: s },
323
- children: e
779
+ }
780
+ const gr = 12;
781
+ function yr(e, t, n) {
782
+ let s = n;
783
+ for (let i = 1; i < gr; i++)
784
+ s = s - e(s) / t(s);
785
+ return s;
786
+ }
787
+ function qe(e, t) {
788
+ return e * Math.sqrt(1 - t * t);
789
+ }
790
+ const br = ["duration", "bounce"], vr = ["stiffness", "damping", "mass"];
791
+ function qt(e, t) {
792
+ return t.some((n) => e[n] !== void 0);
793
+ }
794
+ function Tr(e) {
795
+ let t = {
796
+ velocity: P.velocity,
797
+ stiffness: P.stiffness,
798
+ damping: P.damping,
799
+ mass: P.mass,
800
+ isResolvedFromDuration: !1,
801
+ ...e
802
+ };
803
+ if (!qt(e, vr) && qt(e, br))
804
+ if (e.visualDuration) {
805
+ const n = e.visualDuration, s = 2 * Math.PI / (n * 1.2), i = s * s, r = 2 * Y(0.05, 1, 1 - (e.bounce || 0)) * Math.sqrt(i);
806
+ t = {
807
+ ...t,
808
+ mass: P.mass,
809
+ stiffness: i,
810
+ damping: r
811
+ };
812
+ } else {
813
+ const n = mr(e);
814
+ t = {
815
+ ...t,
816
+ ...n,
817
+ mass: P.mass
818
+ }, t.isResolvedFromDuration = !0;
324
819
  }
325
- );
326
- }, X = () => g.useContext(K), we = ({
327
- defaultOpen: e,
328
- open: t,
329
- onOpenChange: r,
330
- ...o
331
- }) => {
332
- const [n, s] = Ce({
333
- prop: t,
334
- onChange: r,
335
- defaultProp: e ?? !1
336
- }), l = X(), a = o.a11yTitle;
337
- if (g.useEffect(() => {
338
- !n && l.layers.includes(a) && l.removeLayer(a);
339
- }, [a, l, n]), !!n)
340
- return /* @__PURE__ */ d(Re, { open: n, onOpenChange: s, ...o });
341
- }, Re = ({
342
- open: e,
343
- onOpenChange: t,
344
- a11yTitle: r,
345
- a11yDescription: o,
346
- children: n,
347
- // Focus scope props
348
- trapped: s,
349
- onMountAutoFocus: l,
350
- onUnmountAutoFocus: a,
351
- ...f
352
- }) => {
353
- var C, P;
354
- const u = r, c = X();
355
- g.useEffect(() => {
356
- !c || !e || c.layers.includes(u) || c.addLayer(u);
357
- }, [u, c, e]);
358
- const y = ((C = c.layers) == null ? void 0 : C.indexOf(u)) || 0, m = ((P = c.layers) == null ? void 0 : P.length) || 0, L = y !== 0, b = u === c.layers[c.layers.length - 1];
359
- return /* @__PURE__ */ d(
360
- z,
361
- {
362
- onEscapeKeyDown: (h) => {
363
- b && (h.preventDefault(), c.removeTopLayer(), t(!1));
364
- },
365
- onPointerDownOutside: (h) => {
366
- b && (h.preventDefault(), c.removeTopLayer(), t(!1));
367
- },
368
- children: /* @__PURE__ */ S(
369
- v.Root,
370
- {
371
- open: e,
372
- onOpenChange: (h) => {
373
- var w;
374
- if (((w = c == null ? void 0 : c.layers) == null ? void 0 : w.length) > 0)
375
- return h === !1 && u === c.layers[c.layers.length - 1] ? (c.removeLayer(u), t(!1)) : void 0;
376
- t(h);
377
- },
378
- children: [
379
- /* @__PURE__ */ S(G.Root, { children: [
380
- /* @__PURE__ */ d(v.Title, { children: r }),
381
- o && /* @__PURE__ */ d(v.Description, { children: o })
382
- ] }),
383
- /* @__PURE__ */ d(ne, { children: e && // We add the className "tgph" here so that styles within
384
- // the portal get scoped properly to telegraph
385
- /* @__PURE__ */ d(q.Root, { className: "tgph", children: /* @__PURE__ */ d(xe, { layer: y, children: /* @__PURE__ */ d(
386
- Z,
387
- {
388
- trapped: typeof s == "boolean" ? s : b,
389
- onMountAutoFocus: l,
390
- onUnmountAutoFocus: a,
391
- asChild: !0,
392
- children: /* @__PURE__ */ d(Q, { children: /* @__PURE__ */ d(
393
- E,
394
- {
395
- as: T.div,
396
- initial: {
397
- top: `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${m - 1})`
398
- },
399
- animate: {
400
- top: L ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${y} )` : "var(--tgph-spacing-16)"
401
- },
402
- exit: { top: 0 },
403
- transition: { type: "spring", duration: 0.3, bounce: 0 },
404
- w: "full",
405
- justify: "center",
406
- style: {
407
- position: "fixed",
408
- left: 0,
409
- maxHeight: "calc(100vh - var(--tgph-spacing-32))",
410
- maxWidth: "calc(100vw - var(--tgph-spacing-8))",
411
- zIndex: `calc(var(--tgph-zIndex-modal) + ${y})`
412
- },
413
- children: /* @__PURE__ */ d(
414
- E,
415
- {
416
- direction: "column",
417
- as: T.div,
418
- animate: {
419
- scale: 1.02 - Math.abs(m - y) * 0.02,
420
- transformOrigin: "center center"
421
- },
422
- transition: {
423
- duration: 0.2,
424
- bounce: 0,
425
- type: "spring"
426
- },
427
- maxW: f.maxW ?? "160",
428
- w: f.w ?? "full",
429
- bg: "surface-1",
430
- border: "px",
431
- rounded: "4",
432
- shadow: "3",
433
- ...f,
434
- children: n
435
- },
436
- `content-${u}`
437
- )
438
- },
439
- `container-${u}`
440
- ) })
441
- }
442
- ) }) }) })
443
- ]
444
- },
445
- u
446
- )
820
+ return t;
821
+ }
822
+ function Pe(e = P.visualDuration, t = P.bounce) {
823
+ const n = typeof e != "object" ? {
824
+ visualDuration: e,
825
+ keyframes: [0, 1],
826
+ bounce: t
827
+ } : e;
828
+ let { restSpeed: s, restDelta: i } = n;
829
+ const r = n.keyframes[0], o = n.keyframes[n.keyframes.length - 1], a = { done: !1, value: r }, { stiffness: l, damping: u, mass: c, duration: d, velocity: f, isResolvedFromDuration: h } = Tr({
830
+ ...n,
831
+ velocity: -/* @__PURE__ */ K(n.velocity || 0)
832
+ }), g = f || 0, y = u / (2 * Math.sqrt(l * c)), T = o - r, p = /* @__PURE__ */ K(Math.sqrt(l / c)), V = Math.abs(T) < 5;
833
+ s || (s = V ? P.restSpeed.granular : P.restSpeed.default), i || (i = V ? P.restDelta.granular : P.restDelta.default);
834
+ let m;
835
+ if (y < 1) {
836
+ const w = qe(p, y);
837
+ m = (A) => {
838
+ const x = Math.exp(-y * p * A);
839
+ return o - x * ((g + y * p * T) / w * Math.sin(w * A) + T * Math.cos(w * A));
840
+ };
841
+ } else if (y === 1)
842
+ m = (w) => o - Math.exp(-p * w) * (T + (g + p * T) * w);
843
+ else {
844
+ const w = p * Math.sqrt(y * y - 1);
845
+ m = (A) => {
846
+ const x = Math.exp(-y * p * A), S = Math.min(w * A, 300);
847
+ return o - x * ((g + y * p * T) * Math.sinh(S) + w * T * Math.cosh(S)) / w;
848
+ };
849
+ }
850
+ const C = {
851
+ calculatedDuration: h && d || null,
852
+ next: (w) => {
853
+ const A = m(w);
854
+ if (h)
855
+ a.done = w >= d;
856
+ else {
857
+ let x = w === 0 ? g : 0;
858
+ y < 1 && (x = w === 0 ? /* @__PURE__ */ N(g) : es(m, w, A));
859
+ const S = Math.abs(x) <= s, D = Math.abs(o - A) <= i;
860
+ a.done = S && D;
861
+ }
862
+ return a.value = a.done ? o : A, a;
863
+ },
864
+ toString: () => {
865
+ const w = Math.min(St(C), Me), A = Qn((x) => C.next(w * x).value, w, 30);
866
+ return w + "ms " + A;
867
+ },
868
+ toTransition: () => {
447
869
  }
448
- );
449
- }, xe = ({ layer: e, children: t }) => e > 0 ? t : /* @__PURE__ */ S(v.Overlay, { children: [
450
- /* @__PURE__ */ d(
451
- te,
870
+ };
871
+ return C;
872
+ }
873
+ Pe.applyToOptions = (e) => {
874
+ const t = hr(e, 100, Pe);
875
+ return e.ease = t.ease, e.duration = /* @__PURE__ */ N(t.duration), e.type = "keyframes", e;
876
+ };
877
+ function Ze({ keyframes: e, velocity: t = 0, power: n = 0.8, timeConstant: s = 325, bounceDamping: i = 10, bounceStiffness: r = 500, modifyTarget: o, min: a, max: l, restDelta: u = 0.5, restSpeed: c }) {
878
+ const d = e[0], f = {
879
+ done: !1,
880
+ value: d
881
+ }, h = (S) => a !== void 0 && S < a || l !== void 0 && S > l, g = (S) => a === void 0 ? l : l === void 0 || Math.abs(a - S) < Math.abs(l - S) ? a : l;
882
+ let y = n * t;
883
+ const T = d + y, p = o === void 0 ? T : o(T);
884
+ p !== T && (y = p - d);
885
+ const V = (S) => -y * Math.exp(-S / s), m = (S) => p + V(S), C = (S) => {
886
+ const D = V(S), F = m(S);
887
+ f.done = Math.abs(D) <= u, f.value = f.done ? p : F;
888
+ };
889
+ let w, A;
890
+ const x = (S) => {
891
+ h(f.value) && (w = S, A = Pe({
892
+ keyframes: [f.value, g(f.value)],
893
+ velocity: es(m, S, f.value),
894
+ // TODO: This should be passing * 1000
895
+ damping: i,
896
+ stiffness: r,
897
+ restDelta: u,
898
+ restSpeed: c
899
+ }));
900
+ };
901
+ return x(0), {
902
+ calculatedDuration: null,
903
+ next: (S) => {
904
+ let D = !1;
905
+ return !A && w === void 0 && (D = !0, C(S), x(S)), w !== void 0 && S >= w ? A.next(S - w) : (!D && C(S), f);
906
+ }
907
+ };
908
+ }
909
+ function wr(e, t, n) {
910
+ const s = [], i = n || W.mix || Jn, r = e.length - 1;
911
+ for (let o = 0; o < r; o++) {
912
+ let a = i(e[o], e[o + 1]);
913
+ if (t) {
914
+ const l = Array.isArray(t) ? t[o] || re : t;
915
+ a = Re(l, a);
916
+ }
917
+ s.push(a);
918
+ }
919
+ return s;
920
+ }
921
+ function Sr(e, t, { clamp: n = !0, ease: s, mixer: i } = {}) {
922
+ const r = e.length;
923
+ if (_(r === t.length, "Both input and output ranges must be the same length"), r === 1)
924
+ return () => t[0];
925
+ if (r === 2 && t[0] === t[1])
926
+ return () => t[1];
927
+ const o = e[0] === e[1];
928
+ e[0] > e[r - 1] && (e = [...e].reverse(), t = [...t].reverse());
929
+ const a = wr(t, s, i), l = a.length, u = (c) => {
930
+ if (o && c < e[0])
931
+ return t[0];
932
+ let d = 0;
933
+ if (l > 1)
934
+ for (; d < e.length - 2 && !(c < e[d + 1]); d++)
935
+ ;
936
+ const f = /* @__PURE__ */ Dn(e[d], e[d + 1], c);
937
+ return a[d](f);
938
+ };
939
+ return n ? (c) => u(Y(e[0], e[r - 1], c)) : u;
940
+ }
941
+ function xr(e, t) {
942
+ const n = e[e.length - 1];
943
+ for (let s = 1; s <= t; s++) {
944
+ const i = /* @__PURE__ */ Dn(0, t, s);
945
+ e.push(Oe(n, 1, i));
946
+ }
947
+ }
948
+ function Vr(e) {
949
+ const t = [0];
950
+ return xr(t, e.length - 1), t;
951
+ }
952
+ function Ar(e, t) {
953
+ return e.map((n) => n * t);
954
+ }
955
+ function Cr(e, t) {
956
+ return e.map(() => t || $n).splice(0, e.length - 1);
957
+ }
958
+ function Z({ duration: e = 300, keyframes: t, times: n, ease: s = "easeInOut" }) {
959
+ const i = Bi(s) ? s.map(Ut) : Ut(s), r = {
960
+ done: !1,
961
+ value: t[0]
962
+ }, o = Ar(
963
+ // Only use the provided offsets if they're the correct length
964
+ // TODO Maybe we should warn here if there's a length mismatch
965
+ n && n.length === t.length ? n : Vr(t),
966
+ e
967
+ ), a = Sr(o, t, {
968
+ ease: Array.isArray(i) ? i : Cr(t, i)
969
+ });
970
+ return {
971
+ calculatedDuration: e,
972
+ next: (l) => (r.value = a(l), r.done = l >= e, r)
973
+ };
974
+ }
975
+ const Mr = (e) => e !== null;
976
+ function xt(e, { repeat: t, repeatType: n = "loop" }, s, i = 1) {
977
+ const r = e.filter(Mr), a = i < 0 || t && n !== "loop" && t % 2 === 1 ? 0 : r.length - 1;
978
+ return !a || s === void 0 ? r[a] : s;
979
+ }
980
+ const Pr = {
981
+ decay: Ze,
982
+ inertia: Ze,
983
+ tween: Z,
984
+ keyframes: Z,
985
+ spring: Pe
986
+ };
987
+ function ts(e) {
988
+ typeof e.type == "string" && (e.type = Pr[e.type]);
989
+ }
990
+ class Vt {
991
+ constructor() {
992
+ this.updateFinished();
993
+ }
994
+ get finished() {
995
+ return this._finished;
996
+ }
997
+ updateFinished() {
998
+ this._finished = new Promise((t) => {
999
+ this.resolve = t;
1000
+ });
1001
+ }
1002
+ notifyFinished() {
1003
+ this.resolve();
1004
+ }
1005
+ /**
1006
+ * Allows the animation to be awaited.
1007
+ *
1008
+ * @deprecated Use `finished` instead.
1009
+ */
1010
+ then(t, n) {
1011
+ return this.finished.then(t, n);
1012
+ }
1013
+ }
1014
+ const Er = (e) => e / 100;
1015
+ class At extends Vt {
1016
+ constructor(t) {
1017
+ super(), this.state = "idle", this.startTime = null, this.isStopped = !1, this.currentTime = 0, this.holdTime = null, this.playbackSpeed = 1, this.stop = () => {
1018
+ var s, i;
1019
+ const { motionValue: n } = this.options;
1020
+ n && n.updatedAt !== L.now() && this.tick(L.now()), this.isStopped = !0, this.state !== "idle" && (this.teardown(), (i = (s = this.options).onStop) == null || i.call(s));
1021
+ }, this.options = t, this.initAnimation(), this.play(), t.autoplay === !1 && this.pause();
1022
+ }
1023
+ initAnimation() {
1024
+ const { options: t } = this;
1025
+ ts(t);
1026
+ const { type: n = Z, repeat: s = 0, repeatDelay: i = 0, repeatType: r, velocity: o = 0 } = t;
1027
+ let { keyframes: a } = t;
1028
+ const l = n || Z;
1029
+ process.env.NODE_ENV !== "production" && l !== Z && _(a.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`), l !== Z && typeof a[0] != "number" && (this.mixKeyframes = Re(Er, Jn(a[0], a[1])), a = [0, 100]);
1030
+ const u = l({ ...t, keyframes: a });
1031
+ r === "mirror" && (this.mirroredGenerator = l({
1032
+ ...t,
1033
+ keyframes: [...a].reverse(),
1034
+ velocity: -o
1035
+ })), u.calculatedDuration === null && (u.calculatedDuration = St(u));
1036
+ const { calculatedDuration: c } = u;
1037
+ this.calculatedDuration = c, this.resolvedDuration = c + i, this.totalDuration = this.resolvedDuration * (s + 1) - i, this.generator = u;
1038
+ }
1039
+ updateTime(t) {
1040
+ const n = Math.round(t - this.startTime) * this.playbackSpeed;
1041
+ this.holdTime !== null ? this.currentTime = this.holdTime : this.currentTime = n;
1042
+ }
1043
+ tick(t, n = !1) {
1044
+ const { generator: s, totalDuration: i, mixKeyframes: r, mirroredGenerator: o, resolvedDuration: a, calculatedDuration: l } = this;
1045
+ if (this.startTime === null)
1046
+ return s.next(0);
1047
+ const { delay: u = 0, keyframes: c, repeat: d, repeatType: f, repeatDelay: h, type: g, onUpdate: y, finalKeyframe: T } = this.options;
1048
+ this.speed > 0 ? this.startTime = Math.min(this.startTime, t) : this.speed < 0 && (this.startTime = Math.min(t - i / this.speed, this.startTime)), n ? this.currentTime = t : this.updateTime(t);
1049
+ const p = this.currentTime - u * (this.playbackSpeed >= 0 ? 1 : -1), V = this.playbackSpeed >= 0 ? p < 0 : p > i;
1050
+ this.currentTime = Math.max(p, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = i);
1051
+ let m = this.currentTime, C = s;
1052
+ if (d) {
1053
+ const S = Math.min(this.currentTime, i) / a;
1054
+ let D = Math.floor(S), F = S % 1;
1055
+ !F && S >= 1 && (F = 1), F === 1 && D--, D = Math.min(D, d + 1), !!(D % 2) && (f === "reverse" ? (F = 1 - F, h && (F -= h / a)) : f === "mirror" && (C = o)), m = Y(0, 1, F) * a;
1056
+ }
1057
+ const w = V ? { done: !1, value: c[0] } : C.next(m);
1058
+ r && (w.value = r(w.value));
1059
+ let { done: A } = w;
1060
+ !V && l !== null && (A = this.playbackSpeed >= 0 ? this.currentTime >= i : this.currentTime <= 0);
1061
+ const x = this.holdTime === null && (this.state === "finished" || this.state === "running" && A);
1062
+ return x && g !== Ze && (w.value = xt(c, this.options, T, this.speed)), y && y(w.value), x && this.finish(), w;
1063
+ }
1064
+ /**
1065
+ * Allows the returned animation to be awaited or promise-chained. Currently
1066
+ * resolves when the animation finishes at all but in a future update could/should
1067
+ * reject if its cancels.
1068
+ */
1069
+ then(t, n) {
1070
+ return this.finished.then(t, n);
1071
+ }
1072
+ get duration() {
1073
+ return /* @__PURE__ */ K(this.calculatedDuration);
1074
+ }
1075
+ get time() {
1076
+ return /* @__PURE__ */ K(this.currentTime);
1077
+ }
1078
+ set time(t) {
1079
+ var n;
1080
+ t = /* @__PURE__ */ N(t), this.currentTime = t, this.startTime === null || this.holdTime !== null || this.playbackSpeed === 0 ? this.holdTime = t : this.driver && (this.startTime = this.driver.now() - t / this.playbackSpeed), (n = this.driver) == null || n.start(!1);
1081
+ }
1082
+ get speed() {
1083
+ return this.playbackSpeed;
1084
+ }
1085
+ set speed(t) {
1086
+ this.updateTime(L.now());
1087
+ const n = this.playbackSpeed !== t;
1088
+ this.playbackSpeed = t, n && (this.time = /* @__PURE__ */ K(this.currentTime));
1089
+ }
1090
+ play() {
1091
+ var i, r;
1092
+ if (this.isStopped)
1093
+ return;
1094
+ const { driver: t = dr, startTime: n } = this.options;
1095
+ this.driver || (this.driver = t((o) => this.tick(o))), (r = (i = this.options).onPlay) == null || r.call(i);
1096
+ const s = this.driver.now();
1097
+ this.state === "finished" ? (this.updateFinished(), this.startTime = s) : this.holdTime !== null ? this.startTime = s - this.holdTime : this.startTime || (this.startTime = n ?? s), this.state === "finished" && this.speed < 0 && (this.startTime += this.calculatedDuration), this.holdTime = null, this.state = "running", this.driver.start();
1098
+ }
1099
+ pause() {
1100
+ this.state = "paused", this.updateTime(L.now()), this.holdTime = this.currentTime;
1101
+ }
1102
+ complete() {
1103
+ this.state !== "running" && this.play(), this.state = "finished", this.holdTime = null;
1104
+ }
1105
+ finish() {
1106
+ var t, n;
1107
+ this.notifyFinished(), this.teardown(), this.state = "finished", (n = (t = this.options).onComplete) == null || n.call(t);
1108
+ }
1109
+ cancel() {
1110
+ var t, n;
1111
+ this.holdTime = null, this.startTime = 0, this.tick(0), this.teardown(), (n = (t = this.options).onCancel) == null || n.call(t);
1112
+ }
1113
+ teardown() {
1114
+ this.state = "idle", this.stopDriver(), this.startTime = this.holdTime = null;
1115
+ }
1116
+ stopDriver() {
1117
+ this.driver && (this.driver.stop(), this.driver = void 0);
1118
+ }
1119
+ sample(t) {
1120
+ return this.startTime = 0, this.tick(t, !0);
1121
+ }
1122
+ attachTimeline(t) {
1123
+ var n;
1124
+ return this.options.allowFlatten && (this.options.type = "keyframes", this.options.ease = "linear", this.initAnimation()), (n = this.driver) == null || n.stop(), t.observe(this);
1125
+ }
1126
+ }
1127
+ function Dr(e) {
1128
+ for (let t = 1; t < e.length; t++)
1129
+ e[t] ?? (e[t] = e[t - 1]);
1130
+ }
1131
+ const z = (e) => e * 180 / Math.PI, Je = (e) => {
1132
+ const t = z(Math.atan2(e[1], e[0]));
1133
+ return Qe(t);
1134
+ }, Fr = {
1135
+ x: 4,
1136
+ y: 5,
1137
+ translateX: 4,
1138
+ translateY: 5,
1139
+ scaleX: 0,
1140
+ scaleY: 3,
1141
+ scale: (e) => (Math.abs(e[0]) + Math.abs(e[3])) / 2,
1142
+ rotate: Je,
1143
+ rotateZ: Je,
1144
+ skewX: (e) => z(Math.atan(e[1])),
1145
+ skewY: (e) => z(Math.atan(e[2])),
1146
+ skew: (e) => (Math.abs(e[1]) + Math.abs(e[2])) / 2
1147
+ }, Qe = (e) => (e = e % 360, e < 0 && (e += 360), e), Zt = Je, Jt = (e) => Math.sqrt(e[0] * e[0] + e[1] * e[1]), Qt = (e) => Math.sqrt(e[4] * e[4] + e[5] * e[5]), Rr = {
1148
+ x: 12,
1149
+ y: 13,
1150
+ z: 14,
1151
+ translateX: 12,
1152
+ translateY: 13,
1153
+ translateZ: 14,
1154
+ scaleX: Jt,
1155
+ scaleY: Qt,
1156
+ scale: (e) => (Jt(e) + Qt(e)) / 2,
1157
+ rotateX: (e) => Qe(z(Math.atan2(e[6], e[5]))),
1158
+ rotateY: (e) => Qe(z(Math.atan2(-e[2], e[0]))),
1159
+ rotateZ: Zt,
1160
+ rotate: Zt,
1161
+ skewX: (e) => z(Math.atan(e[4])),
1162
+ skewY: (e) => z(Math.atan(e[1])),
1163
+ skew: (e) => (Math.abs(e[1]) + Math.abs(e[4])) / 2
1164
+ };
1165
+ function et(e) {
1166
+ return e.includes("scale") ? 1 : 0;
1167
+ }
1168
+ function tt(e, t) {
1169
+ if (!e || e === "none")
1170
+ return et(t);
1171
+ const n = e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
1172
+ let s, i;
1173
+ if (n)
1174
+ s = Rr, i = n;
1175
+ else {
1176
+ const a = e.match(/^matrix\(([-\d.e\s,]+)\)$/u);
1177
+ s = Fr, i = a;
1178
+ }
1179
+ if (!i)
1180
+ return et(t);
1181
+ const r = s[t], o = i[1].split(",").map(Lr);
1182
+ return typeof r == "function" ? r(o) : o[r];
1183
+ }
1184
+ const Or = (e, t) => {
1185
+ const { transform: n = "none" } = getComputedStyle(e);
1186
+ return tt(n, t);
1187
+ };
1188
+ function Lr(e) {
1189
+ return parseFloat(e.trim());
1190
+ }
1191
+ const ce = [
1192
+ "transformPerspective",
1193
+ "x",
1194
+ "y",
1195
+ "z",
1196
+ "translateX",
1197
+ "translateY",
1198
+ "translateZ",
1199
+ "scale",
1200
+ "scaleX",
1201
+ "scaleY",
1202
+ "rotate",
1203
+ "rotateX",
1204
+ "rotateY",
1205
+ "rotateZ",
1206
+ "skew",
1207
+ "skewX",
1208
+ "skewY"
1209
+ ], ue = new Set(ce), en = (e) => e === oe || e === b, Ir = /* @__PURE__ */ new Set(["x", "y", "z"]), kr = ce.filter((e) => !Ir.has(e));
1210
+ function Nr(e) {
1211
+ const t = [];
1212
+ return kr.forEach((n) => {
1213
+ const s = e.getValue(n);
1214
+ s !== void 0 && (t.push([n, s.get()]), s.set(n.startsWith("scale") ? 1 : 0));
1215
+ }), t;
1216
+ }
1217
+ const G = {
1218
+ // Dimensions
1219
+ width: ({ x: e }, { paddingLeft: t = "0", paddingRight: n = "0" }) => e.max - e.min - parseFloat(t) - parseFloat(n),
1220
+ height: ({ y: e }, { paddingTop: t = "0", paddingBottom: n = "0" }) => e.max - e.min - parseFloat(t) - parseFloat(n),
1221
+ top: (e, { top: t }) => parseFloat(t),
1222
+ left: (e, { left: t }) => parseFloat(t),
1223
+ bottom: ({ y: e }, { top: t }) => parseFloat(t) + (e.max - e.min),
1224
+ right: ({ x: e }, { left: t }) => parseFloat(t) + (e.max - e.min),
1225
+ // Transform
1226
+ x: (e, { transform: t }) => tt(t, "x"),
1227
+ y: (e, { transform: t }) => tt(t, "y")
1228
+ };
1229
+ G.translateX = G.x;
1230
+ G.translateY = G.y;
1231
+ const H = /* @__PURE__ */ new Set();
1232
+ let nt = !1, st = !1, it = !1;
1233
+ function ns() {
1234
+ if (st) {
1235
+ const e = Array.from(H).filter((s) => s.needsMeasurement), t = new Set(e.map((s) => s.element)), n = /* @__PURE__ */ new Map();
1236
+ t.forEach((s) => {
1237
+ const i = Nr(s);
1238
+ i.length && (n.set(s, i), s.render());
1239
+ }), e.forEach((s) => s.measureInitialState()), t.forEach((s) => {
1240
+ s.render();
1241
+ const i = n.get(s);
1242
+ i && i.forEach(([r, o]) => {
1243
+ var a;
1244
+ (a = s.getValue(r)) == null || a.set(o);
1245
+ });
1246
+ }), e.forEach((s) => s.measureEndState()), e.forEach((s) => {
1247
+ s.suspendedScrollY !== void 0 && window.scrollTo(0, s.suspendedScrollY);
1248
+ });
1249
+ }
1250
+ st = !1, nt = !1, H.forEach((e) => e.complete(it)), H.clear();
1251
+ }
1252
+ function ss() {
1253
+ H.forEach((e) => {
1254
+ e.readKeyframes(), e.needsMeasurement && (st = !0);
1255
+ });
1256
+ }
1257
+ function Br() {
1258
+ it = !0, ss(), ns(), it = !1;
1259
+ }
1260
+ class Ct {
1261
+ constructor(t, n, s, i, r, o = !1) {
1262
+ this.state = "pending", this.isAsync = !1, this.needsMeasurement = !1, this.unresolvedKeyframes = [...t], this.onComplete = n, this.name = s, this.motionValue = i, this.element = r, this.isAsync = o;
1263
+ }
1264
+ scheduleResolve() {
1265
+ this.state = "scheduled", this.isAsync ? (H.add(this), nt || (nt = !0, k.read(ss), k.resolveKeyframes(ns))) : (this.readKeyframes(), this.complete());
1266
+ }
1267
+ readKeyframes() {
1268
+ const { unresolvedKeyframes: t, name: n, element: s, motionValue: i } = this;
1269
+ if (t[0] === null) {
1270
+ const r = i == null ? void 0 : i.get(), o = t[t.length - 1];
1271
+ if (r !== void 0)
1272
+ t[0] = r;
1273
+ else if (s && n) {
1274
+ const a = s.readValue(n, o);
1275
+ a != null && (t[0] = a);
1276
+ }
1277
+ t[0] === void 0 && (t[0] = o), i && r === void 0 && i.set(t[0]);
1278
+ }
1279
+ Dr(t);
1280
+ }
1281
+ setFinalKeyframe() {
1282
+ }
1283
+ measureInitialState() {
1284
+ }
1285
+ renderEndStyles() {
1286
+ }
1287
+ measureEndState() {
1288
+ }
1289
+ complete(t = !1) {
1290
+ this.state = "complete", this.onComplete(this.unresolvedKeyframes, this.finalKeyframe, t), H.delete(this);
1291
+ }
1292
+ cancel() {
1293
+ this.state === "scheduled" && (H.delete(this), this.state = "pending");
1294
+ }
1295
+ resume() {
1296
+ this.state === "pending" && this.scheduleResolve();
1297
+ }
1298
+ }
1299
+ const Kr = (e) => e.startsWith("--");
1300
+ function Wr(e, t, n) {
1301
+ Kr(t) ? e.style.setProperty(t, n) : e.style[t] = n;
1302
+ }
1303
+ const $r = /* @__PURE__ */ mt(() => window.ScrollTimeline !== void 0), _r = {};
1304
+ function jr(e, t) {
1305
+ const n = /* @__PURE__ */ mt(e);
1306
+ return () => _r[t] ?? n();
1307
+ }
1308
+ const is = /* @__PURE__ */ jr(() => {
1309
+ try {
1310
+ document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
1311
+ } catch {
1312
+ return !1;
1313
+ }
1314
+ return !0;
1315
+ }, "linearEasing"), fe = ([e, t, n, s]) => `cubic-bezier(${e}, ${t}, ${n}, ${s})`, tn = {
1316
+ linear: "linear",
1317
+ ease: "ease",
1318
+ easeIn: "ease-in",
1319
+ easeOut: "ease-out",
1320
+ easeInOut: "ease-in-out",
1321
+ circIn: /* @__PURE__ */ fe([0, 0.65, 0.55, 1]),
1322
+ circOut: /* @__PURE__ */ fe([0.55, 0, 1, 0.45]),
1323
+ backIn: /* @__PURE__ */ fe([0.31, 0.01, 0.66, -0.59]),
1324
+ backOut: /* @__PURE__ */ fe([0.33, 1.53, 0.69, 0.99])
1325
+ };
1326
+ function rs(e, t) {
1327
+ if (e)
1328
+ return typeof e == "function" ? is() ? Qn(e, t) : "ease-out" : _n(e) ? fe(e) : Array.isArray(e) ? e.map((n) => rs(n, t) || tn.easeOut) : tn[e];
1329
+ }
1330
+ function Ur(e, t, n, { delay: s = 0, duration: i = 300, repeat: r = 0, repeatType: o = "loop", ease: a = "easeOut", times: l } = {}, u = void 0) {
1331
+ const c = {
1332
+ [t]: n
1333
+ };
1334
+ l && (c.offset = l);
1335
+ const d = rs(a, i);
1336
+ Array.isArray(d) && (c.easing = d);
1337
+ const f = {
1338
+ delay: s,
1339
+ duration: i,
1340
+ easing: Array.isArray(d) ? "linear" : d,
1341
+ fill: "both",
1342
+ iterations: r + 1,
1343
+ direction: o === "reverse" ? "alternate" : "normal"
1344
+ };
1345
+ return u && (f.pseudoElement = u), e.animate(c, f);
1346
+ }
1347
+ function os(e) {
1348
+ return typeof e == "function" && "applyToOptions" in e;
1349
+ }
1350
+ function zr({ type: e, ...t }) {
1351
+ return os(e) && is() ? e.applyToOptions(t) : (t.duration ?? (t.duration = 300), t.ease ?? (t.ease = "easeOut"), t);
1352
+ }
1353
+ class Gr extends Vt {
1354
+ constructor(t) {
1355
+ if (super(), this.finishedTime = null, this.isStopped = !1, !t)
1356
+ return;
1357
+ const { element: n, name: s, keyframes: i, pseudoElement: r, allowFlatten: o = !1, finalKeyframe: a, onComplete: l } = t;
1358
+ this.isPseudoElement = !!r, this.allowFlatten = o, this.options = t, _(typeof t.type != "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "motion"?`);
1359
+ const u = zr(t);
1360
+ this.animation = Ur(n, s, i, u, r), u.autoplay === !1 && this.animation.pause(), this.animation.onfinish = () => {
1361
+ if (this.finishedTime = this.time, !r) {
1362
+ const c = xt(i, this.options, a, this.speed);
1363
+ this.updateMotionValue ? this.updateMotionValue(c) : Wr(n, s, c), this.animation.cancel();
1364
+ }
1365
+ l == null || l(), this.notifyFinished();
1366
+ };
1367
+ }
1368
+ play() {
1369
+ this.isStopped || (this.animation.play(), this.state === "finished" && this.updateFinished());
1370
+ }
1371
+ pause() {
1372
+ this.animation.pause();
1373
+ }
1374
+ complete() {
1375
+ var t, n;
1376
+ (n = (t = this.animation).finish) == null || n.call(t);
1377
+ }
1378
+ cancel() {
1379
+ try {
1380
+ this.animation.cancel();
1381
+ } catch {
1382
+ }
1383
+ }
1384
+ stop() {
1385
+ if (this.isStopped)
1386
+ return;
1387
+ this.isStopped = !0;
1388
+ const { state: t } = this;
1389
+ t === "idle" || t === "finished" || (this.updateMotionValue ? this.updateMotionValue() : this.commitStyles(), this.isPseudoElement || this.cancel());
1390
+ }
1391
+ /**
1392
+ * WAAPI doesn't natively have any interruption capabilities.
1393
+ *
1394
+ * In this method, we commit styles back to the DOM before cancelling
1395
+ * the animation.
1396
+ *
1397
+ * This is designed to be overridden by NativeAnimationExtended, which
1398
+ * will create a renderless JS animation and sample it twice to calculate
1399
+ * its current value, "previous" value, and therefore allow
1400
+ * Motion to also correctly calculate velocity for any subsequent animation
1401
+ * while deferring the commit until the next animation frame.
1402
+ */
1403
+ commitStyles() {
1404
+ var t, n;
1405
+ this.isPseudoElement || (n = (t = this.animation).commitStyles) == null || n.call(t);
1406
+ }
1407
+ get duration() {
1408
+ var n, s;
1409
+ const t = ((s = (n = this.animation.effect) == null ? void 0 : n.getComputedTiming) == null ? void 0 : s.call(n).duration) || 0;
1410
+ return /* @__PURE__ */ K(Number(t));
1411
+ }
1412
+ get time() {
1413
+ return /* @__PURE__ */ K(Number(this.animation.currentTime) || 0);
1414
+ }
1415
+ set time(t) {
1416
+ this.finishedTime = null, this.animation.currentTime = /* @__PURE__ */ N(t);
1417
+ }
1418
+ /**
1419
+ * The playback speed of the animation.
1420
+ * 1 = normal speed, 2 = double speed, 0.5 = half speed.
1421
+ */
1422
+ get speed() {
1423
+ return this.animation.playbackRate;
1424
+ }
1425
+ set speed(t) {
1426
+ t < 0 && (this.finishedTime = null), this.animation.playbackRate = t;
1427
+ }
1428
+ get state() {
1429
+ return this.finishedTime !== null ? "finished" : this.animation.playState;
1430
+ }
1431
+ get startTime() {
1432
+ return Number(this.animation.startTime);
1433
+ }
1434
+ set startTime(t) {
1435
+ this.animation.startTime = t;
1436
+ }
1437
+ /**
1438
+ * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
1439
+ */
1440
+ attachTimeline({ timeline: t, observe: n }) {
1441
+ var s;
1442
+ return this.allowFlatten && ((s = this.animation.effect) == null || s.updateTiming({ easing: "linear" })), this.animation.onfinish = null, t && $r() ? (this.animation.timeline = t, re) : n(this);
1443
+ }
1444
+ }
1445
+ const as = {
1446
+ anticipate: Kn,
1447
+ backInOut: Bn,
1448
+ circInOut: Wn
1449
+ };
1450
+ function Hr(e) {
1451
+ return e in as;
1452
+ }
1453
+ function Yr(e) {
1454
+ typeof e.ease == "string" && Hr(e.ease) && (e.ease = as[e.ease]);
1455
+ }
1456
+ const nn = 10;
1457
+ class Xr extends Gr {
1458
+ constructor(t) {
1459
+ Yr(t), ts(t), super(t), t.startTime && (this.startTime = t.startTime), this.options = t;
1460
+ }
1461
+ /**
1462
+ * WAAPI doesn't natively have any interruption capabilities.
1463
+ *
1464
+ * Rather than read commited styles back out of the DOM, we can
1465
+ * create a renderless JS animation and sample it twice to calculate
1466
+ * its current value, "previous" value, and therefore allow
1467
+ * Motion to calculate velocity for any subsequent animation.
1468
+ */
1469
+ updateMotionValue(t) {
1470
+ const { motionValue: n, onUpdate: s, onComplete: i, element: r, ...o } = this.options;
1471
+ if (!n)
1472
+ return;
1473
+ if (t !== void 0) {
1474
+ n.set(t);
1475
+ return;
1476
+ }
1477
+ const a = new At({
1478
+ ...o,
1479
+ autoplay: !1
1480
+ }), l = /* @__PURE__ */ N(this.finishedTime ?? this.time);
1481
+ n.setWithVelocity(a.sample(l - nn).value, a.sample(l).value, nn), a.stop();
1482
+ }
1483
+ }
1484
+ const sn = (e, t) => t === "zIndex" ? !1 : !!(typeof e == "number" || Array.isArray(e) || typeof e == "string" && // It's animatable if we have a string
1485
+ (ae.test(e) || e === "0") && // And it contains numbers and/or colors
1486
+ !e.startsWith("url("));
1487
+ function qr(e) {
1488
+ const t = e[0];
1489
+ if (e.length === 1)
1490
+ return !0;
1491
+ for (let n = 0; n < e.length; n++)
1492
+ if (e[n] !== t)
1493
+ return !0;
1494
+ }
1495
+ function Zr(e, t, n, s) {
1496
+ const i = e[0];
1497
+ if (i === null)
1498
+ return !1;
1499
+ if (t === "display" || t === "visibility")
1500
+ return !0;
1501
+ const r = e[e.length - 1], o = sn(i, t), a = sn(r, t);
1502
+ return ie(o === a, `You are trying to animate ${t} from "${i}" to "${r}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${r} via the \`style\` property.`), !o || !a ? !1 : qr(e) || (n === "spring" || os(n)) && s;
1503
+ }
1504
+ function cs(e) {
1505
+ return Di(e) && "offsetHeight" in e;
1506
+ }
1507
+ const Jr = /* @__PURE__ */ new Set([
1508
+ "opacity",
1509
+ "clipPath",
1510
+ "filter",
1511
+ "transform"
1512
+ // TODO: Could be re-enabled now we have support for linear() easing
1513
+ // "background-color"
1514
+ ]), Qr = /* @__PURE__ */ mt(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
1515
+ function eo(e) {
1516
+ var u;
1517
+ const { motionValue: t, name: n, repeatDelay: s, repeatType: i, damping: r, type: o } = e;
1518
+ if (!cs((u = t == null ? void 0 : t.owner) == null ? void 0 : u.current))
1519
+ return !1;
1520
+ const { onUpdate: a, transformTemplate: l } = t.owner.getProps();
1521
+ return Qr() && n && Jr.has(n) && (n !== "transform" || !l) && /**
1522
+ * If we're outputting values to onUpdate then we can't use WAAPI as there's
1523
+ * no way to read the value from WAAPI every frame.
1524
+ */
1525
+ !a && !s && i !== "mirror" && r !== 0 && o !== "inertia";
1526
+ }
1527
+ const to = 40;
1528
+ class no extends Vt {
1529
+ constructor({ autoplay: t = !0, delay: n = 0, type: s = "keyframes", repeat: i = 0, repeatDelay: r = 0, repeatType: o = "loop", keyframes: a, name: l, motionValue: u, element: c, ...d }) {
1530
+ var g;
1531
+ super(), this.stop = () => {
1532
+ var y, T;
1533
+ this._animation && (this._animation.stop(), (y = this.stopTimeline) == null || y.call(this)), (T = this.keyframeResolver) == null || T.cancel();
1534
+ }, this.createdAt = L.now();
1535
+ const f = {
1536
+ autoplay: t,
1537
+ delay: n,
1538
+ type: s,
1539
+ repeat: i,
1540
+ repeatDelay: r,
1541
+ repeatType: o,
1542
+ name: l,
1543
+ motionValue: u,
1544
+ element: c,
1545
+ ...d
1546
+ }, h = (c == null ? void 0 : c.KeyframeResolver) || Ct;
1547
+ this.keyframeResolver = new h(a, (y, T, p) => this.onKeyframesResolved(y, T, f, !p), l, u, c), (g = this.keyframeResolver) == null || g.scheduleResolve();
1548
+ }
1549
+ onKeyframesResolved(t, n, s, i) {
1550
+ this.keyframeResolver = void 0;
1551
+ const { name: r, type: o, velocity: a, delay: l, isHandoff: u, onUpdate: c } = s;
1552
+ this.resolvedAt = L.now(), Zr(t, r, o, a) || ((W.instantAnimations || !l) && (c == null || c(xt(t, s, n))), t[0] = t[t.length - 1], s.duration = 0, s.repeat = 0);
1553
+ const f = {
1554
+ startTime: i ? this.resolvedAt ? this.resolvedAt - this.createdAt > to ? this.resolvedAt : this.createdAt : this.createdAt : void 0,
1555
+ finalKeyframe: n,
1556
+ ...s,
1557
+ keyframes: t
1558
+ }, h = !u && eo(f) ? new Xr({
1559
+ ...f,
1560
+ element: f.motionValue.owner.current
1561
+ }) : new At(f);
1562
+ h.finished.then(() => this.notifyFinished()).catch(re), this.pendingTimeline && (this.stopTimeline = h.attachTimeline(this.pendingTimeline), this.pendingTimeline = void 0), this._animation = h;
1563
+ }
1564
+ get finished() {
1565
+ return this._animation ? this.animation.finished : this._finished;
1566
+ }
1567
+ then(t, n) {
1568
+ return this.finished.finally(t).then(() => {
1569
+ });
1570
+ }
1571
+ get animation() {
1572
+ var t;
1573
+ return this._animation || ((t = this.keyframeResolver) == null || t.resume(), Br()), this._animation;
1574
+ }
1575
+ get duration() {
1576
+ return this.animation.duration;
1577
+ }
1578
+ get time() {
1579
+ return this.animation.time;
1580
+ }
1581
+ set time(t) {
1582
+ this.animation.time = t;
1583
+ }
1584
+ get speed() {
1585
+ return this.animation.speed;
1586
+ }
1587
+ get state() {
1588
+ return this.animation.state;
1589
+ }
1590
+ set speed(t) {
1591
+ this.animation.speed = t;
1592
+ }
1593
+ get startTime() {
1594
+ return this.animation.startTime;
1595
+ }
1596
+ attachTimeline(t) {
1597
+ return this._animation ? this.stopTimeline = this.animation.attachTimeline(t) : this.pendingTimeline = t, () => this.stop();
1598
+ }
1599
+ play() {
1600
+ this.animation.play();
1601
+ }
1602
+ pause() {
1603
+ this.animation.pause();
1604
+ }
1605
+ complete() {
1606
+ this.animation.complete();
1607
+ }
1608
+ cancel() {
1609
+ var t;
1610
+ this._animation && this.animation.cancel(), (t = this.keyframeResolver) == null || t.cancel();
1611
+ }
1612
+ }
1613
+ const so = (
1614
+ // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
1615
+ /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u
1616
+ );
1617
+ function io(e) {
1618
+ const t = so.exec(e);
1619
+ if (!t)
1620
+ return [,];
1621
+ const [, n, s, i] = t;
1622
+ return [`--${n ?? s}`, i];
1623
+ }
1624
+ const ro = 4;
1625
+ function us(e, t, n = 1) {
1626
+ _(n <= ro, `Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`);
1627
+ const [s, i] = io(e);
1628
+ if (!s)
1629
+ return;
1630
+ const r = window.getComputedStyle(t).getPropertyValue(s);
1631
+ if (r) {
1632
+ const o = r.trim();
1633
+ return Pn(o) ? parseFloat(o) : o;
1634
+ }
1635
+ return bt(i) ? us(i, t, n + 1) : i;
1636
+ }
1637
+ function ls(e, t) {
1638
+ return (e == null ? void 0 : e[t]) ?? (e == null ? void 0 : e.default) ?? e;
1639
+ }
1640
+ const fs = /* @__PURE__ */ new Set([
1641
+ "width",
1642
+ "height",
1643
+ "top",
1644
+ "left",
1645
+ "right",
1646
+ "bottom",
1647
+ ...ce
1648
+ ]), oo = {
1649
+ test: (e) => e === "auto",
1650
+ parse: (e) => e
1651
+ }, ds = (e) => (t) => t.test(e), hs = [oe, b, Q, $, qi, Xi, oo], rn = (e) => hs.find(ds(e));
1652
+ function ao(e) {
1653
+ return typeof e == "number" ? e === 0 : e !== null ? e === "none" || e === "0" || En(e) : !0;
1654
+ }
1655
+ const co = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
1656
+ function uo(e) {
1657
+ const [t, n] = e.slice(0, -1).split("(");
1658
+ if (t === "drop-shadow")
1659
+ return e;
1660
+ const [s] = n.match(vt) || [];
1661
+ if (!s)
1662
+ return e;
1663
+ const i = n.replace(s, "");
1664
+ let r = co.has(t) ? 1 : 0;
1665
+ return s !== n && (r *= 100), t + "(" + r + i + ")";
1666
+ }
1667
+ const lo = /\b([a-z-]*)\(.*?\)/gu, rt = {
1668
+ ...ae,
1669
+ getAnimatableNone: (e) => {
1670
+ const t = e.match(lo);
1671
+ return t ? t.map(uo).join(" ") : e;
1672
+ }
1673
+ }, on = {
1674
+ ...oe,
1675
+ transform: Math.round
1676
+ }, fo = {
1677
+ rotate: $,
1678
+ rotateX: $,
1679
+ rotateY: $,
1680
+ rotateZ: $,
1681
+ scale: we,
1682
+ scaleX: we,
1683
+ scaleY: we,
1684
+ scaleZ: we,
1685
+ skew: $,
1686
+ skewX: $,
1687
+ skewY: $,
1688
+ distance: b,
1689
+ translateX: b,
1690
+ translateY: b,
1691
+ translateZ: b,
1692
+ x: b,
1693
+ y: b,
1694
+ z: b,
1695
+ perspective: b,
1696
+ transformPerspective: b,
1697
+ opacity: pe,
1698
+ originX: zt,
1699
+ originY: zt,
1700
+ originZ: b
1701
+ }, Mt = {
1702
+ // Border props
1703
+ borderWidth: b,
1704
+ borderTopWidth: b,
1705
+ borderRightWidth: b,
1706
+ borderBottomWidth: b,
1707
+ borderLeftWidth: b,
1708
+ borderRadius: b,
1709
+ radius: b,
1710
+ borderTopLeftRadius: b,
1711
+ borderTopRightRadius: b,
1712
+ borderBottomRightRadius: b,
1713
+ borderBottomLeftRadius: b,
1714
+ // Positioning props
1715
+ width: b,
1716
+ maxWidth: b,
1717
+ height: b,
1718
+ maxHeight: b,
1719
+ top: b,
1720
+ right: b,
1721
+ bottom: b,
1722
+ left: b,
1723
+ // Spacing props
1724
+ padding: b,
1725
+ paddingTop: b,
1726
+ paddingRight: b,
1727
+ paddingBottom: b,
1728
+ paddingLeft: b,
1729
+ margin: b,
1730
+ marginTop: b,
1731
+ marginRight: b,
1732
+ marginBottom: b,
1733
+ marginLeft: b,
1734
+ // Misc
1735
+ backgroundPositionX: b,
1736
+ backgroundPositionY: b,
1737
+ ...fo,
1738
+ zIndex: on,
1739
+ // SVG
1740
+ fillOpacity: pe,
1741
+ strokeOpacity: pe,
1742
+ numOctaves: on
1743
+ }, ho = {
1744
+ ...Mt,
1745
+ // Color props
1746
+ color: E,
1747
+ backgroundColor: E,
1748
+ outlineColor: E,
1749
+ fill: E,
1750
+ stroke: E,
1751
+ // Border props
1752
+ borderColor: E,
1753
+ borderTopColor: E,
1754
+ borderRightColor: E,
1755
+ borderBottomColor: E,
1756
+ borderLeftColor: E,
1757
+ filter: rt,
1758
+ WebkitFilter: rt
1759
+ }, ps = (e) => ho[e];
1760
+ function ms(e, t) {
1761
+ let n = ps(e);
1762
+ return n !== rt && (n = ae), n.getAnimatableNone ? n.getAnimatableNone(t) : void 0;
1763
+ }
1764
+ const po = /* @__PURE__ */ new Set(["auto", "none", "0"]);
1765
+ function mo(e, t, n) {
1766
+ let s = 0, i;
1767
+ for (; s < e.length && !i; ) {
1768
+ const r = e[s];
1769
+ typeof r == "string" && !po.has(r) && me(r).values.length && (i = e[s]), s++;
1770
+ }
1771
+ if (i && n)
1772
+ for (const r of t)
1773
+ e[r] = ms(n, i);
1774
+ }
1775
+ class go extends Ct {
1776
+ constructor(t, n, s, i, r) {
1777
+ super(t, n, s, i, r, !0);
1778
+ }
1779
+ readKeyframes() {
1780
+ const { unresolvedKeyframes: t, element: n, name: s } = this;
1781
+ if (!n || !n.current)
1782
+ return;
1783
+ super.readKeyframes();
1784
+ for (let l = 0; l < t.length; l++) {
1785
+ let u = t[l];
1786
+ if (typeof u == "string" && (u = u.trim(), bt(u))) {
1787
+ const c = us(u, n.current);
1788
+ c !== void 0 && (t[l] = c), l === t.length - 1 && (this.finalKeyframe = u);
1789
+ }
1790
+ }
1791
+ if (this.resolveNoneKeyframes(), !fs.has(s) || t.length !== 2)
1792
+ return;
1793
+ const [i, r] = t, o = rn(i), a = rn(r);
1794
+ if (o !== a)
1795
+ if (en(o) && en(a))
1796
+ for (let l = 0; l < t.length; l++) {
1797
+ const u = t[l];
1798
+ typeof u == "string" && (t[l] = parseFloat(u));
1799
+ }
1800
+ else G[s] && (this.needsMeasurement = !0);
1801
+ }
1802
+ resolveNoneKeyframes() {
1803
+ const { unresolvedKeyframes: t, name: n } = this, s = [];
1804
+ for (let i = 0; i < t.length; i++)
1805
+ (t[i] === null || ao(t[i])) && s.push(i);
1806
+ s.length && mo(t, s, n);
1807
+ }
1808
+ measureInitialState() {
1809
+ const { element: t, unresolvedKeyframes: n, name: s } = this;
1810
+ if (!t || !t.current)
1811
+ return;
1812
+ s === "height" && (this.suspendedScrollY = window.pageYOffset), this.measuredOrigin = G[s](t.measureViewportBox(), window.getComputedStyle(t.current)), n[0] = this.measuredOrigin;
1813
+ const i = n[n.length - 1];
1814
+ i !== void 0 && t.getValue(s, i).jump(i, !1);
1815
+ }
1816
+ measureEndState() {
1817
+ var a;
1818
+ const { element: t, name: n, unresolvedKeyframes: s } = this;
1819
+ if (!t || !t.current)
1820
+ return;
1821
+ const i = t.getValue(n);
1822
+ i && i.jump(this.measuredOrigin, !1);
1823
+ const r = s.length - 1, o = s[r];
1824
+ s[r] = G[n](t.measureViewportBox(), window.getComputedStyle(t.current)), o !== null && this.finalKeyframe === void 0 && (this.finalKeyframe = o), (a = this.removedTransforms) != null && a.length && this.removedTransforms.forEach(([l, u]) => {
1825
+ t.getValue(l).set(u);
1826
+ }), this.resolveNoneKeyframes();
1827
+ }
1828
+ }
1829
+ function yo(e, t, n) {
1830
+ if (e instanceof EventTarget)
1831
+ return [e];
1832
+ if (typeof e == "string") {
1833
+ const i = document.querySelectorAll(e);
1834
+ return i ? Array.from(i) : [];
1835
+ }
1836
+ return Array.from(e);
1837
+ }
1838
+ const gs = (e, t) => t && typeof e == "number" ? t.transform(e) : e, an = 30, bo = (e) => !isNaN(parseFloat(e));
1839
+ class vo {
1840
+ /**
1841
+ * @param init - The initiating value
1842
+ * @param config - Optional configuration options
1843
+ *
1844
+ * - `transformer`: A function to transform incoming values with.
1845
+ */
1846
+ constructor(t, n = {}) {
1847
+ this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (s, i = !0) => {
1848
+ var o, a;
1849
+ const r = L.now();
1850
+ if (this.updatedAt !== r && this.setPrevFrameValue(), this.prev = this.current, this.setCurrent(s), this.current !== this.prev && ((o = this.events.change) == null || o.notify(this.current), this.dependents))
1851
+ for (const l of this.dependents)
1852
+ l.dirty();
1853
+ i && ((a = this.events.renderRequest) == null || a.notify(this.current));
1854
+ }, this.hasAnimated = !1, this.setCurrent(t), this.owner = n.owner;
1855
+ }
1856
+ setCurrent(t) {
1857
+ this.current = t, this.updatedAt = L.now(), this.canTrackVelocity === null && t !== void 0 && (this.canTrackVelocity = bo(this.current));
1858
+ }
1859
+ setPrevFrameValue(t = this.current) {
1860
+ this.prevFrameValue = t, this.prevUpdatedAt = this.updatedAt;
1861
+ }
1862
+ /**
1863
+ * Adds a function that will be notified when the `MotionValue` is updated.
1864
+ *
1865
+ * It returns a function that, when called, will cancel the subscription.
1866
+ *
1867
+ * When calling `onChange` inside a React component, it should be wrapped with the
1868
+ * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1869
+ * from the `useEffect` function to ensure you don't add duplicate subscribers..
1870
+ *
1871
+ * ```jsx
1872
+ * export const MyComponent = () => {
1873
+ * const x = useMotionValue(0)
1874
+ * const y = useMotionValue(0)
1875
+ * const opacity = useMotionValue(1)
1876
+ *
1877
+ * useEffect(() => {
1878
+ * function updateOpacity() {
1879
+ * const maxXY = Math.max(x.get(), y.get())
1880
+ * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1881
+ * opacity.set(newOpacity)
1882
+ * }
1883
+ *
1884
+ * const unsubscribeX = x.on("change", updateOpacity)
1885
+ * const unsubscribeY = y.on("change", updateOpacity)
1886
+ *
1887
+ * return () => {
1888
+ * unsubscribeX()
1889
+ * unsubscribeY()
1890
+ * }
1891
+ * }, [])
1892
+ *
1893
+ * return <motion.div style={{ x }} />
1894
+ * }
1895
+ * ```
1896
+ *
1897
+ * @param subscriber - A function that receives the latest value.
1898
+ * @returns A function that, when called, will cancel this subscription.
1899
+ *
1900
+ * @deprecated
1901
+ */
1902
+ onChange(t) {
1903
+ return process.env.NODE_ENV !== "production" && On(!1, 'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'), this.on("change", t);
1904
+ }
1905
+ on(t, n) {
1906
+ this.events[t] || (this.events[t] = new Fn());
1907
+ const s = this.events[t].add(n);
1908
+ return t === "change" ? () => {
1909
+ s(), k.read(() => {
1910
+ this.events.change.getSize() || this.stop();
1911
+ });
1912
+ } : s;
1913
+ }
1914
+ clearListeners() {
1915
+ for (const t in this.events)
1916
+ this.events[t].clear();
1917
+ }
1918
+ /**
1919
+ * Attaches a passive effect to the `MotionValue`.
1920
+ */
1921
+ attach(t, n) {
1922
+ this.passiveEffect = t, this.stopPassiveEffect = n;
1923
+ }
1924
+ /**
1925
+ * Sets the state of the `MotionValue`.
1926
+ *
1927
+ * @remarks
1928
+ *
1929
+ * ```jsx
1930
+ * const x = useMotionValue(0)
1931
+ * x.set(10)
1932
+ * ```
1933
+ *
1934
+ * @param latest - Latest value to set.
1935
+ * @param render - Whether to notify render subscribers. Defaults to `true`
1936
+ *
1937
+ * @public
1938
+ */
1939
+ set(t, n = !0) {
1940
+ !n || !this.passiveEffect ? this.updateAndNotify(t, n) : this.passiveEffect(t, this.updateAndNotify);
1941
+ }
1942
+ setWithVelocity(t, n, s) {
1943
+ this.set(n), this.prev = void 0, this.prevFrameValue = t, this.prevUpdatedAt = this.updatedAt - s;
1944
+ }
1945
+ /**
1946
+ * Set the state of the `MotionValue`, stopping any active animations,
1947
+ * effects, and resets velocity to `0`.
1948
+ */
1949
+ jump(t, n = !0) {
1950
+ this.updateAndNotify(t), this.prev = t, this.prevUpdatedAt = this.prevFrameValue = void 0, n && this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
1951
+ }
1952
+ dirty() {
1953
+ var t;
1954
+ (t = this.events.change) == null || t.notify(this.current);
1955
+ }
1956
+ addDependent(t) {
1957
+ this.dependents || (this.dependents = /* @__PURE__ */ new Set()), this.dependents.add(t);
1958
+ }
1959
+ removeDependent(t) {
1960
+ this.dependents && this.dependents.delete(t);
1961
+ }
1962
+ /**
1963
+ * Returns the latest state of `MotionValue`
1964
+ *
1965
+ * @returns - The latest state of `MotionValue`
1966
+ *
1967
+ * @public
1968
+ */
1969
+ get() {
1970
+ return this.current;
1971
+ }
1972
+ /**
1973
+ * @public
1974
+ */
1975
+ getPrevious() {
1976
+ return this.prev;
1977
+ }
1978
+ /**
1979
+ * Returns the latest velocity of `MotionValue`
1980
+ *
1981
+ * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
1982
+ *
1983
+ * @public
1984
+ */
1985
+ getVelocity() {
1986
+ const t = L.now();
1987
+ if (!this.canTrackVelocity || this.prevFrameValue === void 0 || t - this.updatedAt > an)
1988
+ return 0;
1989
+ const n = Math.min(this.updatedAt - this.prevUpdatedAt, an);
1990
+ return Rn(parseFloat(this.current) - parseFloat(this.prevFrameValue), n);
1991
+ }
1992
+ /**
1993
+ * Registers a new animation to control this `MotionValue`. Only one
1994
+ * animation can drive a `MotionValue` at one time.
1995
+ *
1996
+ * ```jsx
1997
+ * value.start()
1998
+ * ```
1999
+ *
2000
+ * @param animation - A function that starts the provided animation
2001
+ */
2002
+ start(t) {
2003
+ return this.stop(), new Promise((n) => {
2004
+ this.hasAnimated = !0, this.animation = t(n), this.events.animationStart && this.events.animationStart.notify();
2005
+ }).then(() => {
2006
+ this.events.animationComplete && this.events.animationComplete.notify(), this.clearAnimation();
2007
+ });
2008
+ }
2009
+ /**
2010
+ * Stop the currently active animation.
2011
+ *
2012
+ * @public
2013
+ */
2014
+ stop() {
2015
+ this.animation && (this.animation.stop(), this.events.animationCancel && this.events.animationCancel.notify()), this.clearAnimation();
2016
+ }
2017
+ /**
2018
+ * Returns `true` if this value is currently animating.
2019
+ *
2020
+ * @public
2021
+ */
2022
+ isAnimating() {
2023
+ return !!this.animation;
2024
+ }
2025
+ clearAnimation() {
2026
+ delete this.animation;
2027
+ }
2028
+ /**
2029
+ * Destroy and clean up subscribers to this `MotionValue`.
2030
+ *
2031
+ * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
2032
+ * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
2033
+ * created a `MotionValue` via the `motionValue` function.
2034
+ *
2035
+ * @public
2036
+ */
2037
+ destroy() {
2038
+ var t, n;
2039
+ (t = this.dependents) == null || t.clear(), (n = this.events.destroy) == null || n.notify(), this.clearListeners(), this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
2040
+ }
2041
+ }
2042
+ function Ee(e, t) {
2043
+ return new vo(e, t);
2044
+ }
2045
+ const { schedule: To, cancel: Fc } = /* @__PURE__ */ jn(queueMicrotask, !1), wo = {
2046
+ x: !1,
2047
+ y: !1
2048
+ };
2049
+ function So() {
2050
+ return wo.y;
2051
+ }
2052
+ function ys(e, t) {
2053
+ const n = yo(e), s = new AbortController(), i = {
2054
+ passive: !0,
2055
+ ...t,
2056
+ signal: s.signal
2057
+ };
2058
+ return [n, i, () => s.abort()];
2059
+ }
2060
+ function cn(e) {
2061
+ return !(e.pointerType === "touch" || So());
2062
+ }
2063
+ function xo(e, t, n = {}) {
2064
+ const [s, i, r] = ys(e, n), o = (a) => {
2065
+ if (!cn(a))
2066
+ return;
2067
+ const { target: l } = a, u = t(l, a);
2068
+ if (typeof u != "function" || !l)
2069
+ return;
2070
+ const c = (d) => {
2071
+ cn(d) && (u(d), l.removeEventListener("pointerleave", c));
2072
+ };
2073
+ l.addEventListener("pointerleave", c, i);
2074
+ };
2075
+ return s.forEach((a) => {
2076
+ a.addEventListener("pointerenter", o, i);
2077
+ }), r;
2078
+ }
2079
+ const bs = (e, t) => t ? e === t ? !0 : bs(e, t.parentElement) : !1, Vo = (e) => e.pointerType === "mouse" ? typeof e.button != "number" || e.button <= 0 : e.isPrimary !== !1, Ao = /* @__PURE__ */ new Set([
2080
+ "BUTTON",
2081
+ "INPUT",
2082
+ "SELECT",
2083
+ "TEXTAREA",
2084
+ "A"
2085
+ ]);
2086
+ function Co(e) {
2087
+ return Ao.has(e.tagName) || e.tabIndex !== -1;
2088
+ }
2089
+ const xe = /* @__PURE__ */ new WeakSet();
2090
+ function un(e) {
2091
+ return (t) => {
2092
+ t.key === "Enter" && e(t);
2093
+ };
2094
+ }
2095
+ function je(e, t) {
2096
+ e.dispatchEvent(new PointerEvent("pointer" + t, { isPrimary: !0, bubbles: !0 }));
2097
+ }
2098
+ const Mo = (e, t) => {
2099
+ const n = e.currentTarget;
2100
+ if (!n)
2101
+ return;
2102
+ const s = un(() => {
2103
+ if (xe.has(n))
2104
+ return;
2105
+ je(n, "down");
2106
+ const i = un(() => {
2107
+ je(n, "up");
2108
+ }), r = () => je(n, "cancel");
2109
+ n.addEventListener("keyup", i, t), n.addEventListener("blur", r, t);
2110
+ });
2111
+ n.addEventListener("keydown", s, t), n.addEventListener("blur", () => n.removeEventListener("keydown", s), t);
2112
+ };
2113
+ function ln(e) {
2114
+ return Vo(e) && !0;
2115
+ }
2116
+ function Po(e, t, n = {}) {
2117
+ const [s, i, r] = ys(e, n), o = (a) => {
2118
+ const l = a.currentTarget;
2119
+ if (!ln(a))
2120
+ return;
2121
+ xe.add(l);
2122
+ const u = t(l, a), c = (h, g) => {
2123
+ window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", f), xe.has(l) && xe.delete(l), ln(h) && typeof u == "function" && u(h, { success: g });
2124
+ }, d = (h) => {
2125
+ c(h, l === window || l === document || n.useGlobalTarget || bs(l, h.target));
2126
+ }, f = (h) => {
2127
+ c(h, !1);
2128
+ };
2129
+ window.addEventListener("pointerup", d, i), window.addEventListener("pointercancel", f, i);
2130
+ };
2131
+ return s.forEach((a) => {
2132
+ (n.useGlobalTarget ? window : a).addEventListener("pointerdown", o, i), cs(a) && (a.addEventListener("focus", (u) => Mo(u, i)), !Co(a) && !a.hasAttribute("tabindex") && (a.tabIndex = 0));
2133
+ }), r;
2134
+ }
2135
+ const O = (e) => !!(e && e.getVelocity), Eo = [...hs, E, ae], Do = (e) => Eo.find(ds(e)), vs = se({
2136
+ transformPagePoint: (e) => e,
2137
+ isStatic: !1,
2138
+ reducedMotion: "never"
2139
+ }), Pt = se({ strict: !1 }), fn = {
2140
+ animation: [
2141
+ "animate",
2142
+ "variants",
2143
+ "whileHover",
2144
+ "whileTap",
2145
+ "exit",
2146
+ "whileInView",
2147
+ "whileFocus",
2148
+ "whileDrag"
2149
+ ],
2150
+ exit: ["exit"],
2151
+ drag: ["drag", "dragControls"],
2152
+ focus: ["whileFocus"],
2153
+ hover: ["whileHover", "onHoverStart", "onHoverEnd"],
2154
+ tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
2155
+ pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
2156
+ inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
2157
+ layout: ["layout", "layoutId"]
2158
+ }, te = {};
2159
+ for (const e in fn)
2160
+ te[e] = {
2161
+ isEnabled: (t) => fn[e].some((n) => !!t[n])
2162
+ };
2163
+ function ot(e) {
2164
+ for (const t in e)
2165
+ te[t] = {
2166
+ ...te[t],
2167
+ ...e[t]
2168
+ };
2169
+ }
2170
+ function Fo({ children: e, features: t, strict: n = !1 }) {
2171
+ const [, s] = zs(!Ue(t)), i = de(void 0);
2172
+ if (!Ue(t)) {
2173
+ const { renderer: r, ...o } = t;
2174
+ i.current = r, ot(o);
2175
+ }
2176
+ return dt(() => {
2177
+ Ue(t) && t().then(({ renderer: r, ...o }) => {
2178
+ ot(o), i.current = r, s(!0);
2179
+ });
2180
+ }, []), M(Pt.Provider, { value: { renderer: i.current, strict: n }, children: e });
2181
+ }
2182
+ function Ue(e) {
2183
+ return typeof e == "function";
2184
+ }
2185
+ const Ro = /* @__PURE__ */ new Set([
2186
+ "animate",
2187
+ "exit",
2188
+ "variants",
2189
+ "initial",
2190
+ "style",
2191
+ "values",
2192
+ "variants",
2193
+ "transition",
2194
+ "transformTemplate",
2195
+ "custom",
2196
+ "inherit",
2197
+ "onBeforeLayoutMeasure",
2198
+ "onAnimationStart",
2199
+ "onAnimationComplete",
2200
+ "onUpdate",
2201
+ "onDragStart",
2202
+ "onDrag",
2203
+ "onDragEnd",
2204
+ "onMeasureDragConstraints",
2205
+ "onDirectionLock",
2206
+ "onDragTransitionEnd",
2207
+ "_dragX",
2208
+ "_dragY",
2209
+ "onHoverStart",
2210
+ "onHoverEnd",
2211
+ "onViewportEnter",
2212
+ "onViewportLeave",
2213
+ "globalTapTarget",
2214
+ "ignoreStrict",
2215
+ "viewport"
2216
+ ]);
2217
+ function De(e) {
2218
+ return e.startsWith("while") || e.startsWith("drag") && e !== "draggable" || e.startsWith("layout") || e.startsWith("onTap") || e.startsWith("onPan") || e.startsWith("onLayout") || Ro.has(e);
2219
+ }
2220
+ let Ts = (e) => !De(e);
2221
+ function Oo(e) {
2222
+ typeof e == "function" && (Ts = (t) => t.startsWith("on") ? !De(t) : e(t));
2223
+ }
2224
+ try {
2225
+ Oo(require("@emotion/is-prop-valid").default);
2226
+ } catch {
2227
+ }
2228
+ function Lo(e, t, n) {
2229
+ const s = {};
2230
+ for (const i in e)
2231
+ i === "values" && typeof e.values == "object" || (Ts(i) || n === !0 && De(i) || !t && !De(i) || // If trying to use native HTML drag events, forward drag listeners
2232
+ e.draggable && i.startsWith("onDrag")) && (s[i] = e[i]);
2233
+ return s;
2234
+ }
2235
+ const Le = /* @__PURE__ */ se({});
2236
+ function Ie(e) {
2237
+ return e !== null && typeof e == "object" && typeof e.start == "function";
2238
+ }
2239
+ function ge(e) {
2240
+ return typeof e == "string" || Array.isArray(e);
2241
+ }
2242
+ const Et = [
2243
+ "animate",
2244
+ "whileInView",
2245
+ "whileFocus",
2246
+ "whileHover",
2247
+ "whileTap",
2248
+ "whileDrag",
2249
+ "exit"
2250
+ ], Dt = ["initial", ...Et];
2251
+ function ke(e) {
2252
+ return Ie(e.animate) || Dt.some((t) => ge(e[t]));
2253
+ }
2254
+ function ws(e) {
2255
+ return !!(ke(e) || e.variants);
2256
+ }
2257
+ function Io(e, t) {
2258
+ if (ke(e)) {
2259
+ const { initial: n, animate: s } = e;
2260
+ return {
2261
+ initial: n === !1 || ge(n) ? n : void 0,
2262
+ animate: ge(s) ? s : void 0
2263
+ };
2264
+ }
2265
+ return e.inherit !== !1 ? t : {};
2266
+ }
2267
+ function ko(e) {
2268
+ const { initial: t, animate: n } = Io(e, I(Le));
2269
+ return Fe(() => ({ initial: t, animate: n }), [dn(t), dn(n)]);
2270
+ }
2271
+ function dn(e) {
2272
+ return Array.isArray(e) ? e.join(" ") : e;
2273
+ }
2274
+ const No = Symbol.for("motionComponentSymbol");
2275
+ function Ss(e) {
2276
+ return e && typeof e == "object" && Object.prototype.hasOwnProperty.call(e, "current");
2277
+ }
2278
+ function Bo(e, t, n) {
2279
+ return Gs(
2280
+ (s) => {
2281
+ s && e.onMount && e.onMount(s), t && (s ? t.mount(s) : t.unmount()), n && (typeof n == "function" ? n(s) : Ss(n) && (n.current = s));
2282
+ },
2283
+ /**
2284
+ * Only pass a new ref callback to React if we've received a visual element
2285
+ * factory. Otherwise we'll be mounting/remounting every time externalRef
2286
+ * or other dependencies change.
2287
+ */
2288
+ [t]
2289
+ );
2290
+ }
2291
+ const Ft = (e) => e.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase(), Ko = "framerAppearId", xs = "data-" + Ft(Ko), Wo = se({});
2292
+ function $o(e, t, n, s, i) {
2293
+ var y, T;
2294
+ const { visualElement: r } = I(Le), o = I(Pt), a = I(Mn), l = I(vs).reducedMotion, u = de(null);
2295
+ s = s || o.renderer, !u.current && s && (u.current = s(e, {
2296
+ visualState: t,
2297
+ parent: r,
2298
+ props: n,
2299
+ presenceContext: a,
2300
+ blockInitialAnimation: a ? a.initial === !1 : !1,
2301
+ reducedMotionConfig: l
2302
+ }));
2303
+ const c = u.current, d = I(Wo);
2304
+ c && !c.projection && i && (c.type === "html" || c.type === "svg") && _o(u.current, n, i, d);
2305
+ const f = de(!1);
2306
+ Hs(() => {
2307
+ c && f.current && c.update(n, a);
2308
+ });
2309
+ const h = n[xs], g = de(!!h && !((y = window.MotionHandoffIsComplete) != null && y.call(window, h)) && ((T = window.MotionHasOptimisedAnimation) == null ? void 0 : T.call(window, h)));
2310
+ return Mi(() => {
2311
+ c && (f.current = !0, window.MotionIsMounted = !0, c.updateFeatures(), To.render(c.render), g.current && c.animationState && c.animationState.animateChanges());
2312
+ }), dt(() => {
2313
+ c && (!g.current && c.animationState && c.animationState.animateChanges(), g.current && (queueMicrotask(() => {
2314
+ var p;
2315
+ (p = window.MotionHandoffMarkAsComplete) == null || p.call(window, h);
2316
+ }), g.current = !1));
2317
+ }), c;
2318
+ }
2319
+ function _o(e, t, n, s) {
2320
+ const { layoutId: i, layout: r, drag: o, dragConstraints: a, layoutScroll: l, layoutRoot: u, layoutCrossfade: c } = t;
2321
+ e.projection = new n(e.latestValues, t["data-framer-portal-id"] ? void 0 : Vs(e.parent)), e.projection.setOptions({
2322
+ layoutId: i,
2323
+ layout: r,
2324
+ alwaysMeasureLayout: !!o || a && Ss(a),
2325
+ visualElement: e,
2326
+ /**
2327
+ * TODO: Update options in an effect. This could be tricky as it'll be too late
2328
+ * to update by the time layout animations run.
2329
+ * We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
2330
+ * ensuring it gets called if there's no potential layout animations.
2331
+ *
2332
+ */
2333
+ animationType: typeof r == "string" ? r : "both",
2334
+ initialPromotionConfig: s,
2335
+ crossfade: c,
2336
+ layoutScroll: l,
2337
+ layoutRoot: u
2338
+ });
2339
+ }
2340
+ function Vs(e) {
2341
+ if (e)
2342
+ return e.options.allowProjection !== !1 ? e.projection : Vs(e.parent);
2343
+ }
2344
+ function jo({ preloadedFeatures: e, createVisualElement: t, useRender: n, useVisualState: s, Component: i }) {
2345
+ e && ot(e);
2346
+ function r(a, l) {
2347
+ let u;
2348
+ const c = {
2349
+ ...I(vs),
2350
+ ...a,
2351
+ layoutId: Uo(a)
2352
+ }, { isStatic: d } = c, f = ko(a), h = s(a, d);
2353
+ if (!d && pt) {
2354
+ zo(c, e);
2355
+ const g = Go(c);
2356
+ u = g.MeasureLayout, f.visualElement = $o(i, h, c, t, g.ProjectionNode);
2357
+ }
2358
+ return Ve(Le.Provider, { value: f, children: [u && f.visualElement ? M(u, { visualElement: f.visualElement, ...c }) : null, n(i, a, Bo(h, f.visualElement, l), h, d, f.visualElement)] });
2359
+ }
2360
+ r.displayName = `motion.${typeof i == "string" ? i : `create(${i.displayName ?? i.name ?? ""})`}`;
2361
+ const o = Ys(r);
2362
+ return o[No] = i, o;
2363
+ }
2364
+ function Uo({ layoutId: e }) {
2365
+ const t = I(Ai).id;
2366
+ return t && e !== void 0 ? t + "-" + e : e;
2367
+ }
2368
+ function zo(e, t) {
2369
+ const n = I(Pt).strict;
2370
+ if (process.env.NODE_ENV !== "production" && t && n) {
2371
+ const s = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
2372
+ e.ignoreStrict ? ie(!1, s) : _(!1, s);
2373
+ }
2374
+ }
2375
+ function Go(e) {
2376
+ const { drag: t, layout: n } = te;
2377
+ if (!t && !n)
2378
+ return {};
2379
+ const s = { ...t, ...n };
2380
+ return {
2381
+ MeasureLayout: t != null && t.isEnabled(e) || n != null && n.isEnabled(e) ? s.MeasureLayout : void 0,
2382
+ ProjectionNode: s.ProjectionNode
2383
+ };
2384
+ }
2385
+ const Ho = {};
2386
+ function As(e, { layout: t, layoutId: n }) {
2387
+ return ue.has(e) || e.startsWith("origin") || (t || n !== void 0) && (!!Ho[e] || e === "opacity");
2388
+ }
2389
+ const Yo = {
2390
+ x: "translateX",
2391
+ y: "translateY",
2392
+ z: "translateZ",
2393
+ transformPerspective: "perspective"
2394
+ }, Xo = ce.length;
2395
+ function qo(e, t, n) {
2396
+ let s = "", i = !0;
2397
+ for (let r = 0; r < Xo; r++) {
2398
+ const o = ce[r], a = e[o];
2399
+ if (a === void 0)
2400
+ continue;
2401
+ let l = !0;
2402
+ if (typeof a == "number" ? l = a === (o.startsWith("scale") ? 1 : 0) : l = parseFloat(a) === 0, !l || n) {
2403
+ const u = gs(a, Mt[o]);
2404
+ if (!l) {
2405
+ i = !1;
2406
+ const c = Yo[o] || o;
2407
+ s += `${c}(${u}) `;
2408
+ }
2409
+ n && (t[o] = u);
2410
+ }
2411
+ }
2412
+ return s = s.trim(), n ? s = n(t, i ? "" : s) : i && (s = "none"), s;
2413
+ }
2414
+ function Rt(e, t, n) {
2415
+ const { style: s, vars: i, transformOrigin: r } = e;
2416
+ let o = !1, a = !1;
2417
+ for (const l in t) {
2418
+ const u = t[l];
2419
+ if (ue.has(l)) {
2420
+ o = !0;
2421
+ continue;
2422
+ } else if (zn(l)) {
2423
+ i[l] = u;
2424
+ continue;
2425
+ } else {
2426
+ const c = gs(u, Mt[l]);
2427
+ l.startsWith("origin") ? (a = !0, r[l] = c) : s[l] = c;
2428
+ }
2429
+ }
2430
+ if (t.transform || (o || n ? s.transform = qo(t, e.transform, n) : s.transform && (s.transform = "none")), a) {
2431
+ const { originX: l = "50%", originY: u = "50%", originZ: c = 0 } = r;
2432
+ s.transformOrigin = `${l} ${u} ${c}`;
2433
+ }
2434
+ }
2435
+ const Ot = () => ({
2436
+ style: {},
2437
+ transform: {},
2438
+ transformOrigin: {},
2439
+ vars: {}
2440
+ });
2441
+ function Cs(e, t, n) {
2442
+ for (const s in t)
2443
+ !O(t[s]) && !As(s, n) && (e[s] = t[s]);
2444
+ }
2445
+ function Zo({ transformTemplate: e }, t) {
2446
+ return Fe(() => {
2447
+ const n = Ot();
2448
+ return Rt(n, t, e), Object.assign({}, n.vars, n.style);
2449
+ }, [t]);
2450
+ }
2451
+ function Jo(e, t) {
2452
+ const n = e.style || {}, s = {};
2453
+ return Cs(s, n, e), Object.assign(s, Zo(e, t)), s;
2454
+ }
2455
+ function Qo(e, t) {
2456
+ const n = {}, s = Jo(e, t);
2457
+ return e.drag && e.dragListener !== !1 && (n.draggable = !1, s.userSelect = s.WebkitUserSelect = s.WebkitTouchCallout = "none", s.touchAction = e.drag === !0 ? "none" : `pan-${e.drag === "x" ? "y" : "x"}`), e.tabIndex === void 0 && (e.onTap || e.onTapStart || e.whileTap) && (n.tabIndex = 0), n.style = s, n;
2458
+ }
2459
+ const ea = {
2460
+ offset: "stroke-dashoffset",
2461
+ array: "stroke-dasharray"
2462
+ }, ta = {
2463
+ offset: "strokeDashoffset",
2464
+ array: "strokeDasharray"
2465
+ };
2466
+ function na(e, t, n = 1, s = 0, i = !0) {
2467
+ e.pathLength = 1;
2468
+ const r = i ? ea : ta;
2469
+ e[r.offset] = b.transform(-s);
2470
+ const o = b.transform(t), a = b.transform(n);
2471
+ e[r.array] = `${o} ${a}`;
2472
+ }
2473
+ function Ms(e, {
2474
+ attrX: t,
2475
+ attrY: n,
2476
+ attrScale: s,
2477
+ pathLength: i,
2478
+ pathSpacing: r = 1,
2479
+ pathOffset: o = 0,
2480
+ // This is object creation, which we try to avoid per-frame.
2481
+ ...a
2482
+ }, l, u, c) {
2483
+ if (Rt(e, a, u), l) {
2484
+ e.style.viewBox && (e.attrs.viewBox = e.style.viewBox);
2485
+ return;
2486
+ }
2487
+ e.attrs = e.style, e.style = {};
2488
+ const { attrs: d, style: f } = e;
2489
+ d.transform && (f.transform = d.transform, delete d.transform), (f.transform || d.transformOrigin) && (f.transformOrigin = d.transformOrigin ?? "50% 50%", delete d.transformOrigin), f.transform && (f.transformBox = (c == null ? void 0 : c.transformBox) ?? "fill-box", delete d.transformBox), t !== void 0 && (d.x = t), n !== void 0 && (d.y = n), s !== void 0 && (d.scale = s), i !== void 0 && na(d, i, r, o, !1);
2490
+ }
2491
+ const Ps = () => ({
2492
+ ...Ot(),
2493
+ attrs: {}
2494
+ }), Es = (e) => typeof e == "string" && e.toLowerCase() === "svg";
2495
+ function sa(e, t, n, s) {
2496
+ const i = Fe(() => {
2497
+ const r = Ps();
2498
+ return Ms(r, t, Es(s), e.transformTemplate, e.style), {
2499
+ ...r.attrs,
2500
+ style: { ...r.style }
2501
+ };
2502
+ }, [t]);
2503
+ if (e.style) {
2504
+ const r = {};
2505
+ Cs(r, e.style, e), i.style = { ...r, ...i.style };
2506
+ }
2507
+ return i;
2508
+ }
2509
+ const ia = [
2510
+ "animate",
2511
+ "circle",
2512
+ "defs",
2513
+ "desc",
2514
+ "ellipse",
2515
+ "g",
2516
+ "image",
2517
+ "line",
2518
+ "filter",
2519
+ "marker",
2520
+ "mask",
2521
+ "metadata",
2522
+ "path",
2523
+ "pattern",
2524
+ "polygon",
2525
+ "polyline",
2526
+ "rect",
2527
+ "stop",
2528
+ "switch",
2529
+ "symbol",
2530
+ "svg",
2531
+ "text",
2532
+ "tspan",
2533
+ "use",
2534
+ "view"
2535
+ ];
2536
+ function Lt(e) {
2537
+ return (
2538
+ /**
2539
+ * If it's not a string, it's a custom React component. Currently we only support
2540
+ * HTML custom React components.
2541
+ */
2542
+ typeof e != "string" || /**
2543
+ * If it contains a dash, the element is a custom HTML webcomponent.
2544
+ */
2545
+ e.includes("-") ? !1 : (
2546
+ /**
2547
+ * If it's in our list of lowercase SVG tags, it's an SVG component
2548
+ */
2549
+ !!(ia.indexOf(e) > -1 || /**
2550
+ * If it contains a capital letter, it's an SVG component
2551
+ */
2552
+ /[A-Z]/u.test(e))
2553
+ )
2554
+ );
2555
+ }
2556
+ function ra(e = !1) {
2557
+ return (n, s, i, { latestValues: r }, o) => {
2558
+ const l = (Lt(n) ? sa : Qo)(s, r, o, n), u = Lo(s, typeof n == "string", e), c = n !== Tn ? { ...u, ...l, ref: i } : {}, { children: d } = s, f = Fe(() => O(d) ? d.get() : d, [d]);
2559
+ return Xs(n, {
2560
+ ...c,
2561
+ children: f
2562
+ });
2563
+ };
2564
+ }
2565
+ function hn(e) {
2566
+ const t = [{}, {}];
2567
+ return e == null || e.values.forEach((n, s) => {
2568
+ t[0][s] = n.get(), t[1][s] = n.getVelocity();
2569
+ }), t;
2570
+ }
2571
+ function It(e, t, n, s) {
2572
+ if (typeof t == "function") {
2573
+ const [i, r] = hn(s);
2574
+ t = t(n !== void 0 ? n : e.custom, i, r);
2575
+ }
2576
+ if (typeof t == "string" && (t = e.variants && e.variants[t]), typeof t == "function") {
2577
+ const [i, r] = hn(s);
2578
+ t = t(n !== void 0 ? n : e.custom, i, r);
2579
+ }
2580
+ return t;
2581
+ }
2582
+ function oa(e) {
2583
+ return O(e) ? e.get() : e;
2584
+ }
2585
+ function aa({ scrapeMotionValuesFromProps: e, createRenderState: t }, n, s, i) {
2586
+ return {
2587
+ latestValues: ca(n, s, i, e),
2588
+ renderState: t()
2589
+ };
2590
+ }
2591
+ const Ds = (e) => (t, n) => {
2592
+ const s = I(Le), i = I(Mn), r = () => aa(e, t, s, i);
2593
+ return n ? r() : Ci(r);
2594
+ };
2595
+ function ca(e, t, n, s) {
2596
+ const i = {}, r = s(e, {});
2597
+ for (const f in r)
2598
+ i[f] = oa(r[f]);
2599
+ let { initial: o, animate: a } = e;
2600
+ const l = ke(e), u = ws(e);
2601
+ t && u && !l && e.inherit !== !1 && (o === void 0 && (o = t.initial), a === void 0 && (a = t.animate));
2602
+ let c = n ? n.initial === !1 : !1;
2603
+ c = c || o === !1;
2604
+ const d = c ? a : o;
2605
+ if (d && typeof d != "boolean" && !Ie(d)) {
2606
+ const f = Array.isArray(d) ? d : [d];
2607
+ for (let h = 0; h < f.length; h++) {
2608
+ const g = It(e, f[h]);
2609
+ if (g) {
2610
+ const { transitionEnd: y, transition: T, ...p } = g;
2611
+ for (const V in p) {
2612
+ let m = p[V];
2613
+ if (Array.isArray(m)) {
2614
+ const C = c ? m.length - 1 : 0;
2615
+ m = m[C];
2616
+ }
2617
+ m !== null && (i[V] = m);
2618
+ }
2619
+ for (const V in y)
2620
+ i[V] = y[V];
2621
+ }
2622
+ }
2623
+ }
2624
+ return i;
2625
+ }
2626
+ function kt(e, t, n) {
2627
+ var r;
2628
+ const { style: s } = e, i = {};
2629
+ for (const o in s)
2630
+ (O(s[o]) || t.style && O(t.style[o]) || As(o, e) || ((r = n == null ? void 0 : n.getValue(o)) == null ? void 0 : r.liveStyle) !== void 0) && (i[o] = s[o]);
2631
+ return i;
2632
+ }
2633
+ const ua = {
2634
+ useVisualState: Ds({
2635
+ scrapeMotionValuesFromProps: kt,
2636
+ createRenderState: Ot
2637
+ })
2638
+ };
2639
+ function Fs(e, t, n) {
2640
+ const s = kt(e, t, n);
2641
+ for (const i in e)
2642
+ if (O(e[i]) || O(t[i])) {
2643
+ const r = ce.indexOf(i) !== -1 ? "attr" + i.charAt(0).toUpperCase() + i.substring(1) : i;
2644
+ s[r] = e[i];
2645
+ }
2646
+ return s;
2647
+ }
2648
+ const la = {
2649
+ useVisualState: Ds({
2650
+ scrapeMotionValuesFromProps: Fs,
2651
+ createRenderState: Ps
2652
+ })
2653
+ };
2654
+ function fa(e, t) {
2655
+ return function(s, { forwardMotionProps: i } = { forwardMotionProps: !1 }) {
2656
+ const o = {
2657
+ ...Lt(s) ? la : ua,
2658
+ preloadedFeatures: e,
2659
+ useRender: ra(i),
2660
+ createVisualElement: t,
2661
+ Component: s
2662
+ };
2663
+ return jo(o);
2664
+ };
2665
+ }
2666
+ const da = /* @__PURE__ */ fa();
2667
+ function ye(e, t, n) {
2668
+ const s = e.getProps();
2669
+ return It(s, t, n !== void 0 ? n : s.custom, e);
2670
+ }
2671
+ const at = (e) => Array.isArray(e);
2672
+ function ha(e, t, n) {
2673
+ e.hasValue(t) ? e.getValue(t).set(n) : e.addValue(t, Ee(n));
2674
+ }
2675
+ function pa(e) {
2676
+ return at(e) ? e[e.length - 1] || 0 : e;
2677
+ }
2678
+ function ma(e, t) {
2679
+ const n = ye(e, t);
2680
+ let { transitionEnd: s = {}, transition: i = {}, ...r } = n || {};
2681
+ r = { ...r, ...s };
2682
+ for (const o in r) {
2683
+ const a = pa(r[o]);
2684
+ ha(e, o, a);
2685
+ }
2686
+ }
2687
+ function ga(e) {
2688
+ return !!(O(e) && e.add);
2689
+ }
2690
+ function ya(e, t) {
2691
+ const n = e.getValue("willChange");
2692
+ if (ga(n))
2693
+ return n.add(t);
2694
+ if (!n && W.WillChange) {
2695
+ const s = new W.WillChange("auto");
2696
+ e.addValue("willChange", s), s.add(t);
2697
+ }
2698
+ }
2699
+ function ba(e) {
2700
+ return e.props[xs];
2701
+ }
2702
+ const va = (e) => e !== null;
2703
+ function Ta(e, { repeat: t, repeatType: n = "loop" }, s) {
2704
+ const i = e.filter(va), r = t && n !== "loop" && t % 2 === 1 ? 0 : i.length - 1;
2705
+ return i[r];
2706
+ }
2707
+ const wa = {
2708
+ type: "spring",
2709
+ stiffness: 500,
2710
+ damping: 25,
2711
+ restSpeed: 10
2712
+ }, Sa = (e) => ({
2713
+ type: "spring",
2714
+ stiffness: 550,
2715
+ damping: e === 0 ? 2 * Math.sqrt(550) : 30,
2716
+ restSpeed: 10
2717
+ }), xa = {
2718
+ type: "keyframes",
2719
+ duration: 0.8
2720
+ }, Va = {
2721
+ type: "keyframes",
2722
+ ease: [0.25, 0.1, 0.35, 1],
2723
+ duration: 0.3
2724
+ }, Aa = (e, { keyframes: t }) => t.length > 2 ? xa : ue.has(e) ? e.startsWith("scale") ? Sa(t[1]) : wa : Va;
2725
+ function Ca({ when: e, delay: t, delayChildren: n, staggerChildren: s, staggerDirection: i, repeat: r, repeatType: o, repeatDelay: a, from: l, elapsed: u, ...c }) {
2726
+ return !!Object.keys(c).length;
2727
+ }
2728
+ const Ma = (e, t, n, s = {}, i, r) => (o) => {
2729
+ const a = ls(s, e) || {}, l = a.delay || s.delay || 0;
2730
+ let { elapsed: u = 0 } = s;
2731
+ u = u - /* @__PURE__ */ N(l);
2732
+ const c = {
2733
+ keyframes: Array.isArray(n) ? n : [null, n],
2734
+ ease: "easeOut",
2735
+ velocity: t.getVelocity(),
2736
+ ...a,
2737
+ delay: -u,
2738
+ onUpdate: (f) => {
2739
+ t.set(f), a.onUpdate && a.onUpdate(f);
2740
+ },
2741
+ onComplete: () => {
2742
+ o(), a.onComplete && a.onComplete();
2743
+ },
2744
+ name: e,
2745
+ motionValue: t,
2746
+ element: r ? void 0 : i
2747
+ };
2748
+ Ca(a) || Object.assign(c, Aa(e, c)), c.duration && (c.duration = /* @__PURE__ */ N(c.duration)), c.repeatDelay && (c.repeatDelay = /* @__PURE__ */ N(c.repeatDelay)), c.from !== void 0 && (c.keyframes[0] = c.from);
2749
+ let d = !1;
2750
+ if ((c.type === !1 || c.duration === 0 && !c.repeatDelay) && (c.duration = 0, c.delay === 0 && (d = !0)), (W.instantAnimations || W.skipAnimations) && (d = !0, c.duration = 0, c.delay = 0), c.allowFlatten = !a.type && !a.ease, d && !r && t.get() !== void 0) {
2751
+ const f = Ta(c.keyframes, a);
2752
+ if (f !== void 0) {
2753
+ k.update(() => {
2754
+ c.onUpdate(f), c.onComplete();
2755
+ });
2756
+ return;
2757
+ }
2758
+ }
2759
+ return a.isSync ? new At(c) : new no(c);
2760
+ };
2761
+ function Pa({ protectedKeys: e, needsAnimating: t }, n) {
2762
+ const s = e.hasOwnProperty(n) && t[n] !== !0;
2763
+ return t[n] = !1, s;
2764
+ }
2765
+ function Rs(e, t, { delay: n = 0, transitionOverride: s, type: i } = {}) {
2766
+ let { transition: r = e.getDefaultTransition(), transitionEnd: o, ...a } = t;
2767
+ s && (r = s);
2768
+ const l = [], u = i && e.animationState && e.animationState.getState()[i];
2769
+ for (const c in a) {
2770
+ const d = e.getValue(c, e.latestValues[c] ?? null), f = a[c];
2771
+ if (f === void 0 || u && Pa(u, c))
2772
+ continue;
2773
+ const h = {
2774
+ delay: n,
2775
+ ...ls(r || {}, c)
2776
+ }, g = d.get();
2777
+ if (g !== void 0 && !d.isAnimating && !Array.isArray(f) && f === g && !h.velocity)
2778
+ continue;
2779
+ let y = !1;
2780
+ if (window.MotionHandoffAnimation) {
2781
+ const p = ba(e);
2782
+ if (p) {
2783
+ const V = window.MotionHandoffAnimation(p, c, k);
2784
+ V !== null && (h.startTime = V, y = !0);
2785
+ }
2786
+ }
2787
+ ya(e, c), d.start(Ma(c, d, f, e.shouldReduceMotion && fs.has(c) ? { type: !1 } : h, e, y));
2788
+ const T = d.animation;
2789
+ T && l.push(T);
2790
+ }
2791
+ return o && Promise.all(l).then(() => {
2792
+ k.update(() => {
2793
+ o && ma(e, o);
2794
+ });
2795
+ }), l;
2796
+ }
2797
+ function ct(e, t, n = {}) {
2798
+ var l;
2799
+ const s = ye(e, t, n.type === "exit" ? (l = e.presenceContext) == null ? void 0 : l.custom : void 0);
2800
+ let { transition: i = e.getDefaultTransition() || {} } = s || {};
2801
+ n.transitionOverride && (i = n.transitionOverride);
2802
+ const r = s ? () => Promise.all(Rs(e, s, n)) : () => Promise.resolve(), o = e.variantChildren && e.variantChildren.size ? (u = 0) => {
2803
+ const { delayChildren: c = 0, staggerChildren: d, staggerDirection: f } = i;
2804
+ return Ea(e, t, u, c, d, f, n);
2805
+ } : () => Promise.resolve(), { when: a } = i;
2806
+ if (a) {
2807
+ const [u, c] = a === "beforeChildren" ? [r, o] : [o, r];
2808
+ return u().then(() => c());
2809
+ } else
2810
+ return Promise.all([r(), o(n.delay)]);
2811
+ }
2812
+ function Ea(e, t, n = 0, s = 0, i = 0, r = 1, o) {
2813
+ const a = [], l = e.variantChildren.size, u = (l - 1) * i, c = typeof s == "function", d = c ? (f) => s(f, l) : (
2814
+ // Support deprecated staggerChildren
2815
+ r === 1 ? (f = 0) => f * i : (f = 0) => u - f * i
2816
+ );
2817
+ return Array.from(e.variantChildren).sort(Da).forEach((f, h) => {
2818
+ f.notify("AnimationStart", t), a.push(ct(f, t, {
2819
+ ...o,
2820
+ delay: n + (c ? 0 : s) + d(h)
2821
+ }).then(() => f.notify("AnimationComplete", t)));
2822
+ }), Promise.all(a);
2823
+ }
2824
+ function Da(e, t) {
2825
+ return e.sortNodePosition(t);
2826
+ }
2827
+ function Fa(e, t, n = {}) {
2828
+ e.notify("AnimationStart", t);
2829
+ let s;
2830
+ if (Array.isArray(t)) {
2831
+ const i = t.map((r) => ct(e, r, n));
2832
+ s = Promise.all(i);
2833
+ } else if (typeof t == "string")
2834
+ s = ct(e, t, n);
2835
+ else {
2836
+ const i = typeof t == "function" ? ye(e, t, n.custom) : t;
2837
+ s = Promise.all(Rs(e, i, n));
2838
+ }
2839
+ return s.then(() => {
2840
+ e.notify("AnimationComplete", t);
2841
+ });
2842
+ }
2843
+ function Os(e, t) {
2844
+ if (!Array.isArray(t))
2845
+ return !1;
2846
+ const n = t.length;
2847
+ if (n !== e.length)
2848
+ return !1;
2849
+ for (let s = 0; s < n; s++)
2850
+ if (t[s] !== e[s])
2851
+ return !1;
2852
+ return !0;
2853
+ }
2854
+ const Ra = Dt.length;
2855
+ function Ls(e) {
2856
+ if (!e)
2857
+ return;
2858
+ if (!e.isControllingVariants) {
2859
+ const n = e.parent ? Ls(e.parent) || {} : {};
2860
+ return e.props.initial !== void 0 && (n.initial = e.props.initial), n;
2861
+ }
2862
+ const t = {};
2863
+ for (let n = 0; n < Ra; n++) {
2864
+ const s = Dt[n], i = e.props[s];
2865
+ (ge(i) || i === !1) && (t[s] = i);
2866
+ }
2867
+ return t;
2868
+ }
2869
+ const Oa = [...Et].reverse(), La = Et.length;
2870
+ function Ia(e) {
2871
+ return (t) => Promise.all(t.map(({ animation: n, options: s }) => Fa(e, n, s)));
2872
+ }
2873
+ function ka(e) {
2874
+ let t = Ia(e), n = pn(), s = !0;
2875
+ const i = (l) => (u, c) => {
2876
+ var f;
2877
+ const d = ye(e, c, l === "exit" ? (f = e.presenceContext) == null ? void 0 : f.custom : void 0);
2878
+ if (d) {
2879
+ const { transition: h, transitionEnd: g, ...y } = d;
2880
+ u = { ...u, ...y, ...g };
2881
+ }
2882
+ return u;
2883
+ };
2884
+ function r(l) {
2885
+ t = l(e);
2886
+ }
2887
+ function o(l) {
2888
+ const { props: u } = e, c = Ls(e.parent) || {}, d = [], f = /* @__PURE__ */ new Set();
2889
+ let h = {}, g = 1 / 0;
2890
+ for (let T = 0; T < La; T++) {
2891
+ const p = Oa[T], V = n[p], m = u[p] !== void 0 ? u[p] : c[p], C = ge(m), w = p === l ? V.isActive : null;
2892
+ w === !1 && (g = T);
2893
+ let A = m === c[p] && m !== u[p] && C;
2894
+ if (A && s && e.manuallyAnimateOnMount && (A = !1), V.protectedKeys = { ...h }, // If it isn't active and hasn't *just* been set as inactive
2895
+ !V.isActive && w === null || // If we didn't and don't have any defined prop for this animation type
2896
+ !m && !V.prevProp || // Or if the prop doesn't define an animation
2897
+ Ie(m) || typeof m == "boolean")
2898
+ continue;
2899
+ const x = Na(V.prevProp, m);
2900
+ let S = x || // If we're making this variant active, we want to always make it active
2901
+ p === l && V.isActive && !A && C || // If we removed a higher-priority variant (i is in reverse order)
2902
+ T > g && C, D = !1;
2903
+ const F = Array.isArray(m) ? m : [m];
2904
+ let X = F.reduce(i(p), {});
2905
+ w === !1 && (X = {});
2906
+ const { prevResolvedValues: Nt = {} } = V, js = {
2907
+ ...Nt,
2908
+ ...X
2909
+ }, Bt = (R) => {
2910
+ S = !0, f.has(R) && (D = !0, f.delete(R)), V.needsAnimating[R] = !0;
2911
+ const B = e.getValue(R);
2912
+ B && (B.liveStyle = !1);
2913
+ };
2914
+ for (const R in js) {
2915
+ const B = X[R], Ne = Nt[R];
2916
+ if (h.hasOwnProperty(R))
2917
+ continue;
2918
+ let Be = !1;
2919
+ at(B) && at(Ne) ? Be = !Os(B, Ne) : Be = B !== Ne, Be ? B != null ? Bt(R) : f.add(R) : B !== void 0 && f.has(R) ? Bt(R) : V.protectedKeys[R] = !0;
2920
+ }
2921
+ V.prevProp = m, V.prevResolvedValues = X, V.isActive && (h = { ...h, ...X }), s && e.blockInitialAnimation && (S = !1), S && (!(A && x) || D) && d.push(...F.map((R) => ({
2922
+ animation: R,
2923
+ options: { type: p }
2924
+ })));
2925
+ }
2926
+ if (f.size) {
2927
+ const T = {};
2928
+ if (typeof u.initial != "boolean") {
2929
+ const p = ye(e, Array.isArray(u.initial) ? u.initial[0] : u.initial);
2930
+ p && p.transition && (T.transition = p.transition);
2931
+ }
2932
+ f.forEach((p) => {
2933
+ const V = e.getBaseTarget(p), m = e.getValue(p);
2934
+ m && (m.liveStyle = !0), T[p] = V ?? null;
2935
+ }), d.push({ animation: T });
2936
+ }
2937
+ let y = !!d.length;
2938
+ return s && (u.initial === !1 || u.initial === u.animate) && !e.manuallyAnimateOnMount && (y = !1), s = !1, y ? t(d) : Promise.resolve();
2939
+ }
2940
+ function a(l, u) {
2941
+ var d;
2942
+ if (n[l].isActive === u)
2943
+ return Promise.resolve();
2944
+ (d = e.variantChildren) == null || d.forEach((f) => {
2945
+ var h;
2946
+ return (h = f.animationState) == null ? void 0 : h.setActive(l, u);
2947
+ }), n[l].isActive = u;
2948
+ const c = o(l);
2949
+ for (const f in n)
2950
+ n[f].protectedKeys = {};
2951
+ return c;
2952
+ }
2953
+ return {
2954
+ animateChanges: o,
2955
+ setActive: a,
2956
+ setAnimateFunction: r,
2957
+ getState: () => n,
2958
+ reset: () => {
2959
+ n = pn(), s = !0;
2960
+ }
2961
+ };
2962
+ }
2963
+ function Na(e, t) {
2964
+ return typeof t == "string" ? t !== e : Array.isArray(t) ? !Os(t, e) : !1;
2965
+ }
2966
+ function j(e = !1) {
2967
+ return {
2968
+ isActive: e,
2969
+ protectedKeys: {},
2970
+ needsAnimating: {},
2971
+ prevResolvedValues: {}
2972
+ };
2973
+ }
2974
+ function pn() {
2975
+ return {
2976
+ animate: j(!0),
2977
+ whileInView: j(),
2978
+ whileHover: j(),
2979
+ whileTap: j(),
2980
+ whileDrag: j(),
2981
+ whileFocus: j(),
2982
+ exit: j()
2983
+ };
2984
+ }
2985
+ class le {
2986
+ constructor(t) {
2987
+ this.isMounted = !1, this.node = t;
2988
+ }
2989
+ update() {
2990
+ }
2991
+ }
2992
+ class Ba extends le {
2993
+ /**
2994
+ * We dynamically generate the AnimationState manager as it contains a reference
2995
+ * to the underlying animation library. We only want to load that if we load this,
2996
+ * so people can optionally code split it out using the `m` component.
2997
+ */
2998
+ constructor(t) {
2999
+ super(t), t.animationState || (t.animationState = ka(t));
3000
+ }
3001
+ updateAnimationControlsSubscription() {
3002
+ const { animate: t } = this.node.getProps();
3003
+ Ie(t) && (this.unmountControls = t.subscribe(this.node));
3004
+ }
3005
+ /**
3006
+ * Subscribe any provided AnimationControls to the component's VisualElement
3007
+ */
3008
+ mount() {
3009
+ this.updateAnimationControlsSubscription();
3010
+ }
3011
+ update() {
3012
+ const { animate: t } = this.node.getProps(), { animate: n } = this.node.prevProps || {};
3013
+ t !== n && this.updateAnimationControlsSubscription();
3014
+ }
3015
+ unmount() {
3016
+ var t;
3017
+ this.node.animationState.reset(), (t = this.unmountControls) == null || t.call(this);
3018
+ }
3019
+ }
3020
+ let Ka = 0;
3021
+ class Wa extends le {
3022
+ constructor() {
3023
+ super(...arguments), this.id = Ka++;
3024
+ }
3025
+ update() {
3026
+ if (!this.node.presenceContext)
3027
+ return;
3028
+ const { isPresent: t, onExitComplete: n } = this.node.presenceContext, { isPresent: s } = this.node.prevPresenceContext || {};
3029
+ if (!this.node.animationState || t === s)
3030
+ return;
3031
+ const i = this.node.animationState.setActive("exit", !t);
3032
+ n && !t && i.then(() => {
3033
+ n(this.id);
3034
+ });
3035
+ }
3036
+ mount() {
3037
+ const { register: t, onExitComplete: n } = this.node.presenceContext || {};
3038
+ n && n(this.id), t && (this.unmount = t(this.id));
3039
+ }
3040
+ unmount() {
3041
+ }
3042
+ }
3043
+ const $a = {
3044
+ animation: {
3045
+ Feature: Ba
3046
+ },
3047
+ exit: {
3048
+ Feature: Wa
3049
+ }
3050
+ };
3051
+ function mn(e, t, n, s = { passive: !0 }) {
3052
+ return e.addEventListener(t, n, s), () => e.removeEventListener(t, n);
3053
+ }
3054
+ function Is(e) {
3055
+ return {
3056
+ point: {
3057
+ x: e.pageX,
3058
+ y: e.pageY
3059
+ }
3060
+ };
3061
+ }
3062
+ function _a({ top: e, left: t, right: n, bottom: s }) {
3063
+ return {
3064
+ x: { min: t, max: n },
3065
+ y: { min: e, max: s }
3066
+ };
3067
+ }
3068
+ function ja(e, t) {
3069
+ if (!t)
3070
+ return e;
3071
+ const n = t({ x: e.left, y: e.top }), s = t({ x: e.right, y: e.bottom });
3072
+ return {
3073
+ top: n.y,
3074
+ left: n.x,
3075
+ bottom: s.y,
3076
+ right: s.x
3077
+ };
3078
+ }
3079
+ const gn = () => ({ min: 0, max: 0 }), ks = () => ({
3080
+ x: gn(),
3081
+ y: gn()
3082
+ });
3083
+ function Ua(e, t) {
3084
+ return _a(ja(e.getBoundingClientRect(), t));
3085
+ }
3086
+ function yn(e, t, n) {
3087
+ const { props: s } = e;
3088
+ e.animationState && s.whileHover && e.animationState.setActive("whileHover", n === "Start");
3089
+ const i = "onHover" + n, r = s[i];
3090
+ r && k.postRender(() => r(t, Is(t)));
3091
+ }
3092
+ class za extends le {
3093
+ mount() {
3094
+ const { current: t } = this.node;
3095
+ t && (this.unmount = xo(t, (n, s) => (yn(this.node, s, "Start"), (i) => yn(this.node, i, "End"))));
3096
+ }
3097
+ unmount() {
3098
+ }
3099
+ }
3100
+ class Ga extends le {
3101
+ constructor() {
3102
+ super(...arguments), this.isActive = !1;
3103
+ }
3104
+ onFocus() {
3105
+ let t = !1;
3106
+ try {
3107
+ t = this.node.current.matches(":focus-visible");
3108
+ } catch {
3109
+ t = !0;
3110
+ }
3111
+ !t || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !0), this.isActive = !0);
3112
+ }
3113
+ onBlur() {
3114
+ !this.isActive || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !1), this.isActive = !1);
3115
+ }
3116
+ mount() {
3117
+ this.unmount = Re(mn(this.node.current, "focus", () => this.onFocus()), mn(this.node.current, "blur", () => this.onBlur()));
3118
+ }
3119
+ unmount() {
3120
+ }
3121
+ }
3122
+ function bn(e, t, n) {
3123
+ const { props: s } = e;
3124
+ if (e.current instanceof HTMLButtonElement && e.current.disabled)
3125
+ return;
3126
+ e.animationState && s.whileTap && e.animationState.setActive("whileTap", n === "Start");
3127
+ const i = "onTap" + (n === "End" ? "" : n), r = s[i];
3128
+ r && k.postRender(() => r(t, Is(t)));
3129
+ }
3130
+ class Ha extends le {
3131
+ mount() {
3132
+ const { current: t } = this.node;
3133
+ t && (this.unmount = Po(t, (n, s) => (bn(this.node, s, "Start"), (i, { success: r }) => bn(this.node, i, r ? "End" : "Cancel")), { useGlobalTarget: this.node.props.globalTapTarget }));
3134
+ }
3135
+ unmount() {
3136
+ }
3137
+ }
3138
+ const ut = /* @__PURE__ */ new WeakMap(), ze = /* @__PURE__ */ new WeakMap(), Ya = (e) => {
3139
+ const t = ut.get(e.target);
3140
+ t && t(e);
3141
+ }, Xa = (e) => {
3142
+ e.forEach(Ya);
3143
+ };
3144
+ function qa({ root: e, ...t }) {
3145
+ const n = e || document;
3146
+ ze.has(n) || ze.set(n, {});
3147
+ const s = ze.get(n), i = JSON.stringify(t);
3148
+ return s[i] || (s[i] = new IntersectionObserver(Xa, { root: e, ...t })), s[i];
3149
+ }
3150
+ function Za(e, t, n) {
3151
+ const s = qa(t);
3152
+ return ut.set(e, n), s.observe(e), () => {
3153
+ ut.delete(e), s.unobserve(e);
3154
+ };
3155
+ }
3156
+ const Ja = {
3157
+ some: 0,
3158
+ all: 1
3159
+ };
3160
+ class Qa extends le {
3161
+ constructor() {
3162
+ super(...arguments), this.hasEnteredView = !1, this.isInView = !1;
3163
+ }
3164
+ startObserver() {
3165
+ this.unmount();
3166
+ const { viewport: t = {} } = this.node.getProps(), { root: n, margin: s, amount: i = "some", once: r } = t, o = {
3167
+ root: n ? n.current : void 0,
3168
+ rootMargin: s,
3169
+ threshold: typeof i == "number" ? i : Ja[i]
3170
+ }, a = (l) => {
3171
+ const { isIntersecting: u } = l;
3172
+ if (this.isInView === u || (this.isInView = u, r && !u && this.hasEnteredView))
3173
+ return;
3174
+ u && (this.hasEnteredView = !0), this.node.animationState && this.node.animationState.setActive("whileInView", u);
3175
+ const { onViewportEnter: c, onViewportLeave: d } = this.node.getProps(), f = u ? c : d;
3176
+ f && f(l);
3177
+ };
3178
+ return Za(this.node.current, o, a);
3179
+ }
3180
+ mount() {
3181
+ this.startObserver();
3182
+ }
3183
+ update() {
3184
+ if (typeof IntersectionObserver > "u")
3185
+ return;
3186
+ const { props: t, prevProps: n } = this.node;
3187
+ ["amount", "margin", "root"].some(ec(t, n)) && this.startObserver();
3188
+ }
3189
+ unmount() {
3190
+ }
3191
+ }
3192
+ function ec({ viewport: e = {} }, { viewport: t = {} } = {}) {
3193
+ return (n) => e[n] !== t[n];
3194
+ }
3195
+ const tc = {
3196
+ inView: {
3197
+ Feature: Qa
3198
+ },
3199
+ tap: {
3200
+ Feature: Ha
3201
+ },
3202
+ focus: {
3203
+ Feature: Ga
3204
+ },
3205
+ hover: {
3206
+ Feature: za
3207
+ }
3208
+ }, lt = { current: null }, Ns = { current: !1 };
3209
+ function nc() {
3210
+ if (Ns.current = !0, !!pt)
3211
+ if (window.matchMedia) {
3212
+ const e = window.matchMedia("(prefers-reduced-motion)"), t = () => lt.current = e.matches;
3213
+ e.addEventListener("change", t), t();
3214
+ } else
3215
+ lt.current = !1;
3216
+ }
3217
+ const sc = /* @__PURE__ */ new WeakMap();
3218
+ function ic(e, t, n) {
3219
+ for (const s in t) {
3220
+ const i = t[s], r = n[s];
3221
+ if (O(i))
3222
+ e.addValue(s, i);
3223
+ else if (O(r))
3224
+ e.addValue(s, Ee(i, { owner: e }));
3225
+ else if (r !== i)
3226
+ if (e.hasValue(s)) {
3227
+ const o = e.getValue(s);
3228
+ o.liveStyle === !0 ? o.jump(i) : o.hasAnimated || o.set(i);
3229
+ } else {
3230
+ const o = e.getStaticValue(s);
3231
+ e.addValue(s, Ee(o !== void 0 ? o : i, { owner: e }));
3232
+ }
3233
+ }
3234
+ for (const s in n)
3235
+ t[s] === void 0 && e.removeValue(s);
3236
+ return t;
3237
+ }
3238
+ const vn = [
3239
+ "AnimationStart",
3240
+ "AnimationComplete",
3241
+ "Update",
3242
+ "BeforeLayoutMeasure",
3243
+ "LayoutMeasure",
3244
+ "LayoutAnimationStart",
3245
+ "LayoutAnimationComplete"
3246
+ ];
3247
+ class rc {
3248
+ /**
3249
+ * This method takes React props and returns found MotionValues. For example, HTML
3250
+ * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
3251
+ *
3252
+ * This isn't an abstract method as it needs calling in the constructor, but it is
3253
+ * intended to be one.
3254
+ */
3255
+ scrapeMotionValuesFromProps(t, n, s) {
3256
+ return {};
3257
+ }
3258
+ constructor({ parent: t, props: n, presenceContext: s, reducedMotionConfig: i, blockInitialAnimation: r, visualState: o }, a = {}) {
3259
+ this.current = null, this.children = /* @__PURE__ */ new Set(), this.isVariantNode = !1, this.isControllingVariants = !1, this.shouldReduceMotion = null, this.values = /* @__PURE__ */ new Map(), this.KeyframeResolver = Ct, this.features = {}, this.valueSubscriptions = /* @__PURE__ */ new Map(), this.prevMotionValues = {}, this.events = {}, this.propEventSubscriptions = {}, this.notifyUpdate = () => this.notify("Update", this.latestValues), this.render = () => {
3260
+ this.current && (this.triggerBuild(), this.renderInstance(this.current, this.renderState, this.props.style, this.projection));
3261
+ }, this.renderScheduledAt = 0, this.scheduleRender = () => {
3262
+ const f = L.now();
3263
+ this.renderScheduledAt < f && (this.renderScheduledAt = f, k.render(this.render, !1, !0));
3264
+ };
3265
+ const { latestValues: l, renderState: u } = o;
3266
+ this.latestValues = l, this.baseTarget = { ...l }, this.initialValues = n.initial ? { ...l } : {}, this.renderState = u, this.parent = t, this.props = n, this.presenceContext = s, this.depth = t ? t.depth + 1 : 0, this.reducedMotionConfig = i, this.options = a, this.blockInitialAnimation = !!r, this.isControllingVariants = ke(n), this.isVariantNode = ws(n), this.isVariantNode && (this.variantChildren = /* @__PURE__ */ new Set()), this.manuallyAnimateOnMount = !!(t && t.current);
3267
+ const { willChange: c, ...d } = this.scrapeMotionValuesFromProps(n, {}, this);
3268
+ for (const f in d) {
3269
+ const h = d[f];
3270
+ l[f] !== void 0 && O(h) && h.set(l[f], !1);
3271
+ }
3272
+ }
3273
+ mount(t) {
3274
+ this.current = t, sc.set(t, this), this.projection && !this.projection.instance && this.projection.mount(t), this.parent && this.isVariantNode && !this.isControllingVariants && (this.removeFromVariantTree = this.parent.addVariantChild(this)), this.values.forEach((n, s) => this.bindToMotionValue(s, n)), Ns.current || nc(), this.shouldReduceMotion = this.reducedMotionConfig === "never" ? !1 : this.reducedMotionConfig === "always" ? !0 : lt.current, process.env.NODE_ENV !== "production" && On(this.shouldReduceMotion !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected."), this.parent && this.parent.children.add(this), this.update(this.props, this.presenceContext);
3275
+ }
3276
+ unmount() {
3277
+ this.projection && this.projection.unmount(), He(this.notifyUpdate), He(this.render), this.valueSubscriptions.forEach((t) => t()), this.valueSubscriptions.clear(), this.removeFromVariantTree && this.removeFromVariantTree(), this.parent && this.parent.children.delete(this);
3278
+ for (const t in this.events)
3279
+ this.events[t].clear();
3280
+ for (const t in this.features) {
3281
+ const n = this.features[t];
3282
+ n && (n.unmount(), n.isMounted = !1);
3283
+ }
3284
+ this.current = null;
3285
+ }
3286
+ bindToMotionValue(t, n) {
3287
+ this.valueSubscriptions.has(t) && this.valueSubscriptions.get(t)();
3288
+ const s = ue.has(t);
3289
+ s && this.onBindTransform && this.onBindTransform();
3290
+ const i = n.on("change", (a) => {
3291
+ this.latestValues[t] = a, this.props.onUpdate && k.preRender(this.notifyUpdate), s && this.projection && (this.projection.isTransformDirty = !0);
3292
+ }), r = n.on("renderRequest", this.scheduleRender);
3293
+ let o;
3294
+ window.MotionCheckAppearSync && (o = window.MotionCheckAppearSync(this, t, n)), this.valueSubscriptions.set(t, () => {
3295
+ i(), r(), o && o(), n.owner && n.stop();
3296
+ });
3297
+ }
3298
+ sortNodePosition(t) {
3299
+ return !this.current || !this.sortInstanceNodePosition || this.type !== t.type ? 0 : this.sortInstanceNodePosition(this.current, t.current);
3300
+ }
3301
+ updateFeatures() {
3302
+ let t = "animation";
3303
+ for (t in te) {
3304
+ const n = te[t];
3305
+ if (!n)
3306
+ continue;
3307
+ const { isEnabled: s, Feature: i } = n;
3308
+ if (!this.features[t] && i && s(this.props) && (this.features[t] = new i(this)), this.features[t]) {
3309
+ const r = this.features[t];
3310
+ r.isMounted ? r.update() : (r.mount(), r.isMounted = !0);
3311
+ }
3312
+ }
3313
+ }
3314
+ triggerBuild() {
3315
+ this.build(this.renderState, this.latestValues, this.props);
3316
+ }
3317
+ /**
3318
+ * Measure the current viewport box with or without transforms.
3319
+ * Only measures axis-aligned boxes, rotate and skew must be manually
3320
+ * removed with a re-render to work.
3321
+ */
3322
+ measureViewportBox() {
3323
+ return this.current ? this.measureInstanceViewportBox(this.current, this.props) : ks();
3324
+ }
3325
+ getStaticValue(t) {
3326
+ return this.latestValues[t];
3327
+ }
3328
+ setStaticValue(t, n) {
3329
+ this.latestValues[t] = n;
3330
+ }
3331
+ /**
3332
+ * Update the provided props. Ensure any newly-added motion values are
3333
+ * added to our map, old ones removed, and listeners updated.
3334
+ */
3335
+ update(t, n) {
3336
+ (t.transformTemplate || this.props.transformTemplate) && this.scheduleRender(), this.prevProps = this.props, this.props = t, this.prevPresenceContext = this.presenceContext, this.presenceContext = n;
3337
+ for (let s = 0; s < vn.length; s++) {
3338
+ const i = vn[s];
3339
+ this.propEventSubscriptions[i] && (this.propEventSubscriptions[i](), delete this.propEventSubscriptions[i]);
3340
+ const r = "on" + i, o = t[r];
3341
+ o && (this.propEventSubscriptions[i] = this.on(i, o));
3342
+ }
3343
+ this.prevMotionValues = ic(this, this.scrapeMotionValuesFromProps(t, this.prevProps, this), this.prevMotionValues), this.handleChildMotionValue && this.handleChildMotionValue();
3344
+ }
3345
+ getProps() {
3346
+ return this.props;
3347
+ }
3348
+ /**
3349
+ * Returns the variant definition with a given name.
3350
+ */
3351
+ getVariant(t) {
3352
+ return this.props.variants ? this.props.variants[t] : void 0;
3353
+ }
3354
+ /**
3355
+ * Returns the defined default transition on this component.
3356
+ */
3357
+ getDefaultTransition() {
3358
+ return this.props.transition;
3359
+ }
3360
+ getTransformPagePoint() {
3361
+ return this.props.transformPagePoint;
3362
+ }
3363
+ getClosestVariantNode() {
3364
+ return this.isVariantNode ? this : this.parent ? this.parent.getClosestVariantNode() : void 0;
3365
+ }
3366
+ /**
3367
+ * Add a child visual element to our set of children.
3368
+ */
3369
+ addVariantChild(t) {
3370
+ const n = this.getClosestVariantNode();
3371
+ if (n)
3372
+ return n.variantChildren && n.variantChildren.add(t), () => n.variantChildren.delete(t);
3373
+ }
3374
+ /**
3375
+ * Add a motion value and bind it to this visual element.
3376
+ */
3377
+ addValue(t, n) {
3378
+ const s = this.values.get(t);
3379
+ n !== s && (s && this.removeValue(t), this.bindToMotionValue(t, n), this.values.set(t, n), this.latestValues[t] = n.get());
3380
+ }
3381
+ /**
3382
+ * Remove a motion value and unbind any active subscriptions.
3383
+ */
3384
+ removeValue(t) {
3385
+ this.values.delete(t);
3386
+ const n = this.valueSubscriptions.get(t);
3387
+ n && (n(), this.valueSubscriptions.delete(t)), delete this.latestValues[t], this.removeValueFromRenderState(t, this.renderState);
3388
+ }
3389
+ /**
3390
+ * Check whether we have a motion value for this key
3391
+ */
3392
+ hasValue(t) {
3393
+ return this.values.has(t);
3394
+ }
3395
+ getValue(t, n) {
3396
+ if (this.props.values && this.props.values[t])
3397
+ return this.props.values[t];
3398
+ let s = this.values.get(t);
3399
+ return s === void 0 && n !== void 0 && (s = Ee(n === null ? void 0 : n, { owner: this }), this.addValue(t, s)), s;
3400
+ }
3401
+ /**
3402
+ * If we're trying to animate to a previously unencountered value,
3403
+ * we need to check for it in our state and as a last resort read it
3404
+ * directly from the instance (which might have performance implications).
3405
+ */
3406
+ readValue(t, n) {
3407
+ let s = this.latestValues[t] !== void 0 || !this.current ? this.latestValues[t] : this.getBaseTargetFromProps(this.props, t) ?? this.readValueFromInstance(this.current, t, this.options);
3408
+ return s != null && (typeof s == "string" && (Pn(s) || En(s)) ? s = parseFloat(s) : !Do(s) && ae.test(n) && (s = ms(t, n)), this.setBaseTarget(t, O(s) ? s.get() : s)), O(s) ? s.get() : s;
3409
+ }
3410
+ /**
3411
+ * Set the base target to later animate back to. This is currently
3412
+ * only hydrated on creation and when we first read a value.
3413
+ */
3414
+ setBaseTarget(t, n) {
3415
+ this.baseTarget[t] = n;
3416
+ }
3417
+ /**
3418
+ * Find the base target for a value thats been removed from all animation
3419
+ * props.
3420
+ */
3421
+ getBaseTarget(t) {
3422
+ var r;
3423
+ const { initial: n } = this.props;
3424
+ let s;
3425
+ if (typeof n == "string" || typeof n == "object") {
3426
+ const o = It(this.props, n, (r = this.presenceContext) == null ? void 0 : r.custom);
3427
+ o && (s = o[t]);
3428
+ }
3429
+ if (n && s !== void 0)
3430
+ return s;
3431
+ const i = this.getBaseTargetFromProps(this.props, t);
3432
+ return i !== void 0 && !O(i) ? i : this.initialValues[t] !== void 0 && s === void 0 ? void 0 : this.baseTarget[t];
3433
+ }
3434
+ on(t, n) {
3435
+ return this.events[t] || (this.events[t] = new Fn()), this.events[t].add(n);
3436
+ }
3437
+ notify(t, ...n) {
3438
+ this.events[t] && this.events[t].notify(...n);
3439
+ }
3440
+ }
3441
+ class Bs extends rc {
3442
+ constructor() {
3443
+ super(...arguments), this.KeyframeResolver = go;
3444
+ }
3445
+ sortInstanceNodePosition(t, n) {
3446
+ return t.compareDocumentPosition(n) & 2 ? 1 : -1;
3447
+ }
3448
+ getBaseTargetFromProps(t, n) {
3449
+ return t.style ? t.style[n] : void 0;
3450
+ }
3451
+ removeValueFromRenderState(t, { vars: n, style: s }) {
3452
+ delete n[t], delete s[t];
3453
+ }
3454
+ handleChildMotionValue() {
3455
+ this.childSubscription && (this.childSubscription(), delete this.childSubscription);
3456
+ const { children: t } = this.props;
3457
+ O(t) && (this.childSubscription = t.on("change", (n) => {
3458
+ this.current && (this.current.textContent = `${n}`);
3459
+ }));
3460
+ }
3461
+ }
3462
+ function Ks(e, { style: t, vars: n }, s, i) {
3463
+ const r = e.style;
3464
+ let o;
3465
+ for (o in t)
3466
+ r[o] = t[o];
3467
+ i == null || i.applyProjectionStyles(r, s);
3468
+ for (o in n)
3469
+ r.setProperty(o, n[o]);
3470
+ }
3471
+ function oc(e) {
3472
+ return window.getComputedStyle(e);
3473
+ }
3474
+ class ac extends Bs {
3475
+ constructor() {
3476
+ super(...arguments), this.type = "html", this.renderInstance = Ks;
3477
+ }
3478
+ readValueFromInstance(t, n) {
3479
+ var s;
3480
+ if (ue.has(n))
3481
+ return (s = this.projection) != null && s.isProjecting ? et(n) : Or(t, n);
3482
+ {
3483
+ const i = oc(t), r = (zn(n) ? i.getPropertyValue(n) : i[n]) || 0;
3484
+ return typeof r == "string" ? r.trim() : r;
3485
+ }
3486
+ }
3487
+ measureInstanceViewportBox(t, { transformPagePoint: n }) {
3488
+ return Ua(t, n);
3489
+ }
3490
+ build(t, n, s) {
3491
+ Rt(t, n, s.transformTemplate);
3492
+ }
3493
+ scrapeMotionValuesFromProps(t, n, s) {
3494
+ return kt(t, n, s);
3495
+ }
3496
+ }
3497
+ const Ws = /* @__PURE__ */ new Set([
3498
+ "baseFrequency",
3499
+ "diffuseConstant",
3500
+ "kernelMatrix",
3501
+ "kernelUnitLength",
3502
+ "keySplines",
3503
+ "keyTimes",
3504
+ "limitingConeAngle",
3505
+ "markerHeight",
3506
+ "markerWidth",
3507
+ "numOctaves",
3508
+ "targetX",
3509
+ "targetY",
3510
+ "surfaceScale",
3511
+ "specularConstant",
3512
+ "specularExponent",
3513
+ "stdDeviation",
3514
+ "tableValues",
3515
+ "viewBox",
3516
+ "gradientTransform",
3517
+ "pathLength",
3518
+ "startOffset",
3519
+ "textLength",
3520
+ "lengthAdjust"
3521
+ ]);
3522
+ function cc(e, t, n, s) {
3523
+ Ks(e, t, void 0, s);
3524
+ for (const i in t.attrs)
3525
+ e.setAttribute(Ws.has(i) ? i : Ft(i), t.attrs[i]);
3526
+ }
3527
+ class uc extends Bs {
3528
+ constructor() {
3529
+ super(...arguments), this.type = "svg", this.isSVGTag = !1, this.measureInstanceViewportBox = ks;
3530
+ }
3531
+ getBaseTargetFromProps(t, n) {
3532
+ return t[n];
3533
+ }
3534
+ readValueFromInstance(t, n) {
3535
+ if (ue.has(n)) {
3536
+ const s = ps(n);
3537
+ return s && s.default || 0;
3538
+ }
3539
+ return n = Ws.has(n) ? n : Ft(n), t.getAttribute(n);
3540
+ }
3541
+ scrapeMotionValuesFromProps(t, n, s) {
3542
+ return Fs(t, n, s);
3543
+ }
3544
+ build(t, n, s) {
3545
+ Ms(t, n, this.isSVGTag, s.transformTemplate, s.style);
3546
+ }
3547
+ renderInstance(t, n, s, i) {
3548
+ cc(t, n, s, i);
3549
+ }
3550
+ mount(t) {
3551
+ this.isSVGTag = Es(t.tagName), super.mount(t);
3552
+ }
3553
+ }
3554
+ const lc = (e, t) => Lt(e) ? new uc(t) : new ac(t, {
3555
+ allowProjection: e !== Tn
3556
+ }), fc = {
3557
+ renderer: lc,
3558
+ ...$a,
3559
+ ...tc
3560
+ }, ft = /* @__PURE__ */ da("div"), $s = ne.createContext({
3561
+ layers: [],
3562
+ setLayers: () => {
3563
+ },
3564
+ addLayer: () => {
3565
+ },
3566
+ removeLayer: () => {
3567
+ },
3568
+ removeTopLayer: () => {
3569
+ }
3570
+ }), Rc = ({ children: e }) => {
3571
+ const [t, n] = ne.useState([]), s = (o) => {
3572
+ n((a) => [...a, o]);
3573
+ }, i = (o) => {
3574
+ n(t.filter((a) => a !== o));
3575
+ }, r = () => {
3576
+ const o = t[t.length - 1];
3577
+ o && i(o);
3578
+ };
3579
+ return /* @__PURE__ */ M(
3580
+ $s.Provider,
3581
+ {
3582
+ value: { layers: t, setLayers: n, addLayer: s, removeLayer: i, removeTopLayer: r },
3583
+ children: e
3584
+ }
3585
+ );
3586
+ }, _s = () => ne.useContext($s), dc = ({
3587
+ defaultOpen: e,
3588
+ open: t,
3589
+ onOpenChange: n,
3590
+ ...s
3591
+ }) => {
3592
+ const [i, r] = Si({
3593
+ prop: t,
3594
+ onChange: n,
3595
+ defaultProp: e ?? !1
3596
+ }), o = _s(), a = s.a11yTitle;
3597
+ if (ne.useEffect(() => {
3598
+ !i && o.layers.includes(a) && o.removeLayer(a);
3599
+ }, [a, o, i]), !!i)
3600
+ return /* @__PURE__ */ M(hc, { open: i, onOpenChange: r, ...s });
3601
+ }, hc = ({
3602
+ open: e,
3603
+ onOpenChange: t,
3604
+ a11yTitle: n,
3605
+ a11yDescription: s,
3606
+ children: i,
3607
+ // Focus scope props
3608
+ trapped: r,
3609
+ onMountAutoFocus: o,
3610
+ onUnmountAutoFocus: a,
3611
+ ...l
3612
+ }) => {
3613
+ var y, T;
3614
+ const u = n, c = _s();
3615
+ ne.useEffect(() => {
3616
+ !c || !e || c.layers.includes(u) || c.addLayer(u);
3617
+ }, [u, c, e]);
3618
+ const d = ((y = c.layers) == null ? void 0 : y.indexOf(u)) || 0, f = ((T = c.layers) == null ? void 0 : T.length) || 0, h = d !== 0, g = u === c.layers[c.layers.length - 1];
3619
+ return /* @__PURE__ */ M(Fo, { features: fc, children: /* @__PURE__ */ M(
3620
+ An,
3621
+ {
3622
+ onEscapeKeyDown: (p) => {
3623
+ g && (p.preventDefault(), c.removeTopLayer(), t(!1));
3624
+ },
3625
+ onPointerDownOutside: (p) => {
3626
+ g && (p.preventDefault(), c.removeTopLayer(), t(!1));
3627
+ },
3628
+ children: /* @__PURE__ */ Ve(
3629
+ J.Root,
3630
+ {
3631
+ open: e,
3632
+ onOpenChange: (p) => {
3633
+ var m;
3634
+ if (((m = c == null ? void 0 : c.layers) == null ? void 0 : m.length) > 0)
3635
+ return p === !1 && u === c.layers[c.layers.length - 1] ? (c.removeLayer(u), t(!1)) : void 0;
3636
+ t(p);
3637
+ },
3638
+ children: [
3639
+ /* @__PURE__ */ Ve(Qs.Root, { children: [
3640
+ /* @__PURE__ */ M(J.Title, { children: n }),
3641
+ s && /* @__PURE__ */ M(J.Description, { children: s })
3642
+ ] }),
3643
+ e && // We add the className "tgph" here so that styles within
3644
+ // the portal get scoped properly to telegraph
3645
+ /* @__PURE__ */ M(Js.Root, { className: "tgph", children: /* @__PURE__ */ M(pc, { layer: d, children: /* @__PURE__ */ M(
3646
+ Zs,
3647
+ {
3648
+ trapped: typeof r == "boolean" ? r : g,
3649
+ onMountAutoFocus: o,
3650
+ onUnmountAutoFocus: a,
3651
+ asChild: !0,
3652
+ children: /* @__PURE__ */ M(ti, { children: /* @__PURE__ */ M(
3653
+ ee,
3654
+ {
3655
+ as: ft,
3656
+ initial: {
3657
+ top: `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${f - 1})`
3658
+ },
3659
+ animate: {
3660
+ top: h ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${d} )` : "var(--tgph-spacing-16)"
3661
+ },
3662
+ exit: { top: 0 },
3663
+ transition: { type: "spring", duration: 0.3, bounce: 0 },
3664
+ w: "full",
3665
+ justify: "center",
3666
+ style: {
3667
+ position: "fixed",
3668
+ left: 0,
3669
+ maxHeight: "calc(100vh - var(--tgph-spacing-32))",
3670
+ maxWidth: "calc(100vw - var(--tgph-spacing-8))",
3671
+ zIndex: `calc(var(--tgph-zIndex-modal) + ${d})`
3672
+ },
3673
+ children: /* @__PURE__ */ M(
3674
+ ee,
3675
+ {
3676
+ direction: "column",
3677
+ as: ft,
3678
+ animate: {
3679
+ scale: 1.02 - Math.abs(f - d) * 0.02,
3680
+ transformOrigin: "center center"
3681
+ },
3682
+ transition: {
3683
+ duration: 0.2,
3684
+ bounce: 0,
3685
+ type: "spring"
3686
+ },
3687
+ maxW: l.maxW ?? "160",
3688
+ w: l.w ?? "full",
3689
+ bg: "surface-1",
3690
+ border: "px",
3691
+ rounded: "4",
3692
+ shadow: "3",
3693
+ ...l,
3694
+ children: i
3695
+ },
3696
+ `content-${u}`
3697
+ )
3698
+ },
3699
+ `container-${u}`
3700
+ ) })
3701
+ }
3702
+ ) }) })
3703
+ ]
3704
+ },
3705
+ u
3706
+ )
3707
+ }
3708
+ ) });
3709
+ }, pc = ({ layer: e, children: t }) => e > 0 ? t : /* @__PURE__ */ Ve(J.Overlay, { children: [
3710
+ /* @__PURE__ */ M(
3711
+ ni,
452
3712
  {
453
- as: T.div,
3713
+ as: ft,
454
3714
  initial: { opacity: 0 },
455
3715
  animate: { opacity: 1 },
456
3716
  exit: { opacity: 0 },
@@ -467,26 +3727,26 @@ const K = g.createContext({
467
3727
  }
468
3728
  ),
469
3729
  t
470
- ] }), De = g.forwardRef(
471
- ({ children: e, ...t }, r) => /* @__PURE__ */ d(v.Content, { ref: r, asChild: !0, ...t, children: /* @__PURE__ */ d(E, { direction: "column", h: "full", ...t, children: e }) })
472
- ), Oe = ({
3730
+ ] }), mc = ne.forwardRef(
3731
+ ({ children: e, ...t }, n) => /* @__PURE__ */ M(J.Content, { ref: n, asChild: !0, ...t, children: /* @__PURE__ */ M(ee, { direction: "column", h: "full", ...t, children: e }) })
3732
+ ), gc = ({
473
3733
  size: e = "1",
474
3734
  variant: t = "ghost",
475
- ...r
476
- }) => /* @__PURE__ */ d(v.Close, { asChild: !0, children: /* @__PURE__ */ d(
477
- J,
3735
+ ...n
3736
+ }) => /* @__PURE__ */ M(J.Close, { asChild: !0, children: /* @__PURE__ */ M(
3737
+ ei,
478
3738
  {
479
- icon: { icon: ee.X, alt: "Close Modal" },
3739
+ icon: { icon: si, alt: "Close Modal" },
480
3740
  variant: t,
481
3741
  size: e,
482
- ...r
3742
+ ...n
483
3743
  }
484
- ) }), Se = ({
3744
+ ) }), yc = ({
485
3745
  style: e,
486
3746
  children: t,
487
- ...r
488
- }) => /* @__PURE__ */ d(
489
- E,
3747
+ ...n
3748
+ }) => /* @__PURE__ */ M(
3749
+ ee,
490
3750
  {
491
3751
  direction: "column",
492
3752
  px: "6",
@@ -495,14 +3755,14 @@ const K = g.createContext({
495
3755
  overflowY: "auto",
496
3756
  ...e
497
3757
  },
498
- ...r,
3758
+ ...n,
499
3759
  children: t
500
3760
  }
501
- ), Te = ({
3761
+ ), bc = ({
502
3762
  children: e,
503
3763
  ...t
504
- }) => /* @__PURE__ */ d(
505
- E,
3764
+ }) => /* @__PURE__ */ M(
3765
+ ee,
506
3766
  {
507
3767
  direction: "row",
508
3768
  justify: "space-between",
@@ -513,11 +3773,11 @@ const K = g.createContext({
513
3773
  ...t,
514
3774
  children: e
515
3775
  }
516
- ), Be = ({
3776
+ ), vc = ({
517
3777
  children: e,
518
3778
  ...t
519
- }) => /* @__PURE__ */ d(
520
- E,
3779
+ }) => /* @__PURE__ */ M(
3780
+ ee,
521
3781
  {
522
3782
  direction: "row",
523
3783
  align: "center",
@@ -529,17 +3789,17 @@ const K = g.createContext({
529
3789
  ...t,
530
3790
  children: e
531
3791
  }
532
- ), Ie = {};
533
- Object.assign(Ie, {
534
- Root: we,
535
- Content: De,
536
- Close: Oe,
537
- Body: Se,
538
- Header: Te,
539
- Footer: Be
3792
+ ), Tc = {};
3793
+ Object.assign(Tc, {
3794
+ Root: dc,
3795
+ Content: mc,
3796
+ Close: gc,
3797
+ Body: yc,
3798
+ Header: bc,
3799
+ Footer: vc
540
3800
  });
541
3801
  export {
542
- Ie as Modal,
543
- je as ModalStackingProvider
3802
+ Tc as Modal,
3803
+ Rc as ModalStackingProvider
544
3804
  };
545
3805
  //# sourceMappingURL=index.mjs.map