@konstructio/ui 0.1.2-alpha.101 → 0.1.2-alpha.103

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 (221) hide show
  1. package/dist/AlertDialogTrigger-CgcsW_ta.js +109 -0
  2. package/dist/{Breadcrumb-Bmv0vzgt.js → Breadcrumb-Cp3abB2w.js} +1 -1
  3. package/dist/Checkbox-DzAx7n67.js +249 -0
  4. package/dist/{CommandInput-CYYsk_31.js → CommandInput-BnvRMfLI.js} +2 -2
  5. package/dist/{Counter-DWKyr569.js → Counter-CY0xGnVM.js} +2 -2
  6. package/dist/{DayPicker-CwO8Zff5.js → DayPicker-kweJz134.js} +750 -746
  7. package/dist/{DropdownButton-Beel5_gN.js → DropdownButton-DnlwdPmb.js} +1 -1
  8. package/dist/FlagSelectorList-BoYG-_It.js +852 -0
  9. package/dist/{HamburgerTrigger-7a4POUaM.js → HamburgerTrigger-1vOTrm8-.js} +2 -2
  10. package/dist/{Input-DG3snJf_.js → Input-CW0VwW2T.js} +4 -4
  11. package/dist/{Modal-Bcu6LLAp.js → Modal-Bfzggwlr.js} +2 -2
  12. package/dist/{Spinner-BegZ5yd7.js → Spinner-Lw9mZYhg.js} +1 -1
  13. package/dist/Switch-WBRr8uOJ.js +196 -0
  14. package/dist/Toast-ByH-l4XK.js +459 -0
  15. package/dist/{Wrapper-DwxJAkNQ.js → Wrapper-ClJ_Mham.js} +2 -2
  16. package/dist/{Wrapper-DtT29fc5.js → Wrapper-XeeD3av7.js} +1 -1
  17. package/dist/components/Alert/Alert.js +2 -2
  18. package/dist/components/AlertDialog/AlertDialog.js +1 -1
  19. package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
  20. package/dist/components/AlertDialog/components/index.js +1 -1
  21. package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
  22. package/dist/components/Checkbox/Checkbox.js +1 -1
  23. package/dist/components/Command/Command.js +2 -2
  24. package/dist/components/Command/components/Command.js +1 -1
  25. package/dist/components/Command/components/CommandEmpty.js +1 -1
  26. package/dist/components/Command/components/CommandGroup.js +1 -1
  27. package/dist/components/Command/components/CommandInput.js +1 -1
  28. package/dist/components/Command/components/CommandItem.js +1 -1
  29. package/dist/components/Command/components/CommandList.js +1 -1
  30. package/dist/components/Command/components/CommandSeparator.js +1 -1
  31. package/dist/components/Command/components/DialogContent.js +2 -2
  32. package/dist/components/Command/components/DialogOverlay.js +1 -1
  33. package/dist/components/Command/components/index.js +1 -1
  34. package/dist/components/Counter/Counter.js +1 -1
  35. package/dist/components/DateRangePicker/components/CalendarPanel/components/CalendarMonth/CalendarMonth.js +1 -1
  36. package/dist/components/DateRangePicker/components/DateTimeInputs/components/EndInputFields/EndInputFields.js +1 -1
  37. package/dist/components/DateRangePicker/components/DateTimeInputs/components/StartInputFields/StartInputFields.js +1 -1
  38. package/dist/components/Datepicker/DatePicker.js +2 -3
  39. package/dist/components/Drawer/Drawer.js +2 -2
  40. package/dist/components/DropdownButton/DropdownButton.js +1 -1
  41. package/dist/components/Filter/Filter.js +4 -3
  42. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.hook.js +23 -24
  43. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +60 -65
  44. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.hook.js +35 -43
  45. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.js +40 -45
  46. package/dist/components/Filter/components/DateRangeFilterDropdown/DateRangeFilterDropdown.hook.js +33 -34
  47. package/dist/components/Filter/components/DateRangeFilterDropdown/DateRangeFilterDropdown.js +45 -51
  48. package/dist/components/Filter/components/FilterDropdown/FilterDropdown.js +28 -0
  49. package/dist/components/Filter/components/TextMultiSelect/TextMultiSelect.js +56 -61
  50. package/dist/components/Filter/components/TimeFilterDropdown/TimeFilterDropdown.hook.js +33 -34
  51. package/dist/components/Filter/components/TimeFilterDropdown/TimeFilterDropdown.js +70 -75
  52. package/dist/components/Filter/contexts/filter.provider.js +8 -5
  53. package/dist/components/Filter/utils/index.js +1 -1
  54. package/dist/components/Input/Input.js +1 -1
  55. package/dist/components/LineChart/LineChart.js +1 -1
  56. package/dist/components/Modal/Modal.js +1 -1
  57. package/dist/components/Modal/components/Wrapper/Wrapper.js +1 -1
  58. package/dist/components/Modal/components/index.js +1 -1
  59. package/dist/components/MultiSelectDropdown/MultiSelectDropdown.js +1 -1
  60. package/dist/components/MultiSelectDropdown/components/List/List.js +1 -1
  61. package/dist/components/MultiSelectDropdown/components/Wrapper/Wrapper.js +1 -1
  62. package/dist/components/MultiSelectDropdown/components/index.js +1 -1
  63. package/dist/components/PhoneNumberInput/PhoneNumberInput.js +2 -2
  64. package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +1 -1
  65. package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js +2 -2
  66. package/dist/components/PhoneNumberInput/components/TruncateText/TruncateText.js +2 -2
  67. package/dist/components/PhoneNumberInput/components/Wrapper.js +1 -1
  68. package/dist/components/PhoneNumberInput/components/index.js +2 -2
  69. package/dist/components/PhoneNumberInput/contexts/index.js +1 -1
  70. package/dist/components/PhoneNumberInput/contexts/phone-number.provider.js +1 -1
  71. package/dist/components/PieChart/PieChart.js +1 -1
  72. package/dist/components/Range/Range.js +1 -1
  73. package/dist/components/Select/components/List/List.js +1 -1
  74. package/dist/components/Sidebar/components/HamburgerTrigger/HamburgerTrigger.js +1 -1
  75. package/dist/components/Sidebar/components/NavigationOption/NavigationOption.js +1 -1
  76. package/dist/components/Sidebar/components/Wrapper/Wrapper.js +1 -1
  77. package/dist/components/Sidebar/components/index.js +1 -1
  78. package/dist/components/Slider/Slider.js +1 -1
  79. package/dist/components/Spinner/Spinner.js +1 -1
  80. package/dist/components/Switch/Switch.js +1 -1
  81. package/dist/components/Table/components/Filter.js +1 -1
  82. package/dist/components/Tabs/Tabs.js +1 -1
  83. package/dist/components/Tabs/components/Content.js +1 -1
  84. package/dist/components/Tabs/components/List.js +1 -1
  85. package/dist/components/Tabs/components/Trigger.js +1 -1
  86. package/dist/components/TagSelect/TagSelect.js +1 -1
  87. package/dist/components/TagSelect/components/Wrapper/Wrapper.js +1 -1
  88. package/dist/components/TagSelect/components/index.js +1 -1
  89. package/dist/components/Toast/Toast.js +1 -1
  90. package/dist/components/Tooltip/Tooltip.js +1 -1
  91. package/dist/components/VirtualizedTable/VirtualizedTable.js +87 -87
  92. package/dist/components/VirtualizedTable/components/Actions/Actions.js +19 -19
  93. package/dist/components/VirtualizedTable/components/Body/Body.js +50 -49
  94. package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +67 -21
  95. package/dist/components/VirtualizedTable/components/ExpandableRow/ExpandableRow.js +1 -1
  96. package/dist/components/VirtualizedTable/components/Filter/Filter.js +53 -63
  97. package/dist/components/VirtualizedTable/components/FormPaginate/FormPaginate.js +10 -10
  98. package/dist/components/VirtualizedTable/components/Header/Header.js +47 -34
  99. package/dist/components/VirtualizedTable/components/Pagination/Pagination.js +19 -15
  100. package/dist/components/VirtualizedTable/components/Skeleton/Skeleton.js +10 -10
  101. package/dist/components/VirtualizedTable/components/TruncateText/TruncateText.js +1 -1
  102. package/dist/components/VirtualizedTable/components/WrapperBody/WrapperBody.js +8 -8
  103. package/dist/components/VirtualizedTable/contexts/index.js +1 -1
  104. package/dist/components/VirtualizedTable/contexts/table.context.js +1 -0
  105. package/dist/components/VirtualizedTable/contexts/table.provider.js +1 -1
  106. package/dist/components/index.js +10 -10
  107. package/dist/{components-CYt24H4n.js → components-BIHlj4yH.js} +1 -1
  108. package/dist/{debounce-KoeGNmnW.js → debounce-C5Ycjilj.js} +14 -14
  109. package/dist/dist-2bGlmy8N2.js +165 -0
  110. package/dist/dist-BiJrNvNo.js +193 -0
  111. package/dist/dist-BuFiu480.js +13 -0
  112. package/dist/dist-C2aTw0m62.js +1320 -0
  113. package/dist/{dist-DvoMuWKO2.js → dist-C2s4VX-42.js} +4 -4
  114. package/dist/dist-CT6d9xe7.js +441 -0
  115. package/dist/dist-CTvBzxW8.js +31 -0
  116. package/dist/dist-CVDFmWf2.js +358 -0
  117. package/dist/dist-D4FePjTS.js +194 -0
  118. package/dist/dist-DISvWx7U.js +99 -0
  119. package/dist/dist-Db6UeFo4.js +291 -0
  120. package/dist/{dist-DGO9opgu.js → dist-Dse3gSmZ.js} +49 -49
  121. package/dist/dist-j7FOUrFU.js +206 -0
  122. package/dist/{dist-C8NWUTUh.js → dist-l-aDnQZC.js} +1 -1
  123. package/dist/es2015-BWf6xQHm.js +222 -0
  124. package/dist/index.js +10 -10
  125. package/dist/{isObject-1ZmdWuhC.js → isObject-BeFFiVJK.js} +8 -8
  126. package/dist/lib/components/Alert/Alert.types.d.ts +1 -1
  127. package/dist/lib/components/AlertDialog/AlertDialog.types.d.ts +1 -1
  128. package/dist/lib/components/AlertDialog/components/AlertDialogTrigger.types.d.ts +2 -2
  129. package/dist/lib/components/Autocomplete/Autocomplete.types.d.ts +1 -1
  130. package/dist/lib/components/Breadcrumb/Breadcrumb.types.d.ts +1 -1
  131. package/dist/lib/components/Breadcrumb/components/BackButton/BackButton.types.d.ts +1 -1
  132. package/dist/lib/components/Breadcrumb/components/Item/Item.types.d.ts +1 -1
  133. package/dist/lib/components/Button/Button.types.d.ts +1 -1
  134. package/dist/lib/components/ButtonGroup/ButtonGroup.types.d.ts +1 -1
  135. package/dist/lib/components/Card/Card.types.d.ts +1 -1
  136. package/dist/lib/components/Checkbox/Checkbox.types.d.ts +1 -1
  137. package/dist/lib/components/Command/Command.types.d.ts +1 -1
  138. package/dist/lib/components/Counter/Counter.types.d.ts +1 -1
  139. package/dist/lib/components/DateRangePicker/DateRangePicker.types.d.ts +1 -1
  140. package/dist/lib/components/Drawer/Drawer.types.d.ts +1 -1
  141. package/dist/lib/components/Filter/Filter.types.d.ts +1 -1
  142. package/dist/lib/components/Filter/components/BadgeDropdown/BadgeMultiSelect.hook.d.ts +2 -3
  143. package/dist/lib/components/Filter/components/DateFilterDropdown/DateFilterDropdown.hook.d.ts +1 -2
  144. package/dist/lib/components/Filter/components/DateRangeFilterDropdown/DateRangeFilterDropdown.hook.d.ts +2 -3
  145. package/dist/lib/components/Filter/components/DateRangeFilterDropdown/DateRangeFilterDropdown.types.d.ts +1 -1
  146. package/dist/lib/components/Filter/components/FilterDropdown/FilterDropdown.d.ts +3 -0
  147. package/dist/lib/components/Filter/components/FilterDropdown/FilterDropdown.types.d.ts +9 -0
  148. package/dist/lib/components/Filter/components/ResetButton/ResetButton.types.d.ts +1 -1
  149. package/dist/lib/components/Filter/components/TimeFilterDropdown/TimeFilterDropdown.hook.d.ts +1 -2
  150. package/dist/lib/components/Filter/contexts/filter.context.d.ts +1 -0
  151. package/dist/lib/components/ImageUpload/ImageUpload.types.d.ts +1 -1
  152. package/dist/lib/components/Input/Input.types.d.ts +1 -1
  153. package/dist/lib/components/LineChart/LineChart.types.d.ts +1 -1
  154. package/dist/lib/components/Loading/Loading.types.d.ts +1 -1
  155. package/dist/lib/components/Modal/Modal.types.d.ts +1 -1
  156. package/dist/lib/components/Modal/components/Wrapper/Wrapper.types.d.ts +1 -1
  157. package/dist/lib/components/MultiSelectDropdown/components/Item/Item.types.d.ts +1 -1
  158. package/dist/lib/components/MultiSelectDropdown/components/List/List.types.d.ts +1 -1
  159. package/dist/lib/components/MultiSelectDropdown/components/Wrapper/Wrapper.types.d.ts +1 -1
  160. package/dist/lib/components/ProgressBar/ProgressBar.types.d.ts +1 -1
  161. package/dist/lib/components/Radio/Radio.types.d.ts +1 -1
  162. package/dist/lib/components/RadioCard/RadioCard.types.d.ts +1 -1
  163. package/dist/lib/components/RadioCardGroup/RadioCardGroup.types.d.ts +1 -1
  164. package/dist/lib/components/RadioGroup/RadioGroup.types.d.ts +1 -1
  165. package/dist/lib/components/Range/Range.types.d.ts +1 -1
  166. package/dist/lib/components/Select/Select.types.d.ts +1 -1
  167. package/dist/lib/components/Sidebar/Sidebar.types.d.ts +2 -2
  168. package/dist/lib/components/Sidebar/components/Label/Label.types.d.ts +1 -1
  169. package/dist/lib/components/Slider/Slider.types.d.ts +1 -1
  170. package/dist/lib/components/Spinner/Spinner.types.d.ts +2 -2
  171. package/dist/lib/components/Stepper/Stepper.types.d.ts +1 -1
  172. package/dist/lib/components/Stepper/components/StepItem/StepItem.types.d.ts +1 -1
  173. package/dist/lib/components/Switch/Switch.types.d.ts +1 -1
  174. package/dist/lib/components/Table/Table.types.d.ts +1 -1
  175. package/dist/lib/components/Tabs/Tabs.types.d.ts +1 -1
  176. package/dist/lib/components/TagSelect/TagSelect.types.d.ts +1 -1
  177. package/dist/lib/components/TagSelect/components/Item/Item.types.d.ts +2 -2
  178. package/dist/lib/components/TagSelect/components/List/List.types.d.ts +1 -1
  179. package/dist/lib/components/TagSelect/components/Wrapper/Wrapper.types.d.ts +1 -1
  180. package/dist/lib/components/TagSelect/contexts/TagSelect.types.d.ts +1 -1
  181. package/dist/lib/components/TextArea/TextArea.types.d.ts +1 -1
  182. package/dist/lib/components/Toast/Toast.types.d.ts +1 -1
  183. package/dist/lib/components/Typography/Typography.types.d.ts +1 -1
  184. package/dist/lib/components/VirtualizedTable/VirtualizedTable.types.d.ts +27 -3
  185. package/dist/lib/components/VirtualizedTable/components/Body/Body.d.ts +1 -1
  186. package/dist/lib/components/VirtualizedTable/components/Body/Body.types.d.ts +1 -0
  187. package/dist/lib/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.types.d.ts +2 -0
  188. package/dist/lib/components/VirtualizedTable/components/Filter/Filter.types.d.ts +1 -1
  189. package/dist/lib/components/VirtualizedTable/components/Header/Header.d.ts +1 -1
  190. package/dist/lib/components/VirtualizedTable/components/Header/Header.types.d.ts +1 -0
  191. package/dist/lib/components/VirtualizedTable/components/Pagination/Pagination.types.d.ts +2 -0
  192. package/dist/lib/components/VirtualizedTable/components/TruncateText/TruncateText.types.d.ts +1 -1
  193. package/dist/lib/components/VirtualizedTable/contexts/table.context.d.ts +2 -0
  194. package/dist/lib/components/VirtualizedTable/contexts/table.provider.d.ts +1 -1
  195. package/dist/lib/components/VirtualizedTable/contexts/table.types.d.ts +1 -0
  196. package/dist/lib/contexts/theme.context.d.ts +1 -1
  197. package/dist/lib/contexts/theme.hook.d.ts +1 -1
  198. package/dist/package.json +34 -33
  199. package/dist/{phone-number.provider-CJJOFYk-.js → phone-number.provider-BxQCTxp8.js} +457 -457
  200. package/dist/{prop-types-CaJpPVsa.js → prop-types-CfEYxTbR.js} +52 -52
  201. package/dist/styles.css +1 -1
  202. package/dist/{table.provider-9uUt5a-s.js → table.provider-2sAkE7z_.js} +395 -368
  203. package/dist/{utils-B6A9pnrH.js → utils-B-BTGYA5.js} +193 -193
  204. package/dist/{x-CESTrenk.js → x-BI9jmc7e.js} +1 -1
  205. package/package.json +34 -33
  206. package/dist/AlertDialogTrigger-HhbFOOUE.js +0 -124
  207. package/dist/Checkbox-B1rTwzR3.js +0 -240
  208. package/dist/FlagSelectorList-BARhzfj2.js +0 -848
  209. package/dist/Switch-1RGhhTtg.js +0 -178
  210. package/dist/Toast-CS-igZor.js +0 -467
  211. package/dist/dist-7edduNXi.js +0 -398
  212. package/dist/dist-BkYHh2kH.js +0 -408
  213. package/dist/dist-C6Cif8-U.js +0 -28
  214. package/dist/dist-CeuUxVmT.js +0 -13
  215. package/dist/dist-CfYOvauX.js +0 -125
  216. package/dist/dist-CktbIsHq.js +0 -264
  217. package/dist/dist-DGqWMRtc.js +0 -183
  218. package/dist/dist-DdFwUrO22.js +0 -11
  219. package/dist/dist-DnGj9MTf.js +0 -1692
  220. package/dist/dist-eAwtFCCA.js +0 -87
  221. /package/dist/{dist-AihTpWdF2.js → dist-AihTpWdF.js} +0 -0
@@ -1,848 +0,0 @@
1
- import { t as C } from "./utils-Cx-WzRZF.js";
2
- import { Typography as R } from "./components/Typography/Typography.js";
3
- import { usePhoneNumberContext as N } from "./components/PhoneNumberInput/contexts/phone-number.hook.js";
4
- import { TruncateText as V } from "./components/PhoneNumberInput/components/TruncateText/TruncateText.js";
5
- import * as w from "react";
6
- import { useEffect as W, useMemo as j, useRef as L } from "react";
7
- import { flushSync as P } from "react-dom";
8
- import { jsx as E, jsxs as K } from "react/jsx-runtime";
9
- function $(l, t, s) {
10
- const e = new Array(l);
11
- return new Proxy(e, { get(n, i, o) {
12
- if (typeof i == "string") {
13
- const r = i.charCodeAt(0);
14
- if (r >= 48 && r <= 57) {
15
- const h = +i;
16
- if (Number.isInteger(h) && h >= 0 && h < l) {
17
- let a = n[h];
18
- if (!a) {
19
- const c = t[h * 2];
20
- a = n[h] = {
21
- index: h,
22
- key: s(h),
23
- start: c,
24
- size: t[h * 2 + 1],
25
- end: c + t[h * 2 + 1],
26
- lane: 0
27
- };
28
- }
29
- return a;
30
- }
31
- }
32
- if (i === "length") return l;
33
- }
34
- return Reflect.get(n, i, o);
35
- } });
36
- }
37
- function y(l, t, s) {
38
- let e = s.initialDeps ?? [], n, i = !0;
39
- function o() {
40
- var r;
41
- const h = process.env.NODE_ENV !== "production" && !!s.key && !!((r = s.debug) != null && r.call(s));
42
- let a = 0;
43
- h && (a = Date.now());
44
- const c = l();
45
- if (!(c.length !== e.length || c.some((f, d) => e[d] !== f))) return n;
46
- e = c;
47
- let u = 0;
48
- if (h && (u = Date.now()), n = t(...c), h) {
49
- const f = Math.round((Date.now() - a) * 100) / 100, d = Math.round((Date.now() - u) * 100) / 100, p = d / 16, g = (m, v) => {
50
- for (m = String(m); m.length < v; ) m = " " + m;
51
- return m;
52
- };
53
- console.info(`%c⏱ ${g(d, 5)} /${g(f, 5)} ms`, `
54
- font-size: .6rem;
55
- font-weight: bold;
56
- color: hsl(${Math.max(0, Math.min(120 - 120 * p, 120))}deg 100% 31%);`, s?.key);
57
- }
58
- return s?.onChange && !(i && s.skipInitialOnChange) && s.onChange(n), i = !1, n;
59
- }
60
- return o.updateDeps = (r) => {
61
- e = r;
62
- }, o;
63
- }
64
- function F(l, t) {
65
- if (l === void 0) throw new Error(`Unexpected undefined${t ? `: ${t}` : ""}`);
66
- return l;
67
- }
68
- var B = (l, t) => Math.abs(l - t) < 1.01, H = (l, t, s) => {
69
- let e;
70
- return function(...n) {
71
- l.clearTimeout(e), e = l.setTimeout(() => t.apply(this, n), s);
72
- };
73
- }, I, T = () => {
74
- if (I !== void 0) return I;
75
- if (typeof navigator > "u") return I = !1;
76
- if (/iP(hone|od|ad)/.test(navigator.userAgent)) return I = !0;
77
- const l = navigator.maxTouchPoints;
78
- return I = navigator.platform === "MacIntel" && l !== void 0 && l > 0;
79
- }, k = (l) => {
80
- const { offsetWidth: t, offsetHeight: s } = l;
81
- return {
82
- width: t,
83
- height: s
84
- };
85
- }, J = (l) => l, q = (l) => {
86
- const t = Math.max(l.startIndex - l.overscan, 0), s = Math.min(l.endIndex + l.overscan, l.count - 1) - t + 1, e = new Array(s);
87
- for (let n = 0; n < s; n++) e[n] = t + n;
88
- return e;
89
- }, U = (l, t) => {
90
- const s = l.scrollElement;
91
- if (!s) return;
92
- const e = l.targetWindow;
93
- if (!e) return;
94
- const n = (o) => {
95
- const { width: r, height: h } = o;
96
- t({
97
- width: Math.round(r),
98
- height: Math.round(h)
99
- });
100
- };
101
- if (n(k(s)), !e.ResizeObserver) return () => {
102
- };
103
- const i = new e.ResizeObserver((o) => {
104
- const r = () => {
105
- const h = o[0];
106
- if (h?.borderBoxSize) {
107
- const a = h.borderBoxSize[0];
108
- if (a) {
109
- n({
110
- width: a.inlineSize,
111
- height: a.blockSize
112
- });
113
- return;
114
- }
115
- }
116
- n(k(s));
117
- };
118
- l.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
119
- });
120
- return i.observe(s, { box: "border-box" }), () => {
121
- i.unobserve(s);
122
- };
123
- }, M = { passive: !0 }, G = typeof window > "u" ? !0 : "onscrollend" in window, Q = (l, t, s) => {
124
- const e = l.scrollElement;
125
- if (!e) return;
126
- const n = l.targetWindow;
127
- if (!n) return;
128
- const i = l.options.useScrollendEvent && G;
129
- let o = 0;
130
- const r = i ? null : H(n, () => t(o, !1), l.options.isScrollingResetDelay), h = (u) => () => {
131
- o = s(e), r?.(), t(o, u);
132
- }, a = h(!0), c = h(!1);
133
- return e.addEventListener("scroll", a, M), i && e.addEventListener("scrollend", c, M), () => {
134
- e.removeEventListener("scroll", a), i && e.removeEventListener("scrollend", c);
135
- };
136
- }, X = (l, t) => Q(l, t, (s) => {
137
- const { horizontal: e, isRtl: n } = l.options;
138
- return e ? s.scrollLeft * (n && -1 || 1) : s.scrollTop;
139
- }), Y = (l, t, s) => {
140
- if (s.options.useCachedMeasurements) {
141
- const e = s.indexFromElement(l), n = s.options.getItemKey(e);
142
- return s.itemSizeCache.get(n) ?? s.options.estimateSize(e);
143
- }
144
- if (t?.borderBoxSize) {
145
- const e = t.borderBoxSize[0];
146
- if (e) return Math.round(e[s.options.horizontal ? "inlineSize" : "blockSize"]);
147
- }
148
- if (!t) {
149
- const e = s.indexFromElement(l), n = s.options.getItemKey(e), i = s.itemSizeCache.get(n);
150
- if (i !== void 0) return i;
151
- }
152
- return l[s.options.horizontal ? "offsetWidth" : "offsetHeight"];
153
- }, Z = (l, { adjustments: t = 0, behavior: s }, e) => {
154
- var n, i;
155
- (i = (n = e.scrollElement) == null ? void 0 : n.scrollTo) == null || i.call(n, {
156
- [e.options.horizontal ? "left" : "top"]: l + t,
157
- behavior: s
158
- });
159
- }, tt = Z, et = class {
160
- constructor(l) {
161
- this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollState = null, this.measurementsCache = [], this._flatMeasurements = null, this.itemSizeCache = /* @__PURE__ */ new Map(), this.itemSizeCacheVersion = 0, this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMin = null, this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.pendingScrollAnchor = null, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this._iosDeferredAdjustment = 0, this._iosTouching = !1, this._iosJustTouchEnded = !1, this._iosTouchEndTimerId = null, this._intendedScrollOffset = null, this.elementsCache = /* @__PURE__ */ new Map(), this.now = () => {
162
- var t, s, e;
163
- return ((e = (s = (t = this.targetWindow) == null ? void 0 : t.performance) == null ? void 0 : s.now) == null ? void 0 : e.call(s)) ?? Date.now();
164
- }, this.observer = /* @__PURE__ */ (() => {
165
- let t = null;
166
- const s = () => t || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : t = new this.targetWindow.ResizeObserver((e) => {
167
- e.forEach((n) => {
168
- const i = () => {
169
- const o = n.target, r = this.indexFromElement(o);
170
- if (!o.isConnected) {
171
- this.observer.unobserve(o);
172
- for (const [h, a] of this.elementsCache) if (a === o) {
173
- this.elementsCache.delete(h);
174
- break;
175
- }
176
- return;
177
- }
178
- this.shouldMeasureDuringScroll(r) && this.resizeItem(r, this.options.measureElement(o, n, this));
179
- };
180
- this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(i) : i();
181
- });
182
- }));
183
- return {
184
- disconnect: () => {
185
- var e;
186
- (e = s()) == null || e.disconnect(), t = null;
187
- },
188
- observe: (e) => {
189
- var n;
190
- return (n = s()) == null ? void 0 : n.observe(e, { box: "border-box" });
191
- },
192
- unobserve: (e) => {
193
- var n;
194
- return (n = s()) == null ? void 0 : n.unobserve(e);
195
- }
196
- };
197
- })(), this.range = null, this.setOptions = (t) => {
198
- var s, e;
199
- const n = {
200
- debug: !1,
201
- initialOffset: 0,
202
- overscan: 1,
203
- paddingStart: 0,
204
- paddingEnd: 0,
205
- scrollPaddingStart: 0,
206
- scrollPaddingEnd: 0,
207
- horizontal: !1,
208
- getItemKey: J,
209
- rangeExtractor: q,
210
- onChange: () => {
211
- },
212
- measureElement: Y,
213
- initialRect: {
214
- width: 0,
215
- height: 0
216
- },
217
- scrollMargin: 0,
218
- gap: 0,
219
- indexAttribute: "data-index",
220
- initialMeasurementsCache: [],
221
- lanes: 1,
222
- anchorTo: "start",
223
- followOnAppend: !1,
224
- scrollEndThreshold: 1,
225
- isScrollingResetDelay: 150,
226
- enabled: !0,
227
- isRtl: !1,
228
- useScrollendEvent: !1,
229
- useAnimationFrameWithResizeObserver: !1,
230
- laneAssignmentMode: "estimate",
231
- useCachedMeasurements: !1
232
- };
233
- for (const u in t) {
234
- const f = t[u];
235
- f !== void 0 && (n[u] = f);
236
- }
237
- const i = this.options;
238
- let o = null, r = null, h = !1;
239
- if (i !== void 0 && i.enabled && n.enabled && n.anchorTo === "end" && this.scrollElement !== null) {
240
- const u = i.count, f = n.count, d = this.getMeasurements(), p = u > 0 ? ((s = d[0]) == null ? void 0 : s.key) ?? i.getItemKey(0) : null, g = u > 0 ? ((e = d[u - 1]) == null ? void 0 : e.key) ?? i.getItemKey(u - 1) : null;
241
- if (f !== u || u > 0 && f > 0 && (n.getItemKey(0) !== p || n.getItemKey(f - 1) !== g)) {
242
- h = !0;
243
- const m = u > 0 ? this.getVirtualItemForOffset(this.getScrollOffset()) ?? d[0] : null;
244
- m && (o = [m.key, this.getScrollOffset() - m.start]);
245
- const v = n.followOnAppend === !0 ? "auto" : n.followOnAppend || null;
246
- v && f > u && this.isAtEnd(i.scrollEndThreshold) && (u === 0 || n.getItemKey(f - 1) !== g) && (r = v);
247
- }
248
- }
249
- this.options = n, h && (this.pendingMin = 0, this.itemSizeCacheVersion++);
250
- let a = !1, c = 0;
251
- if (o && this.scrollOffset !== null) {
252
- const [u, f] = o, d = this.getMeasurements(), { count: p, getItemKey: g } = this.options;
253
- let m = 0;
254
- for (; m < p && g(m) !== u; ) m++;
255
- if (m < p) {
256
- const v = d[m];
257
- if (v) {
258
- const S = v.start + f;
259
- S !== this.scrollOffset && (c = S - this.scrollOffset, this.scrollOffset = S, a = !0);
260
- }
261
- }
262
- }
263
- (a || r) && (this.pendingScrollAnchor = [
264
- a ? o[0] : null,
265
- a ? o[1] : 0,
266
- r,
267
- c
268
- ]);
269
- }, this.notify = (t) => {
270
- var s, e;
271
- (e = (s = this.options).onChange) == null || e.call(s, this, t);
272
- }, this.maybeNotify = y(() => (this.calculateRange(), [
273
- this.isScrolling,
274
- this.range ? this.range.startIndex : null,
275
- this.range ? this.range.endIndex : null
276
- ]), (t) => {
277
- this.notify(t);
278
- }, {
279
- key: process.env.NODE_ENV !== "production" && "maybeNotify",
280
- debug: () => this.options.debug,
281
- initialDeps: [
282
- this.isScrolling,
283
- this.range ? this.range.startIndex : null,
284
- this.range ? this.range.endIndex : null
285
- ]
286
- }), this.cleanup = () => {
287
- this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.observer.disconnect(), this.rafId != null && this.targetWindow && (this.targetWindow.cancelAnimationFrame(this.rafId), this.rafId = null), this.scrollState = null, this.scrollElement = null, this.targetWindow = null;
288
- }, this._didMount = () => () => {
289
- this.cleanup();
290
- }, this._willUpdate = () => {
291
- var t;
292
- const s = this.options.enabled ? this.options.getScrollElement() : null;
293
- if (this.scrollElement !== s) {
294
- if (this.cleanup(), !s) {
295
- this.maybeNotify();
296
- return;
297
- }
298
- if (this.scrollElement = s, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((t = this.scrollElement) == null ? void 0 : t.window) ?? null, this.elementsCache.forEach((n) => {
299
- this.observer.observe(n);
300
- }), this.unsubs.push(this.options.observeElementRect(this, (n) => {
301
- this.scrollRect = n, this.maybeNotify();
302
- })), this.unsubs.push(this.options.observeElementOffset(this, (n, i) => {
303
- if (i && this._intendedScrollOffset === null && n === this.scrollOffset) return;
304
- this._intendedScrollOffset !== null && Math.abs(n - this._intendedScrollOffset) < 1.5 && (n = this._intendedScrollOffset), this._intendedScrollOffset = null, this.scrollAdjustments = 0;
305
- const o = this.getScrollOffset();
306
- this.scrollDirection = i ? o === n ? this.scrollDirection : o < n ? "forward" : "backward" : null, this.scrollOffset = n, this.isScrolling = i, this._flushIosDeferredIfReady(), this.scrollState && this.scheduleScrollReconcile(), this.maybeNotify();
307
- })), "addEventListener" in this.scrollElement) {
308
- const n = this.scrollElement, i = () => {
309
- this._iosTouching = !0, this._iosJustTouchEnded = !1, this._iosTouchEndTimerId !== null && this.targetWindow != null && (this.targetWindow.clearTimeout(this._iosTouchEndTimerId), this._iosTouchEndTimerId = null);
310
- }, o = () => {
311
- this._iosTouching = !1, !(!T() || this.targetWindow == null) && (this._iosJustTouchEnded = !0, this._iosTouchEndTimerId = this.targetWindow.setTimeout(() => {
312
- this._iosJustTouchEnded = !1, this._iosTouchEndTimerId = null, this._flushIosDeferredIfReady();
313
- }, 150));
314
- };
315
- n.addEventListener("touchstart", i, M), n.addEventListener("touchend", o, M), this.unsubs.push(() => {
316
- n.removeEventListener("touchstart", i), n.removeEventListener("touchend", o), this._iosTouchEndTimerId !== null && this.targetWindow != null && (this.targetWindow.clearTimeout(this._iosTouchEndTimerId), this._iosTouchEndTimerId = null);
317
- });
318
- }
319
- this._scrollToOffset(this.getScrollOffset(), {
320
- adjustments: void 0,
321
- behavior: void 0
322
- });
323
- }
324
- const e = this.pendingScrollAnchor;
325
- if (this.pendingScrollAnchor = null, e && this.scrollElement && this.options.enabled) {
326
- const [n, i, o, r] = e;
327
- n !== null && !o && (T() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded) ? r !== 0 && (this._iosDeferredAdjustment += r) : this._scrollToOffset(this.getScrollOffset(), {
328
- adjustments: void 0,
329
- behavior: void 0
330
- })), o && this.scrollToEnd({ behavior: o });
331
- }
332
- }, this._flushIosDeferredIfReady = () => {
333
- if (this._iosDeferredAdjustment === 0 || this.isScrolling || this._iosTouching || this._iosJustTouchEnded) return;
334
- const t = this.getScrollOffset(), s = this.getMaxScrollOffset();
335
- if (t < 0 || t > s) return;
336
- const e = this._iosDeferredAdjustment;
337
- this._iosDeferredAdjustment = 0, this._scrollToOffset(t, {
338
- adjustments: this.scrollAdjustments += e,
339
- behavior: void 0
340
- });
341
- }, this.rafId = null, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (t, s) => {
342
- const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
343
- for (let i = s - 1; i >= 0; i--) {
344
- const o = t[i];
345
- if (e.has(o.lane)) continue;
346
- const r = n.get(o.lane);
347
- if (r == null || o.end > r.end ? n.set(o.lane, o) : o.end < r.end && e.set(o.lane, !0), e.size === this.options.lanes) break;
348
- }
349
- return n.size === this.options.lanes ? Array.from(n.values()).sort((i, o) => i.end === o.end ? i.index - o.index : i.end - o.end)[0] : void 0;
350
- }, this.getMeasurementOptions = y(() => [
351
- this.options.count,
352
- this.options.paddingStart,
353
- this.options.scrollMargin,
354
- this.options.getItemKey,
355
- this.options.enabled,
356
- this.options.lanes,
357
- this.options.laneAssignmentMode
358
- ], (t, s, e, n, i, o, r) => (this.prevLanes !== void 0 && this.prevLanes !== o && (this.lanesChangedFlag = !0), this.prevLanes = o, this.pendingMin = null, {
359
- count: t,
360
- paddingStart: s,
361
- scrollMargin: e,
362
- getItemKey: n,
363
- enabled: i,
364
- lanes: o,
365
- laneAssignmentMode: r
366
- }), { key: !1 }), this.getMeasurements = y(() => [this.getMeasurementOptions(), this.itemSizeCacheVersion], ({ count: t, paddingStart: s, scrollMargin: e, getItemKey: n, enabled: i, lanes: o, laneAssignmentMode: r }, h) => {
367
- const a = this.itemSizeCache;
368
- if (!i)
369
- return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
370
- if (this.laneAssignments.size > t)
371
- for (const d of this.laneAssignments.keys()) d >= t && this.laneAssignments.delete(d);
372
- this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMin = null), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((d) => {
373
- this.itemSizeCache.set(d.key, d.size);
374
- }));
375
- const c = this.lanesSettling ? 0 : this.pendingMin ?? 0;
376
- if (this.pendingMin = null, this.lanesSettling && this.measurementsCache.length === t && (this.lanesSettling = !1), o === 1) {
377
- const d = this.options.gap, p = t * 2;
378
- let g = this._flatMeasurements;
379
- if (!g || g.length < p) {
380
- const S = new Float64Array(p);
381
- g && c > 0 && S.set(g.subarray(0, c * 2)), g = S, this._flatMeasurements = g;
382
- }
383
- let m;
384
- if (c === 0) m = s + e;
385
- else {
386
- const S = c - 1;
387
- m = g[S * 2] + g[S * 2 + 1] + d;
388
- }
389
- for (let S = c; S < t; S++) {
390
- const b = n(S), O = a.get(b), z = typeof O == "number" ? O : this.options.estimateSize(S);
391
- g[S * 2] = m, g[S * 2 + 1] = z, m += z + d;
392
- }
393
- const v = $(t, g, n);
394
- return this.measurementsCache = v, v;
395
- }
396
- const u = this.measurementsCache.slice(0, c), f = new Array(o).fill(void 0);
397
- for (let d = 0; d < c; d++) {
398
- const p = u[d];
399
- p && (f[p.lane] = d);
400
- }
401
- for (let d = c; d < t; d++) {
402
- const p = n(d), g = this.laneAssignments.get(d);
403
- let m, v;
404
- const S = r === "estimate" || a.has(p);
405
- if (g !== void 0 && this.options.lanes > 1) {
406
- m = g;
407
- const x = f[m], A = x !== void 0 ? u[x] : void 0;
408
- v = A ? A.end + this.options.gap : s + e;
409
- } else {
410
- const x = this.options.lanes === 1 ? u[d - 1] : this.getFurthestMeasurement(u, d);
411
- v = x ? x.end + this.options.gap : s + e, m = x ? x.lane : d % this.options.lanes, this.options.lanes > 1 && S && this.laneAssignments.set(d, m);
412
- }
413
- const b = a.get(p), O = typeof b == "number" ? b : this.options.estimateSize(d), z = v + O;
414
- u[d] = {
415
- index: d,
416
- start: v,
417
- size: O,
418
- end: z,
419
- key: p,
420
- lane: m
421
- }, f[m] = d;
422
- }
423
- return this.measurementsCache = u, u;
424
- }, {
425
- key: process.env.NODE_ENV !== "production" && "getMeasurements",
426
- debug: () => this.options.debug
427
- }), this.calculateRange = y(() => [
428
- this.getMeasurements(),
429
- this.getSize(),
430
- this.getScrollOffset(),
431
- this.options.lanes
432
- ], (t, s, e, n) => t.length === 0 || s === 0 ? (this.range = null, null) : (this.range = nt(t, s, e, n, n === 1 && this._flatMeasurements != null ? this._flatMeasurements : null), this.range), {
433
- key: process.env.NODE_ENV !== "production" && "calculateRange",
434
- debug: () => this.options.debug
435
- }), this.getVirtualIndexes = y(() => {
436
- let t = null, s = null;
437
- const e = this.calculateRange();
438
- return e && (t = e.startIndex, s = e.endIndex), this.maybeNotify.updateDeps([
439
- this.isScrolling,
440
- t,
441
- s
442
- ]), [
443
- this.options.rangeExtractor,
444
- this.options.overscan,
445
- this.options.count,
446
- t,
447
- s
448
- ];
449
- }, (t, s, e, n, i) => n === null || i === null ? [] : t({
450
- startIndex: n,
451
- endIndex: i,
452
- overscan: s,
453
- count: e
454
- }), {
455
- key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
456
- debug: () => this.options.debug
457
- }), this.indexFromElement = (t) => {
458
- const s = this.options.indexAttribute, e = t.getAttribute(s);
459
- return e ? parseInt(e, 10) : (console.warn(`Missing attribute name '${s}={index}' on measured element.`), -1);
460
- }, this.shouldMeasureDuringScroll = (t) => {
461
- var s;
462
- if (!this.scrollState || this.scrollState.behavior !== "smooth") return !0;
463
- const e = this.scrollState.index ?? ((s = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : s.index);
464
- if (e !== void 0 && this.range) {
465
- const n = Math.max(this.options.overscan, Math.ceil((this.range.endIndex - this.range.startIndex) / 2)), i = Math.max(0, e - n), o = Math.min(this.options.count - 1, e + n);
466
- return t >= i && t <= o;
467
- }
468
- return !0;
469
- }, this.measureElement = (t) => {
470
- if (!t) {
471
- this.elementsCache.forEach((i, o) => {
472
- i.isConnected || (this.observer.unobserve(i), this.elementsCache.delete(o));
473
- });
474
- return;
475
- }
476
- const s = this.indexFromElement(t), e = this.options.getItemKey(s), n = this.elementsCache.get(e);
477
- n !== t && (n && this.observer.unobserve(n), this.observer.observe(t), this.elementsCache.set(e, t)), (!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(s) && this.resizeItem(s, this.options.measureElement(t, void 0, this));
478
- }, this.resizeItem = (t, s) => {
479
- var e, n;
480
- if (t < 0 || t >= this.options.count) return;
481
- let i, o, r;
482
- const h = this._flatMeasurements;
483
- if (this.options.lanes === 1 && h !== null)
484
- r = this.options.getItemKey(t), o = h[t * 2], i = h[t * 2 + 1];
485
- else {
486
- const c = this.measurementsCache[t];
487
- if (!c) return;
488
- r = c.key, o = c.start, i = c.size;
489
- }
490
- const a = s - (this.itemSizeCache.get(r) ?? i);
491
- if (a !== 0) {
492
- const c = this.options.anchorTo === "end" && ((e = this.scrollState) == null ? void 0 : e.behavior) !== "smooth" && this.getVirtualDistanceFromEnd() <= this.options.scrollEndThreshold, u = c ? this.getTotalSize() : 0, f = ((n = this.scrollState) == null ? void 0 : n.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t] ?? {
493
- index: t,
494
- key: r,
495
- start: o,
496
- size: i,
497
- end: o + i,
498
- lane: 0
499
- }, a, this) : o < this.getScrollOffset() + this.scrollAdjustments && (!this.itemSizeCache.has(r) || this.scrollDirection !== "backward"));
500
- (this.pendingMin === null || t < this.pendingMin) && (this.pendingMin = t), this.itemSizeCache.set(r, s), this.itemSizeCacheVersion++, c ? this.applyScrollAdjustment(this.getTotalSize() - u) : f && this.applyScrollAdjustment(a), this.notify(!1);
501
- }
502
- }, this.getVirtualItems = y(() => [this.getVirtualIndexes(), this.getMeasurements()], (t, s) => {
503
- const e = [];
504
- for (let n = 0, i = t.length; n < i; n++) {
505
- const o = s[t[n]];
506
- e.push(o);
507
- }
508
- return e;
509
- }, {
510
- key: process.env.NODE_ENV !== "production" && "getVirtualItems",
511
- debug: () => this.options.debug
512
- }), this.getVirtualItemForOffset = (t) => {
513
- const s = this.getMeasurements();
514
- if (s.length === 0) return;
515
- const e = this._flatMeasurements, n = this.options.lanes === 1 && e != null;
516
- return F(s[D(0, s.length - 1, n ? (i) => e[i * 2] : (i) => F(s[i]).start, t)]);
517
- }, this.getMaxScrollOffset = () => {
518
- if (!this.scrollElement) return 0;
519
- if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
520
- {
521
- const t = this.scrollElement.document.documentElement;
522
- return this.options.horizontal ? t.scrollWidth - this.scrollElement.innerWidth : t.scrollHeight - this.scrollElement.innerHeight;
523
- }
524
- }, this.getVirtualDistanceFromEnd = () => Math.max(this.getTotalSize() - this.getSize() - this.getScrollOffset(), 0), this.getDistanceFromEnd = () => Math.max(this.getMaxScrollOffset() - this.getScrollOffset(), 0), this.isAtEnd = (t = this.options.scrollEndThreshold) => this.getDistanceFromEnd() <= t, this.getOffsetForAlignment = (t, s, e = 0) => {
525
- if (!this.scrollElement) return 0;
526
- const n = this.getSize(), i = this.getScrollOffset();
527
- s === "auto" && (s = t >= i + n ? "end" : "start"), s === "center" ? t += (e - n) / 2 : s === "end" && (t -= n);
528
- const o = this.getMaxScrollOffset();
529
- return Math.max(Math.min(o, t), 0);
530
- }, this.getOffsetForIndex = (t, s = "auto") => {
531
- t = Math.max(0, Math.min(t, this.options.count - 1));
532
- const e = this.getSize(), n = this.getScrollOffset(), i = this.measurementsCache[t];
533
- if (!i) return;
534
- if (s === "auto") if (i.end >= n + e - this.options.scrollPaddingEnd) s = "end";
535
- else if (i.start <= n + this.options.scrollPaddingStart) s = "start";
536
- else return [n, s];
537
- if (s === "end" && t === this.options.count - 1) return [this.getMaxScrollOffset(), s];
538
- const o = s === "end" ? i.end + this.options.scrollPaddingEnd : i.start - this.options.scrollPaddingStart;
539
- return [this.getOffsetForAlignment(o, s, i.size), s];
540
- }, this.scrollToOffset = (t, { align: s = "start", behavior: e = "auto" } = {}) => {
541
- const n = this.getOffsetForAlignment(t, s), i = this.now();
542
- this.scrollState = {
543
- index: null,
544
- align: s,
545
- behavior: e,
546
- startedAt: i,
547
- lastTargetOffset: n,
548
- stableFrames: 0
549
- }, this._scrollToOffset(n, {
550
- adjustments: void 0,
551
- behavior: e
552
- }), this.scheduleScrollReconcile();
553
- }, this.scrollToIndex = (t, { align: s = "auto", behavior: e = "auto" } = {}) => {
554
- t = Math.max(0, Math.min(t, this.options.count - 1));
555
- const n = this.getOffsetForIndex(t, s);
556
- if (!n) return;
557
- const [i, o] = n, r = this.now();
558
- this.scrollState = {
559
- index: t,
560
- align: o,
561
- behavior: e,
562
- startedAt: r,
563
- lastTargetOffset: i,
564
- stableFrames: 0
565
- }, this._scrollToOffset(i, {
566
- adjustments: void 0,
567
- behavior: e
568
- }), this.scheduleScrollReconcile();
569
- }, this.scrollBy = (t, { behavior: s = "auto" } = {}) => {
570
- const e = this.getScrollOffset() + t, n = this.now();
571
- this.scrollState = {
572
- index: null,
573
- align: "start",
574
- behavior: s,
575
- startedAt: n,
576
- lastTargetOffset: e,
577
- stableFrames: 0
578
- }, this._scrollToOffset(e, {
579
- adjustments: void 0,
580
- behavior: s
581
- }), this.scheduleScrollReconcile();
582
- }, this.scrollToEnd = ({ behavior: t = "auto" } = {}) => {
583
- if (this.options.count > 0) {
584
- this.scrollToIndex(this.options.count - 1, {
585
- align: "end",
586
- behavior: t
587
- });
588
- return;
589
- }
590
- this.scrollToOffset(Math.max(this.getTotalSize() - this.getSize(), 0), { behavior: t });
591
- }, this.getTotalSize = () => {
592
- var t;
593
- const s = this.getMeasurements();
594
- let e;
595
- if (s.length === 0) e = this.options.paddingStart;
596
- else if (this.options.lanes === 1) {
597
- const n = s.length - 1, i = this._flatMeasurements;
598
- i != null ? e = i[n * 2] + i[n * 2 + 1] : e = ((t = s[n]) == null ? void 0 : t.end) ?? 0;
599
- } else {
600
- const n = Array(this.options.lanes).fill(null);
601
- let i = s.length - 1;
602
- for (; i >= 0 && n.some((o) => o === null); ) {
603
- const o = s[i];
604
- n[o.lane] === null && (n[o.lane] = o.end), i--;
605
- }
606
- e = Math.max(...n.filter((o) => o !== null));
607
- }
608
- return Math.max(e - this.options.scrollMargin + this.options.paddingEnd, 0);
609
- }, this.takeSnapshot = () => {
610
- const t = [];
611
- if (this.itemSizeCache.size === 0) return t;
612
- const s = this.getMeasurements();
613
- for (const e of s) e && this.itemSizeCache.has(e.key) && t.push({
614
- index: e.index,
615
- key: e.key,
616
- start: e.start,
617
- size: e.size,
618
- end: e.end,
619
- lane: e.lane
620
- });
621
- return t;
622
- }, this._scrollToOffset = (t, { adjustments: s, behavior: e }) => {
623
- this._intendedScrollOffset = t + (s ?? 0), this.options.scrollToFn(t, {
624
- behavior: e,
625
- adjustments: s
626
- }, this);
627
- }, this.measure = () => {
628
- this.pendingMin = null, this.itemSizeCache.clear(), this.laneAssignments.clear(), this.itemSizeCacheVersion++, this.notify(!1);
629
- }, this.setOptions(l);
630
- }
631
- applyScrollAdjustment(l, t) {
632
- l !== 0 && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", l), T() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded) ? this._iosDeferredAdjustment += l : (this._scrollToOffset(this.getScrollOffset(), {
633
- adjustments: this.scrollAdjustments += l,
634
- behavior: t
635
- }), this.scrollOffset !== null && (this.scrollOffset += this.scrollAdjustments, this.scrollAdjustments = 0)));
636
- }
637
- scheduleScrollReconcile() {
638
- if (!this.targetWindow) {
639
- this.scrollState = null;
640
- return;
641
- }
642
- this.rafId == null && (this.rafId = this.targetWindow.requestAnimationFrame(() => {
643
- this.rafId = null, this.reconcileScroll();
644
- }));
645
- }
646
- reconcileScroll() {
647
- if (!this.scrollState || !this.scrollElement) return;
648
- if (this.now() - this.scrollState.startedAt > 5e3) {
649
- this.scrollState = null;
650
- return;
651
- }
652
- const l = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0, t = l ? l[0] : this.scrollState.lastTargetOffset, s = 1, e = t !== this.scrollState.lastTargetOffset;
653
- if (!e && B(t, this.getScrollOffset())) {
654
- if (this.scrollState.stableFrames++, this.scrollState.stableFrames >= s) {
655
- this.getScrollOffset() !== t && this._scrollToOffset(t, {
656
- adjustments: void 0,
657
- behavior: "auto"
658
- }), this.scrollState = null;
659
- return;
660
- }
661
- } else if (this.scrollState.stableFrames = 0, e) {
662
- const n = this.getSize() || 600, i = Math.abs(t - this.getScrollOffset()), o = this.scrollState.behavior === "smooth" && i > n;
663
- this.scrollState.lastTargetOffset = t, o || (this.scrollState.behavior = "auto"), this._scrollToOffset(t, {
664
- adjustments: void 0,
665
- behavior: o ? "smooth" : "auto"
666
- });
667
- }
668
- this.scheduleScrollReconcile();
669
- }
670
- }, D = (l, t, s, e) => {
671
- for (; l <= t; ) {
672
- const n = (l + t) / 2 | 0, i = s(n);
673
- if (i < e) l = n + 1;
674
- else if (i > e) t = n - 1;
675
- else return n;
676
- }
677
- return l > 0 ? l - 1 : 0;
678
- };
679
- function st(l, t, s) {
680
- let e = 0;
681
- for (; e <= t; ) {
682
- const n = (e + t) / 2 | 0, i = l[n * 2];
683
- if (i < s) e = n + 1;
684
- else if (i > s) t = n - 1;
685
- else return n;
686
- }
687
- return e > 0 ? e - 1 : 0;
688
- }
689
- function nt(l, t, s, e, n) {
690
- const i = l.length - 1;
691
- if (l.length <= e) return {
692
- startIndex: 0,
693
- endIndex: i
694
- };
695
- if (e === 1 && n !== null) {
696
- const a = st(n, i, s);
697
- let c = a;
698
- const u = s + t;
699
- for (; c < i && n[c * 2] + n[c * 2 + 1] < u; ) c++;
700
- return {
701
- startIndex: a,
702
- endIndex: c
703
- };
704
- }
705
- let r = D(0, i, (a) => l[a].start, s), h = r;
706
- if (e === 1) for (; h < i && l[h].end < s + t; ) h++;
707
- else if (e > 1) {
708
- const a = Array(e).fill(0);
709
- for (; h < i && a.some((u) => u < s + t); ) {
710
- const u = l[h];
711
- a[u.lane] = u.end, h++;
712
- }
713
- const c = Array(e).fill(s + t);
714
- for (; r >= 0 && c.some((u) => u >= s); ) {
715
- const u = l[r];
716
- c[u.lane] = u.start, r--;
717
- }
718
- r = Math.max(0, r - r % e), h = Math.min(i, h + (e - 1 - h % e));
719
- }
720
- return {
721
- startIndex: r,
722
- endIndex: h
723
- };
724
- }
725
- var _ = typeof document < "u" ? w.useLayoutEffect : w.useEffect;
726
- function it({ useFlushSync: l = !0, directDomUpdates: t = !1, directDomUpdatesMode: s = "transform", ...e }) {
727
- const n = w.useReducer((a) => a + 1, 0)[1], i = w.useRef({
728
- enabled: t,
729
- mode: s,
730
- container: null,
731
- lastSize: null,
732
- lastPositions: /* @__PURE__ */ new WeakMap(),
733
- prevRange: null
734
- });
735
- i.current.enabled = t, i.current.mode = s;
736
- const o = (a) => {
737
- const c = i.current;
738
- if (!c.enabled || !c.container) return;
739
- const u = a.getTotalSize();
740
- if (u !== c.lastSize) {
741
- c.lastSize = u;
742
- const v = a.options.horizontal ? "width" : "height";
743
- c.container.style[v] = `${u}px`;
744
- }
745
- const f = !!a.options.horizontal, d = c.mode === "transform", p = f ? "left" : "top", g = a.options.scrollMargin, m = a.getVirtualItems();
746
- for (const v of m) {
747
- const S = v.start - g, b = a.elementsCache.get(v.key);
748
- b && c.lastPositions.get(b) !== S && (c.lastPositions.set(b, S), d ? b.style.transform = f ? `translate3d(${S}px, 0, 0)` : `translate3d(0, ${S}px, 0)` : b.style[p] = `${S}px`);
749
- }
750
- }, r = {
751
- ...e,
752
- onChange: (a, c) => {
753
- var u;
754
- const f = i.current;
755
- let d = !0;
756
- if (f.enabled) {
757
- o(a);
758
- const p = a.range, g = f.prevRange;
759
- d = !g || g.isScrolling !== a.isScrolling || g.startIndex !== p?.startIndex || g.endIndex !== p?.endIndex, d && (f.prevRange = p ? {
760
- startIndex: p.startIndex,
761
- endIndex: p.endIndex,
762
- isScrolling: a.isScrolling
763
- } : null);
764
- }
765
- d && (l && c ? P(n) : n()), (u = e.onChange) == null || u.call(e, a, c);
766
- }
767
- }, [h] = w.useState(() => {
768
- const a = new et(r);
769
- return Object.assign(a, { containerRef: (c) => {
770
- const u = i.current;
771
- if (u.container = c, u.lastSize = null, c && u.enabled) {
772
- const f = a.getTotalSize();
773
- u.lastSize = f;
774
- const d = a.options.horizontal ? "width" : "height";
775
- c.style[d] = `${f}px`;
776
- }
777
- } });
778
- });
779
- return h.setOptions(r), _(() => h._didMount(), []), _(() => h._willUpdate()), _(() => {
780
- o(h);
781
- }), h;
782
- }
783
- function ot(l) {
784
- return it({
785
- observeElementRect: U,
786
- observeElementOffset: X,
787
- scrollToFn: tt,
788
- ...l
789
- });
790
- }
791
- var ft = ({ showFlagOnSearch: l, showNameOnSearch: t }) => {
792
- const s = L(null), { termOfSearch: e, countries: n, handleSelectCountry: i } = N(), o = j(() => n.filter((h) => h.name.toLocaleLowerCase().includes(e.toLowerCase())), [e]), r = ot({
793
- count: o.length,
794
- overscan: 5,
795
- getScrollElement: () => s.current,
796
- estimateSize: () => 40
797
- });
798
- return W(() => {
799
- o.length > 0 && r.scrollToIndex(0);
800
- }, [e, r]), o.length === 0 ? /* @__PURE__ */ E("div", {
801
- className: "overflow-y-auto max-h-60 snap-y snap-mandatory",
802
- children: /* @__PURE__ */ E("ul", {
803
- className: "relative",
804
- children: /* @__PURE__ */ E("li", {
805
- className: "w-full flex items-center h-10 select-none px-6",
806
- children: /* @__PURE__ */ E(R, {
807
- variant: "body2",
808
- component: "span",
809
- className: "flex gap-2 items-center text-left",
810
- children: "No options"
811
- })
812
- })
813
- })
814
- }) : /* @__PURE__ */ E("div", {
815
- ref: s,
816
- className: "overflow-y-auto max-h-60 snap-y snap-mandatory scrollbar",
817
- children: /* @__PURE__ */ E("ul", {
818
- className: "relative",
819
- style: { height: r.getTotalSize() },
820
- children: r.getVirtualItems().map((h) => {
821
- const a = o[h.index], { flag: c, name: u, prefix: f } = a;
822
- return /* @__PURE__ */ E("li", {
823
- className: C("absolute", "w-full", "snap-start", "snap-always", "scroll-m-0", "flex", "items-center", "h-10"),
824
- style: {
825
- top: h.start,
826
- height: h.size
827
- },
828
- children: /* @__PURE__ */ E("button", {
829
- className: C("w-full", "h-full", "cursor-pointer", "px-6", "hover:bg-gray-50", "transition-colors", "duration-150", "focus-visible:outline-0", "hover:outline-gray-100", "focus:bg-gray-50", "dark:hover:bg-metal-700"),
830
- onClick: () => i(a),
831
- children: /* @__PURE__ */ K(R, {
832
- variant: "body2",
833
- component: "span",
834
- className: "flex gap-2 items-center text-left",
835
- children: [l && /* @__PURE__ */ E(c, {}), t && /* @__PURE__ */ E(V, {
836
- text: u,
837
- prefix: f
838
- })]
839
- })
840
- })
841
- }, h.key);
842
- })
843
- })
844
- });
845
- };
846
- export {
847
- ft as t
848
- };