@js-empire/emperor-ui 1.2.3 → 1.2.4

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.
Files changed (157) hide show
  1. package/.cursor/rules/code-conventions.mdc +50 -0
  2. package/README.md +0 -15
  3. package/dist/emperor-ui.js +119 -71
  4. package/dist/emperor-ui.umd.cjs +27 -13
  5. package/dist/globals.css +1 -1
  6. package/dist/index-BXtdEByK.js +5 -0
  7. package/dist/index-CDB93OLO.js +55965 -0
  8. package/dist/index-CYORMghp.js +290 -0
  9. package/dist/index.d.ts +334 -33
  10. package/dist/src-UW24ZMRV-C1Pn8-w8.js +5 -0
  11. package/package.json +32 -2
  12. package/src/animations/blink.ts +26 -0
  13. package/src/animations/floating.ts +12 -0
  14. package/src/animations/index.ts +2 -0
  15. package/src/components/atoms/brand/brand.tsx +1 -1
  16. package/src/components/atoms/color-picker/color-picker.tsx +13 -0
  17. package/src/components/atoms/color-picker/free-color-picker.tsx +60 -0
  18. package/src/components/atoms/color-picker/index.ts +3 -0
  19. package/src/components/atoms/color-picker/preset-color-picker.tsx +64 -0
  20. package/src/components/atoms/color-picker/stories/color-picker.stories.tsx +49 -0
  21. package/src/components/atoms/color-picker/styles/color-picker.css +23 -0
  22. package/src/components/atoms/copy-button/copy-button.tsx +73 -0
  23. package/src/components/atoms/copy-button/index.ts +1 -0
  24. package/src/components/atoms/copy-button/stories/copy-button.stories.tsx +21 -0
  25. package/src/components/atoms/field/field.stories.tsx +27 -0
  26. package/src/components/atoms/field/field.tsx +11 -0
  27. package/src/components/atoms/field/index.ts +1 -0
  28. package/src/components/atoms/field/styles/classes.ts +9 -0
  29. package/src/components/atoms/field/styles/index.ts +1 -0
  30. package/src/components/atoms/filter/filter.tsx +92 -0
  31. package/src/components/atoms/filter/index.ts +3 -0
  32. package/src/components/atoms/filter/stories/filter.stories.tsx +97 -0
  33. package/src/components/atoms/filter/styles/classes.ts +20 -0
  34. package/src/components/atoms/filter/styles/index.ts +1 -0
  35. package/src/components/atoms/filter/units/autocomplete-filter.tsx +39 -0
  36. package/src/components/atoms/filter/units/checkbox-filter.tsx +32 -0
  37. package/src/components/atoms/filter/units/checkbox-group-filter.tsx +37 -0
  38. package/src/components/atoms/filter/units/date-filter.tsx +50 -0
  39. package/src/components/atoms/filter/units/index.ts +9 -0
  40. package/src/components/atoms/filter/units/numeric-filter.tsx +36 -0
  41. package/src/components/atoms/filter/units/range-filter.tsx +36 -0
  42. package/src/components/atoms/filter/units/search-filter.tsx +52 -0
  43. package/src/components/atoms/filter/units/select-filter.tsx +49 -0
  44. package/src/components/atoms/filter/units/switch-filter.tsx +33 -0
  45. package/src/components/atoms/index.ts +5 -0
  46. package/src/components/atoms/theme-switch/index.ts +1 -0
  47. package/src/components/atoms/theme-switch/styles/classes.ts +16 -0
  48. package/src/components/atoms/theme-switch/styles/index.ts +1 -0
  49. package/src/components/atoms/theme-switch/theme-switch.stories.tsx +26 -0
  50. package/src/components/atoms/theme-switch/theme-switch.tsx +54 -0
  51. package/src/components/atoms/uploader/avatar-label.tsx +3 -1
  52. package/src/components/atoms/uploader/stories/uploader.stories.tsx +1 -1
  53. package/src/components/atoms/uploader/upload-file-error-box.tsx +1 -1
  54. package/src/components/atoms/uploader/upload-file-input.tsx +1 -1
  55. package/src/components/atoms/uploader/upload-file-label.tsx +2 -1
  56. package/src/components/atoms/uploader/upload-file-listing.tsx +2 -1
  57. package/src/components/atoms/uploader/view-image-modal.tsx +2 -1
  58. package/src/components/molecules/index.ts +0 -1
  59. package/src/components/molecules/item-card/index.ts +6 -0
  60. package/src/components/molecules/item-card/item-actions-dropdown.tsx +57 -0
  61. package/src/components/molecules/item-card/item-banner.tsx +22 -0
  62. package/src/components/molecules/item-card/item-card-body.tsx +68 -0
  63. package/src/components/molecules/item-card/item-card-footer.tsx +55 -0
  64. package/src/components/molecules/item-card/item-card-header.tsx +61 -0
  65. package/src/components/molecules/item-card/item-card.tsx +83 -3
  66. package/src/components/molecules/item-card/loading-item.tsx +88 -0
  67. package/src/components/molecules/item-card/stories/item-card.stories.tsx +182 -0
  68. package/src/components/molecules/item-card/styles/classes.ts +138 -0
  69. package/src/components/molecules/item-card/styles/index.ts +1 -0
  70. package/src/components/molecules/nav-bar/sub-items-box.tsx +2 -1
  71. package/src/components/molecules/scaffold/index.ts +1 -0
  72. package/src/components/molecules/scaffold/scaffold.tsx +4 -17
  73. package/src/components/molecules/scaffold/styles/index.ts +1 -0
  74. package/src/components/molecules/scaffold/styles/scaffold-classes.ts +10 -0
  75. package/src/components/molecules/side-bar/compact-side-bar.tsx +3 -1
  76. package/src/components/molecules/side-bar/side-bar-drawer.tsx +6 -17
  77. package/src/components/molecules/side-bar/side-bar.stories.tsx +1 -1
  78. package/src/components/organisms/filters/filters.stories.tsx +32 -0
  79. package/src/components/organisms/filters/filters.tsx +36 -0
  80. package/src/components/organisms/filters/index.ts +1 -0
  81. package/src/components/organisms/filters/styles/classes.ts +9 -0
  82. package/src/components/organisms/filters/styles/index.ts +1 -0
  83. package/src/components/organisms/footer/copy-rights-box.tsx +1 -1
  84. package/src/components/organisms/footer/footer.tsx +1 -1
  85. package/src/components/organisms/footer/policies-box.tsx +2 -1
  86. package/src/components/organisms/footer/quick-links-box.tsx +2 -1
  87. package/src/components/organisms/footer/social-links-box.tsx +2 -1
  88. package/src/components/organisms/footer/stories/footer.stories.tsx +1 -1
  89. package/src/components/organisms/header/header.tsx +1 -8
  90. package/src/components/organisms/index.ts +1 -0
  91. package/src/components/organisms/listings/empty-listings.tsx +80 -0
  92. package/src/components/organisms/listings/index.ts +2 -0
  93. package/src/components/organisms/listings/listings.tsx +90 -9
  94. package/src/components/organisms/listings/stories/grid-listings.stories.tsx +153 -0
  95. package/src/components/organisms/listings/stories/list-listings.stories.tsx +171 -0
  96. package/src/components/organisms/listings/styles/classes.ts +41 -3
  97. package/src/constants/animations.ts +14 -0
  98. package/src/constants/card.tsx +26 -0
  99. package/src/constants/defaults.ts +1 -16
  100. package/src/constants/index.ts +2 -0
  101. package/src/hooks/index.ts +3 -0
  102. package/src/hooks/use-filters.ts +20 -0
  103. package/src/hooks/use-search-params-handler.tsx +186 -0
  104. package/src/hooks/use-uploader.tsx +1 -1
  105. package/src/hooks/use-window-size.tsx +53 -0
  106. package/src/i18n/locales/atoms/ar.ts +3 -0
  107. package/src/i18n/locales/atoms/en.ts +3 -0
  108. package/src/i18n/locales/organisms/ar.ts +7 -1
  109. package/src/i18n/locales/organisms/en.ts +7 -1
  110. package/src/mocks/constants.ts +103 -0
  111. package/src/mocks/index.ts +2 -0
  112. package/src/mocks/listings.tsx +154 -0
  113. package/src/mocks/types.ts +64 -0
  114. package/src/providers/config-provider.tsx +0 -8
  115. package/src/providers/emperor-ui-provider.tsx +16 -5
  116. package/src/providers/index.ts +1 -0
  117. package/src/providers/theme-provider.tsx +16 -0
  118. package/src/providers/uploader-provider.tsx +1 -1
  119. package/src/styles/hero.ts +1 -1
  120. package/src/styles/index.css +23 -0
  121. package/src/types/components/atoms/color-picker/color-picker.ts +12 -0
  122. package/src/types/components/atoms/color-picker/index.ts +1 -0
  123. package/src/types/components/atoms/field/field.ts +9 -0
  124. package/src/types/components/atoms/field/index.ts +1 -0
  125. package/src/types/components/atoms/filter/filter.ts +43 -0
  126. package/src/types/components/atoms/filter/index.ts +2 -0
  127. package/src/types/components/atoms/filter/select-filter.ts +8 -0
  128. package/src/types/components/atoms/index.ts +3 -0
  129. package/src/types/components/atoms/uploader.ts +1 -1
  130. package/src/types/components/index.ts +1 -0
  131. package/src/types/components/molecules/index.ts +1 -1
  132. package/src/types/components/molecules/item-card/item-card.ts +50 -0
  133. package/src/types/components/molecules/listings/listings.ts +21 -5
  134. package/src/types/components/molecules/side-bar/side-bar.ts +1 -1
  135. package/src/types/components/molecules/theme-switch/index.ts +1 -0
  136. package/src/types/components/molecules/theme-switch/theme-switch.ts +9 -0
  137. package/src/types/components/organisms/filters/filters.ts +11 -0
  138. package/src/types/components/organisms/filters/index.ts +1 -0
  139. package/src/types/components/organisms/index.ts +1 -0
  140. package/src/types/context/config.ts +3 -4
  141. package/src/types/context/index.ts +0 -1
  142. package/src/types/context/localization.ts +1 -0
  143. package/src/types/shared/components.ts +3 -0
  144. package/src/utils/uploader.ts +1 -1
  145. package/dist/features-animation-w9dWMd15.js +0 -1938
  146. package/dist/index-BY47HgaP.js +0 -26533
  147. package/dist/index-CN4cJ1N7.js +0 -1630
  148. package/dist/index-Cr1mc-d4.js +0 -5
  149. package/dist/src-UW24ZMRV-nsR4cpiy.js +0 -5
  150. package/src/components/molecules/filter/filter.tsx +0 -6
  151. package/src/components/molecules/filter/index.ts +0 -1
  152. package/src/components/organisms/listings/stories/listings.stories.tsx +0 -30
  153. package/src/main.tsx +0 -3
  154. package/src/mocks/listings.ts +0 -200
  155. package/src/types/components/molecules/filter/filter.ts +0 -9
  156. package/src/types/components/molecules/filter/index.ts +0 -1
  157. package/src/types/context/theme.ts +0 -17
@@ -1,1630 +0,0 @@
1
- import { i as re, m as T, p as W, a as le, n as B, b as he, c as Ot, d as Ut, r as Ft, t as Nt, f as S, e as b, S as ce, g as Wt, h as E, j as z, k as Gt, l as P, o as M, q as H, s as tt, u as I, v as ue, w as de, L as me, x as fe, y as pe } from "./index-BY47HgaP.js";
2
- import { A as zs, Z as Hs, B as $s, M as Xs, Q as Ys, R as Ks, N as qs, a7 as _s, P as Zs, z as Js, T as Qs, V as ti, al as ei, ad as si, aO as ii, aQ as ni, aS as oi, E as ai, aN as ri, a8 as li, ae as hi, U as ci, aK as ui, aM as di, aI as mi, aJ as fi, a0 as pi, a1 as gi, ah as yi, ao as vi, af as xi, $ as Pi, H as Ti, ag as Di, au as Si, _ as Ei, at as Vi, ai as Ai, aw as Li, av as Ri, aU as Ci, a9 as wi, aa as Mi, aH as Bi, ay as ji, I as ki, W as bi, X as Ii, az as Oi, aB as Ui, a6 as Fi, aX as Ni, aR as Wi, O as Gi, aC as zi, aA as Hi, aY as $i, C as Xi, D as Yi, am as Ki, aj as qi, F as _i, Y as Zi, a2 as Ji, aL as Qi, aV as tn, ap as en, a3 as sn, aE as nn, ab as on, ac as an, an as rn, aP as ln, aT as hn, ax as cn, as as un, a4 as dn, a5 as mn, ak as fn, aD as pn, J as gn, K as yn, aF as vn, aG as xn, aZ as Pn, aq as Tn, G as Dn, ar as Sn, a_ as En, aW as Vn } from "./index-BY47HgaP.js";
3
- import { i as L, s as et, p as Z, c as ge, a as zt, g as ye, h as w, t as O, b as U, e as st, f as ve, j as xe, k as Pe, l as Te, m as Q, n as De, o as Se, q as Ht, r as Ee, u as Ve, v as Ae, w as Le, x as Re, y as Ce, z as it, A as we, F as $t, d as Me } from "./features-animation-w9dWMd15.js";
4
- import { D as Ln, Z as Rn, aw as Cn, ax as wn, J as Mn, N as Bn, E as jn, ay as kn, P as bn, Q as In, C as On, B as Un, aN as Fn, aF as Nn, a6 as Wn, aG as Gn, aO as zn, aP as Hn, aQ as $n, G as Xn, V as Yn, aK as Kn, az as qn, aR as _n, aS as Zn, a0 as Jn, aA as Qn, X as to, aT as eo, a1 as so, S as io, _ as no, aU as oo, aV as ao, aW as ro, a$ as lo, $ as ho, a7 as co, K as uo, L as mo, aj as fo, H as po, aB as go, a9 as yo, au as vo, R as xo, af as Po, ao as To, aZ as Do, a8 as So, a_ as Eo, Y as Vo, ad as Ao, ab as Lo, M as Ro, av as Co, T as wo, O as Mo, a2 as Bo, W as jo, aI as ko, aM as bo, aX as Io, ag as Oo, ak as Uo, ah as Fo, al as No, an as Wo, ai as Go, am as zo, ap as Ho, I as $o, ae as Xo, aa as Yo, aJ as Ko, aL as qo, aq as _o, aC as Zo, aY as Jo, ac as Qo, aD as ta, U as ea, a4 as sa, a3 as ia, a5 as na, ar as oa, as as aa, at as ra, aH as la, aE as ha } from "./features-animation-w9dWMd15.js";
5
- import { useContext as nt, Component as Be } from "react";
6
- function je(t) {
7
- return t === "x" || t === "y" ? L[t] ? null : (L[t] = !0, () => {
8
- L[t] = !1;
9
- }) : L.x || L.y ? null : (L.x = L.y = !0, () => {
10
- L.x = L.y = !1;
11
- });
12
- }
13
- function Xt(t) {
14
- return re(t) && "ownerSVGElement" in t;
15
- }
16
- function ke(t) {
17
- return Xt(t) && t.tagName === "svg";
18
- }
19
- function ot(t, e) {
20
- t.min = e.min, t.max = e.max;
21
- }
22
- function A(t, e) {
23
- ot(t.x, e.x), ot(t.y, e.y);
24
- }
25
- function at(t, e) {
26
- t.translate = e.translate, t.scale = e.scale, t.originPoint = e.originPoint, t.origin = e.origin;
27
- }
28
- const Yt = 1e-4, be = 1 - Yt, Ie = 1 + Yt, Kt = 0.01, Oe = 0 - Kt, Ue = 0 + Kt;
29
- function D(t) {
30
- return t.max - t.min;
31
- }
32
- function Fe(t, e, i) {
33
- return Math.abs(t - e) <= i;
34
- }
35
- function rt(t, e, i, n = 0.5) {
36
- t.origin = n, t.originPoint = T(e.min, e.max, t.origin), t.scale = D(i) / D(e), t.translate = T(i.min, i.max, t.origin) - t.originPoint, (t.scale >= be && t.scale <= Ie || isNaN(t.scale)) && (t.scale = 1), (t.translate >= Oe && t.translate <= Ue || isNaN(t.translate)) && (t.translate = 0);
37
- }
38
- function j(t, e, i, n) {
39
- rt(t.x, e.x, i.x, n ? n.originX : void 0), rt(t.y, e.y, i.y, n ? n.originY : void 0);
40
- }
41
- function lt(t, e, i) {
42
- t.min = i.min + e.min, t.max = t.min + D(e);
43
- }
44
- function Ne(t, e, i) {
45
- lt(t.x, e.x, i.x), lt(t.y, e.y, i.y);
46
- }
47
- function ht(t, e, i) {
48
- t.min = e.min - i.min, t.max = t.min + D(e);
49
- }
50
- function G(t, e, i) {
51
- ht(t.x, e.x, i.x), ht(t.y, e.y, i.y);
52
- }
53
- function ct(t, e, i, n, r) {
54
- return t -= e, t = et(t, 1 / i, n), r !== void 0 && (t = et(t, 1 / r, n)), t;
55
- }
56
- function We(t, e = 0, i = 1, n = 0.5, r, c = t, s = t) {
57
- if (W.test(e) && (e = parseFloat(e), e = T(s.min, s.max, e / 100) - s.min), typeof e != "number")
58
- return;
59
- let o = T(c.min, c.max, n);
60
- t === c && (o -= e), t.min = ct(t.min, e, i, o, r), t.max = ct(t.max, e, i, o, r);
61
- }
62
- function ut(t, e, [i, n, r], c, s) {
63
- We(t, e[i], e[n], e[r], e.scale, c, s);
64
- }
65
- const Ge = ["x", "scaleX", "originX"], ze = ["y", "scaleY", "originY"];
66
- function dt(t, e, i, n) {
67
- ut(t.x, e, Ge, i ? i.x : void 0, n ? n.x : void 0), ut(t.y, e, ze, i ? i.y : void 0, n ? n.y : void 0);
68
- }
69
- function mt(t) {
70
- return t.translate === 0 && t.scale === 1;
71
- }
72
- function qt(t) {
73
- return mt(t.x) && mt(t.y);
74
- }
75
- function ft(t, e) {
76
- return t.min === e.min && t.max === e.max;
77
- }
78
- function He(t, e) {
79
- return ft(t.x, e.x) && ft(t.y, e.y);
80
- }
81
- function pt(t, e) {
82
- return Math.round(t.min) === Math.round(e.min) && Math.round(t.max) === Math.round(e.max);
83
- }
84
- function _t(t, e) {
85
- return pt(t.x, e.x) && pt(t.y, e.y);
86
- }
87
- function gt(t) {
88
- return D(t.x) / D(t.y);
89
- }
90
- function yt(t, e) {
91
- return t.translate === e.translate && t.scale === e.scale && t.originPoint === e.originPoint;
92
- }
93
- function V(t) {
94
- return [t("x"), t("y")];
95
- }
96
- function $e(t, e, i) {
97
- let n = "";
98
- const r = t.x.translate / e.x, c = t.y.translate / e.y, s = i?.z || 0;
99
- if ((r || c || s) && (n = `translate3d(${r}px, ${c}px, ${s}px) `), (e.x !== 1 || e.y !== 1) && (n += `scale(${1 / e.x}, ${1 / e.y}) `), i) {
100
- const { transformPerspective: l, rotate: h, rotateX: u, rotateY: d, skewX: m, skewY: f } = i;
101
- l && (n = `perspective(${l}px) ${n}`), h && (n += `rotate(${h}deg) `), u && (n += `rotateX(${u}deg) `), d && (n += `rotateY(${d}deg) `), m && (n += `skewX(${m}deg) `), f && (n += `skewY(${f}deg) `);
102
- }
103
- const o = t.x.scale * e.x, a = t.y.scale * e.y;
104
- return (o !== 1 || a !== 1) && (n += `scale(${o}, ${a})`), n || "none";
105
- }
106
- const Zt = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"], Xe = Zt.length, vt = (t) => typeof t == "string" ? parseFloat(t) : t, xt = (t) => typeof t == "number" || le.test(t);
107
- function Ye(t, e, i, n, r, c) {
108
- r ? (t.opacity = T(0, i.opacity ?? 1, Ke(n)), t.opacityExit = T(e.opacity ?? 1, 0, qe(n))) : c && (t.opacity = T(e.opacity ?? 1, i.opacity ?? 1, n));
109
- for (let s = 0; s < Xe; s++) {
110
- const o = `border${Zt[s]}Radius`;
111
- let a = Pt(e, o), l = Pt(i, o);
112
- if (a === void 0 && l === void 0)
113
- continue;
114
- a || (a = 0), l || (l = 0), a === 0 || l === 0 || xt(a) === xt(l) ? (t[o] = Math.max(T(vt(a), vt(l), n), 0), (W.test(l) || W.test(a)) && (t[o] += "%")) : t[o] = l;
115
- }
116
- (e.rotate || i.rotate) && (t.rotate = T(e.rotate || 0, i.rotate || 0, n));
117
- }
118
- function Pt(t, e) {
119
- return t[e] !== void 0 ? t[e] : t.borderRadius;
120
- }
121
- const Ke = /* @__PURE__ */ Jt(0, 0.5, ge), qe = /* @__PURE__ */ Jt(0.5, 0.95, B);
122
- function Jt(t, e, i) {
123
- return (n) => n < t ? 0 : n > e ? 1 : i(Z(t, e, n));
124
- }
125
- function _e(t, e, i) {
126
- const n = he(t) ? t : Ot(t);
127
- return n.start(zt("", n, e, i)), n.animation;
128
- }
129
- const Ze = (t, e) => t.depth - e.depth;
130
- class Je {
131
- constructor() {
132
- this.children = [], this.isDirty = !1;
133
- }
134
- add(e) {
135
- Ut(this.children, e), this.isDirty = !0;
136
- }
137
- remove(e) {
138
- Ft(this.children, e), this.isDirty = !0;
139
- }
140
- forEach(e) {
141
- this.isDirty && this.children.sort(Ze), this.isDirty = !1, this.children.forEach(e);
142
- }
143
- }
144
- function Qe(t, e) {
145
- const i = Nt.now(), n = ({ timestamp: r }) => {
146
- const c = r - i;
147
- c >= e && (b(n), t(c - e));
148
- };
149
- return S.setup(n, !0), () => b(n);
150
- }
151
- class ts {
152
- constructor() {
153
- this.members = [];
154
- }
155
- add(e) {
156
- Ut(this.members, e), e.scheduleRender();
157
- }
158
- remove(e) {
159
- if (Ft(this.members, e), e === this.prevLead && (this.prevLead = void 0), e === this.lead) {
160
- const i = this.members[this.members.length - 1];
161
- i && this.promote(i);
162
- }
163
- }
164
- relegate(e) {
165
- const i = this.members.findIndex((r) => e === r);
166
- if (i === 0)
167
- return !1;
168
- let n;
169
- for (let r = i; r >= 0; r--) {
170
- const c = this.members[r];
171
- if (c.isPresent !== !1) {
172
- n = c;
173
- break;
174
- }
175
- }
176
- return n ? (this.promote(n), !0) : !1;
177
- }
178
- promote(e, i) {
179
- const n = this.lead;
180
- if (e !== n && (this.prevLead = n, this.lead = e, e.show(), n)) {
181
- n.instance && n.scheduleRender(), e.scheduleRender(), e.resumeFrom = n, i && (e.resumeFrom.preserveOpacity = !0), n.snapshot && (e.snapshot = n.snapshot, e.snapshot.latestValues = n.animationValues || n.latestValues), e.root && e.root.isUpdating && (e.isLayoutDirty = !0);
182
- const { crossfade: r } = e.options;
183
- r === !1 && n.hide();
184
- }
185
- }
186
- exitAnimationComplete() {
187
- this.members.forEach((e) => {
188
- const { options: i, resumingFrom: n } = e;
189
- i.onExitComplete && i.onExitComplete(), n && n.options.onExitComplete && n.options.onExitComplete();
190
- });
191
- }
192
- scheduleRender() {
193
- this.members.forEach((e) => {
194
- e.instance && e.scheduleRender(!1);
195
- });
196
- }
197
- /**
198
- * Clear any leads that have been removed this render to prevent them from being
199
- * used in future animations and to prevent memory leaks
200
- */
201
- removeLeadSnapshot() {
202
- this.lead && this.lead.snapshot && (this.lead.snapshot = void 0);
203
- }
204
- }
205
- const N = {
206
- /**
207
- * Global flag as to whether the tree has animated since the last time
208
- * we resized the window
209
- */
210
- hasAnimatedSinceResize: !0,
211
- /**
212
- * We set this to true once, on the first update. Any nodes added to the tree beyond that
213
- * update will be given a `data-projection-id` attribute.
214
- */
215
- hasEverUpdated: !1
216
- }, $ = ["", "X", "Y", "Z"], es = 1e3;
217
- let ss = 0;
218
- function X(t, e, i, n) {
219
- const { latestValues: r } = e;
220
- r[t] && (i[t] = r[t], e.setStaticValue(t, 0), n && (n[t] = 0));
221
- }
222
- function Qt(t) {
223
- if (t.hasCheckedOptimisedAppear = !0, t.root === t)
224
- return;
225
- const { visualElement: e } = t.options;
226
- if (!e)
227
- return;
228
- const i = Te(e);
229
- if (window.MotionHasOptimisedAnimation(i, "transform")) {
230
- const { layout: r, layoutId: c } = t.options;
231
- window.MotionCancelOptimisedAnimation(i, "transform", S, !(r || c));
232
- }
233
- const { parent: n } = t;
234
- n && !n.hasCheckedOptimisedAppear && Qt(n);
235
- }
236
- function te({ attachResizeListener: t, defaultParent: e, measureScroll: i, checkIsScrollRoot: n, resetTransform: r }) {
237
- return class {
238
- constructor(s = {}, o = e?.()) {
239
- this.id = ss++, this.animationId = 0, this.animationCommitId = 0, this.children = /* @__PURE__ */ new Set(), this.options = {}, this.isTreeAnimating = !1, this.isAnimationBlocked = !1, this.isLayoutDirty = !1, this.isProjectionDirty = !1, this.isSharedProjectionDirty = !1, this.isTransformDirty = !1, this.updateManuallyBlocked = !1, this.updateBlockedByResize = !1, this.isUpdating = !1, this.isSVG = !1, this.needsReset = !1, this.shouldResetTransform = !1, this.hasCheckedOptimisedAppear = !1, this.treeScale = { x: 1, y: 1 }, this.eventHandlers = /* @__PURE__ */ new Map(), this.hasTreeAnimated = !1, this.layoutVersion = 0, this.updateScheduled = !1, this.scheduleUpdate = () => this.update(), this.projectionUpdateScheduled = !1, this.checkUpdateFailed = () => {
240
- this.isUpdating && (this.isUpdating = !1, this.clearAllSnapshots());
241
- }, this.updateProjection = () => {
242
- this.projectionUpdateScheduled = !1, this.nodes.forEach(os), this.nodes.forEach(hs), this.nodes.forEach(cs), this.nodes.forEach(as);
243
- }, this.resolvedRelativeTargetAt = 0, this.linkedParentVersion = 0, this.hasProjected = !1, this.isVisible = !0, this.animationProgress = 0, this.sharedNodes = /* @__PURE__ */ new Map(), this.latestValues = s, this.root = o ? o.root || o : this, this.path = o ? [...o.path, o] : [], this.parent = o, this.depth = o ? o.depth + 1 : 0;
244
- for (let a = 0; a < this.path.length; a++)
245
- this.path[a].shouldResetTransform = !0;
246
- this.root === this && (this.nodes = new Je());
247
- }
248
- addEventListener(s, o) {
249
- return this.eventHandlers.has(s) || this.eventHandlers.set(s, new ce()), this.eventHandlers.get(s).add(o);
250
- }
251
- notifyListeners(s, ...o) {
252
- const a = this.eventHandlers.get(s);
253
- a && a.notify(...o);
254
- }
255
- hasListeners(s) {
256
- return this.eventHandlers.has(s);
257
- }
258
- /**
259
- * Lifecycles
260
- */
261
- mount(s) {
262
- if (this.instance)
263
- return;
264
- this.isSVG = Xt(s) && !ke(s), this.instance = s;
265
- const { layoutId: o, layout: a, visualElement: l } = this.options;
266
- if (l && !l.current && l.mount(s), this.root.nodes.add(this), this.parent && this.parent.children.add(this), this.root.hasTreeAnimated && (a || o) && (this.isLayoutDirty = !0), t) {
267
- let h, u = 0;
268
- const d = () => this.root.updateBlockedByResize = !1;
269
- S.read(() => {
270
- u = window.innerWidth;
271
- }), t(s, () => {
272
- const m = window.innerWidth;
273
- m !== u && (u = m, this.root.updateBlockedByResize = !0, h && h(), h = Qe(d, 250), N.hasAnimatedSinceResize && (N.hasAnimatedSinceResize = !1, this.nodes.forEach(St)));
274
- });
275
- }
276
- o && this.root.registerSharedNode(o, this), this.options.animate !== !1 && l && (o || a) && this.addEventListener("didUpdate", ({ delta: h, hasLayoutChanged: u, hasRelativeLayoutChanged: d, layout: m }) => {
277
- if (this.isTreeAnimationBlocked()) {
278
- this.target = void 0, this.relativeTarget = void 0;
279
- return;
280
- }
281
- const f = this.options.transition || l.getDefaultTransition() || ps, { onLayoutAnimationStart: x, onLayoutAnimationComplete: p } = l.getProps(), g = !this.targetLayout || !_t(this.targetLayout, m), y = !u && d;
282
- if (this.options.layoutRoot || this.resumeFrom || y || u && (g || !this.currentAnimation)) {
283
- this.resumeFrom && (this.resumingFrom = this.resumeFrom, this.resumingFrom.resumingFrom = void 0);
284
- const v = {
285
- ...ye(f, "layout"),
286
- onPlay: x,
287
- onComplete: p
288
- };
289
- (l.shouldReduceMotion || this.options.layoutRoot) && (v.delay = 0, v.type = !1), this.startAnimation(v), this.setAnimationOrigin(h, y);
290
- } else
291
- u || St(this), this.isLead() && this.options.onExitComplete && this.options.onExitComplete();
292
- this.targetLayout = m;
293
- });
294
- }
295
- unmount() {
296
- this.options.layoutId && this.willUpdate(), this.root.nodes.remove(this);
297
- const s = this.getStack();
298
- s && s.remove(this), this.parent && this.parent.children.delete(this), this.instance = void 0, this.eventHandlers.clear(), b(this.updateProjection);
299
- }
300
- // only on the root
301
- blockUpdate() {
302
- this.updateManuallyBlocked = !0;
303
- }
304
- unblockUpdate() {
305
- this.updateManuallyBlocked = !1;
306
- }
307
- isUpdateBlocked() {
308
- return this.updateManuallyBlocked || this.updateBlockedByResize;
309
- }
310
- isTreeAnimationBlocked() {
311
- return this.isAnimationBlocked || this.parent && this.parent.isTreeAnimationBlocked() || !1;
312
- }
313
- // Note: currently only running on root node
314
- startUpdate() {
315
- this.isUpdateBlocked() || (this.isUpdating = !0, this.nodes && this.nodes.forEach(us), this.animationId++);
316
- }
317
- getTransformTemplate() {
318
- const { visualElement: s } = this.options;
319
- return s && s.getProps().transformTemplate;
320
- }
321
- willUpdate(s = !0) {
322
- if (this.root.hasTreeAnimated = !0, this.root.isUpdateBlocked()) {
323
- this.options.onExitComplete && this.options.onExitComplete();
324
- return;
325
- }
326
- if (window.MotionCancelOptimisedAnimation && !this.hasCheckedOptimisedAppear && Qt(this), !this.root.isUpdating && this.root.startUpdate(), this.isLayoutDirty)
327
- return;
328
- this.isLayoutDirty = !0;
329
- for (let h = 0; h < this.path.length; h++) {
330
- const u = this.path[h];
331
- u.shouldResetTransform = !0, u.updateScroll("snapshot"), u.options.layoutRoot && u.willUpdate(!1);
332
- }
333
- const { layoutId: o, layout: a } = this.options;
334
- if (o === void 0 && !a)
335
- return;
336
- const l = this.getTransformTemplate();
337
- this.prevTransformTemplateValue = l ? l(this.latestValues, "") : void 0, this.updateSnapshot(), s && this.notifyListeners("willUpdate");
338
- }
339
- update() {
340
- if (this.updateScheduled = !1, this.isUpdateBlocked()) {
341
- this.unblockUpdate(), this.clearAllSnapshots(), this.nodes.forEach(Tt);
342
- return;
343
- }
344
- if (this.animationId <= this.animationCommitId) {
345
- this.nodes.forEach(Dt);
346
- return;
347
- }
348
- this.animationCommitId = this.animationId, this.isUpdating ? (this.isUpdating = !1, this.nodes.forEach(ls), this.nodes.forEach(is), this.nodes.forEach(ns)) : this.nodes.forEach(Dt), this.clearAllSnapshots();
349
- const o = Nt.now();
350
- E.delta = Wt(0, 1e3 / 60, o - E.timestamp), E.timestamp = o, E.isProcessing = !0, z.update.process(E), z.preRender.process(E), z.render.process(E), E.isProcessing = !1;
351
- }
352
- didUpdate() {
353
- this.updateScheduled || (this.updateScheduled = !0, Gt.read(this.scheduleUpdate));
354
- }
355
- clearAllSnapshots() {
356
- this.nodes.forEach(rs), this.sharedNodes.forEach(ds);
357
- }
358
- scheduleUpdateProjection() {
359
- this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0, S.preRender(this.updateProjection, !1, !0));
360
- }
361
- scheduleCheckAfterUnmount() {
362
- S.postRender(() => {
363
- this.isLayoutDirty ? this.root.didUpdate() : this.root.checkUpdateFailed();
364
- });
365
- }
366
- /**
367
- * Update measurements
368
- */
369
- updateSnapshot() {
370
- this.snapshot || !this.instance || (this.snapshot = this.measure(), this.snapshot && !D(this.snapshot.measuredBox.x) && !D(this.snapshot.measuredBox.y) && (this.snapshot = void 0));
371
- }
372
- updateLayout() {
373
- if (!this.instance || (this.updateScroll(), !(this.options.alwaysMeasureLayout && this.isLead()) && !this.isLayoutDirty))
374
- return;
375
- if (this.resumeFrom && !this.resumeFrom.instance)
376
- for (let a = 0; a < this.path.length; a++)
377
- this.path[a].updateScroll();
378
- const s = this.layout;
379
- this.layout = this.measure(!1), this.layoutVersion++, this.layoutCorrected = P(), this.isLayoutDirty = !1, this.projectionDelta = void 0, this.notifyListeners("measure", this.layout.layoutBox);
380
- const { visualElement: o } = this.options;
381
- o && o.notify("LayoutMeasure", this.layout.layoutBox, s ? s.layoutBox : void 0);
382
- }
383
- updateScroll(s = "measure") {
384
- let o = !!(this.options.layoutScroll && this.instance);
385
- if (this.scroll && this.scroll.animationId === this.root.animationId && this.scroll.phase === s && (o = !1), o && this.instance) {
386
- const a = n(this.instance);
387
- this.scroll = {
388
- animationId: this.root.animationId,
389
- phase: s,
390
- isRoot: a,
391
- offset: i(this.instance),
392
- wasRoot: this.scroll ? this.scroll.isRoot : a
393
- };
394
- }
395
- }
396
- resetTransform() {
397
- if (!r)
398
- return;
399
- const s = this.isLayoutDirty || this.shouldResetTransform || this.options.alwaysMeasureLayout, o = this.projectionDelta && !qt(this.projectionDelta), a = this.getTransformTemplate(), l = a ? a(this.latestValues, "") : void 0, h = l !== this.prevTransformTemplateValue;
400
- s && this.instance && (o || w(this.latestValues) || h) && (r(this.instance, l), this.shouldResetTransform = !1, this.scheduleRender());
401
- }
402
- measure(s = !0) {
403
- const o = this.measurePageBox();
404
- let a = this.removeElementScroll(o);
405
- return s && (a = this.removeTransform(a)), gs(a), {
406
- animationId: this.root.animationId,
407
- measuredBox: o,
408
- layoutBox: a,
409
- latestValues: {},
410
- source: this.id
411
- };
412
- }
413
- measurePageBox() {
414
- const { visualElement: s } = this.options;
415
- if (!s)
416
- return P();
417
- const o = s.measureViewportBox();
418
- if (!(this.scroll?.wasRoot || this.path.some(ys))) {
419
- const { scroll: l } = this.root;
420
- l && (O(o.x, l.offset.x), O(o.y, l.offset.y));
421
- }
422
- return o;
423
- }
424
- removeElementScroll(s) {
425
- const o = P();
426
- if (A(o, s), this.scroll?.wasRoot)
427
- return o;
428
- for (let a = 0; a < this.path.length; a++) {
429
- const l = this.path[a], { scroll: h, options: u } = l;
430
- l !== this.root && h && u.layoutScroll && (h.wasRoot && A(o, s), O(o.x, h.offset.x), O(o.y, h.offset.y));
431
- }
432
- return o;
433
- }
434
- applyTransform(s, o = !1) {
435
- const a = P();
436
- A(a, s);
437
- for (let l = 0; l < this.path.length; l++) {
438
- const h = this.path[l];
439
- !o && h.options.layoutScroll && h.scroll && h !== h.root && U(a, {
440
- x: -h.scroll.offset.x,
441
- y: -h.scroll.offset.y
442
- }), w(h.latestValues) && U(a, h.latestValues);
443
- }
444
- return w(this.latestValues) && U(a, this.latestValues), a;
445
- }
446
- removeTransform(s) {
447
- const o = P();
448
- A(o, s);
449
- for (let a = 0; a < this.path.length; a++) {
450
- const l = this.path[a];
451
- if (!l.instance || !w(l.latestValues))
452
- continue;
453
- st(l.latestValues) && l.updateSnapshot();
454
- const h = P(), u = l.measurePageBox();
455
- A(h, u), dt(o, l.latestValues, l.snapshot ? l.snapshot.layoutBox : void 0, h);
456
- }
457
- return w(this.latestValues) && dt(o, this.latestValues), o;
458
- }
459
- setTargetDelta(s) {
460
- this.targetDelta = s, this.root.scheduleUpdateProjection(), this.isProjectionDirty = !0;
461
- }
462
- setOptions(s) {
463
- this.options = {
464
- ...this.options,
465
- ...s,
466
- crossfade: s.crossfade !== void 0 ? s.crossfade : !0
467
- };
468
- }
469
- clearMeasurements() {
470
- this.scroll = void 0, this.layout = void 0, this.snapshot = void 0, this.prevTransformTemplateValue = void 0, this.targetDelta = void 0, this.target = void 0, this.isLayoutDirty = !1;
471
- }
472
- forceRelativeParentToResolveTarget() {
473
- this.relativeParent && this.relativeParent.resolvedRelativeTargetAt !== E.timestamp && this.relativeParent.resolveTargetDelta(!0);
474
- }
475
- resolveTargetDelta(s = !1) {
476
- const o = this.getLead();
477
- this.isProjectionDirty || (this.isProjectionDirty = o.isProjectionDirty), this.isTransformDirty || (this.isTransformDirty = o.isTransformDirty), this.isSharedProjectionDirty || (this.isSharedProjectionDirty = o.isSharedProjectionDirty);
478
- const a = !!this.resumingFrom || this !== o;
479
- if (!(s || a && this.isSharedProjectionDirty || this.isProjectionDirty || this.parent?.isProjectionDirty || this.attemptToResolveRelativeTarget || this.root.updateBlockedByResize))
480
- return;
481
- const { layout: h, layoutId: u } = this.options;
482
- if (!this.layout || !(h || u))
483
- return;
484
- this.resolvedRelativeTargetAt = E.timestamp;
485
- const d = this.getClosestProjectingParent();
486
- d && this.linkedParentVersion !== d.layoutVersion && !d.options.layoutRoot && this.removeRelativeTarget(), !this.targetDelta && !this.relativeTarget && (d && d.layout ? this.createRelativeTarget(d, this.layout.layoutBox, d.layout.layoutBox) : this.removeRelativeTarget()), !(!this.relativeTarget && !this.targetDelta) && (this.target || (this.target = P(), this.targetWithTransforms = P()), this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target ? (this.forceRelativeParentToResolveTarget(), Ne(this.target, this.relativeTarget, this.relativeParent.target)) : this.targetDelta ? (this.resumingFrom ? this.target = this.applyTransform(this.layout.layoutBox) : A(this.target, this.layout.layoutBox), ve(this.target, this.targetDelta)) : A(this.target, this.layout.layoutBox), this.attemptToResolveRelativeTarget && (this.attemptToResolveRelativeTarget = !1, d && !!d.resumingFrom == !!this.resumingFrom && !d.options.layoutScroll && d.target && this.animationProgress !== 1 ? this.createRelativeTarget(d, this.target, d.target) : this.relativeParent = this.relativeTarget = void 0));
487
- }
488
- getClosestProjectingParent() {
489
- if (!(!this.parent || st(this.parent.latestValues) || xe(this.parent.latestValues)))
490
- return this.parent.isProjecting() ? this.parent : this.parent.getClosestProjectingParent();
491
- }
492
- isProjecting() {
493
- return !!((this.relativeTarget || this.targetDelta || this.options.layoutRoot) && this.layout);
494
- }
495
- createRelativeTarget(s, o, a) {
496
- this.relativeParent = s, this.linkedParentVersion = s.layoutVersion, this.forceRelativeParentToResolveTarget(), this.relativeTarget = P(), this.relativeTargetOrigin = P(), G(this.relativeTargetOrigin, o, a), A(this.relativeTarget, this.relativeTargetOrigin);
497
- }
498
- removeRelativeTarget() {
499
- this.relativeParent = this.relativeTarget = void 0;
500
- }
501
- calcProjection() {
502
- const s = this.getLead(), o = !!this.resumingFrom || this !== s;
503
- let a = !0;
504
- if ((this.isProjectionDirty || this.parent?.isProjectionDirty) && (a = !1), o && (this.isSharedProjectionDirty || this.isTransformDirty) && (a = !1), this.resolvedRelativeTargetAt === E.timestamp && (a = !1), a)
505
- return;
506
- const { layout: l, layoutId: h } = this.options;
507
- if (this.isTreeAnimating = !!(this.parent && this.parent.isTreeAnimating || this.currentAnimation || this.pendingAnimation), this.isTreeAnimating || (this.targetDelta = this.relativeTarget = void 0), !this.layout || !(l || h))
508
- return;
509
- A(this.layoutCorrected, this.layout.layoutBox);
510
- const u = this.treeScale.x, d = this.treeScale.y;
511
- Pe(this.layoutCorrected, this.treeScale, this.path, o), s.layout && !s.target && (this.treeScale.x !== 1 || this.treeScale.y !== 1) && (s.target = s.layout.layoutBox, s.targetWithTransforms = P());
512
- const { target: m } = s;
513
- if (!m) {
514
- this.prevProjectionDelta && (this.createProjectionDeltas(), this.scheduleRender());
515
- return;
516
- }
517
- !this.projectionDelta || !this.prevProjectionDelta ? this.createProjectionDeltas() : (at(this.prevProjectionDelta.x, this.projectionDelta.x), at(this.prevProjectionDelta.y, this.projectionDelta.y)), j(this.projectionDelta, this.layoutCorrected, m, this.latestValues), (this.treeScale.x !== u || this.treeScale.y !== d || !yt(this.projectionDelta.x, this.prevProjectionDelta.x) || !yt(this.projectionDelta.y, this.prevProjectionDelta.y)) && (this.hasProjected = !0, this.scheduleRender(), this.notifyListeners("projectionUpdate", m));
518
- }
519
- hide() {
520
- this.isVisible = !1;
521
- }
522
- show() {
523
- this.isVisible = !0;
524
- }
525
- scheduleRender(s = !0) {
526
- if (this.options.visualElement?.scheduleRender(), s) {
527
- const o = this.getStack();
528
- o && o.scheduleRender();
529
- }
530
- this.resumingFrom && !this.resumingFrom.instance && (this.resumingFrom = void 0);
531
- }
532
- createProjectionDeltas() {
533
- this.prevProjectionDelta = M(), this.projectionDelta = M(), this.projectionDeltaWithTransform = M();
534
- }
535
- setAnimationOrigin(s, o = !1) {
536
- const a = this.snapshot, l = a ? a.latestValues : {}, h = { ...this.latestValues }, u = M();
537
- (!this.relativeParent || !this.relativeParent.options.layoutRoot) && (this.relativeTarget = this.relativeTargetOrigin = void 0), this.attemptToResolveRelativeTarget = !o;
538
- const d = P(), m = a ? a.source : void 0, f = this.layout ? this.layout.source : void 0, x = m !== f, p = this.getStack(), g = !p || p.members.length <= 1, y = !!(x && !g && this.options.crossfade === !0 && !this.path.some(fs));
539
- this.animationProgress = 0;
540
- let v;
541
- this.mixTargetDelta = (R) => {
542
- const C = R / 1e3;
543
- Et(u.x, s.x, C), Et(u.y, s.y, C), this.setTargetDelta(u), this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout && (G(d, this.layout.layoutBox, this.relativeParent.layout.layoutBox), ms(this.relativeTarget, this.relativeTargetOrigin, d, C), v && He(this.relativeTarget, v) && (this.isProjectionDirty = !1), v || (v = P()), A(v, this.relativeTarget)), x && (this.animationValues = h, Ye(h, l, this.latestValues, C, y, g)), this.root.scheduleUpdateProjection(), this.scheduleRender(), this.animationProgress = C;
544
- }, this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0);
545
- }
546
- startAnimation(s) {
547
- this.notifyListeners("animationStart"), this.currentAnimation?.stop(), this.resumingFrom?.currentAnimation?.stop(), this.pendingAnimation && (b(this.pendingAnimation), this.pendingAnimation = void 0), this.pendingAnimation = S.update(() => {
548
- N.hasAnimatedSinceResize = !0, this.motionValue || (this.motionValue = Ot(0)), this.currentAnimation = _e(this.motionValue, [0, 1e3], {
549
- ...s,
550
- velocity: 0,
551
- isSync: !0,
552
- onUpdate: (o) => {
553
- this.mixTargetDelta(o), s.onUpdate && s.onUpdate(o);
554
- },
555
- onStop: () => {
556
- },
557
- onComplete: () => {
558
- s.onComplete && s.onComplete(), this.completeAnimation();
559
- }
560
- }), this.resumingFrom && (this.resumingFrom.currentAnimation = this.currentAnimation), this.pendingAnimation = void 0;
561
- });
562
- }
563
- completeAnimation() {
564
- this.resumingFrom && (this.resumingFrom.currentAnimation = void 0, this.resumingFrom.preserveOpacity = void 0);
565
- const s = this.getStack();
566
- s && s.exitAnimationComplete(), this.resumingFrom = this.currentAnimation = this.animationValues = void 0, this.notifyListeners("animationComplete");
567
- }
568
- finishAnimation() {
569
- this.currentAnimation && (this.mixTargetDelta && this.mixTargetDelta(es), this.currentAnimation.stop()), this.completeAnimation();
570
- }
571
- applyTransformsToTarget() {
572
- const s = this.getLead();
573
- let { targetWithTransforms: o, target: a, layout: l, latestValues: h } = s;
574
- if (!(!o || !a || !l)) {
575
- if (this !== s && this.layout && l && ee(this.options.animationType, this.layout.layoutBox, l.layoutBox)) {
576
- a = this.target || P();
577
- const u = D(this.layout.layoutBox.x);
578
- a.x.min = s.target.x.min, a.x.max = a.x.min + u;
579
- const d = D(this.layout.layoutBox.y);
580
- a.y.min = s.target.y.min, a.y.max = a.y.min + d;
581
- }
582
- A(o, a), U(o, h), j(this.projectionDeltaWithTransform, this.layoutCorrected, o, h);
583
- }
584
- }
585
- registerSharedNode(s, o) {
586
- this.sharedNodes.has(s) || this.sharedNodes.set(s, new ts()), this.sharedNodes.get(s).add(o);
587
- const l = o.options.initialPromotionConfig;
588
- o.promote({
589
- transition: l ? l.transition : void 0,
590
- preserveFollowOpacity: l && l.shouldPreserveFollowOpacity ? l.shouldPreserveFollowOpacity(o) : void 0
591
- });
592
- }
593
- isLead() {
594
- const s = this.getStack();
595
- return s ? s.lead === this : !0;
596
- }
597
- getLead() {
598
- const { layoutId: s } = this.options;
599
- return s ? this.getStack()?.lead || this : this;
600
- }
601
- getPrevLead() {
602
- const { layoutId: s } = this.options;
603
- return s ? this.getStack()?.prevLead : void 0;
604
- }
605
- getStack() {
606
- const { layoutId: s } = this.options;
607
- if (s)
608
- return this.root.sharedNodes.get(s);
609
- }
610
- promote({ needsReset: s, transition: o, preserveFollowOpacity: a } = {}) {
611
- const l = this.getStack();
612
- l && l.promote(this, a), s && (this.projectionDelta = void 0, this.needsReset = !0), o && this.setOptions({ transition: o });
613
- }
614
- relegate() {
615
- const s = this.getStack();
616
- return s ? s.relegate(this) : !1;
617
- }
618
- resetSkewAndRotation() {
619
- const { visualElement: s } = this.options;
620
- if (!s)
621
- return;
622
- let o = !1;
623
- const { latestValues: a } = s;
624
- if ((a.z || a.rotate || a.rotateX || a.rotateY || a.rotateZ || a.skewX || a.skewY) && (o = !0), !o)
625
- return;
626
- const l = {};
627
- a.z && X("z", s, l, this.animationValues);
628
- for (let h = 0; h < $.length; h++)
629
- X(`rotate${$[h]}`, s, l, this.animationValues), X(`skew${$[h]}`, s, l, this.animationValues);
630
- s.render();
631
- for (const h in l)
632
- s.setStaticValue(h, l[h]), this.animationValues && (this.animationValues[h] = l[h]);
633
- s.scheduleRender();
634
- }
635
- applyProjectionStyles(s, o) {
636
- if (!this.instance || this.isSVG)
637
- return;
638
- if (!this.isVisible) {
639
- s.visibility = "hidden";
640
- return;
641
- }
642
- const a = this.getTransformTemplate();
643
- if (this.needsReset) {
644
- this.needsReset = !1, s.visibility = "", s.opacity = "", s.pointerEvents = H(o?.pointerEvents) || "", s.transform = a ? a(this.latestValues, "") : "none";
645
- return;
646
- }
647
- const l = this.getLead();
648
- if (!this.projectionDelta || !this.layout || !l.target) {
649
- this.options.layoutId && (s.opacity = this.latestValues.opacity !== void 0 ? this.latestValues.opacity : 1, s.pointerEvents = H(o?.pointerEvents) || ""), this.hasProjected && !w(this.latestValues) && (s.transform = a ? a({}, "") : "none", this.hasProjected = !1);
650
- return;
651
- }
652
- s.visibility = "";
653
- const h = l.animationValues || l.latestValues;
654
- this.applyTransformsToTarget();
655
- let u = $e(this.projectionDeltaWithTransform, this.treeScale, h);
656
- a && (u = a(h, u)), s.transform = u;
657
- const { x: d, y: m } = this.projectionDelta;
658
- s.transformOrigin = `${d.origin * 100}% ${m.origin * 100}% 0`, l.animationValues ? s.opacity = l === this ? h.opacity ?? this.latestValues.opacity ?? 1 : this.preserveOpacity ? this.latestValues.opacity : h.opacityExit : s.opacity = l === this ? h.opacity !== void 0 ? h.opacity : "" : h.opacityExit !== void 0 ? h.opacityExit : 0;
659
- for (const f in tt) {
660
- if (h[f] === void 0)
661
- continue;
662
- const { correct: x, applyTo: p, isCSSVariable: g } = tt[f], y = u === "none" ? h[f] : x(h[f], l);
663
- if (p) {
664
- const v = p.length;
665
- for (let R = 0; R < v; R++)
666
- s[p[R]] = y;
667
- } else
668
- g ? this.options.visualElement.renderState.vars[f] = y : s[f] = y;
669
- }
670
- this.options.layoutId && (s.pointerEvents = l === this ? H(o?.pointerEvents) || "" : "none");
671
- }
672
- clearSnapshot() {
673
- this.resumeFrom = this.snapshot = void 0;
674
- }
675
- // Only run on root
676
- resetTree() {
677
- this.root.nodes.forEach((s) => s.currentAnimation?.stop()), this.root.nodes.forEach(Tt), this.root.sharedNodes.clear();
678
- }
679
- };
680
- }
681
- function is(t) {
682
- t.updateLayout();
683
- }
684
- function ns(t) {
685
- const e = t.resumeFrom?.snapshot || t.snapshot;
686
- if (t.isLead() && t.layout && e && t.hasListeners("didUpdate")) {
687
- const { layoutBox: i, measuredBox: n } = t.layout, { animationType: r } = t.options, c = e.source !== t.layout.source;
688
- r === "size" ? V((h) => {
689
- const u = c ? e.measuredBox[h] : e.layoutBox[h], d = D(u);
690
- u.min = i[h].min, u.max = u.min + d;
691
- }) : ee(r, e.layoutBox, i) && V((h) => {
692
- const u = c ? e.measuredBox[h] : e.layoutBox[h], d = D(i[h]);
693
- u.max = u.min + d, t.relativeTarget && !t.currentAnimation && (t.isProjectionDirty = !0, t.relativeTarget[h].max = t.relativeTarget[h].min + d);
694
- });
695
- const s = M();
696
- j(s, i, e.layoutBox);
697
- const o = M();
698
- c ? j(o, t.applyTransform(n, !0), e.measuredBox) : j(o, i, e.layoutBox);
699
- const a = !qt(s);
700
- let l = !1;
701
- if (!t.resumeFrom) {
702
- const h = t.getClosestProjectingParent();
703
- if (h && !h.resumeFrom) {
704
- const { snapshot: u, layout: d } = h;
705
- if (u && d) {
706
- const m = P();
707
- G(m, e.layoutBox, u.layoutBox);
708
- const f = P();
709
- G(f, i, d.layoutBox), _t(m, f) || (l = !0), h.options.layoutRoot && (t.relativeTarget = f, t.relativeTargetOrigin = m, t.relativeParent = h);
710
- }
711
- }
712
- }
713
- t.notifyListeners("didUpdate", {
714
- layout: i,
715
- snapshot: e,
716
- delta: o,
717
- layoutDelta: s,
718
- hasLayoutChanged: a,
719
- hasRelativeLayoutChanged: l
720
- });
721
- } else if (t.isLead()) {
722
- const { onExitComplete: i } = t.options;
723
- i && i();
724
- }
725
- t.options.transition = void 0;
726
- }
727
- function os(t) {
728
- t.parent && (t.isProjecting() || (t.isProjectionDirty = t.parent.isProjectionDirty), t.isSharedProjectionDirty || (t.isSharedProjectionDirty = !!(t.isProjectionDirty || t.parent.isProjectionDirty || t.parent.isSharedProjectionDirty)), t.isTransformDirty || (t.isTransformDirty = t.parent.isTransformDirty));
729
- }
730
- function as(t) {
731
- t.isProjectionDirty = t.isSharedProjectionDirty = t.isTransformDirty = !1;
732
- }
733
- function rs(t) {
734
- t.clearSnapshot();
735
- }
736
- function Tt(t) {
737
- t.clearMeasurements();
738
- }
739
- function Dt(t) {
740
- t.isLayoutDirty = !1;
741
- }
742
- function ls(t) {
743
- const { visualElement: e } = t.options;
744
- e && e.getProps().onBeforeLayoutMeasure && e.notify("BeforeLayoutMeasure"), t.resetTransform();
745
- }
746
- function St(t) {
747
- t.finishAnimation(), t.targetDelta = t.relativeTarget = t.target = void 0, t.isProjectionDirty = !0;
748
- }
749
- function hs(t) {
750
- t.resolveTargetDelta();
751
- }
752
- function cs(t) {
753
- t.calcProjection();
754
- }
755
- function us(t) {
756
- t.resetSkewAndRotation();
757
- }
758
- function ds(t) {
759
- t.removeLeadSnapshot();
760
- }
761
- function Et(t, e, i) {
762
- t.translate = T(e.translate, 0, i), t.scale = T(e.scale, 1, i), t.origin = e.origin, t.originPoint = e.originPoint;
763
- }
764
- function Vt(t, e, i, n) {
765
- t.min = T(e.min, i.min, n), t.max = T(e.max, i.max, n);
766
- }
767
- function ms(t, e, i, n) {
768
- Vt(t.x, e.x, i.x, n), Vt(t.y, e.y, i.y, n);
769
- }
770
- function fs(t) {
771
- return t.animationValues && t.animationValues.opacityExit !== void 0;
772
- }
773
- const ps = {
774
- duration: 0.45,
775
- ease: [0.4, 0, 0.1, 1]
776
- }, At = (t) => typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().includes(t), Lt = At("applewebkit/") && !At("chrome/") ? Math.round : B;
777
- function Rt(t) {
778
- t.min = Lt(t.min), t.max = Lt(t.max);
779
- }
780
- function gs(t) {
781
- Rt(t.x), Rt(t.y);
782
- }
783
- function ee(t, e, i) {
784
- return t === "position" || t === "preserve-aspect" && !Fe(gt(e), gt(i), 0.2);
785
- }
786
- function ys(t) {
787
- return t !== t.root && t.scroll?.wasRoot;
788
- }
789
- const vs = te({
790
- attachResizeListener: (t, e) => Q(t, "resize", e),
791
- measureScroll: () => ({
792
- x: document.documentElement.scrollLeft || document.body?.scrollLeft || 0,
793
- y: document.documentElement.scrollTop || document.body?.scrollTop || 0
794
- }),
795
- checkIsScrollRoot: () => !0
796
- }), Y = {
797
- current: void 0
798
- }, se = te({
799
- measureScroll: (t) => ({
800
- x: t.scrollLeft,
801
- y: t.scrollTop
802
- }),
803
- defaultParent: () => {
804
- if (!Y.current) {
805
- const t = new vs({});
806
- t.mount(window), t.setOptions({ layoutScroll: !0 }), Y.current = t;
807
- }
808
- return Y.current;
809
- },
810
- resetTransform: (t, e) => {
811
- t.style.transform = e !== void 0 ? e : "none";
812
- },
813
- checkIsScrollRoot: (t) => window.getComputedStyle(t).position === "fixed"
814
- });
815
- function k(t, e, i, n) {
816
- return Q(t, e, De(i), n);
817
- }
818
- const ie = ({ current: t }) => t ? t.ownerDocument.defaultView : null, Ct = (t, e) => Math.abs(t - e);
819
- function xs(t, e) {
820
- const i = Ct(t.x, e.x), n = Ct(t.y, e.y);
821
- return Math.sqrt(i ** 2 + n ** 2);
822
- }
823
- const wt = /* @__PURE__ */ new Set(["auto", "scroll"]);
824
- class ne {
825
- constructor(e, i, { transformPagePoint: n, contextWindow: r = window, dragSnapToOrigin: c = !1, distanceThreshold: s = 3, element: o } = {}) {
826
- if (this.startEvent = null, this.lastMoveEvent = null, this.lastMoveEventInfo = null, this.handlers = {}, this.contextWindow = window, this.scrollPositions = /* @__PURE__ */ new Map(), this.removeScrollListeners = null, this.onElementScroll = (m) => {
827
- this.handleScroll(m.target);
828
- }, this.onWindowScroll = () => {
829
- this.handleScroll(window);
830
- }, this.updatePoint = () => {
831
- if (!(this.lastMoveEvent && this.lastMoveEventInfo))
832
- return;
833
- const m = q(this.lastMoveEventInfo, this.history), f = this.startEvent !== null, x = xs(m.offset, { x: 0, y: 0 }) >= this.distanceThreshold;
834
- if (!f && !x)
835
- return;
836
- const { point: p } = m, { timestamp: g } = E;
837
- this.history.push({ ...p, timestamp: g });
838
- const { onStart: y, onMove: v } = this.handlers;
839
- f || (y && y(this.lastMoveEvent, m), this.startEvent = this.lastMoveEvent), v && v(this.lastMoveEvent, m);
840
- }, this.handlePointerMove = (m, f) => {
841
- this.lastMoveEvent = m, this.lastMoveEventInfo = K(f, this.transformPagePoint), S.update(this.updatePoint, !0);
842
- }, this.handlePointerUp = (m, f) => {
843
- this.end();
844
- const { onEnd: x, onSessionEnd: p, resumeAnimation: g } = this.handlers;
845
- if ((this.dragSnapToOrigin || !this.startEvent) && g && g(), !(this.lastMoveEvent && this.lastMoveEventInfo))
846
- return;
847
- const y = q(m.type === "pointercancel" ? this.lastMoveEventInfo : K(f, this.transformPagePoint), this.history);
848
- this.startEvent && x && x(m, y), p && p(m, y);
849
- }, !Se(e))
850
- return;
851
- this.dragSnapToOrigin = c, this.handlers = i, this.transformPagePoint = n, this.distanceThreshold = s, this.contextWindow = r || window;
852
- const a = Ht(e), l = K(a, this.transformPagePoint), { point: h } = l, { timestamp: u } = E;
853
- this.history = [{ ...h, timestamp: u }];
854
- const { onSessionStart: d } = i;
855
- d && d(e, q(l, this.history)), this.removeListeners = Ee(k(this.contextWindow, "pointermove", this.handlePointerMove), k(this.contextWindow, "pointerup", this.handlePointerUp), k(this.contextWindow, "pointercancel", this.handlePointerUp)), o && this.startScrollTracking(o);
856
- }
857
- /**
858
- * Start tracking scroll on ancestors and window.
859
- */
860
- startScrollTracking(e) {
861
- let i = e.parentElement;
862
- for (; i; ) {
863
- const n = getComputedStyle(i);
864
- (wt.has(n.overflowX) || wt.has(n.overflowY)) && this.scrollPositions.set(i, {
865
- x: i.scrollLeft,
866
- y: i.scrollTop
867
- }), i = i.parentElement;
868
- }
869
- this.scrollPositions.set(window, {
870
- x: window.scrollX,
871
- y: window.scrollY
872
- }), window.addEventListener("scroll", this.onElementScroll, {
873
- capture: !0,
874
- passive: !0
875
- }), window.addEventListener("scroll", this.onWindowScroll, {
876
- passive: !0
877
- }), this.removeScrollListeners = () => {
878
- window.removeEventListener("scroll", this.onElementScroll, {
879
- capture: !0
880
- }), window.removeEventListener("scroll", this.onWindowScroll);
881
- };
882
- }
883
- /**
884
- * Handle scroll compensation during drag.
885
- *
886
- * For element scroll: adjusts history origin since pageX/pageY doesn't change.
887
- * For window scroll: adjusts lastMoveEventInfo since pageX/pageY would change.
888
- */
889
- handleScroll(e) {
890
- const i = this.scrollPositions.get(e);
891
- if (!i)
892
- return;
893
- const n = e === window, r = n ? { x: window.scrollX, y: window.scrollY } : {
894
- x: e.scrollLeft,
895
- y: e.scrollTop
896
- }, c = { x: r.x - i.x, y: r.y - i.y };
897
- c.x === 0 && c.y === 0 || (n ? this.lastMoveEventInfo && (this.lastMoveEventInfo.point.x += c.x, this.lastMoveEventInfo.point.y += c.y) : this.history.length > 0 && (this.history[0].x -= c.x, this.history[0].y -= c.y), this.scrollPositions.set(e, r), S.update(this.updatePoint, !0));
898
- }
899
- updateHandlers(e) {
900
- this.handlers = e;
901
- }
902
- end() {
903
- this.removeListeners && this.removeListeners(), this.removeScrollListeners && this.removeScrollListeners(), this.scrollPositions.clear(), b(this.updatePoint);
904
- }
905
- }
906
- function K(t, e) {
907
- return e ? { point: e(t.point) } : t;
908
- }
909
- function Mt(t, e) {
910
- return { x: t.x - e.x, y: t.y - e.y };
911
- }
912
- function q({ point: t }, e) {
913
- return {
914
- point: t,
915
- delta: Mt(t, oe(e)),
916
- offset: Mt(t, Ps(e)),
917
- velocity: Ts(e, 0.1)
918
- };
919
- }
920
- function Ps(t) {
921
- return t[0];
922
- }
923
- function oe(t) {
924
- return t[t.length - 1];
925
- }
926
- function Ts(t, e) {
927
- if (t.length < 2)
928
- return { x: 0, y: 0 };
929
- let i = t.length - 1, n = null;
930
- const r = oe(t);
931
- for (; i >= 0 && (n = t[i], !(r.timestamp - n.timestamp > Ve(e))); )
932
- i--;
933
- if (!n)
934
- return { x: 0, y: 0 };
935
- const c = Ae(r.timestamp - n.timestamp);
936
- if (c === 0)
937
- return { x: 0, y: 0 };
938
- const s = {
939
- x: (r.x - n.x) / c,
940
- y: (r.y - n.y) / c
941
- };
942
- return s.x === 1 / 0 && (s.x = 0), s.y === 1 / 0 && (s.y = 0), s;
943
- }
944
- function Ds(t, { min: e, max: i }, n) {
945
- return e !== void 0 && t < e ? t = n ? T(e, t, n.min) : Math.max(t, e) : i !== void 0 && t > i && (t = n ? T(i, t, n.max) : Math.min(t, i)), t;
946
- }
947
- function Bt(t, e, i) {
948
- return {
949
- min: e !== void 0 ? t.min + e : void 0,
950
- max: i !== void 0 ? t.max + i - (t.max - t.min) : void 0
951
- };
952
- }
953
- function Ss(t, { top: e, left: i, bottom: n, right: r }) {
954
- return {
955
- x: Bt(t.x, i, r),
956
- y: Bt(t.y, e, n)
957
- };
958
- }
959
- function jt(t, e) {
960
- let i = e.min - t.min, n = e.max - t.max;
961
- return e.max - e.min < t.max - t.min && ([i, n] = [n, i]), { min: i, max: n };
962
- }
963
- function Es(t, e) {
964
- return {
965
- x: jt(t.x, e.x),
966
- y: jt(t.y, e.y)
967
- };
968
- }
969
- function Vs(t, e) {
970
- let i = 0.5;
971
- const n = D(t), r = D(e);
972
- return r > n ? i = Z(e.min, e.max - n, t.min) : n > r && (i = Z(t.min, t.max - r, e.min)), Wt(0, 1, i);
973
- }
974
- function As(t, e) {
975
- const i = {};
976
- return e.min !== void 0 && (i.min = e.min - t.min), e.max !== void 0 && (i.max = e.max - t.min), i;
977
- }
978
- const J = 0.35;
979
- function Ls(t = J) {
980
- return t === !1 ? t = 0 : t === !0 && (t = J), {
981
- x: kt(t, "left", "right"),
982
- y: kt(t, "top", "bottom")
983
- };
984
- }
985
- function kt(t, e, i) {
986
- return {
987
- min: bt(t, e),
988
- max: bt(t, i)
989
- };
990
- }
991
- function bt(t, e) {
992
- return typeof t == "number" ? t : t[e] || 0;
993
- }
994
- const Rs = /* @__PURE__ */ new WeakMap();
995
- class Cs {
996
- constructor(e) {
997
- this.openDragLock = null, this.isDragging = !1, this.currentDirection = null, this.originPoint = { x: 0, y: 0 }, this.constraints = !1, this.hasMutatedConstraints = !1, this.elastic = P(), this.latestPointerEvent = null, this.latestPanInfo = null, this.visualElement = e;
998
- }
999
- start(e, { snapToCursor: i = !1, distanceThreshold: n } = {}) {
1000
- const { presenceContext: r } = this.visualElement;
1001
- if (r && r.isPresent === !1)
1002
- return;
1003
- const c = (u) => {
1004
- i ? (this.stopAnimation(), this.snapToCursor(Ht(u).point)) : this.pauseAnimation();
1005
- }, s = (u, d) => {
1006
- this.stopAnimation();
1007
- const { drag: m, dragPropagation: f, onDragStart: x } = this.getProps();
1008
- if (m && !f && (this.openDragLock && this.openDragLock(), this.openDragLock = je(m), !this.openDragLock))
1009
- return;
1010
- this.latestPointerEvent = u, this.latestPanInfo = d, this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), V((g) => {
1011
- let y = this.getAxisMotionValue(g).get() || 0;
1012
- if (W.test(y)) {
1013
- const { projection: v } = this.visualElement;
1014
- if (v && v.layout) {
1015
- const R = v.layout.layoutBox[g];
1016
- R && (y = D(R) * (parseFloat(y) / 100));
1017
- }
1018
- }
1019
- this.originPoint[g] = y;
1020
- }), x && S.postRender(() => x(u, d)), it(this.visualElement, "transform");
1021
- const { animationState: p } = this.visualElement;
1022
- p && p.setActive("whileDrag", !0);
1023
- }, o = (u, d) => {
1024
- this.latestPointerEvent = u, this.latestPanInfo = d;
1025
- const { dragPropagation: m, dragDirectionLock: f, onDirectionLock: x, onDrag: p } = this.getProps();
1026
- if (!m && !this.openDragLock)
1027
- return;
1028
- const { offset: g } = d;
1029
- if (f && this.currentDirection === null) {
1030
- this.currentDirection = ws(g), this.currentDirection !== null && x && x(this.currentDirection);
1031
- return;
1032
- }
1033
- this.updateAxis("x", d.point, g), this.updateAxis("y", d.point, g), this.visualElement.render(), p && p(u, d);
1034
- }, a = (u, d) => {
1035
- this.latestPointerEvent = u, this.latestPanInfo = d, this.stop(u, d), this.latestPointerEvent = null, this.latestPanInfo = null;
1036
- }, l = () => V((u) => this.getAnimationState(u) === "paused" && this.getAxisMotionValue(u).animation?.play()), { dragSnapToOrigin: h } = this.getProps();
1037
- this.panSession = new ne(e, {
1038
- onSessionStart: c,
1039
- onStart: s,
1040
- onMove: o,
1041
- onSessionEnd: a,
1042
- resumeAnimation: l
1043
- }, {
1044
- transformPagePoint: this.visualElement.getTransformPagePoint(),
1045
- dragSnapToOrigin: h,
1046
- distanceThreshold: n,
1047
- contextWindow: ie(this.visualElement),
1048
- element: this.visualElement.current
1049
- });
1050
- }
1051
- /**
1052
- * @internal
1053
- */
1054
- stop(e, i) {
1055
- const n = e || this.latestPointerEvent, r = i || this.latestPanInfo, c = this.isDragging;
1056
- if (this.cancel(), !c || !r || !n)
1057
- return;
1058
- const { velocity: s } = r;
1059
- this.startAnimation(s);
1060
- const { onDragEnd: o } = this.getProps();
1061
- o && S.postRender(() => o(n, r));
1062
- }
1063
- /**
1064
- * @internal
1065
- */
1066
- cancel() {
1067
- this.isDragging = !1;
1068
- const { projection: e, animationState: i } = this.visualElement;
1069
- e && (e.isAnimationBlocked = !1), this.endPanSession();
1070
- const { dragPropagation: n } = this.getProps();
1071
- !n && this.openDragLock && (this.openDragLock(), this.openDragLock = null), i && i.setActive("whileDrag", !1);
1072
- }
1073
- /**
1074
- * Clean up the pan session without modifying other drag state.
1075
- * This is used during unmount to ensure event listeners are removed
1076
- * without affecting projection animations or drag locks.
1077
- * @internal
1078
- */
1079
- endPanSession() {
1080
- this.panSession && this.panSession.end(), this.panSession = void 0;
1081
- }
1082
- updateAxis(e, i, n) {
1083
- const { drag: r } = this.getProps();
1084
- if (!n || !F(e, r, this.currentDirection))
1085
- return;
1086
- const c = this.getAxisMotionValue(e);
1087
- let s = this.originPoint[e] + n[e];
1088
- this.constraints && this.constraints[e] && (s = Ds(s, this.constraints[e], this.elastic[e])), c.set(s);
1089
- }
1090
- resolveConstraints() {
1091
- const { dragConstraints: e, dragElastic: i } = this.getProps(), n = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(!1) : this.visualElement.projection?.layout, r = this.constraints;
1092
- e && I(e) ? this.constraints || (this.constraints = this.resolveRefConstraints()) : e && n ? this.constraints = Ss(n.layoutBox, e) : this.constraints = !1, this.elastic = Ls(i), r !== this.constraints && n && this.constraints && !this.hasMutatedConstraints && V((c) => {
1093
- this.constraints !== !1 && this.getAxisMotionValue(c) && (this.constraints[c] = As(n.layoutBox[c], this.constraints[c]));
1094
- });
1095
- }
1096
- resolveRefConstraints() {
1097
- const { dragConstraints: e, onMeasureDragConstraints: i } = this.getProps();
1098
- if (!e || !I(e))
1099
- return !1;
1100
- const n = e.current;
1101
- ue(n !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.", "drag-constraints-ref");
1102
- const { projection: r } = this.visualElement;
1103
- if (!r || !r.layout)
1104
- return !1;
1105
- const c = Le(n, r.root, this.visualElement.getTransformPagePoint());
1106
- let s = Es(r.layout.layoutBox, c);
1107
- if (i) {
1108
- const o = i(Re(s));
1109
- this.hasMutatedConstraints = !!o, o && (s = Ce(o));
1110
- }
1111
- return s;
1112
- }
1113
- startAnimation(e) {
1114
- const { drag: i, dragMomentum: n, dragElastic: r, dragTransition: c, dragSnapToOrigin: s, onDragTransitionEnd: o } = this.getProps(), a = this.constraints || {}, l = V((h) => {
1115
- if (!F(h, i, this.currentDirection))
1116
- return;
1117
- let u = a && a[h] || {};
1118
- s && (u = { min: 0, max: 0 });
1119
- const d = r ? 200 : 1e6, m = r ? 40 : 1e7, f = {
1120
- type: "inertia",
1121
- velocity: n ? e[h] : 0,
1122
- bounceStiffness: d,
1123
- bounceDamping: m,
1124
- timeConstant: 750,
1125
- restDelta: 1,
1126
- restSpeed: 10,
1127
- ...c,
1128
- ...u
1129
- };
1130
- return this.startAxisValueAnimation(h, f);
1131
- });
1132
- return Promise.all(l).then(o);
1133
- }
1134
- startAxisValueAnimation(e, i) {
1135
- const n = this.getAxisMotionValue(e);
1136
- return it(this.visualElement, e), n.start(zt(e, n, 0, i, this.visualElement, !1));
1137
- }
1138
- stopAnimation() {
1139
- V((e) => this.getAxisMotionValue(e).stop());
1140
- }
1141
- pauseAnimation() {
1142
- V((e) => this.getAxisMotionValue(e).animation?.pause());
1143
- }
1144
- getAnimationState(e) {
1145
- return this.getAxisMotionValue(e).animation?.state;
1146
- }
1147
- /**
1148
- * Drag works differently depending on which props are provided.
1149
- *
1150
- * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
1151
- * - Otherwise, we apply the delta to the x/y motion values.
1152
- */
1153
- getAxisMotionValue(e) {
1154
- const i = `_drag${e.toUpperCase()}`, n = this.visualElement.getProps(), r = n[i];
1155
- return r || this.visualElement.getValue(e, (n.initial ? n.initial[e] : void 0) || 0);
1156
- }
1157
- snapToCursor(e) {
1158
- V((i) => {
1159
- const { drag: n } = this.getProps();
1160
- if (!F(i, n, this.currentDirection))
1161
- return;
1162
- const { projection: r } = this.visualElement, c = this.getAxisMotionValue(i);
1163
- if (r && r.layout) {
1164
- const { min: s, max: o } = r.layout.layoutBox[i], a = c.get() || 0;
1165
- c.set(e[i] - T(s, o, 0.5) + a);
1166
- }
1167
- });
1168
- }
1169
- /**
1170
- * When the viewport resizes we want to check if the measured constraints
1171
- * have changed and, if so, reposition the element within those new constraints
1172
- * relative to where it was before the resize.
1173
- */
1174
- scalePositionWithinConstraints() {
1175
- if (!this.visualElement.current)
1176
- return;
1177
- const { drag: e, dragConstraints: i } = this.getProps(), { projection: n } = this.visualElement;
1178
- if (!I(i) || !n || !this.constraints)
1179
- return;
1180
- this.stopAnimation();
1181
- const r = { x: 0, y: 0 };
1182
- V((s) => {
1183
- const o = this.getAxisMotionValue(s);
1184
- if (o && this.constraints !== !1) {
1185
- const a = o.get();
1186
- r[s] = Vs({ min: a, max: a }, this.constraints[s]);
1187
- }
1188
- });
1189
- const { transformTemplate: c } = this.visualElement.getProps();
1190
- this.visualElement.current.style.transform = c ? c({}, "") : "none", n.root && n.root.updateScroll(), n.updateLayout(), this.resolveConstraints(), V((s) => {
1191
- if (!F(s, e, null))
1192
- return;
1193
- const o = this.getAxisMotionValue(s), { min: a, max: l } = this.constraints[s];
1194
- o.set(T(a, l, r[s]));
1195
- });
1196
- }
1197
- addListeners() {
1198
- if (!this.visualElement.current)
1199
- return;
1200
- Rs.set(this.visualElement, this);
1201
- const e = this.visualElement.current, i = k(e, "pointerdown", (a) => {
1202
- const { drag: l, dragListener: h = !0 } = this.getProps(), u = a.target, d = u !== e && we(u);
1203
- l && h && !d && this.start(a);
1204
- }), n = () => {
1205
- const { dragConstraints: a } = this.getProps();
1206
- I(a) && a.current && (this.constraints = this.resolveRefConstraints());
1207
- }, { projection: r } = this.visualElement, c = r.addEventListener("measure", n);
1208
- r && !r.layout && (r.root && r.root.updateScroll(), r.updateLayout()), S.read(n);
1209
- const s = Q(window, "resize", () => this.scalePositionWithinConstraints()), o = r.addEventListener("didUpdate", (({ delta: a, hasLayoutChanged: l }) => {
1210
- this.isDragging && l && (V((h) => {
1211
- const u = this.getAxisMotionValue(h);
1212
- u && (this.originPoint[h] += a[h].translate, u.set(u.get() + a[h].translate));
1213
- }), this.visualElement.render());
1214
- }));
1215
- return () => {
1216
- s(), i(), c(), o && o();
1217
- };
1218
- }
1219
- getProps() {
1220
- const e = this.visualElement.getProps(), { drag: i = !1, dragDirectionLock: n = !1, dragPropagation: r = !1, dragConstraints: c = !1, dragElastic: s = J, dragMomentum: o = !0 } = e;
1221
- return {
1222
- ...e,
1223
- drag: i,
1224
- dragDirectionLock: n,
1225
- dragPropagation: r,
1226
- dragConstraints: c,
1227
- dragElastic: s,
1228
- dragMomentum: o
1229
- };
1230
- }
1231
- }
1232
- function F(t, e, i) {
1233
- return (e === !0 || e === t) && (i === null || i === t);
1234
- }
1235
- function ws(t, e = 10) {
1236
- let i = null;
1237
- return Math.abs(t.y) > e ? i = "y" : Math.abs(t.x) > e && (i = "x"), i;
1238
- }
1239
- class Ms extends $t {
1240
- constructor(e) {
1241
- super(e), this.removeGroupControls = B, this.removeListeners = B, this.controls = new Cs(e);
1242
- }
1243
- mount() {
1244
- const { dragControls: e } = this.node.getProps();
1245
- e && (this.removeGroupControls = e.subscribe(this.controls)), this.removeListeners = this.controls.addListeners() || B;
1246
- }
1247
- update() {
1248
- const { dragControls: e } = this.node.getProps(), { dragControls: i } = this.node.prevProps || {};
1249
- e !== i && (this.removeGroupControls(), e && (this.removeGroupControls = e.subscribe(this.controls)));
1250
- }
1251
- unmount() {
1252
- this.removeGroupControls(), this.removeListeners(), this.controls.endPanSession();
1253
- }
1254
- }
1255
- const It = (t) => (e, i) => {
1256
- t && S.postRender(() => t(e, i));
1257
- };
1258
- class Bs extends $t {
1259
- constructor() {
1260
- super(...arguments), this.removePointerDownListener = B;
1261
- }
1262
- onPointerDown(e) {
1263
- this.session = new ne(e, this.createPanHandlers(), {
1264
- transformPagePoint: this.node.getTransformPagePoint(),
1265
- contextWindow: ie(this.node)
1266
- });
1267
- }
1268
- createPanHandlers() {
1269
- const { onPanSessionStart: e, onPanStart: i, onPan: n, onPanEnd: r } = this.node.getProps();
1270
- return {
1271
- onSessionStart: It(e),
1272
- onStart: It(i),
1273
- onMove: n,
1274
- onEnd: (c, s) => {
1275
- delete this.session, r && S.postRender(() => r(c, s));
1276
- }
1277
- };
1278
- }
1279
- mount() {
1280
- this.removePointerDownListener = k(this.node.current, "pointerdown", (e) => this.onPointerDown(e));
1281
- }
1282
- update() {
1283
- this.session && this.session.updateHandlers(this.createPanHandlers());
1284
- }
1285
- unmount() {
1286
- this.removePointerDownListener(), this.session && this.session.end();
1287
- }
1288
- }
1289
- let _ = !1;
1290
- class js extends Be {
1291
- /**
1292
- * This only mounts projection nodes for components that
1293
- * need measuring, we might want to do it for all components
1294
- * in order to incorporate transforms
1295
- */
1296
- componentDidMount() {
1297
- const { visualElement: e, layoutGroup: i, switchLayoutGroup: n, layoutId: r } = this.props, { projection: c } = e;
1298
- c && (i.group && i.group.add(c), n && n.register && r && n.register(c), _ && c.root.didUpdate(), c.addEventListener("animationComplete", () => {
1299
- this.safeToRemove();
1300
- }), c.setOptions({
1301
- ...c.options,
1302
- onExitComplete: () => this.safeToRemove()
1303
- })), N.hasEverUpdated = !0;
1304
- }
1305
- getSnapshotBeforeUpdate(e) {
1306
- const { layoutDependency: i, visualElement: n, drag: r, isPresent: c } = this.props, { projection: s } = n;
1307
- return s && (s.isPresent = c, _ = !0, r || e.layoutDependency !== i || i === void 0 || e.isPresent !== c ? s.willUpdate() : this.safeToRemove(), e.isPresent !== c && (c ? s.promote() : s.relegate() || S.postRender(() => {
1308
- const o = s.getStack();
1309
- (!o || !o.members.length) && this.safeToRemove();
1310
- }))), null;
1311
- }
1312
- componentDidUpdate() {
1313
- const { projection: e } = this.props.visualElement;
1314
- e && (e.root.didUpdate(), Gt.postRender(() => {
1315
- !e.currentAnimation && e.isLead() && this.safeToRemove();
1316
- }));
1317
- }
1318
- componentWillUnmount() {
1319
- const { visualElement: e, layoutGroup: i, switchLayoutGroup: n } = this.props, { projection: r } = e;
1320
- _ = !0, r && (r.scheduleCheckAfterUnmount(), i && i.group && i.group.remove(r), n && n.deregister && n.deregister(r));
1321
- }
1322
- safeToRemove() {
1323
- const { safeToRemove: e } = this.props;
1324
- e && e();
1325
- }
1326
- render() {
1327
- return null;
1328
- }
1329
- }
1330
- function ae(t) {
1331
- const [e, i] = de(), n = nt(me);
1332
- return fe.jsx(js, { ...t, layoutGroup: n, switchLayoutGroup: nt(pe), isPresent: e, safeToRemove: i });
1333
- }
1334
- const ks = {
1335
- pan: {
1336
- Feature: Bs
1337
- },
1338
- drag: {
1339
- Feature: Ms,
1340
- ProjectionNode: se,
1341
- MeasureLayout: ae
1342
- }
1343
- }, bs = {
1344
- layout: {
1345
- ProjectionNode: se,
1346
- MeasureLayout: ae
1347
- }
1348
- }, Ns = {
1349
- ...Me,
1350
- ...ks,
1351
- ...bs
1352
- };
1353
- export {
1354
- zs as AnimatePresence,
1355
- Ln as AsyncMotionValueAnimation,
1356
- Rn as DOMKeyframesResolver,
1357
- Cn as DOMVisualElement,
1358
- vs as DocumentProjectionNode,
1359
- $t as Feature,
1360
- Je as FlatTree,
1361
- se as HTMLProjectionNode,
1362
- wn as HTMLVisualElement,
1363
- Mn as JSAnimation,
1364
- Hs as KeyframeResolver,
1365
- me as LayoutGroupContext,
1366
- $s as LazyMotion,
1367
- Xs as MotionConfig,
1368
- Ys as MotionConfigContext,
1369
- Ks as MotionContext,
1370
- qs as MotionGlobalConfig,
1371
- _s as MotionValue,
1372
- Bn as NativeAnimation,
1373
- jn as NativeAnimationExtended,
1374
- ts as NodeStack,
1375
- Zs as PopChild,
1376
- Js as PresenceChild,
1377
- Qs as PresenceContext,
1378
- kn as SVGVisualElement,
1379
- ce as SubscriptionManager,
1380
- pe as SwitchLayoutGroupContext,
1381
- ti as VisualElement,
1382
- Q as addDomEvent,
1383
- k as addPointerEvent,
1384
- De as addPointerInfo,
1385
- Ut as addUniqueItem,
1386
- it as addValueToWillChange,
1387
- ei as alpha,
1388
- si as analyseComplexValue,
1389
- zt as animateMotionValue,
1390
- _e as animateSingleValue,
1391
- bn as animateTarget,
1392
- In as animateVariant,
1393
- On as animateVisualElement,
1394
- Un as animations,
1395
- Fn as anticipate,
1396
- Nn as applyAxisDelta,
1397
- ve as applyBoxDelta,
1398
- Wn as applyGeneratorOptions,
1399
- Gn as applyPointDelta,
1400
- Pe as applyTreeDeltas,
1401
- gt as aspectRatio,
1402
- yt as axisDeltaEquals,
1403
- ft as axisEquals,
1404
- pt as axisEqualsRounded,
1405
- zn as backIn,
1406
- Hn as backInOut,
1407
- $n as backOut,
1408
- He as boxEquals,
1409
- _t as boxEqualsRounded,
1410
- ii as buildHTMLStyles,
1411
- $e as buildProjectionTransform,
1412
- ni as buildSVGAttrs,
1413
- oi as buildSVGPath,
1414
- ai as buildTransform,
1415
- rt as calcAxisDelta,
1416
- j as calcBoxDelta,
1417
- Xn as calcChildStagger,
1418
- Yn as calcGeneratorDuration,
1419
- D as calcLength,
1420
- lt as calcRelativeAxis,
1421
- ht as calcRelativeAxisPosition,
1422
- Ne as calcRelativeBox,
1423
- G as calcRelativePosition,
1424
- Kn as camelCaseAttributes,
1425
- ri as camelToDash,
1426
- b as cancelFrame,
1427
- qn as checkVariantsDidChange,
1428
- _n as circIn,
1429
- Zn as circInOut,
1430
- ge as circOut,
1431
- Wt as clamp,
1432
- as as cleanDirtyNodes,
1433
- li as color,
1434
- Ze as compareByDepth,
1435
- hi as complex,
1436
- ci as containsCSSVariable,
1437
- Ce as convertBoundingBoxToBox,
1438
- Re as convertBoxToBoundingBox,
1439
- Jn as convertOffsetToTimes,
1440
- at as copyAxisDeltaInto,
1441
- ot as copyAxisInto,
1442
- A as copyBoxInto,
1443
- ui as correctBorderRadius,
1444
- di as correctBoxShadow,
1445
- Qn as createAnimationState,
1446
- mi as createAxis,
1447
- fi as createAxisDelta,
1448
- P as createBox,
1449
- M as createDelta,
1450
- to as createGeneratorEasing,
1451
- te as createProjectionNode,
1452
- pi as createRenderBatcher,
1453
- eo as cubicBezier,
1454
- so as cubicBezierAsString,
1455
- io as defaultEasing,
1456
- no as defaultOffset,
1457
- gi as defaultTransformValue,
1458
- yi as defaultValueTypes,
1459
- vi as degrees,
1460
- Qe as delay,
1461
- xi as dimensionValueTypes,
1462
- Ct as distance,
1463
- xs as distance2D,
1464
- Me as domAnimation,
1465
- Ns as domMax,
1466
- V as eachAxis,
1467
- oo as easeIn,
1468
- ao as easeInOut,
1469
- ro as easeOut,
1470
- lo as easingDefinitionToFunction,
1471
- ho as fillOffset,
1472
- Pi as fillWildcards,
1473
- Ti as filterProps,
1474
- Di as findDimensionValueType,
1475
- Si as findValueType,
1476
- Ei as flushKeyframeResolvers,
1477
- S as frame,
1478
- E as frameData,
1479
- z as frameSteps,
1480
- co as generateLinearEasing,
1481
- Vi as getAnimatableNone,
1482
- uo as getDefaultTransition,
1483
- Ai as getDefaultValueType,
1484
- Li as getFeatureDefinitions,
1485
- mo as getFinalKeyframe,
1486
- fo as getMixer,
1487
- Te as getOptimisedAppearId,
1488
- Ri as getValueAsType,
1489
- ye as getValueTransition,
1490
- po as getVariableValue,
1491
- go as getVariantContext,
1492
- N as globalProjectionState,
1493
- xe as has2DTranslate,
1494
- Ci as hasReducedMotionListener,
1495
- st as hasScale,
1496
- w as hasTransform,
1497
- wi as hex,
1498
- yo as hover,
1499
- Mi as hsla,
1500
- vo as hslaToRgba,
1501
- xo as inertia,
1502
- Bi as initPrefersReducedMotion,
1503
- Po as interpolate,
1504
- ue as invariant,
1505
- To as invisibleValues,
1506
- ji as isAnimationControls,
1507
- Do as isBezierDefinition,
1508
- ki as isBrowser,
1509
- bi as isCSSVariableName,
1510
- Ii as isCSSVariableToken,
1511
- Oi as isControllingVariants,
1512
- qt as isDeltaZero,
1513
- So as isDragActive,
1514
- L as isDragging,
1515
- Eo as isEasingArray,
1516
- we as isElementKeyboardAccessible,
1517
- Ui as isForcedMotionValue,
1518
- Vo as isGenerator,
1519
- Fi as isHTMLElement,
1520
- Ao as isKeyframesTarget,
1521
- he as isMotionValue,
1522
- Fe as isNear,
1523
- Lo as isNodeOrChild,
1524
- Ni as isNumericalString,
1525
- re as isObject,
1526
- Se as isPrimaryPointer,
1527
- Xt as isSVGElement,
1528
- ke as isSVGSVGElement,
1529
- Wi as isSVGTag,
1530
- Ro as isTransitionDefined,
1531
- Gi as isValidMotionProp,
1532
- zi as isVariantLabel,
1533
- Hi as isVariantNode,
1534
- Co as isWillChangeMotionValue,
1535
- $i as isZeroValueString,
1536
- wo as keyframes,
1537
- Xi as m,
1538
- Mo as makeAnimationInstant,
1539
- Yi as makeUseVisualState,
1540
- Bo as mapEasingToNativeEasing,
1541
- jo as maxGeneratorDuration,
1542
- Le as measurePageBox,
1543
- ko as measureViewportBox,
1544
- bo as memo,
1545
- Gt as microtask,
1546
- Ae as millisecondsToSeconds,
1547
- Io as mirrorEasing,
1548
- Oo as mix,
1549
- Uo as mixArray,
1550
- Fo as mixColor,
1551
- No as mixComplex,
1552
- Wo as mixImmediate,
1553
- Go as mixLinearColor,
1554
- T as mixNumber,
1555
- zo as mixObject,
1556
- Ye as mixValues,
1557
- Ho as mixVisibility,
1558
- Ot as motionValue,
1559
- B as noop,
1560
- Ki as number,
1561
- qi as numberValueTypes,
1562
- _i as optimizedAppearDataAttribute,
1563
- Zi as optimizedAppearDataId,
1564
- $o as parseCSSVariable,
1565
- Ji as parseValueFromTransform,
1566
- W as percent,
1567
- Ee as pipe,
1568
- Qi as pixelsToPercent,
1569
- Xo as positionalKeys,
1570
- tn as prefersReducedMotion,
1571
- Yo as press,
1572
- Z as progress,
1573
- en as progressPercentage,
1574
- os as propagateDirtyNodes,
1575
- le as px,
1576
- sn as readTransformValue,
1577
- We as removeAxisDelta,
1578
- ut as removeAxisTransforms,
1579
- dt as removeBoxTransforms,
1580
- Ft as removeItem,
1581
- ct as removePointDelta,
1582
- Ko as renderHTML,
1583
- qo as renderSVG,
1584
- _o as resolveElements,
1585
- H as resolveMotionValue,
1586
- Zo as resolveVariant,
1587
- nn as resolveVariantFromProps,
1588
- Jo as reverseEasing,
1589
- on as rgbUnit,
1590
- an as rgba,
1591
- Y as rootProjectionNode,
1592
- rn as scale,
1593
- tt as scaleCorrectors,
1594
- et as scalePoint,
1595
- ln as scrapeHTMLMotionValuesFromProps,
1596
- hn as scrapeSVGMotionValuesFromProps,
1597
- Ve as secondsToMilliseconds,
1598
- je as setDragLock,
1599
- cn as setFeatureDefinitions,
1600
- Qo as setStyle,
1601
- ta as setTarget,
1602
- ea as spring,
1603
- sa as startWaapiAnimation,
1604
- ia as supportedWaapiEasing,
1605
- na as supportsBrowserAnimation,
1606
- oa as supportsFlags,
1607
- aa as supportsLinearEasing,
1608
- ra as supportsScrollTimeline,
1609
- un as testValueType,
1610
- Nt as time,
1611
- la as transformAxis,
1612
- U as transformBox,
1613
- ha as transformBoxPoints,
1614
- dn as transformPropOrder,
1615
- mn as transformProps,
1616
- fn as transformValueTypes,
1617
- O as translateAxis,
1618
- pn as updateMotionValuesFromProps,
1619
- gn as useComposedRefs,
1620
- yn as useIsomorphicLayoutEffect,
1621
- de as usePresence,
1622
- vn as variantPriorityOrder,
1623
- xn as variantProps,
1624
- Pn as velocityPerSecond,
1625
- Tn as vh,
1626
- Dn as visualElementStore,
1627
- Sn as vw,
1628
- En as warnOnce,
1629
- Vn as warning
1630
- };