mimir-ui-kit 1.10.0 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/README.md +62 -62
  2. package/dist/DatePickerModal-DUUCHAWF.js +204 -0
  3. package/dist/{NavigationButtons-B8tMfqrg.js → NavigationButtons-DuOoqaPo.js} +20 -20
  4. package/dist/assets/Button.css +1 -1
  5. package/dist/assets/DatePickerModal.css +1 -0
  6. package/dist/assets/Drawer.css +1 -0
  7. package/dist/assets/Input.css +1 -1
  8. package/dist/assets/MergedButton.css +1 -1
  9. package/dist/assets/OtpInput.css +1 -1
  10. package/dist/assets/RadioGroup.css +1 -1
  11. package/dist/assets/SelectSearch.css +1 -0
  12. package/dist/assets/Slider.css +1 -1
  13. package/dist/assets/Switch.css +1 -0
  14. package/dist/assets/Tag.css +1 -0
  15. package/dist/assets/Timer.css +1 -0
  16. package/dist/assets/index.css +1 -1
  17. package/dist/components/Button/Button.d.ts +0 -1
  18. package/dist/components/Button/Button.js +25 -25
  19. package/dist/components/DatePicker/DatePicker.d.ts +44 -0
  20. package/dist/components/DatePicker/DatePicker.js +69 -0
  21. package/dist/components/DatePicker/DatePickerModal.d.ts +8 -0
  22. package/dist/components/DatePicker/DatePickerModal.js +9 -0
  23. package/dist/components/DatePicker/constants.d.ts +6 -0
  24. package/dist/components/DatePicker/constants.js +11 -0
  25. package/dist/components/DatePicker/index.d.ts +2 -0
  26. package/dist/components/DatePicker/index.js +4 -0
  27. package/dist/components/Drawer/Drawer.d.ts +38 -0
  28. package/dist/components/Drawer/Drawer.js +144 -0
  29. package/dist/components/Drawer/constants.d.ts +5 -0
  30. package/dist/components/Drawer/constants.js +9 -0
  31. package/dist/components/Drawer/index.d.ts +2 -0
  32. package/dist/components/Drawer/index.js +6 -0
  33. package/dist/components/Input/Input.d.ts +2 -2
  34. package/dist/components/Input/Input.js +17 -16
  35. package/dist/components/InputPassword/InputPassword.js +2 -2
  36. package/dist/components/InputPhoneNumber/InputPhoneNumber.js +1 -1
  37. package/dist/components/MergedButton/MergedButton.d.ts +1 -1
  38. package/dist/components/MergedButton/MergedButton.js +17 -19
  39. package/dist/components/OtpInput/OtpInput.js +6 -6
  40. package/dist/components/Portal/Portal.d.ts +7 -0
  41. package/dist/components/Portal/Portal.js +10 -0
  42. package/dist/components/Portal/index.d.ts +1 -0
  43. package/dist/components/Portal/index.js +4 -0
  44. package/dist/components/RadioGroup/RadioGroup.d.ts +18 -2
  45. package/dist/components/RadioGroup/RadioGroup.js +127 -1061
  46. package/dist/components/RadioGroup/index.d.ts +1 -1
  47. package/dist/components/SelectSearch/SelectSearch.d.ts +15 -0
  48. package/dist/components/SelectSearch/SelectSearch.js +3961 -0
  49. package/dist/components/SelectSearch/constants.d.ts +4 -0
  50. package/dist/components/SelectSearch/constants.js +8 -0
  51. package/dist/components/SelectSearch/index.d.ts +2 -0
  52. package/dist/components/SelectSearch/index.js +6 -0
  53. package/dist/components/Slider/NavigationButtons/NavigationButtons.js +1 -1
  54. package/dist/components/Slider/NavigationButtons/index.js +1 -1
  55. package/dist/components/Slider/Slider.js +10 -10
  56. package/dist/components/Switch/Switch.d.ts +294 -0
  57. package/dist/components/Switch/Switch.js +57 -0
  58. package/dist/components/Switch/index.d.ts +2 -0
  59. package/dist/components/Switch/index.js +4 -0
  60. package/dist/components/Tag/Tag.d.ts +19 -57
  61. package/dist/components/Tag/Tag.js +39 -84
  62. package/dist/components/Tag/constants.d.ts +5 -37
  63. package/dist/components/Tag/constants.js +13 -53
  64. package/dist/components/Tag/index.d.ts +2 -3
  65. package/dist/components/Tag/index.js +5 -6
  66. package/dist/components/Tag/types.d.ts +0 -6
  67. package/dist/components/Timer/Timer.d.ts +24 -0
  68. package/dist/components/Timer/Timer.js +29 -0
  69. package/dist/components/Timer/index.d.ts +1 -0
  70. package/dist/components/Timer/index.js +4 -0
  71. package/dist/components/index.d.ts +11 -1
  72. package/dist/components/index.js +19 -0
  73. package/dist/focus-management-CFDo6ZSc.js +91 -0
  74. package/dist/hooks/index.d.ts +3 -0
  75. package/dist/hooks/index.js +7 -1
  76. package/dist/hooks/useClickOutside/index.d.ts +1 -0
  77. package/dist/hooks/useClickOutside/index.js +4 -0
  78. package/dist/hooks/useClickOutside/useClickOutside.d.ts +7 -0
  79. package/dist/hooks/useClickOutside/useClickOutside.js +25 -0
  80. package/dist/hooks/useInterval/index.d.ts +1 -0
  81. package/dist/hooks/useInterval/index.js +4 -0
  82. package/dist/hooks/useInterval/useInterval.d.ts +1 -0
  83. package/dist/hooks/useInterval/useInterval.js +17 -0
  84. package/dist/hooks/useLockBodyScroll/index.d.ts +1 -0
  85. package/dist/hooks/useLockBodyScroll/index.js +4 -0
  86. package/dist/hooks/useLockBodyScroll/useLockBodyScroll.d.ts +6 -0
  87. package/dist/hooks/useLockBodyScroll/useLockBodyScroll.js +20 -0
  88. package/dist/hooks/useTimer/index.d.ts +18 -0
  89. package/dist/hooks/useTimer/index.js +83 -0
  90. package/dist/hooks/useTimer/useTimer.d.ts +18 -0
  91. package/dist/hooks/useTimer/useTimer.js +87 -0
  92. package/dist/hooks/useTimer/utils.d.ts +24 -0
  93. package/dist/hooks/useTimer/utils.js +88 -0
  94. package/dist/index.d.ts +1 -0
  95. package/dist/index.js +28 -1
  96. package/dist/label-BXAcSLy0.js +913 -0
  97. package/dist/use-active-press-9MCrfRZk.js +31 -0
  98. package/dist/utils/formating/Date.d.ts +1 -0
  99. package/dist/utils/formating/Date.js +26 -0
  100. package/dist/utils/formating/Month.d.ts +8 -0
  101. package/dist/utils/formating/Month.js +80 -0
  102. package/dist/utils/formating/Numbers.d.ts +6 -0
  103. package/dist/utils/formating/Numbers.js +8 -0
  104. package/dist/utils/index.d.ts +9 -0
  105. package/dist/utils/index.js +11 -0
  106. package/package.json +128 -128
@@ -0,0 +1,3961 @@
1
+ import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import * as React from "react";
4
+ import React__default, { useReducer, useMemo, useSyncExternalStore, useId as useId$1, useEffect, useCallback, useRef, useState, useLayoutEffect, createContext, useContext, Fragment, createRef, forwardRef } from "react";
5
+ import { ESelectSearchSize } from "./constants.js";
6
+ import { useMediaQuery } from "../../hooks/useMediaQuery/useMediaQuery.js";
7
+ import { EMediaQuery } from "../../hooks/useMediaQuery/constants.js";
8
+ import { Icon } from "../../icons/Icon.js";
9
+ import { n as n$3, u as u$4, g as o$1, s as s$3, o as o$2, p as p$1, t as t$3, h as s$4, W as W$1, y as y$3, i as T$1, H, M as M$2, K, b as a$5, l as l$4, T as T$2, a as u$6, z, j as j$1, d as u$7, I as I$1, G, $ as $f7dceffc5ad7768b$export$4e328f61c538687f, c as $6179b936705e76d3$export$ae780daf29e6d456, D as D$3, e as o$3, r as r$2 } from "../../label-BXAcSLy0.js";
10
+ import * as ReactDOM from "react-dom";
11
+ import { flushSync, createPortal } from "react-dom";
12
+ import { w } from "../../use-active-press-9MCrfRZk.js";
13
+ import { A as A$1, h as h$1, f as f$6, u as u$5, _ } from "../../focus-management-CFDo6ZSc.js";
14
+ import '../../assets/SelectSearch.css';function memo(getDeps, fn, opts) {
15
+ let deps = opts.initialDeps ?? [];
16
+ let result;
17
+ return () => {
18
+ var _a, _b, _c, _d;
19
+ let depTime;
20
+ if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
21
+ const newDeps = getDeps();
22
+ const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index2) => deps[index2] !== dep);
23
+ if (!depsChanged) {
24
+ return result;
25
+ }
26
+ deps = newDeps;
27
+ let resultTime;
28
+ if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
29
+ result = fn(...newDeps);
30
+ if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) {
31
+ const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
32
+ const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
33
+ const resultFpsPercentage = resultEndTime / 16;
34
+ const pad = (str, num) => {
35
+ str = String(str);
36
+ while (str.length < num) {
37
+ str = " " + str;
38
+ }
39
+ return str;
40
+ };
41
+ console.info(
42
+ `%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`,
43
+ `
44
+ font-size: .6rem;
45
+ font-weight: bold;
46
+ color: hsl(${Math.max(
47
+ 0,
48
+ Math.min(120 - 120 * resultFpsPercentage, 120)
49
+ )}deg 100% 31%);`,
50
+ opts == null ? void 0 : opts.key
51
+ );
52
+ }
53
+ (_d = opts == null ? void 0 : opts.onChange) == null ? void 0 : _d.call(opts, result);
54
+ return result;
55
+ };
56
+ }
57
+ function notUndefined(value, msg) {
58
+ if (value === void 0) {
59
+ throw new Error(`Unexpected undefined${""}`);
60
+ } else {
61
+ return value;
62
+ }
63
+ }
64
+ const approxEqual = (a3, b) => Math.abs(a3 - b) < 1;
65
+ const debounce = (targetWindow, fn, ms) => {
66
+ let timeoutId;
67
+ return function(...args) {
68
+ targetWindow.clearTimeout(timeoutId);
69
+ timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
70
+ };
71
+ };
72
+ const defaultKeyExtractor = (index2) => index2;
73
+ const defaultRangeExtractor = (range) => {
74
+ const start = Math.max(range.startIndex - range.overscan, 0);
75
+ const end = Math.min(range.endIndex + range.overscan, range.count - 1);
76
+ const arr = [];
77
+ for (let i2 = start; i2 <= end; i2++) {
78
+ arr.push(i2);
79
+ }
80
+ return arr;
81
+ };
82
+ const observeElementRect = (instance, cb) => {
83
+ const element = instance.scrollElement;
84
+ if (!element) {
85
+ return;
86
+ }
87
+ const targetWindow = instance.targetWindow;
88
+ if (!targetWindow) {
89
+ return;
90
+ }
91
+ const handler = (rect) => {
92
+ const { width, height } = rect;
93
+ cb({ width: Math.round(width), height: Math.round(height) });
94
+ };
95
+ handler(element.getBoundingClientRect());
96
+ if (!targetWindow.ResizeObserver) {
97
+ return () => {
98
+ };
99
+ }
100
+ const observer = new targetWindow.ResizeObserver((entries) => {
101
+ const entry = entries[0];
102
+ if (entry == null ? void 0 : entry.borderBoxSize) {
103
+ const box = entry.borderBoxSize[0];
104
+ if (box) {
105
+ handler({ width: box.inlineSize, height: box.blockSize });
106
+ return;
107
+ }
108
+ }
109
+ handler(element.getBoundingClientRect());
110
+ });
111
+ observer.observe(element, { box: "border-box" });
112
+ return () => {
113
+ observer.unobserve(element);
114
+ };
115
+ };
116
+ const addEventListenerOptions = {
117
+ passive: true
118
+ };
119
+ const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
120
+ const observeElementOffset = (instance, cb) => {
121
+ const element = instance.scrollElement;
122
+ if (!element) {
123
+ return;
124
+ }
125
+ const targetWindow = instance.targetWindow;
126
+ if (!targetWindow) {
127
+ return;
128
+ }
129
+ let offset2 = 0;
130
+ const fallback = supportsScrollend ? () => void 0 : debounce(
131
+ targetWindow,
132
+ () => {
133
+ cb(offset2, false);
134
+ },
135
+ instance.options.isScrollingResetDelay
136
+ );
137
+ const createHandler = (isScrolling) => () => {
138
+ offset2 = element[instance.options.horizontal ? "scrollLeft" : "scrollTop"];
139
+ fallback();
140
+ cb(offset2, isScrolling);
141
+ };
142
+ const handler = createHandler(true);
143
+ const endHandler = createHandler(false);
144
+ endHandler();
145
+ element.addEventListener("scroll", handler, addEventListenerOptions);
146
+ element.addEventListener("scrollend", endHandler, addEventListenerOptions);
147
+ return () => {
148
+ element.removeEventListener("scroll", handler);
149
+ element.removeEventListener("scrollend", endHandler);
150
+ };
151
+ };
152
+ const measureElement = (element, entry, instance) => {
153
+ if (entry == null ? void 0 : entry.borderBoxSize) {
154
+ const box = entry.borderBoxSize[0];
155
+ if (box) {
156
+ const size2 = Math.round(
157
+ box[instance.options.horizontal ? "inlineSize" : "blockSize"]
158
+ );
159
+ return size2;
160
+ }
161
+ }
162
+ return Math.round(
163
+ element.getBoundingClientRect()[instance.options.horizontal ? "width" : "height"]
164
+ );
165
+ };
166
+ const elementScroll = (offset2, {
167
+ adjustments = 0,
168
+ behavior
169
+ }, instance) => {
170
+ var _a, _b;
171
+ const toOffset = offset2 + adjustments;
172
+ (_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
173
+ [instance.options.horizontal ? "left" : "top"]: toOffset,
174
+ behavior
175
+ });
176
+ };
177
+ class Virtualizer {
178
+ constructor(opts) {
179
+ this.unsubs = [];
180
+ this.scrollElement = null;
181
+ this.targetWindow = null;
182
+ this.isScrolling = false;
183
+ this.scrollToIndexTimeoutId = null;
184
+ this.measurementsCache = [];
185
+ this.itemSizeCache = /* @__PURE__ */ new Map();
186
+ this.pendingMeasuredCacheIndexes = [];
187
+ this.scrollRect = null;
188
+ this.scrollOffset = null;
189
+ this.scrollDirection = null;
190
+ this.scrollAdjustments = 0;
191
+ this.elementsCache = /* @__PURE__ */ new Map();
192
+ this.observer = /* @__PURE__ */ (() => {
193
+ let _ro = null;
194
+ const get = () => {
195
+ if (_ro) {
196
+ return _ro;
197
+ }
198
+ if (!this.targetWindow || !this.targetWindow.ResizeObserver) {
199
+ return null;
200
+ }
201
+ return _ro = new this.targetWindow.ResizeObserver((entries) => {
202
+ entries.forEach((entry) => {
203
+ this._measureElement(entry.target, entry);
204
+ });
205
+ });
206
+ };
207
+ return {
208
+ disconnect: () => {
209
+ var _a;
210
+ return (_a = get()) == null ? void 0 : _a.disconnect();
211
+ },
212
+ observe: (target) => {
213
+ var _a;
214
+ return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
215
+ },
216
+ unobserve: (target) => {
217
+ var _a;
218
+ return (_a = get()) == null ? void 0 : _a.unobserve(target);
219
+ }
220
+ };
221
+ })();
222
+ this.range = null;
223
+ this.setOptions = (opts2) => {
224
+ Object.entries(opts2).forEach(([key, value]) => {
225
+ if (typeof value === "undefined") delete opts2[key];
226
+ });
227
+ this.options = {
228
+ debug: false,
229
+ initialOffset: 0,
230
+ overscan: 1,
231
+ paddingStart: 0,
232
+ paddingEnd: 0,
233
+ scrollPaddingStart: 0,
234
+ scrollPaddingEnd: 0,
235
+ horizontal: false,
236
+ getItemKey: defaultKeyExtractor,
237
+ rangeExtractor: defaultRangeExtractor,
238
+ onChange: () => {
239
+ },
240
+ measureElement,
241
+ initialRect: { width: 0, height: 0 },
242
+ scrollMargin: 0,
243
+ gap: 0,
244
+ indexAttribute: "data-index",
245
+ initialMeasurementsCache: [],
246
+ lanes: 1,
247
+ isScrollingResetDelay: 150,
248
+ enabled: true,
249
+ ...opts2
250
+ };
251
+ };
252
+ this.notify = (force, sync) => {
253
+ var _a, _b;
254
+ const { startIndex, endIndex } = this.range ?? {
255
+ startIndex: void 0,
256
+ endIndex: void 0
257
+ };
258
+ const range = this.calculateRange();
259
+ if (force || startIndex !== (range == null ? void 0 : range.startIndex) || endIndex !== (range == null ? void 0 : range.endIndex)) {
260
+ (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
261
+ }
262
+ };
263
+ this.cleanup = () => {
264
+ this.unsubs.filter(Boolean).forEach((d2) => d2());
265
+ this.unsubs = [];
266
+ this.scrollElement = null;
267
+ this.targetWindow = null;
268
+ this.observer.disconnect();
269
+ this.elementsCache.clear();
270
+ };
271
+ this._didMount = () => {
272
+ return () => {
273
+ this.cleanup();
274
+ };
275
+ };
276
+ this._willUpdate = () => {
277
+ var _a;
278
+ const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
279
+ if (this.scrollElement !== scrollElement) {
280
+ this.cleanup();
281
+ if (!scrollElement) {
282
+ this.notify(false, false);
283
+ return;
284
+ }
285
+ this.scrollElement = scrollElement;
286
+ if (this.scrollElement && "ownerDocument" in this.scrollElement) {
287
+ this.targetWindow = this.scrollElement.ownerDocument.defaultView;
288
+ } else {
289
+ this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
290
+ }
291
+ this._scrollToOffset(this.getScrollOffset(), {
292
+ adjustments: void 0,
293
+ behavior: void 0
294
+ });
295
+ this.unsubs.push(
296
+ this.options.observeElementRect(this, (rect) => {
297
+ this.scrollRect = rect;
298
+ this.notify(false, false);
299
+ })
300
+ );
301
+ this.unsubs.push(
302
+ this.options.observeElementOffset(this, (offset2, isScrolling) => {
303
+ this.scrollAdjustments = 0;
304
+ this.scrollDirection = isScrolling ? this.getScrollOffset() < offset2 ? "forward" : "backward" : null;
305
+ this.scrollOffset = offset2;
306
+ const prevIsScrolling = this.isScrolling;
307
+ this.isScrolling = isScrolling;
308
+ this.notify(prevIsScrolling !== isScrolling, isScrolling);
309
+ })
310
+ );
311
+ }
312
+ };
313
+ this.getSize = () => {
314
+ if (!this.options.enabled) {
315
+ this.scrollRect = null;
316
+ return 0;
317
+ }
318
+ this.scrollRect = this.scrollRect ?? this.options.initialRect;
319
+ return this.scrollRect[this.options.horizontal ? "width" : "height"];
320
+ };
321
+ this.getScrollOffset = () => {
322
+ if (!this.options.enabled) {
323
+ this.scrollOffset = null;
324
+ return 0;
325
+ }
326
+ this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
327
+ return this.scrollOffset;
328
+ };
329
+ this.getFurthestMeasurement = (measurements, index2) => {
330
+ const furthestMeasurementsFound = /* @__PURE__ */ new Map();
331
+ const furthestMeasurements = /* @__PURE__ */ new Map();
332
+ for (let m2 = index2 - 1; m2 >= 0; m2--) {
333
+ const measurement = measurements[m2];
334
+ if (furthestMeasurementsFound.has(measurement.lane)) {
335
+ continue;
336
+ }
337
+ const previousFurthestMeasurement = furthestMeasurements.get(
338
+ measurement.lane
339
+ );
340
+ if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
341
+ furthestMeasurements.set(measurement.lane, measurement);
342
+ } else if (measurement.end < previousFurthestMeasurement.end) {
343
+ furthestMeasurementsFound.set(measurement.lane, true);
344
+ }
345
+ if (furthestMeasurementsFound.size === this.options.lanes) {
346
+ break;
347
+ }
348
+ }
349
+ return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a3, b) => {
350
+ if (a3.end === b.end) {
351
+ return a3.index - b.index;
352
+ }
353
+ return a3.end - b.end;
354
+ })[0] : void 0;
355
+ };
356
+ this.getMeasurementOptions = memo(
357
+ () => [
358
+ this.options.count,
359
+ this.options.paddingStart,
360
+ this.options.scrollMargin,
361
+ this.options.getItemKey,
362
+ this.options.enabled
363
+ ],
364
+ (count2, paddingStart, scrollMargin, getItemKey, enabled) => {
365
+ this.pendingMeasuredCacheIndexes = [];
366
+ return {
367
+ count: count2,
368
+ paddingStart,
369
+ scrollMargin,
370
+ getItemKey,
371
+ enabled
372
+ };
373
+ },
374
+ {
375
+ key: false
376
+ }
377
+ );
378
+ this.getMeasurements = memo(
379
+ () => [this.getMeasurementOptions(), this.itemSizeCache],
380
+ ({ count: count2, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => {
381
+ var _a;
382
+ if (!enabled) {
383
+ this.measurementsCache = [];
384
+ this.itemSizeCache.clear();
385
+ return [];
386
+ }
387
+ if (this.measurementsCache.length === 0) {
388
+ this.measurementsCache = this.options.initialMeasurementsCache;
389
+ this.measurementsCache.forEach((item) => {
390
+ this.itemSizeCache.set(item.key, item.size);
391
+ });
392
+ }
393
+ const min2 = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
394
+ this.pendingMeasuredCacheIndexes = [];
395
+ const measurements = this.measurementsCache.slice(0, min2);
396
+ for (let i2 = min2; i2 < count2; i2++) {
397
+ let measureElement2 = (_a = this.measurementsCache[i2]) == null ? void 0 : _a.measureElement;
398
+ if (!measureElement2) {
399
+ measureElement2 = (node) => {
400
+ const key2 = getItemKey(i2);
401
+ const prevNode = this.elementsCache.get(key2);
402
+ if (!node) {
403
+ if (prevNode) {
404
+ this.observer.unobserve(prevNode);
405
+ this.elementsCache.delete(key2);
406
+ }
407
+ return;
408
+ }
409
+ if (prevNode !== node) {
410
+ if (prevNode) {
411
+ this.observer.unobserve(prevNode);
412
+ }
413
+ this.observer.observe(node);
414
+ this.elementsCache.set(key2, node);
415
+ }
416
+ if (node.isConnected) {
417
+ this.resizeItem(
418
+ i2,
419
+ this.options.measureElement(node, void 0, this)
420
+ );
421
+ }
422
+ };
423
+ }
424
+ const key = getItemKey(i2);
425
+ const furthestMeasurement = this.options.lanes === 1 ? measurements[i2 - 1] : this.getFurthestMeasurement(measurements, i2);
426
+ const start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
427
+ const measuredSize = itemSizeCache.get(key);
428
+ const size2 = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i2);
429
+ const end = start + size2;
430
+ const lane = furthestMeasurement ? furthestMeasurement.lane : i2 % this.options.lanes;
431
+ measurements[i2] = {
432
+ index: i2,
433
+ start,
434
+ size: size2,
435
+ end,
436
+ key,
437
+ lane,
438
+ measureElement: measureElement2
439
+ };
440
+ }
441
+ this.measurementsCache = measurements;
442
+ return measurements;
443
+ },
444
+ {
445
+ key: process.env.NODE_ENV !== "production" && "getMeasurements",
446
+ debug: () => this.options.debug
447
+ }
448
+ );
449
+ this.calculateRange = memo(
450
+ () => [this.getMeasurements(), this.getSize(), this.getScrollOffset()],
451
+ (measurements, outerSize, scrollOffset) => {
452
+ return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
453
+ measurements,
454
+ outerSize,
455
+ scrollOffset
456
+ }) : null;
457
+ },
458
+ {
459
+ key: process.env.NODE_ENV !== "production" && "calculateRange",
460
+ debug: () => this.options.debug
461
+ }
462
+ );
463
+ this.getIndexes = memo(
464
+ () => [
465
+ this.options.rangeExtractor,
466
+ this.calculateRange(),
467
+ this.options.overscan,
468
+ this.options.count
469
+ ],
470
+ (rangeExtractor, range, overscan, count2) => {
471
+ return range === null ? [] : rangeExtractor({
472
+ startIndex: range.startIndex,
473
+ endIndex: range.endIndex,
474
+ overscan,
475
+ count: count2
476
+ });
477
+ },
478
+ {
479
+ key: process.env.NODE_ENV !== "production" && "getIndexes",
480
+ debug: () => this.options.debug
481
+ }
482
+ );
483
+ this.indexFromElement = (node) => {
484
+ const attributeName = this.options.indexAttribute;
485
+ const indexStr = node.getAttribute(attributeName);
486
+ if (!indexStr) {
487
+ console.warn(
488
+ `Missing attribute name '${attributeName}={index}' on measured element.`
489
+ );
490
+ return -1;
491
+ }
492
+ return parseInt(indexStr, 10);
493
+ };
494
+ this._measureElement = (node, entry) => {
495
+ const i2 = this.indexFromElement(node);
496
+ const item = this.getMeasurements()[i2];
497
+ if (!item || !node.isConnected) {
498
+ this.elementsCache.forEach((cached, key) => {
499
+ if (cached === node) {
500
+ this.observer.unobserve(node);
501
+ this.elementsCache.delete(key);
502
+ }
503
+ });
504
+ return;
505
+ }
506
+ const prevNode = this.elementsCache.get(item.key);
507
+ if (prevNode !== node) {
508
+ if (prevNode) {
509
+ this.observer.unobserve(prevNode);
510
+ }
511
+ this.observer.observe(node);
512
+ this.elementsCache.set(item.key, node);
513
+ }
514
+ this.resizeItem(i2, this.options.measureElement(node, entry, this));
515
+ };
516
+ this.resizeItem = (index2, size2) => {
517
+ const item = this.getMeasurements()[index2];
518
+ if (!item) {
519
+ return;
520
+ }
521
+ const itemSize = this.itemSizeCache.get(item.key) ?? item.size;
522
+ const delta = size2 - itemSize;
523
+ if (delta !== 0) {
524
+ if (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments) {
525
+ if (process.env.NODE_ENV !== "production" && this.options.debug) {
526
+ console.info("correction", delta);
527
+ }
528
+ this._scrollToOffset(this.getScrollOffset(), {
529
+ adjustments: this.scrollAdjustments += delta,
530
+ behavior: void 0
531
+ });
532
+ }
533
+ this.pendingMeasuredCacheIndexes.push(item.index);
534
+ this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size2));
535
+ this.notify(true, false);
536
+ }
537
+ };
538
+ this.measureElement = (node) => {
539
+ if (!node) {
540
+ return;
541
+ }
542
+ this._measureElement(node, void 0);
543
+ };
544
+ this.getVirtualItems = memo(
545
+ () => [this.getIndexes(), this.getMeasurements()],
546
+ (indexes, measurements) => {
547
+ const virtualItems = [];
548
+ for (let k = 0, len = indexes.length; k < len; k++) {
549
+ const i2 = indexes[k];
550
+ const measurement = measurements[i2];
551
+ virtualItems.push(measurement);
552
+ }
553
+ return virtualItems;
554
+ },
555
+ {
556
+ key: process.env.NODE_ENV !== "production" && "getIndexes",
557
+ debug: () => this.options.debug
558
+ }
559
+ );
560
+ this.getVirtualItemForOffset = (offset2) => {
561
+ const measurements = this.getMeasurements();
562
+ if (measurements.length === 0) {
563
+ return void 0;
564
+ }
565
+ return notUndefined(
566
+ measurements[findNearestBinarySearch(
567
+ 0,
568
+ measurements.length - 1,
569
+ (index2) => notUndefined(measurements[index2]).start,
570
+ offset2
571
+ )]
572
+ );
573
+ };
574
+ this.getOffsetForAlignment = (toOffset, align) => {
575
+ const size2 = this.getSize();
576
+ const scrollOffset = this.getScrollOffset();
577
+ if (align === "auto") {
578
+ if (toOffset <= scrollOffset) {
579
+ align = "start";
580
+ } else if (toOffset >= scrollOffset + size2) {
581
+ align = "end";
582
+ } else {
583
+ align = "start";
584
+ }
585
+ }
586
+ if (align === "start") {
587
+ toOffset = toOffset;
588
+ } else if (align === "end") {
589
+ toOffset = toOffset - size2;
590
+ } else if (align === "center") {
591
+ toOffset = toOffset - size2 / 2;
592
+ }
593
+ const scrollSizeProp = this.options.horizontal ? "scrollWidth" : "scrollHeight";
594
+ const scrollSize = this.scrollElement ? "document" in this.scrollElement ? this.scrollElement.document.documentElement[scrollSizeProp] : this.scrollElement[scrollSizeProp] : 0;
595
+ const maxOffset = scrollSize - size2;
596
+ return Math.max(Math.min(maxOffset, toOffset), 0);
597
+ };
598
+ this.getOffsetForIndex = (index2, align = "auto") => {
599
+ index2 = Math.max(0, Math.min(index2, this.options.count - 1));
600
+ const item = this.getMeasurements()[index2];
601
+ if (!item) {
602
+ return void 0;
603
+ }
604
+ const size2 = this.getSize();
605
+ const scrollOffset = this.getScrollOffset();
606
+ if (align === "auto") {
607
+ if (item.end >= scrollOffset + size2 - this.options.scrollPaddingEnd) {
608
+ align = "end";
609
+ } else if (item.start <= scrollOffset + this.options.scrollPaddingStart) {
610
+ align = "start";
611
+ } else {
612
+ return [scrollOffset, align];
613
+ }
614
+ }
615
+ const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
616
+ return [this.getOffsetForAlignment(toOffset, align), align];
617
+ };
618
+ this.isDynamicMode = () => this.elementsCache.size > 0;
619
+ this.cancelScrollToIndex = () => {
620
+ if (this.scrollToIndexTimeoutId !== null && this.targetWindow) {
621
+ this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId);
622
+ this.scrollToIndexTimeoutId = null;
623
+ }
624
+ };
625
+ this.scrollToOffset = (toOffset, { align = "start", behavior } = {}) => {
626
+ this.cancelScrollToIndex();
627
+ if (behavior === "smooth" && this.isDynamicMode()) {
628
+ console.warn(
629
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
630
+ );
631
+ }
632
+ this._scrollToOffset(this.getOffsetForAlignment(toOffset, align), {
633
+ adjustments: void 0,
634
+ behavior
635
+ });
636
+ };
637
+ this.scrollToIndex = (index2, { align: initialAlign = "auto", behavior } = {}) => {
638
+ index2 = Math.max(0, Math.min(index2, this.options.count - 1));
639
+ this.cancelScrollToIndex();
640
+ if (behavior === "smooth" && this.isDynamicMode()) {
641
+ console.warn(
642
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
643
+ );
644
+ }
645
+ const offsetAndAlign = this.getOffsetForIndex(index2, initialAlign);
646
+ if (!offsetAndAlign) return;
647
+ const [offset2, align] = offsetAndAlign;
648
+ this._scrollToOffset(offset2, { adjustments: void 0, behavior });
649
+ if (behavior !== "smooth" && this.isDynamicMode() && this.targetWindow) {
650
+ this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
651
+ this.scrollToIndexTimeoutId = null;
652
+ const elementInDOM = this.elementsCache.has(
653
+ this.options.getItemKey(index2)
654
+ );
655
+ if (elementInDOM) {
656
+ const [latestOffset] = notUndefined(
657
+ this.getOffsetForIndex(index2, align)
658
+ );
659
+ if (!approxEqual(latestOffset, this.getScrollOffset())) {
660
+ this.scrollToIndex(index2, { align, behavior });
661
+ }
662
+ } else {
663
+ this.scrollToIndex(index2, { align, behavior });
664
+ }
665
+ });
666
+ }
667
+ };
668
+ this.scrollBy = (delta, { behavior } = {}) => {
669
+ this.cancelScrollToIndex();
670
+ if (behavior === "smooth" && this.isDynamicMode()) {
671
+ console.warn(
672
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
673
+ );
674
+ }
675
+ this._scrollToOffset(this.getScrollOffset() + delta, {
676
+ adjustments: void 0,
677
+ behavior
678
+ });
679
+ };
680
+ this.getTotalSize = () => {
681
+ var _a;
682
+ const measurements = this.getMeasurements();
683
+ let end;
684
+ if (measurements.length === 0) {
685
+ end = this.options.paddingStart;
686
+ } else {
687
+ end = this.options.lanes === 1 ? ((_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) ?? 0 : Math.max(
688
+ ...measurements.slice(-this.options.lanes).map((m2) => m2.end)
689
+ );
690
+ }
691
+ return end - this.options.scrollMargin + this.options.paddingEnd;
692
+ };
693
+ this._scrollToOffset = (offset2, {
694
+ adjustments,
695
+ behavior
696
+ }) => {
697
+ this.options.scrollToFn(offset2, { behavior, adjustments }, this);
698
+ };
699
+ this.measure = () => {
700
+ var _a, _b;
701
+ this.itemSizeCache = /* @__PURE__ */ new Map();
702
+ (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, false);
703
+ };
704
+ this.setOptions(opts);
705
+ }
706
+ }
707
+ const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
708
+ while (low <= high) {
709
+ const middle = (low + high) / 2 | 0;
710
+ const currentValue = getCurrentValue(middle);
711
+ if (currentValue < value) {
712
+ low = middle + 1;
713
+ } else if (currentValue > value) {
714
+ high = middle - 1;
715
+ } else {
716
+ return middle;
717
+ }
718
+ }
719
+ if (low > 0) {
720
+ return low - 1;
721
+ } else {
722
+ return 0;
723
+ }
724
+ };
725
+ function calculateRange({
726
+ measurements,
727
+ outerSize,
728
+ scrollOffset
729
+ }) {
730
+ const count2 = measurements.length - 1;
731
+ const getOffset = (index2) => measurements[index2].start;
732
+ const startIndex = findNearestBinarySearch(0, count2, getOffset, scrollOffset);
733
+ let endIndex = startIndex;
734
+ while (endIndex < count2 && measurements[endIndex].end < scrollOffset + outerSize) {
735
+ endIndex++;
736
+ }
737
+ return { startIndex, endIndex };
738
+ }
739
+ const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
740
+ function useVirtualizerBase(options2) {
741
+ const rerender = React.useReducer(() => ({}), {})[1];
742
+ const resolvedOptions = {
743
+ ...options2,
744
+ onChange: (instance2, sync) => {
745
+ var _a;
746
+ if (sync) {
747
+ flushSync(rerender);
748
+ } else {
749
+ rerender();
750
+ }
751
+ (_a = options2.onChange) == null ? void 0 : _a.call(options2, instance2, sync);
752
+ }
753
+ };
754
+ const [instance] = React.useState(
755
+ () => new Virtualizer(resolvedOptions)
756
+ );
757
+ instance.setOptions(resolvedOptions);
758
+ React.useEffect(() => {
759
+ return instance._didMount();
760
+ }, []);
761
+ useIsomorphicLayoutEffect(() => {
762
+ return instance._willUpdate();
763
+ });
764
+ return instance;
765
+ }
766
+ function useVirtualizer(options2) {
767
+ return useVirtualizerBase({
768
+ observeElementRect,
769
+ observeElementOffset,
770
+ scrollToFn: elementScroll,
771
+ ...options2
772
+ });
773
+ }
774
+ function s$2(e2) {
775
+ if (e2 === null) return { width: 0, height: 0 };
776
+ let { width: n2, height: t2 } = e2.getBoundingClientRect();
777
+ return { width: n2, height: t2 };
778
+ }
779
+ function f$5(e2, n2 = false) {
780
+ let t2 = e2 === null ? null : "current" in e2 ? e2.current : e2, [l2, u2] = useReducer(() => ({}), {}), r2 = useMemo(() => s$2(t2), [t2, l2]);
781
+ return n$3(() => {
782
+ if (!t2) return;
783
+ let i2 = new ResizeObserver(u2);
784
+ return i2.observe(t2), () => {
785
+ i2.disconnect();
786
+ };
787
+ }, [t2]), n2 ? { width: `${r2.width}px`, height: `${r2.height}px` } : r2;
788
+ }
789
+ let a$4 = class a extends Map {
790
+ constructor(t2) {
791
+ super();
792
+ this.factory = t2;
793
+ }
794
+ get(t2) {
795
+ let e2 = super.get(t2);
796
+ return e2 === void 0 && (e2 = this.factory(t2), this.set(t2, e2)), e2;
797
+ }
798
+ };
799
+ function a$3(o2, r2) {
800
+ let t2 = o2(), n2 = /* @__PURE__ */ new Set();
801
+ return { getSnapshot() {
802
+ return t2;
803
+ }, subscribe(e2) {
804
+ return n2.add(e2), () => n2.delete(e2);
805
+ }, dispatch(e2, ...s2) {
806
+ let i2 = r2[e2].call(t2, ...s2);
807
+ i2 && (t2 = i2, n2.forEach((c2) => c2()));
808
+ } };
809
+ }
810
+ function o(t2) {
811
+ return useSyncExternalStore(t2.subscribe, t2.getSnapshot, t2.getSnapshot);
812
+ }
813
+ let p = new a$4(() => a$3(() => [], { ADD(r2) {
814
+ return this.includes(r2) ? this : [...this, r2];
815
+ }, REMOVE(r2) {
816
+ let e2 = this.indexOf(r2);
817
+ if (e2 === -1) return this;
818
+ let t2 = this.slice();
819
+ return t2.splice(e2, 1), t2;
820
+ } }));
821
+ function x(r2, e2) {
822
+ let t2 = p.get(e2), i2 = useId$1(), h2 = o(t2);
823
+ if (n$3(() => {
824
+ if (r2) return t2.dispatch("ADD", i2), () => t2.dispatch("REMOVE", i2);
825
+ }, [t2, r2]), !r2) return false;
826
+ let s2 = h2.indexOf(i2), o$12 = h2.length;
827
+ return s2 === -1 && (s2 = o$12, o$12 += 1), s2 === o$12 - 1;
828
+ }
829
+ let f$4 = /* @__PURE__ */ new Map(), u$3 = /* @__PURE__ */ new Map();
830
+ function h(t2) {
831
+ var e2;
832
+ let r2 = (e2 = u$3.get(t2)) != null ? e2 : 0;
833
+ return u$3.set(t2, r2 + 1), r2 !== 0 ? () => m$3(t2) : (f$4.set(t2, { "aria-hidden": t2.getAttribute("aria-hidden"), inert: t2.inert }), t2.setAttribute("aria-hidden", "true"), t2.inert = true, () => m$3(t2));
834
+ }
835
+ function m$3(t2) {
836
+ var i2;
837
+ let r2 = (i2 = u$3.get(t2)) != null ? i2 : 1;
838
+ if (r2 === 1 ? u$3.delete(t2) : u$3.set(t2, r2 - 1), r2 !== 1) return;
839
+ let e2 = f$4.get(t2);
840
+ e2 && (e2["aria-hidden"] === null ? t2.removeAttribute("aria-hidden") : t2.setAttribute("aria-hidden", e2["aria-hidden"]), t2.inert = e2.inert, f$4.delete(t2));
841
+ }
842
+ function y$2(t2, { allowed: r2, disallowed: e2 } = {}) {
843
+ let i2 = x(t2, "inert-others");
844
+ n$3(() => {
845
+ var d2, c2;
846
+ if (!i2) return;
847
+ let a3 = o$1();
848
+ for (let n2 of (d2 = e2 == null ? void 0 : e2()) != null ? d2 : []) n2 && a3.add(h(n2));
849
+ let s2 = (c2 = r2 == null ? void 0 : r2()) != null ? c2 : [];
850
+ for (let n2 of s2) {
851
+ if (!n2) continue;
852
+ let l2 = u$4(n2);
853
+ if (!l2) continue;
854
+ let o2 = n2.parentElement;
855
+ for (; o2 && o2 !== l2.body; ) {
856
+ for (let p2 of o2.children) s2.some((E2) => p2.contains(E2)) || a3.add(h(p2));
857
+ o2 = o2.parentElement;
858
+ }
859
+ }
860
+ return a3.dispose;
861
+ }, [i2, r2, e2]);
862
+ }
863
+ function m$2(s2, n2, l2) {
864
+ let i2 = s$3((t2) => {
865
+ let e2 = t2.getBoundingClientRect();
866
+ e2.x === 0 && e2.y === 0 && e2.width === 0 && e2.height === 0 && l2();
867
+ });
868
+ useEffect(() => {
869
+ if (!s2) return;
870
+ let t2 = n2 === null ? null : n2 instanceof HTMLElement ? n2 : n2.current;
871
+ if (!t2) return;
872
+ let e2 = o$1();
873
+ if (typeof ResizeObserver != "undefined") {
874
+ let r2 = new ResizeObserver(() => i2.current(t2));
875
+ r2.observe(t2), e2.add(() => r2.disconnect());
876
+ }
877
+ if (typeof IntersectionObserver != "undefined") {
878
+ let r2 = new IntersectionObserver(() => i2.current(t2));
879
+ r2.observe(t2), e2.add(() => r2.disconnect());
880
+ }
881
+ return () => e2.dispose();
882
+ }, [n2, i2, s2]);
883
+ }
884
+ function t$2() {
885
+ return /iPhone/gi.test(window.navigator.platform) || /Mac/gi.test(window.navigator.platform) && window.navigator.maxTouchPoints > 0;
886
+ }
887
+ function i$3() {
888
+ return /Android/gi.test(window.navigator.userAgent);
889
+ }
890
+ function n$2() {
891
+ return t$2() || i$3();
892
+ }
893
+ function i$2(t2, e2, o2, n2) {
894
+ let u2 = s$3(o2);
895
+ useEffect(() => {
896
+ if (!t2) return;
897
+ function r2(m2) {
898
+ u2.current(m2);
899
+ }
900
+ return document.addEventListener(e2, r2, n2), () => document.removeEventListener(e2, r2, n2);
901
+ }, [t2, e2, n2]);
902
+ }
903
+ function s$1(t2, e2, o2, n2) {
904
+ let i2 = s$3(o2);
905
+ useEffect(() => {
906
+ if (!t2) return;
907
+ function r2(d2) {
908
+ i2.current(d2);
909
+ }
910
+ return window.addEventListener(e2, r2, n2), () => window.removeEventListener(e2, r2, n2);
911
+ }, [t2, e2, n2]);
912
+ }
913
+ const d$2 = 30;
914
+ function F$2(E2, p2, C) {
915
+ let u2 = x(E2, "outside-click"), f2 = s$3(C), s2 = useCallback(function(e2, o2) {
916
+ if (e2.defaultPrevented) return;
917
+ let r2 = o2(e2);
918
+ if (r2 === null || !r2.getRootNode().contains(r2) || !r2.isConnected) return;
919
+ let T2 = function i2(n2) {
920
+ return typeof n2 == "function" ? i2(n2()) : Array.isArray(n2) || n2 instanceof Set ? n2 : [n2];
921
+ }(p2);
922
+ for (let i2 of T2) {
923
+ if (i2 === null) continue;
924
+ let n2 = i2 instanceof HTMLElement ? i2 : i2.current;
925
+ if (n2 != null && n2.contains(r2) || e2.composed && e2.composedPath().includes(n2)) return;
926
+ }
927
+ return !A$1(r2, h$1.Loose) && r2.tabIndex !== -1 && e2.preventDefault(), f2.current(e2, r2);
928
+ }, [f2]), l2 = useRef(null);
929
+ i$2(u2, "pointerdown", (t2) => {
930
+ var e2, o2;
931
+ l2.current = ((o2 = (e2 = t2.composedPath) == null ? void 0 : e2.call(t2)) == null ? void 0 : o2[0]) || t2.target;
932
+ }, true), i$2(u2, "mousedown", (t2) => {
933
+ var e2, o2;
934
+ l2.current = ((o2 = (e2 = t2.composedPath) == null ? void 0 : e2.call(t2)) == null ? void 0 : o2[0]) || t2.target;
935
+ }, true), i$2(u2, "click", (t2) => {
936
+ n$2() || l2.current && (s2(t2, () => l2.current), l2.current = null);
937
+ }, true);
938
+ let a3 = useRef({ x: 0, y: 0 });
939
+ i$2(u2, "touchstart", (t2) => {
940
+ a3.current.x = t2.touches[0].clientX, a3.current.y = t2.touches[0].clientY;
941
+ }, true), i$2(u2, "touchend", (t2) => {
942
+ let e2 = { x: t2.changedTouches[0].clientX, y: t2.changedTouches[0].clientY };
943
+ if (!(Math.abs(e2.x - a3.current.x) >= d$2 || Math.abs(e2.y - a3.current.y) >= d$2)) return s2(t2, () => t2.target instanceof HTMLElement ? t2.target : null);
944
+ }, true), s$1(u2, "blur", (t2) => s2(t2, () => window.document.activeElement instanceof HTMLIFrameElement ? window.document.activeElement : null), true);
945
+ }
946
+ function n$1(...e2) {
947
+ return useMemo(() => u$4(...e2), [...e2]);
948
+ }
949
+ function E(n2, e2, a3, t2) {
950
+ let i2 = s$3(a3);
951
+ useEffect(() => {
952
+ n2 = n2 != null ? n2 : window;
953
+ function r2(o2) {
954
+ i2.current(o2);
955
+ }
956
+ return n2.addEventListener(e2, r2, t2), () => n2.removeEventListener(e2, r2, t2);
957
+ }, [n2, e2, t2]);
958
+ }
959
+ function f$3(l2) {
960
+ let n2 = useRef({ value: "", selectionStart: null, selectionEnd: null });
961
+ return E(l2.current, "blur", (e2) => {
962
+ let t2 = e2.target;
963
+ t2 instanceof HTMLInputElement && (n2.current = { value: t2.value, selectionStart: t2.selectionStart, selectionEnd: t2.selectionEnd });
964
+ }), o$2(() => {
965
+ let e2 = l2.current;
966
+ if (document.activeElement !== e2 && e2 instanceof HTMLInputElement && e2.isConnected) {
967
+ if (e2.focus({ preventScroll: true }), e2.value !== n2.current.value) e2.setSelectionRange(e2.value.length, e2.value.length);
968
+ else {
969
+ let { selectionStart: t2, selectionEnd: u2 } = n2.current;
970
+ t2 !== null && u2 !== null && e2.setSelectionRange(t2, u2);
971
+ }
972
+ n2.current = { value: "", selectionStart: null, selectionEnd: null };
973
+ }
974
+ });
975
+ }
976
+ function i$1(t2) {
977
+ var n2;
978
+ if (t2.type) return t2.type;
979
+ let e2 = (n2 = t2.as) != null ? n2 : "button";
980
+ if (typeof e2 == "string" && e2.toLowerCase() === "button") return "button";
981
+ }
982
+ function T(t2, e2) {
983
+ let [n2, u2] = useState(() => i$1(t2));
984
+ return n$3(() => {
985
+ u2(i$1(t2));
986
+ }, [t2.type, t2.as]), n$3(() => {
987
+ n2 || e2.current && e2.current instanceof HTMLButtonElement && !e2.current.hasAttribute("type") && u2("button");
988
+ }, [n2, e2]), n2;
989
+ }
990
+ function d$1() {
991
+ let r2;
992
+ return { before({ doc: e2 }) {
993
+ var l2;
994
+ let o2 = e2.documentElement, t2 = (l2 = e2.defaultView) != null ? l2 : window;
995
+ r2 = Math.max(0, t2.innerWidth - o2.clientWidth);
996
+ }, after({ doc: e2, d: o2 }) {
997
+ let t2 = e2.documentElement, l2 = Math.max(0, t2.clientWidth - t2.offsetWidth), n2 = Math.max(0, r2 - l2);
998
+ o2.style(t2, "paddingRight", `${n2}px`);
999
+ } };
1000
+ }
1001
+ function d() {
1002
+ return t$2() ? { before({ doc: r2, d: n2, meta: c2 }) {
1003
+ function o2(a3) {
1004
+ return c2.containers.flatMap((l2) => l2()).some((l2) => l2.contains(a3));
1005
+ }
1006
+ n2.microTask(() => {
1007
+ var s2;
1008
+ if (window.getComputedStyle(r2.documentElement).scrollBehavior !== "auto") {
1009
+ let t2 = o$1();
1010
+ t2.style(r2.documentElement, "scrollBehavior", "auto"), n2.add(() => n2.microTask(() => t2.dispose()));
1011
+ }
1012
+ let a3 = (s2 = window.scrollY) != null ? s2 : window.pageYOffset, l2 = null;
1013
+ n2.addEventListener(r2, "click", (t2) => {
1014
+ if (t2.target instanceof HTMLElement) try {
1015
+ let e2 = t2.target.closest("a");
1016
+ if (!e2) return;
1017
+ let { hash: f2 } = new URL(e2.href), i2 = r2.querySelector(f2);
1018
+ i2 && !o2(i2) && (l2 = i2);
1019
+ } catch {
1020
+ }
1021
+ }, true), n2.addEventListener(r2, "touchstart", (t2) => {
1022
+ if (t2.target instanceof HTMLElement) if (o2(t2.target)) {
1023
+ let e2 = t2.target;
1024
+ for (; e2.parentElement && o2(e2.parentElement); ) e2 = e2.parentElement;
1025
+ n2.style(e2, "overscrollBehavior", "contain");
1026
+ } else n2.style(t2.target, "touchAction", "none");
1027
+ }), n2.addEventListener(r2, "touchmove", (t2) => {
1028
+ if (t2.target instanceof HTMLElement) {
1029
+ if (t2.target.tagName === "INPUT") return;
1030
+ if (o2(t2.target)) {
1031
+ let e2 = t2.target;
1032
+ for (; e2.parentElement && e2.dataset.headlessuiPortal !== "" && !(e2.scrollHeight > e2.clientHeight || e2.scrollWidth > e2.clientWidth); ) e2 = e2.parentElement;
1033
+ e2.dataset.headlessuiPortal === "" && t2.preventDefault();
1034
+ } else t2.preventDefault();
1035
+ }
1036
+ }, { passive: false }), n2.add(() => {
1037
+ var e2;
1038
+ let t2 = (e2 = window.scrollY) != null ? e2 : window.pageYOffset;
1039
+ a3 !== t2 && window.scrollTo(0, a3), l2 && l2.isConnected && (l2.scrollIntoView({ block: "nearest" }), l2 = null);
1040
+ });
1041
+ });
1042
+ } } : {};
1043
+ }
1044
+ function r$1() {
1045
+ return { before({ doc: e2, d: o2 }) {
1046
+ o2.style(e2.documentElement, "overflow", "hidden");
1047
+ } };
1048
+ }
1049
+ function m$1(e2) {
1050
+ let n2 = {};
1051
+ for (let t2 of e2) Object.assign(n2, t2(n2));
1052
+ return n2;
1053
+ }
1054
+ let a$2 = a$3(() => /* @__PURE__ */ new Map(), { PUSH(e2, n2) {
1055
+ var o2;
1056
+ let t2 = (o2 = this.get(e2)) != null ? o2 : { doc: e2, count: 0, d: o$1(), meta: /* @__PURE__ */ new Set() };
1057
+ return t2.count++, t2.meta.add(n2), this.set(e2, t2), this;
1058
+ }, POP(e2, n2) {
1059
+ let t2 = this.get(e2);
1060
+ return t2 && (t2.count--, t2.meta.delete(n2)), this;
1061
+ }, SCROLL_PREVENT({ doc: e2, d: n2, meta: t2 }) {
1062
+ let o2 = { doc: e2, d: n2, meta: m$1(t2) }, c2 = [d(), d$1(), r$1()];
1063
+ c2.forEach(({ before: r2 }) => r2 == null ? void 0 : r2(o2)), c2.forEach(({ after: r2 }) => r2 == null ? void 0 : r2(o2));
1064
+ }, SCROLL_ALLOW({ d: e2 }) {
1065
+ e2.dispose();
1066
+ }, TEARDOWN({ doc: e2 }) {
1067
+ this.delete(e2);
1068
+ } });
1069
+ a$2.subscribe(() => {
1070
+ let e2 = a$2.getSnapshot(), n2 = /* @__PURE__ */ new Map();
1071
+ for (let [t2] of e2) n2.set(t2, t2.documentElement.style.overflow);
1072
+ for (let t2 of e2.values()) {
1073
+ let o2 = n2.get(t2.doc) === "hidden", c2 = t2.count !== 0;
1074
+ (c2 && !o2 || !c2 && o2) && a$2.dispatch(t2.count > 0 ? "SCROLL_PREVENT" : "SCROLL_ALLOW", t2), t2.count === 0 && a$2.dispatch("TEARDOWN", t2);
1075
+ }
1076
+ });
1077
+ function a$1(r2, e2, n2 = () => ({ containers: [] })) {
1078
+ let f2 = o(a$2), o$12 = e2 ? f2.get(e2) : void 0, i2 = o$12 ? o$12.count > 0 : false;
1079
+ return n$3(() => {
1080
+ if (!(!e2 || !r2)) return a$2.dispatch("PUSH", e2, n2), () => a$2.dispatch("POP", e2, n2);
1081
+ }, [r2, e2]), i2;
1082
+ }
1083
+ function f$2(e2, c2, n2 = () => [document.body]) {
1084
+ let r2 = x(e2, "scroll-lock");
1085
+ a$1(r2, c2, (t2) => {
1086
+ var o2;
1087
+ return { containers: [...(o2 = t2.containers) != null ? o2 : [], n2] };
1088
+ });
1089
+ }
1090
+ function t$1(e2) {
1091
+ return [e2.screenX, e2.screenY];
1092
+ }
1093
+ function u$2() {
1094
+ let e2 = useRef([-1, -1]);
1095
+ return { wasMoved(r2) {
1096
+ let n2 = t$1(r2);
1097
+ return e2.current[0] === n2[0] && e2.current[1] === n2[1] ? false : (e2.current = n2, true);
1098
+ }, update(r2) {
1099
+ e2.current = t$1(r2);
1100
+ } };
1101
+ }
1102
+ function l$3(r2) {
1103
+ let e2 = { called: false };
1104
+ return (...t2) => {
1105
+ if (!e2.called) return e2.called = true, r2(...t2);
1106
+ };
1107
+ }
1108
+ function c$3(u2 = 0) {
1109
+ let [t2, l2] = useState(u2), g2 = useCallback((e2) => l2(e2), [t2]), s2 = useCallback((e2) => l2((a3) => a3 | e2), [t2]), m2 = useCallback((e2) => (t2 & e2) === e2, [t2]), n2 = useCallback((e2) => l2((a3) => a3 & ~e2), [l2]), F2 = useCallback((e2) => l2((a3) => a3 ^ e2), [l2]);
1110
+ return { flags: t2, setFlag: g2, addFlag: s2, hasFlag: m2, removeFlag: n2, toggleFlag: F2 };
1111
+ }
1112
+ var D$2 = ((i2) => (i2[i2.None = 0] = "None", i2[i2.Closed = 1] = "Closed", i2[i2.Enter = 2] = "Enter", i2[i2.Leave = 4] = "Leave", i2))(D$2 || {});
1113
+ function A(e2) {
1114
+ let a3 = {};
1115
+ for (let t2 in e2) e2[t2] === true && (a3[`data-${t2}`] = "");
1116
+ return a3;
1117
+ }
1118
+ function V(e2, a3, t2, r2) {
1119
+ let [i2, u2] = useState(t2), { hasFlag: d2, addFlag: f2, removeFlag: s2 } = c$3(e2 && i2 ? 3 : 0), l2 = useRef(false), n2 = useRef(false), o2 = p$1();
1120
+ return n$3(function p2() {
1121
+ var T2;
1122
+ if (!e2) return;
1123
+ t2 && u2(true);
1124
+ let c2 = a3.current;
1125
+ return c2 ? ((T2 = void 0) == null || T2.call(r2, t2), M$1(c2, { inFlight: l2, prepare() {
1126
+ n2.current ? n2.current = false : n2.current = l2.current, l2.current = true, !n2.current && (t2 ? (f2(3), s2(4)) : (f2(4), s2(2)));
1127
+ }, run() {
1128
+ n2.current ? t2 ? (s2(3), f2(4)) : (s2(4), f2(3)) : t2 ? s2(1) : f2(1);
1129
+ }, done() {
1130
+ var m2;
1131
+ n2.current && typeof c2.getAnimations == "function" && c2.getAnimations().length > 0 || (l2.current = false, s2(7), t2 || u2(false), (m2 = void 0) == null || m2.call(r2, t2));
1132
+ } })) : t2 ? (f2(3), o2.nextFrame(() => p2())) : void 0;
1133
+ }, [e2, t2, a3, o2]), e2 ? [i2, { closed: d2(1), enter: d2(2), leave: d2(4), transition: d2(2) || d2(4) }] : [t2, { closed: void 0, enter: void 0, leave: void 0, transition: void 0 }];
1134
+ }
1135
+ function M$1(e2, { prepare: a3, run: t2, done: r2, inFlight: i2 }) {
1136
+ let u2 = o$1();
1137
+ return R(e2, { prepare: a3, inFlight: i2 }), u2.nextFrame(() => {
1138
+ u2.add(F$1(e2, r2)), t2();
1139
+ }), u2.dispose;
1140
+ }
1141
+ function F$1(e2, a3) {
1142
+ let t2 = l$3(a3), r2 = o$1();
1143
+ if (!e2) return r2.dispose;
1144
+ let { transitionDuration: i2, transitionDelay: u2 } = getComputedStyle(e2), [d2, f2] = [i2, u2].map((l2) => {
1145
+ let [n2 = 0] = l2.split(",").filter(Boolean).map((o2) => o2.includes("ms") ? parseFloat(o2) : parseFloat(o2) * 1e3).sort((o2, p2) => p2 - o2);
1146
+ return n2;
1147
+ }), s2 = d2 + f2;
1148
+ if (s2 !== 0) {
1149
+ let l2 = r2.group((n2) => {
1150
+ let o2 = n2.setTimeout(() => {
1151
+ t2(), n2.dispose();
1152
+ }, s2);
1153
+ n2.addEventListener(e2, "transitionrun", (p2) => {
1154
+ p2.target === p2.currentTarget && (o2(), n2.addEventListener(e2, "transitioncancel", (c2) => {
1155
+ c2.target === c2.currentTarget && (t2(), l2());
1156
+ }));
1157
+ });
1158
+ });
1159
+ r2.addEventListener(e2, "transitionend", (n2) => {
1160
+ n2.target === n2.currentTarget && (t2(), r2.dispose());
1161
+ });
1162
+ } else t2();
1163
+ return r2.dispose;
1164
+ }
1165
+ function R(e2, { inFlight: a3, prepare: t2 }) {
1166
+ if (a3 != null && a3.current) {
1167
+ t2();
1168
+ return;
1169
+ }
1170
+ let r2 = e2.style.transition;
1171
+ e2.style.transition = "none", t2(), e2.offsetHeight, e2.style.transition = r2;
1172
+ }
1173
+ function F(c2, { container: e2, accept: t2, walk: r2 }) {
1174
+ let o2 = useRef(t2), l2 = useRef(r2);
1175
+ useEffect(() => {
1176
+ o2.current = t2, l2.current = r2;
1177
+ }, [t2, r2]), n$3(() => {
1178
+ if (!e2 || !c2) return;
1179
+ let n2 = u$4(e2);
1180
+ if (!n2) return;
1181
+ let f2 = o2.current, p2 = l2.current, i2 = Object.assign((m2) => f2(m2), { acceptNode: f2 }), u2 = n2.createTreeWalker(e2, NodeFilter.SHOW_ELEMENT, i2, false);
1182
+ for (; u2.nextNode(); ) p2(u2.currentNode);
1183
+ }, [e2, c2, o2, l2]);
1184
+ }
1185
+ function m(u2, t2) {
1186
+ let e2 = useRef([]), r2 = o$2(u2);
1187
+ useEffect(() => {
1188
+ let o2 = [...e2.current];
1189
+ for (let [a3, l2] of t2.entries()) if (e2.current[a3] !== l2) {
1190
+ let n2 = r2(t2, o2);
1191
+ return e2.current = t2, n2;
1192
+ }
1193
+ }, [r2, ...t2]);
1194
+ }
1195
+ function getNodeName(node) {
1196
+ if (isNode(node)) {
1197
+ return (node.nodeName || "").toLowerCase();
1198
+ }
1199
+ return "#document";
1200
+ }
1201
+ function getWindow(node) {
1202
+ var _node$ownerDocument;
1203
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1204
+ }
1205
+ function getDocumentElement(node) {
1206
+ var _ref;
1207
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1208
+ }
1209
+ function isNode(value) {
1210
+ return value instanceof Node || value instanceof getWindow(value).Node;
1211
+ }
1212
+ function isElement(value) {
1213
+ return value instanceof Element || value instanceof getWindow(value).Element;
1214
+ }
1215
+ function isHTMLElement(value) {
1216
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1217
+ }
1218
+ function isShadowRoot(value) {
1219
+ if (typeof ShadowRoot === "undefined") {
1220
+ return false;
1221
+ }
1222
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1223
+ }
1224
+ function isOverflowElement(element) {
1225
+ const {
1226
+ overflow,
1227
+ overflowX,
1228
+ overflowY,
1229
+ display
1230
+ } = getComputedStyle$1(element);
1231
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
1232
+ }
1233
+ function isTableElement(element) {
1234
+ return ["table", "td", "th"].includes(getNodeName(element));
1235
+ }
1236
+ function isTopLayer(element) {
1237
+ return [":popover-open", ":modal"].some((selector) => {
1238
+ try {
1239
+ return element.matches(selector);
1240
+ } catch (e2) {
1241
+ return false;
1242
+ }
1243
+ });
1244
+ }
1245
+ function isContainingBlock(element) {
1246
+ const webkit = isWebKit();
1247
+ const css = getComputedStyle$1(element);
1248
+ return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
1249
+ }
1250
+ function getContainingBlock(element) {
1251
+ let currentNode = getParentNode(element);
1252
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1253
+ if (isTopLayer(currentNode)) {
1254
+ return null;
1255
+ }
1256
+ if (isContainingBlock(currentNode)) {
1257
+ return currentNode;
1258
+ }
1259
+ currentNode = getParentNode(currentNode);
1260
+ }
1261
+ return null;
1262
+ }
1263
+ function isWebKit() {
1264
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
1265
+ return CSS.supports("-webkit-backdrop-filter", "none");
1266
+ }
1267
+ function isLastTraversableNode(node) {
1268
+ return ["html", "body", "#document"].includes(getNodeName(node));
1269
+ }
1270
+ function getComputedStyle$1(element) {
1271
+ return getWindow(element).getComputedStyle(element);
1272
+ }
1273
+ function getNodeScroll(element) {
1274
+ if (isElement(element)) {
1275
+ return {
1276
+ scrollLeft: element.scrollLeft,
1277
+ scrollTop: element.scrollTop
1278
+ };
1279
+ }
1280
+ return {
1281
+ scrollLeft: element.scrollX,
1282
+ scrollTop: element.scrollY
1283
+ };
1284
+ }
1285
+ function getParentNode(node) {
1286
+ if (getNodeName(node) === "html") {
1287
+ return node;
1288
+ }
1289
+ const result = (
1290
+ // Step into the shadow DOM of the parent of a slotted node.
1291
+ node.assignedSlot || // DOM Element detected.
1292
+ node.parentNode || // ShadowRoot detected.
1293
+ isShadowRoot(node) && node.host || // Fallback.
1294
+ getDocumentElement(node)
1295
+ );
1296
+ return isShadowRoot(result) ? result.host : result;
1297
+ }
1298
+ function getNearestOverflowAncestor(node) {
1299
+ const parentNode = getParentNode(node);
1300
+ if (isLastTraversableNode(parentNode)) {
1301
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1302
+ }
1303
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1304
+ return parentNode;
1305
+ }
1306
+ return getNearestOverflowAncestor(parentNode);
1307
+ }
1308
+ function getOverflowAncestors(node, list, traverseIframes) {
1309
+ var _node$ownerDocument2;
1310
+ if (list === void 0) {
1311
+ list = [];
1312
+ }
1313
+ if (traverseIframes === void 0) {
1314
+ traverseIframes = true;
1315
+ }
1316
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1317
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1318
+ const win = getWindow(scrollableAncestor);
1319
+ if (isBody) {
1320
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
1321
+ }
1322
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1323
+ }
1324
+ function getUserAgent() {
1325
+ const uaData = navigator.userAgentData;
1326
+ if (uaData && Array.isArray(uaData.brands)) {
1327
+ return uaData.brands.map((_ref) => {
1328
+ let {
1329
+ brand,
1330
+ version
1331
+ } = _ref;
1332
+ return brand + "/" + version;
1333
+ }).join(" ");
1334
+ }
1335
+ return navigator.userAgent;
1336
+ }
1337
+ const min = Math.min;
1338
+ const max = Math.max;
1339
+ const round = Math.round;
1340
+ const floor = Math.floor;
1341
+ const createCoords = (v2) => ({
1342
+ x: v2,
1343
+ y: v2
1344
+ });
1345
+ const oppositeSideMap = {
1346
+ left: "right",
1347
+ right: "left",
1348
+ bottom: "top",
1349
+ top: "bottom"
1350
+ };
1351
+ const oppositeAlignmentMap = {
1352
+ start: "end",
1353
+ end: "start"
1354
+ };
1355
+ function clamp(start, value, end) {
1356
+ return max(start, min(value, end));
1357
+ }
1358
+ function evaluate(value, param) {
1359
+ return typeof value === "function" ? value(param) : value;
1360
+ }
1361
+ function getSide(placement) {
1362
+ return placement.split("-")[0];
1363
+ }
1364
+ function getAlignment(placement) {
1365
+ return placement.split("-")[1];
1366
+ }
1367
+ function getOppositeAxis(axis) {
1368
+ return axis === "x" ? "y" : "x";
1369
+ }
1370
+ function getAxisLength(axis) {
1371
+ return axis === "y" ? "height" : "width";
1372
+ }
1373
+ function getSideAxis(placement) {
1374
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
1375
+ }
1376
+ function getAlignmentAxis(placement) {
1377
+ return getOppositeAxis(getSideAxis(placement));
1378
+ }
1379
+ function getAlignmentSides(placement, rects, rtl) {
1380
+ if (rtl === void 0) {
1381
+ rtl = false;
1382
+ }
1383
+ const alignment = getAlignment(placement);
1384
+ const alignmentAxis = getAlignmentAxis(placement);
1385
+ const length = getAxisLength(alignmentAxis);
1386
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
1387
+ if (rects.reference[length] > rects.floating[length]) {
1388
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1389
+ }
1390
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1391
+ }
1392
+ function getExpandedPlacements(placement) {
1393
+ const oppositePlacement = getOppositePlacement(placement);
1394
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1395
+ }
1396
+ function getOppositeAlignmentPlacement(placement) {
1397
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
1398
+ }
1399
+ function getSideList(side, isStart, rtl) {
1400
+ const lr = ["left", "right"];
1401
+ const rl = ["right", "left"];
1402
+ const tb = ["top", "bottom"];
1403
+ const bt = ["bottom", "top"];
1404
+ switch (side) {
1405
+ case "top":
1406
+ case "bottom":
1407
+ if (rtl) return isStart ? rl : lr;
1408
+ return isStart ? lr : rl;
1409
+ case "left":
1410
+ case "right":
1411
+ return isStart ? tb : bt;
1412
+ default:
1413
+ return [];
1414
+ }
1415
+ }
1416
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1417
+ const alignment = getAlignment(placement);
1418
+ let list = getSideList(getSide(placement), direction === "start", rtl);
1419
+ if (alignment) {
1420
+ list = list.map((side) => side + "-" + alignment);
1421
+ if (flipAlignment) {
1422
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
1423
+ }
1424
+ }
1425
+ return list;
1426
+ }
1427
+ function getOppositePlacement(placement) {
1428
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
1429
+ }
1430
+ function expandPaddingObject(padding) {
1431
+ return {
1432
+ top: 0,
1433
+ right: 0,
1434
+ bottom: 0,
1435
+ left: 0,
1436
+ ...padding
1437
+ };
1438
+ }
1439
+ function getPaddingObject(padding) {
1440
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
1441
+ top: padding,
1442
+ right: padding,
1443
+ bottom: padding,
1444
+ left: padding
1445
+ };
1446
+ }
1447
+ function rectToClientRect(rect) {
1448
+ const {
1449
+ x: x2,
1450
+ y: y2,
1451
+ width,
1452
+ height
1453
+ } = rect;
1454
+ return {
1455
+ width,
1456
+ height,
1457
+ top: y2,
1458
+ left: x2,
1459
+ right: x2 + width,
1460
+ bottom: y2 + height,
1461
+ x: x2,
1462
+ y: y2
1463
+ };
1464
+ }
1465
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
1466
+ let {
1467
+ reference,
1468
+ floating
1469
+ } = _ref;
1470
+ const sideAxis = getSideAxis(placement);
1471
+ const alignmentAxis = getAlignmentAxis(placement);
1472
+ const alignLength = getAxisLength(alignmentAxis);
1473
+ const side = getSide(placement);
1474
+ const isVertical = sideAxis === "y";
1475
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
1476
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
1477
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1478
+ let coords;
1479
+ switch (side) {
1480
+ case "top":
1481
+ coords = {
1482
+ x: commonX,
1483
+ y: reference.y - floating.height
1484
+ };
1485
+ break;
1486
+ case "bottom":
1487
+ coords = {
1488
+ x: commonX,
1489
+ y: reference.y + reference.height
1490
+ };
1491
+ break;
1492
+ case "right":
1493
+ coords = {
1494
+ x: reference.x + reference.width,
1495
+ y: commonY
1496
+ };
1497
+ break;
1498
+ case "left":
1499
+ coords = {
1500
+ x: reference.x - floating.width,
1501
+ y: commonY
1502
+ };
1503
+ break;
1504
+ default:
1505
+ coords = {
1506
+ x: reference.x,
1507
+ y: reference.y
1508
+ };
1509
+ }
1510
+ switch (getAlignment(placement)) {
1511
+ case "start":
1512
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1513
+ break;
1514
+ case "end":
1515
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1516
+ break;
1517
+ }
1518
+ return coords;
1519
+ }
1520
+ const computePosition$1 = async (reference, floating, config) => {
1521
+ const {
1522
+ placement = "bottom",
1523
+ strategy = "absolute",
1524
+ middleware = [],
1525
+ platform: platform2
1526
+ } = config;
1527
+ const validMiddleware = middleware.filter(Boolean);
1528
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
1529
+ let rects = await platform2.getElementRects({
1530
+ reference,
1531
+ floating,
1532
+ strategy
1533
+ });
1534
+ let {
1535
+ x: x2,
1536
+ y: y2
1537
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1538
+ let statefulPlacement = placement;
1539
+ let middlewareData = {};
1540
+ let resetCount = 0;
1541
+ for (let i2 = 0; i2 < validMiddleware.length; i2++) {
1542
+ const {
1543
+ name,
1544
+ fn
1545
+ } = validMiddleware[i2];
1546
+ const {
1547
+ x: nextX,
1548
+ y: nextY,
1549
+ data,
1550
+ reset
1551
+ } = await fn({
1552
+ x: x2,
1553
+ y: y2,
1554
+ initialPlacement: placement,
1555
+ placement: statefulPlacement,
1556
+ strategy,
1557
+ middlewareData,
1558
+ rects,
1559
+ platform: platform2,
1560
+ elements: {
1561
+ reference,
1562
+ floating
1563
+ }
1564
+ });
1565
+ x2 = nextX != null ? nextX : x2;
1566
+ y2 = nextY != null ? nextY : y2;
1567
+ middlewareData = {
1568
+ ...middlewareData,
1569
+ [name]: {
1570
+ ...middlewareData[name],
1571
+ ...data
1572
+ }
1573
+ };
1574
+ if (reset && resetCount <= 50) {
1575
+ resetCount++;
1576
+ if (typeof reset === "object") {
1577
+ if (reset.placement) {
1578
+ statefulPlacement = reset.placement;
1579
+ }
1580
+ if (reset.rects) {
1581
+ rects = reset.rects === true ? await platform2.getElementRects({
1582
+ reference,
1583
+ floating,
1584
+ strategy
1585
+ }) : reset.rects;
1586
+ }
1587
+ ({
1588
+ x: x2,
1589
+ y: y2
1590
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1591
+ }
1592
+ i2 = -1;
1593
+ }
1594
+ }
1595
+ return {
1596
+ x: x2,
1597
+ y: y2,
1598
+ placement: statefulPlacement,
1599
+ strategy,
1600
+ middlewareData
1601
+ };
1602
+ };
1603
+ async function detectOverflow$1(state, options2) {
1604
+ var _await$platform$isEle;
1605
+ if (options2 === void 0) {
1606
+ options2 = {};
1607
+ }
1608
+ const {
1609
+ x: x2,
1610
+ y: y2,
1611
+ platform: platform2,
1612
+ rects,
1613
+ elements,
1614
+ strategy
1615
+ } = state;
1616
+ const {
1617
+ boundary = "clippingAncestors",
1618
+ rootBoundary = "viewport",
1619
+ elementContext = "floating",
1620
+ altBoundary = false,
1621
+ padding = 0
1622
+ } = evaluate(options2, state);
1623
+ const paddingObject = getPaddingObject(padding);
1624
+ const altContext = elementContext === "floating" ? "reference" : "floating";
1625
+ const element = elements[altBoundary ? altContext : elementContext];
1626
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
1627
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
1628
+ boundary,
1629
+ rootBoundary,
1630
+ strategy
1631
+ }));
1632
+ const rect = elementContext === "floating" ? {
1633
+ x: x2,
1634
+ y: y2,
1635
+ width: rects.floating.width,
1636
+ height: rects.floating.height
1637
+ } : rects.reference;
1638
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
1639
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
1640
+ x: 1,
1641
+ y: 1
1642
+ } : {
1643
+ x: 1,
1644
+ y: 1
1645
+ };
1646
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
1647
+ elements,
1648
+ rect,
1649
+ offsetParent,
1650
+ strategy
1651
+ }) : rect);
1652
+ return {
1653
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1654
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1655
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1656
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1657
+ };
1658
+ }
1659
+ const flip$2 = function(options2) {
1660
+ if (options2 === void 0) {
1661
+ options2 = {};
1662
+ }
1663
+ return {
1664
+ name: "flip",
1665
+ options: options2,
1666
+ async fn(state) {
1667
+ var _middlewareData$arrow, _middlewareData$flip;
1668
+ const {
1669
+ placement,
1670
+ middlewareData,
1671
+ rects,
1672
+ initialPlacement,
1673
+ platform: platform2,
1674
+ elements
1675
+ } = state;
1676
+ const {
1677
+ mainAxis: checkMainAxis = true,
1678
+ crossAxis: checkCrossAxis = true,
1679
+ fallbackPlacements: specifiedFallbackPlacements,
1680
+ fallbackStrategy = "bestFit",
1681
+ fallbackAxisSideDirection = "none",
1682
+ flipAlignment = true,
1683
+ ...detectOverflowOptions
1684
+ } = evaluate(options2, state);
1685
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1686
+ return {};
1687
+ }
1688
+ const side = getSide(placement);
1689
+ const initialSideAxis = getSideAxis(initialPlacement);
1690
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1691
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1692
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1693
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
1694
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1695
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1696
+ }
1697
+ const placements = [initialPlacement, ...fallbackPlacements];
1698
+ const overflow = await detectOverflow$1(state, detectOverflowOptions);
1699
+ const overflows = [];
1700
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1701
+ if (checkMainAxis) {
1702
+ overflows.push(overflow[side]);
1703
+ }
1704
+ if (checkCrossAxis) {
1705
+ const sides = getAlignmentSides(placement, rects, rtl);
1706
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
1707
+ }
1708
+ overflowsData = [...overflowsData, {
1709
+ placement,
1710
+ overflows
1711
+ }];
1712
+ if (!overflows.every((side2) => side2 <= 0)) {
1713
+ var _middlewareData$flip2, _overflowsData$filter;
1714
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1715
+ const nextPlacement = placements[nextIndex];
1716
+ if (nextPlacement) {
1717
+ return {
1718
+ data: {
1719
+ index: nextIndex,
1720
+ overflows: overflowsData
1721
+ },
1722
+ reset: {
1723
+ placement: nextPlacement
1724
+ }
1725
+ };
1726
+ }
1727
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a3, b) => a3.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1728
+ if (!resetPlacement) {
1729
+ switch (fallbackStrategy) {
1730
+ case "bestFit": {
1731
+ var _overflowsData$filter2;
1732
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
1733
+ if (hasFallbackAxisSideDirection) {
1734
+ const currentSideAxis = getSideAxis(d2.placement);
1735
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
1736
+ // reading directions favoring greater width.
1737
+ currentSideAxis === "y";
1738
+ }
1739
+ return true;
1740
+ }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a3, b) => a3[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
1741
+ if (placement2) {
1742
+ resetPlacement = placement2;
1743
+ }
1744
+ break;
1745
+ }
1746
+ case "initialPlacement":
1747
+ resetPlacement = initialPlacement;
1748
+ break;
1749
+ }
1750
+ }
1751
+ if (placement !== resetPlacement) {
1752
+ return {
1753
+ reset: {
1754
+ placement: resetPlacement
1755
+ }
1756
+ };
1757
+ }
1758
+ }
1759
+ return {};
1760
+ }
1761
+ };
1762
+ };
1763
+ async function convertValueToCoords(state, options2) {
1764
+ const {
1765
+ placement,
1766
+ platform: platform2,
1767
+ elements
1768
+ } = state;
1769
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1770
+ const side = getSide(placement);
1771
+ const alignment = getAlignment(placement);
1772
+ const isVertical = getSideAxis(placement) === "y";
1773
+ const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
1774
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1775
+ const rawValue = evaluate(options2, state);
1776
+ let {
1777
+ mainAxis,
1778
+ crossAxis,
1779
+ alignmentAxis
1780
+ } = typeof rawValue === "number" ? {
1781
+ mainAxis: rawValue,
1782
+ crossAxis: 0,
1783
+ alignmentAxis: null
1784
+ } : {
1785
+ mainAxis: 0,
1786
+ crossAxis: 0,
1787
+ alignmentAxis: null,
1788
+ ...rawValue
1789
+ };
1790
+ if (alignment && typeof alignmentAxis === "number") {
1791
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
1792
+ }
1793
+ return isVertical ? {
1794
+ x: crossAxis * crossAxisMulti,
1795
+ y: mainAxis * mainAxisMulti
1796
+ } : {
1797
+ x: mainAxis * mainAxisMulti,
1798
+ y: crossAxis * crossAxisMulti
1799
+ };
1800
+ }
1801
+ const offset$2 = function(options2) {
1802
+ if (options2 === void 0) {
1803
+ options2 = 0;
1804
+ }
1805
+ return {
1806
+ name: "offset",
1807
+ options: options2,
1808
+ async fn(state) {
1809
+ var _middlewareData$offse, _middlewareData$arrow;
1810
+ const {
1811
+ x: x2,
1812
+ y: y2,
1813
+ placement,
1814
+ middlewareData
1815
+ } = state;
1816
+ const diffCoords = await convertValueToCoords(state, options2);
1817
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1818
+ return {};
1819
+ }
1820
+ return {
1821
+ x: x2 + diffCoords.x,
1822
+ y: y2 + diffCoords.y,
1823
+ data: {
1824
+ ...diffCoords,
1825
+ placement
1826
+ }
1827
+ };
1828
+ }
1829
+ };
1830
+ };
1831
+ const shift$2 = function(options2) {
1832
+ if (options2 === void 0) {
1833
+ options2 = {};
1834
+ }
1835
+ return {
1836
+ name: "shift",
1837
+ options: options2,
1838
+ async fn(state) {
1839
+ const {
1840
+ x: x2,
1841
+ y: y2,
1842
+ placement
1843
+ } = state;
1844
+ const {
1845
+ mainAxis: checkMainAxis = true,
1846
+ crossAxis: checkCrossAxis = false,
1847
+ limiter = {
1848
+ fn: (_ref) => {
1849
+ let {
1850
+ x: x3,
1851
+ y: y3
1852
+ } = _ref;
1853
+ return {
1854
+ x: x3,
1855
+ y: y3
1856
+ };
1857
+ }
1858
+ },
1859
+ ...detectOverflowOptions
1860
+ } = evaluate(options2, state);
1861
+ const coords = {
1862
+ x: x2,
1863
+ y: y2
1864
+ };
1865
+ const overflow = await detectOverflow$1(state, detectOverflowOptions);
1866
+ const crossAxis = getSideAxis(getSide(placement));
1867
+ const mainAxis = getOppositeAxis(crossAxis);
1868
+ let mainAxisCoord = coords[mainAxis];
1869
+ let crossAxisCoord = coords[crossAxis];
1870
+ if (checkMainAxis) {
1871
+ const minSide = mainAxis === "y" ? "top" : "left";
1872
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
1873
+ const min2 = mainAxisCoord + overflow[minSide];
1874
+ const max2 = mainAxisCoord - overflow[maxSide];
1875
+ mainAxisCoord = clamp(min2, mainAxisCoord, max2);
1876
+ }
1877
+ if (checkCrossAxis) {
1878
+ const minSide = crossAxis === "y" ? "top" : "left";
1879
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
1880
+ const min2 = crossAxisCoord + overflow[minSide];
1881
+ const max2 = crossAxisCoord - overflow[maxSide];
1882
+ crossAxisCoord = clamp(min2, crossAxisCoord, max2);
1883
+ }
1884
+ const limitedCoords = limiter.fn({
1885
+ ...state,
1886
+ [mainAxis]: mainAxisCoord,
1887
+ [crossAxis]: crossAxisCoord
1888
+ });
1889
+ return {
1890
+ ...limitedCoords,
1891
+ data: {
1892
+ x: limitedCoords.x - x2,
1893
+ y: limitedCoords.y - y2
1894
+ }
1895
+ };
1896
+ }
1897
+ };
1898
+ };
1899
+ const size$2 = function(options2) {
1900
+ if (options2 === void 0) {
1901
+ options2 = {};
1902
+ }
1903
+ return {
1904
+ name: "size",
1905
+ options: options2,
1906
+ async fn(state) {
1907
+ const {
1908
+ placement,
1909
+ rects,
1910
+ platform: platform2,
1911
+ elements
1912
+ } = state;
1913
+ const {
1914
+ apply = () => {
1915
+ },
1916
+ ...detectOverflowOptions
1917
+ } = evaluate(options2, state);
1918
+ const overflow = await detectOverflow$1(state, detectOverflowOptions);
1919
+ const side = getSide(placement);
1920
+ const alignment = getAlignment(placement);
1921
+ const isYAxis = getSideAxis(placement) === "y";
1922
+ const {
1923
+ width,
1924
+ height
1925
+ } = rects.floating;
1926
+ let heightSide;
1927
+ let widthSide;
1928
+ if (side === "top" || side === "bottom") {
1929
+ heightSide = side;
1930
+ widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
1931
+ } else {
1932
+ widthSide = side;
1933
+ heightSide = alignment === "end" ? "top" : "bottom";
1934
+ }
1935
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
1936
+ const maximumClippingWidth = width - overflow.left - overflow.right;
1937
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1938
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1939
+ const noShift = !state.middlewareData.shift;
1940
+ let availableHeight = overflowAvailableHeight;
1941
+ let availableWidth = overflowAvailableWidth;
1942
+ if (isYAxis) {
1943
+ availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
1944
+ } else {
1945
+ availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
1946
+ }
1947
+ if (noShift && !alignment) {
1948
+ const xMin = max(overflow.left, 0);
1949
+ const xMax = max(overflow.right, 0);
1950
+ const yMin = max(overflow.top, 0);
1951
+ const yMax = max(overflow.bottom, 0);
1952
+ if (isYAxis) {
1953
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1954
+ } else {
1955
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1956
+ }
1957
+ }
1958
+ await apply({
1959
+ ...state,
1960
+ availableWidth,
1961
+ availableHeight
1962
+ });
1963
+ const nextDimensions = await platform2.getDimensions(elements.floating);
1964
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1965
+ return {
1966
+ reset: {
1967
+ rects: true
1968
+ }
1969
+ };
1970
+ }
1971
+ return {};
1972
+ }
1973
+ };
1974
+ };
1975
+ function getCssDimensions(element) {
1976
+ const css = getComputedStyle$1(element);
1977
+ let width = parseFloat(css.width) || 0;
1978
+ let height = parseFloat(css.height) || 0;
1979
+ const hasOffset = isHTMLElement(element);
1980
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1981
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1982
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1983
+ if (shouldFallback) {
1984
+ width = offsetWidth;
1985
+ height = offsetHeight;
1986
+ }
1987
+ return {
1988
+ width,
1989
+ height,
1990
+ $: shouldFallback
1991
+ };
1992
+ }
1993
+ function unwrapElement(element) {
1994
+ return !isElement(element) ? element.contextElement : element;
1995
+ }
1996
+ function getScale(element) {
1997
+ const domElement = unwrapElement(element);
1998
+ if (!isHTMLElement(domElement)) {
1999
+ return createCoords(1);
2000
+ }
2001
+ const rect = domElement.getBoundingClientRect();
2002
+ const {
2003
+ width,
2004
+ height,
2005
+ $
2006
+ } = getCssDimensions(domElement);
2007
+ let x2 = ($ ? round(rect.width) : rect.width) / width;
2008
+ let y2 = ($ ? round(rect.height) : rect.height) / height;
2009
+ if (!x2 || !Number.isFinite(x2)) {
2010
+ x2 = 1;
2011
+ }
2012
+ if (!y2 || !Number.isFinite(y2)) {
2013
+ y2 = 1;
2014
+ }
2015
+ return {
2016
+ x: x2,
2017
+ y: y2
2018
+ };
2019
+ }
2020
+ const noOffsets = /* @__PURE__ */ createCoords(0);
2021
+ function getVisualOffsets(element) {
2022
+ const win = getWindow(element);
2023
+ if (!isWebKit() || !win.visualViewport) {
2024
+ return noOffsets;
2025
+ }
2026
+ return {
2027
+ x: win.visualViewport.offsetLeft,
2028
+ y: win.visualViewport.offsetTop
2029
+ };
2030
+ }
2031
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2032
+ if (isFixed === void 0) {
2033
+ isFixed = false;
2034
+ }
2035
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2036
+ return false;
2037
+ }
2038
+ return isFixed;
2039
+ }
2040
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2041
+ if (includeScale === void 0) {
2042
+ includeScale = false;
2043
+ }
2044
+ if (isFixedStrategy === void 0) {
2045
+ isFixedStrategy = false;
2046
+ }
2047
+ const clientRect = element.getBoundingClientRect();
2048
+ const domElement = unwrapElement(element);
2049
+ let scale = createCoords(1);
2050
+ if (includeScale) {
2051
+ if (offsetParent) {
2052
+ if (isElement(offsetParent)) {
2053
+ scale = getScale(offsetParent);
2054
+ }
2055
+ } else {
2056
+ scale = getScale(element);
2057
+ }
2058
+ }
2059
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2060
+ let x2 = (clientRect.left + visualOffsets.x) / scale.x;
2061
+ let y2 = (clientRect.top + visualOffsets.y) / scale.y;
2062
+ let width = clientRect.width / scale.x;
2063
+ let height = clientRect.height / scale.y;
2064
+ if (domElement) {
2065
+ const win = getWindow(domElement);
2066
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2067
+ let currentWin = win;
2068
+ let currentIFrame = currentWin.frameElement;
2069
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2070
+ const iframeScale = getScale(currentIFrame);
2071
+ const iframeRect = currentIFrame.getBoundingClientRect();
2072
+ const css = getComputedStyle$1(currentIFrame);
2073
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2074
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2075
+ x2 *= iframeScale.x;
2076
+ y2 *= iframeScale.y;
2077
+ width *= iframeScale.x;
2078
+ height *= iframeScale.y;
2079
+ x2 += left;
2080
+ y2 += top;
2081
+ currentWin = getWindow(currentIFrame);
2082
+ currentIFrame = currentWin.frameElement;
2083
+ }
2084
+ }
2085
+ return rectToClientRect({
2086
+ width,
2087
+ height,
2088
+ x: x2,
2089
+ y: y2
2090
+ });
2091
+ }
2092
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2093
+ let {
2094
+ elements,
2095
+ rect,
2096
+ offsetParent,
2097
+ strategy
2098
+ } = _ref;
2099
+ const isFixed = strategy === "fixed";
2100
+ const documentElement = getDocumentElement(offsetParent);
2101
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
2102
+ if (offsetParent === documentElement || topLayer && isFixed) {
2103
+ return rect;
2104
+ }
2105
+ let scroll = {
2106
+ scrollLeft: 0,
2107
+ scrollTop: 0
2108
+ };
2109
+ let scale = createCoords(1);
2110
+ const offsets = createCoords(0);
2111
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2112
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2113
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2114
+ scroll = getNodeScroll(offsetParent);
2115
+ }
2116
+ if (isHTMLElement(offsetParent)) {
2117
+ const offsetRect = getBoundingClientRect(offsetParent);
2118
+ scale = getScale(offsetParent);
2119
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2120
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2121
+ }
2122
+ }
2123
+ return {
2124
+ width: rect.width * scale.x,
2125
+ height: rect.height * scale.y,
2126
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2127
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
2128
+ };
2129
+ }
2130
+ function getClientRects(element) {
2131
+ return Array.from(element.getClientRects());
2132
+ }
2133
+ function getWindowScrollBarX(element) {
2134
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
2135
+ }
2136
+ function getDocumentRect(element) {
2137
+ const html = getDocumentElement(element);
2138
+ const scroll = getNodeScroll(element);
2139
+ const body = element.ownerDocument.body;
2140
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2141
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2142
+ let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
2143
+ const y2 = -scroll.scrollTop;
2144
+ if (getComputedStyle$1(body).direction === "rtl") {
2145
+ x2 += max(html.clientWidth, body.clientWidth) - width;
2146
+ }
2147
+ return {
2148
+ width,
2149
+ height,
2150
+ x: x2,
2151
+ y: y2
2152
+ };
2153
+ }
2154
+ function getViewportRect(element, strategy) {
2155
+ const win = getWindow(element);
2156
+ const html = getDocumentElement(element);
2157
+ const visualViewport = win.visualViewport;
2158
+ let width = html.clientWidth;
2159
+ let height = html.clientHeight;
2160
+ let x2 = 0;
2161
+ let y2 = 0;
2162
+ if (visualViewport) {
2163
+ width = visualViewport.width;
2164
+ height = visualViewport.height;
2165
+ const visualViewportBased = isWebKit();
2166
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
2167
+ x2 = visualViewport.offsetLeft;
2168
+ y2 = visualViewport.offsetTop;
2169
+ }
2170
+ }
2171
+ return {
2172
+ width,
2173
+ height,
2174
+ x: x2,
2175
+ y: y2
2176
+ };
2177
+ }
2178
+ function getInnerBoundingClientRect(element, strategy) {
2179
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
2180
+ const top = clientRect.top + element.clientTop;
2181
+ const left = clientRect.left + element.clientLeft;
2182
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2183
+ const width = element.clientWidth * scale.x;
2184
+ const height = element.clientHeight * scale.y;
2185
+ const x2 = left * scale.x;
2186
+ const y2 = top * scale.y;
2187
+ return {
2188
+ width,
2189
+ height,
2190
+ x: x2,
2191
+ y: y2
2192
+ };
2193
+ }
2194
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2195
+ let rect;
2196
+ if (clippingAncestor === "viewport") {
2197
+ rect = getViewportRect(element, strategy);
2198
+ } else if (clippingAncestor === "document") {
2199
+ rect = getDocumentRect(getDocumentElement(element));
2200
+ } else if (isElement(clippingAncestor)) {
2201
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2202
+ } else {
2203
+ const visualOffsets = getVisualOffsets(element);
2204
+ rect = {
2205
+ ...clippingAncestor,
2206
+ x: clippingAncestor.x - visualOffsets.x,
2207
+ y: clippingAncestor.y - visualOffsets.y
2208
+ };
2209
+ }
2210
+ return rectToClientRect(rect);
2211
+ }
2212
+ function hasFixedPositionAncestor(element, stopNode) {
2213
+ const parentNode = getParentNode(element);
2214
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2215
+ return false;
2216
+ }
2217
+ return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
2218
+ }
2219
+ function getClippingElementAncestors(element, cache) {
2220
+ const cachedResult = cache.get(element);
2221
+ if (cachedResult) {
2222
+ return cachedResult;
2223
+ }
2224
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
2225
+ let currentContainingBlockComputedStyle = null;
2226
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
2227
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2228
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2229
+ const computedStyle = getComputedStyle$1(currentNode);
2230
+ const currentNodeIsContaining = isContainingBlock(currentNode);
2231
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
2232
+ currentContainingBlockComputedStyle = null;
2233
+ }
2234
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2235
+ if (shouldDropCurrentNode) {
2236
+ result = result.filter((ancestor) => ancestor !== currentNode);
2237
+ } else {
2238
+ currentContainingBlockComputedStyle = computedStyle;
2239
+ }
2240
+ currentNode = getParentNode(currentNode);
2241
+ }
2242
+ cache.set(element, result);
2243
+ return result;
2244
+ }
2245
+ function getClippingRect(_ref) {
2246
+ let {
2247
+ element,
2248
+ boundary,
2249
+ rootBoundary,
2250
+ strategy
2251
+ } = _ref;
2252
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2253
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2254
+ const firstClippingAncestor = clippingAncestors[0];
2255
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2256
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2257
+ accRect.top = max(rect.top, accRect.top);
2258
+ accRect.right = min(rect.right, accRect.right);
2259
+ accRect.bottom = min(rect.bottom, accRect.bottom);
2260
+ accRect.left = max(rect.left, accRect.left);
2261
+ return accRect;
2262
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2263
+ return {
2264
+ width: clippingRect.right - clippingRect.left,
2265
+ height: clippingRect.bottom - clippingRect.top,
2266
+ x: clippingRect.left,
2267
+ y: clippingRect.top
2268
+ };
2269
+ }
2270
+ function getDimensions(element) {
2271
+ const {
2272
+ width,
2273
+ height
2274
+ } = getCssDimensions(element);
2275
+ return {
2276
+ width,
2277
+ height
2278
+ };
2279
+ }
2280
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2281
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2282
+ const documentElement = getDocumentElement(offsetParent);
2283
+ const isFixed = strategy === "fixed";
2284
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2285
+ let scroll = {
2286
+ scrollLeft: 0,
2287
+ scrollTop: 0
2288
+ };
2289
+ const offsets = createCoords(0);
2290
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2291
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2292
+ scroll = getNodeScroll(offsetParent);
2293
+ }
2294
+ if (isOffsetParentAnElement) {
2295
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2296
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2297
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2298
+ } else if (documentElement) {
2299
+ offsets.x = getWindowScrollBarX(documentElement);
2300
+ }
2301
+ }
2302
+ const x2 = rect.left + scroll.scrollLeft - offsets.x;
2303
+ const y2 = rect.top + scroll.scrollTop - offsets.y;
2304
+ return {
2305
+ x: x2,
2306
+ y: y2,
2307
+ width: rect.width,
2308
+ height: rect.height
2309
+ };
2310
+ }
2311
+ function isStaticPositioned(element) {
2312
+ return getComputedStyle$1(element).position === "static";
2313
+ }
2314
+ function getTrueOffsetParent(element, polyfill) {
2315
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
2316
+ return null;
2317
+ }
2318
+ if (polyfill) {
2319
+ return polyfill(element);
2320
+ }
2321
+ return element.offsetParent;
2322
+ }
2323
+ function getOffsetParent(element, polyfill) {
2324
+ const win = getWindow(element);
2325
+ if (isTopLayer(element)) {
2326
+ return win;
2327
+ }
2328
+ if (!isHTMLElement(element)) {
2329
+ let svgOffsetParent = getParentNode(element);
2330
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2331
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2332
+ return svgOffsetParent;
2333
+ }
2334
+ svgOffsetParent = getParentNode(svgOffsetParent);
2335
+ }
2336
+ return win;
2337
+ }
2338
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2339
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2340
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2341
+ }
2342
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2343
+ return win;
2344
+ }
2345
+ return offsetParent || getContainingBlock(element) || win;
2346
+ }
2347
+ const getElementRects = async function(data) {
2348
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2349
+ const getDimensionsFn = this.getDimensions;
2350
+ const floatingDimensions = await getDimensionsFn(data.floating);
2351
+ return {
2352
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2353
+ floating: {
2354
+ x: 0,
2355
+ y: 0,
2356
+ width: floatingDimensions.width,
2357
+ height: floatingDimensions.height
2358
+ }
2359
+ };
2360
+ };
2361
+ function isRTL(element) {
2362
+ return getComputedStyle$1(element).direction === "rtl";
2363
+ }
2364
+ const platform = {
2365
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2366
+ getDocumentElement,
2367
+ getClippingRect,
2368
+ getOffsetParent,
2369
+ getElementRects,
2370
+ getClientRects,
2371
+ getDimensions,
2372
+ getScale,
2373
+ isElement,
2374
+ isRTL
2375
+ };
2376
+ function observeMove(element, onMove) {
2377
+ let io = null;
2378
+ let timeoutId;
2379
+ const root = getDocumentElement(element);
2380
+ function cleanup() {
2381
+ var _io;
2382
+ clearTimeout(timeoutId);
2383
+ (_io = io) == null || _io.disconnect();
2384
+ io = null;
2385
+ }
2386
+ function refresh(skip, threshold) {
2387
+ if (skip === void 0) {
2388
+ skip = false;
2389
+ }
2390
+ if (threshold === void 0) {
2391
+ threshold = 1;
2392
+ }
2393
+ cleanup();
2394
+ const {
2395
+ left,
2396
+ top,
2397
+ width,
2398
+ height
2399
+ } = element.getBoundingClientRect();
2400
+ if (!skip) {
2401
+ onMove();
2402
+ }
2403
+ if (!width || !height) {
2404
+ return;
2405
+ }
2406
+ const insetTop = floor(top);
2407
+ const insetRight = floor(root.clientWidth - (left + width));
2408
+ const insetBottom = floor(root.clientHeight - (top + height));
2409
+ const insetLeft = floor(left);
2410
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2411
+ const options2 = {
2412
+ rootMargin,
2413
+ threshold: max(0, min(1, threshold)) || 1
2414
+ };
2415
+ let isFirstUpdate = true;
2416
+ function handleObserve(entries) {
2417
+ const ratio = entries[0].intersectionRatio;
2418
+ if (ratio !== threshold) {
2419
+ if (!isFirstUpdate) {
2420
+ return refresh();
2421
+ }
2422
+ if (!ratio) {
2423
+ timeoutId = setTimeout(() => {
2424
+ refresh(false, 1e-7);
2425
+ }, 1e3);
2426
+ } else {
2427
+ refresh(false, ratio);
2428
+ }
2429
+ }
2430
+ isFirstUpdate = false;
2431
+ }
2432
+ try {
2433
+ io = new IntersectionObserver(handleObserve, {
2434
+ ...options2,
2435
+ // Handle <iframe>s
2436
+ root: root.ownerDocument
2437
+ });
2438
+ } catch (e2) {
2439
+ io = new IntersectionObserver(handleObserve, options2);
2440
+ }
2441
+ io.observe(element);
2442
+ }
2443
+ refresh(true);
2444
+ return cleanup;
2445
+ }
2446
+ function autoUpdate(reference, floating, update, options2) {
2447
+ if (options2 === void 0) {
2448
+ options2 = {};
2449
+ }
2450
+ const {
2451
+ ancestorScroll = true,
2452
+ ancestorResize = true,
2453
+ elementResize = typeof ResizeObserver === "function",
2454
+ layoutShift = typeof IntersectionObserver === "function",
2455
+ animationFrame = false
2456
+ } = options2;
2457
+ const referenceEl = unwrapElement(reference);
2458
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
2459
+ ancestors.forEach((ancestor) => {
2460
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
2461
+ passive: true
2462
+ });
2463
+ ancestorResize && ancestor.addEventListener("resize", update);
2464
+ });
2465
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2466
+ let reobserveFrame = -1;
2467
+ let resizeObserver = null;
2468
+ if (elementResize) {
2469
+ resizeObserver = new ResizeObserver((_ref) => {
2470
+ let [firstEntry] = _ref;
2471
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2472
+ resizeObserver.unobserve(floating);
2473
+ cancelAnimationFrame(reobserveFrame);
2474
+ reobserveFrame = requestAnimationFrame(() => {
2475
+ var _resizeObserver;
2476
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2477
+ });
2478
+ }
2479
+ update();
2480
+ });
2481
+ if (referenceEl && !animationFrame) {
2482
+ resizeObserver.observe(referenceEl);
2483
+ }
2484
+ resizeObserver.observe(floating);
2485
+ }
2486
+ let frameId;
2487
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2488
+ if (animationFrame) {
2489
+ frameLoop();
2490
+ }
2491
+ function frameLoop() {
2492
+ const nextRefRect = getBoundingClientRect(reference);
2493
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2494
+ update();
2495
+ }
2496
+ prevRefRect = nextRefRect;
2497
+ frameId = requestAnimationFrame(frameLoop);
2498
+ }
2499
+ update();
2500
+ return () => {
2501
+ var _resizeObserver2;
2502
+ ancestors.forEach((ancestor) => {
2503
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
2504
+ ancestorResize && ancestor.removeEventListener("resize", update);
2505
+ });
2506
+ cleanupIo == null || cleanupIo();
2507
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2508
+ resizeObserver = null;
2509
+ if (animationFrame) {
2510
+ cancelAnimationFrame(frameId);
2511
+ }
2512
+ };
2513
+ }
2514
+ const detectOverflow = detectOverflow$1;
2515
+ const offset$1 = offset$2;
2516
+ const shift$1 = shift$2;
2517
+ const flip$1 = flip$2;
2518
+ const size$1 = size$2;
2519
+ const computePosition = (reference, floating, options2) => {
2520
+ const cache = /* @__PURE__ */ new Map();
2521
+ const mergedOptions = {
2522
+ platform,
2523
+ ...options2
2524
+ };
2525
+ const platformWithCache = {
2526
+ ...mergedOptions.platform,
2527
+ _c: cache
2528
+ };
2529
+ return computePosition$1(reference, floating, {
2530
+ ...mergedOptions,
2531
+ platform: platformWithCache
2532
+ });
2533
+ };
2534
+ var index$1 = typeof document !== "undefined" ? useLayoutEffect : useEffect;
2535
+ function deepEqual(a3, b) {
2536
+ if (a3 === b) {
2537
+ return true;
2538
+ }
2539
+ if (typeof a3 !== typeof b) {
2540
+ return false;
2541
+ }
2542
+ if (typeof a3 === "function" && a3.toString() === b.toString()) {
2543
+ return true;
2544
+ }
2545
+ let length;
2546
+ let i2;
2547
+ let keys;
2548
+ if (a3 && b && typeof a3 === "object") {
2549
+ if (Array.isArray(a3)) {
2550
+ length = a3.length;
2551
+ if (length !== b.length) return false;
2552
+ for (i2 = length; i2-- !== 0; ) {
2553
+ if (!deepEqual(a3[i2], b[i2])) {
2554
+ return false;
2555
+ }
2556
+ }
2557
+ return true;
2558
+ }
2559
+ keys = Object.keys(a3);
2560
+ length = keys.length;
2561
+ if (length !== Object.keys(b).length) {
2562
+ return false;
2563
+ }
2564
+ for (i2 = length; i2-- !== 0; ) {
2565
+ if (!{}.hasOwnProperty.call(b, keys[i2])) {
2566
+ return false;
2567
+ }
2568
+ }
2569
+ for (i2 = length; i2-- !== 0; ) {
2570
+ const key = keys[i2];
2571
+ if (key === "_owner" && a3.$$typeof) {
2572
+ continue;
2573
+ }
2574
+ if (!deepEqual(a3[key], b[key])) {
2575
+ return false;
2576
+ }
2577
+ }
2578
+ return true;
2579
+ }
2580
+ return a3 !== a3 && b !== b;
2581
+ }
2582
+ function getDPR(element) {
2583
+ if (typeof window === "undefined") {
2584
+ return 1;
2585
+ }
2586
+ const win = element.ownerDocument.defaultView || window;
2587
+ return win.devicePixelRatio || 1;
2588
+ }
2589
+ function roundByDPR(element, value) {
2590
+ const dpr = getDPR(element);
2591
+ return Math.round(value * dpr) / dpr;
2592
+ }
2593
+ function useLatestRef(value) {
2594
+ const ref = React.useRef(value);
2595
+ index$1(() => {
2596
+ ref.current = value;
2597
+ });
2598
+ return ref;
2599
+ }
2600
+ function useFloating$1(options2) {
2601
+ if (options2 === void 0) {
2602
+ options2 = {};
2603
+ }
2604
+ const {
2605
+ placement = "bottom",
2606
+ strategy = "absolute",
2607
+ middleware = [],
2608
+ platform: platform2,
2609
+ elements: {
2610
+ reference: externalReference,
2611
+ floating: externalFloating
2612
+ } = {},
2613
+ transform = true,
2614
+ whileElementsMounted,
2615
+ open
2616
+ } = options2;
2617
+ const [data, setData] = React.useState({
2618
+ x: 0,
2619
+ y: 0,
2620
+ strategy,
2621
+ placement,
2622
+ middlewareData: {},
2623
+ isPositioned: false
2624
+ });
2625
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
2626
+ if (!deepEqual(latestMiddleware, middleware)) {
2627
+ setLatestMiddleware(middleware);
2628
+ }
2629
+ const [_reference, _setReference] = React.useState(null);
2630
+ const [_floating, _setFloating] = React.useState(null);
2631
+ const setReference = React.useCallback((node) => {
2632
+ if (node !== referenceRef.current) {
2633
+ referenceRef.current = node;
2634
+ _setReference(node);
2635
+ }
2636
+ }, []);
2637
+ const setFloating = React.useCallback((node) => {
2638
+ if (node !== floatingRef.current) {
2639
+ floatingRef.current = node;
2640
+ _setFloating(node);
2641
+ }
2642
+ }, []);
2643
+ const referenceEl = externalReference || _reference;
2644
+ const floatingEl = externalFloating || _floating;
2645
+ const referenceRef = React.useRef(null);
2646
+ const floatingRef = React.useRef(null);
2647
+ const dataRef = React.useRef(data);
2648
+ const hasWhileElementsMounted = whileElementsMounted != null;
2649
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2650
+ const platformRef = useLatestRef(platform2);
2651
+ const update = React.useCallback(() => {
2652
+ if (!referenceRef.current || !floatingRef.current) {
2653
+ return;
2654
+ }
2655
+ const config = {
2656
+ placement,
2657
+ strategy,
2658
+ middleware: latestMiddleware
2659
+ };
2660
+ if (platformRef.current) {
2661
+ config.platform = platformRef.current;
2662
+ }
2663
+ computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
2664
+ const fullData = {
2665
+ ...data2,
2666
+ isPositioned: true
2667
+ };
2668
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2669
+ dataRef.current = fullData;
2670
+ ReactDOM.flushSync(() => {
2671
+ setData(fullData);
2672
+ });
2673
+ }
2674
+ });
2675
+ }, [latestMiddleware, placement, strategy, platformRef]);
2676
+ index$1(() => {
2677
+ if (open === false && dataRef.current.isPositioned) {
2678
+ dataRef.current.isPositioned = false;
2679
+ setData((data2) => ({
2680
+ ...data2,
2681
+ isPositioned: false
2682
+ }));
2683
+ }
2684
+ }, [open]);
2685
+ const isMountedRef = React.useRef(false);
2686
+ index$1(() => {
2687
+ isMountedRef.current = true;
2688
+ return () => {
2689
+ isMountedRef.current = false;
2690
+ };
2691
+ }, []);
2692
+ index$1(() => {
2693
+ if (referenceEl) referenceRef.current = referenceEl;
2694
+ if (floatingEl) floatingRef.current = floatingEl;
2695
+ if (referenceEl && floatingEl) {
2696
+ if (whileElementsMountedRef.current) {
2697
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2698
+ }
2699
+ update();
2700
+ }
2701
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2702
+ const refs = React.useMemo(() => ({
2703
+ reference: referenceRef,
2704
+ floating: floatingRef,
2705
+ setReference,
2706
+ setFloating
2707
+ }), [setReference, setFloating]);
2708
+ const elements = React.useMemo(() => ({
2709
+ reference: referenceEl,
2710
+ floating: floatingEl
2711
+ }), [referenceEl, floatingEl]);
2712
+ const floatingStyles = React.useMemo(() => {
2713
+ const initialStyles = {
2714
+ position: strategy,
2715
+ left: 0,
2716
+ top: 0
2717
+ };
2718
+ if (!elements.floating) {
2719
+ return initialStyles;
2720
+ }
2721
+ const x2 = roundByDPR(elements.floating, data.x);
2722
+ const y2 = roundByDPR(elements.floating, data.y);
2723
+ if (transform) {
2724
+ return {
2725
+ ...initialStyles,
2726
+ transform: "translate(" + x2 + "px, " + y2 + "px)",
2727
+ ...getDPR(elements.floating) >= 1.5 && {
2728
+ willChange: "transform"
2729
+ }
2730
+ };
2731
+ }
2732
+ return {
2733
+ position: strategy,
2734
+ left: x2,
2735
+ top: y2
2736
+ };
2737
+ }, [strategy, transform, elements.floating, data.x, data.y]);
2738
+ return React.useMemo(() => ({
2739
+ ...data,
2740
+ update,
2741
+ refs,
2742
+ elements,
2743
+ floatingStyles
2744
+ }), [data, update, refs, elements, floatingStyles]);
2745
+ }
2746
+ const offset = (options2, deps) => ({
2747
+ ...offset$1(options2),
2748
+ options: [options2, deps]
2749
+ });
2750
+ const shift = (options2, deps) => ({
2751
+ ...shift$1(options2),
2752
+ options: [options2, deps]
2753
+ });
2754
+ const flip = (options2, deps) => ({
2755
+ ...flip$1(options2),
2756
+ options: [options2, deps]
2757
+ });
2758
+ const size = (options2, deps) => ({
2759
+ ...size$1(options2),
2760
+ options: [options2, deps]
2761
+ });
2762
+ const SafeReact = {
2763
+ ...React
2764
+ };
2765
+ const useInsertionEffect = SafeReact.useInsertionEffect;
2766
+ const useSafeInsertionEffect = useInsertionEffect || ((fn) => fn());
2767
+ function useEffectEvent(callback) {
2768
+ const ref = React.useRef(() => {
2769
+ if (process.env.NODE_ENV !== "production") {
2770
+ throw new Error("Cannot call an event handler while rendering.");
2771
+ }
2772
+ });
2773
+ useSafeInsertionEffect(() => {
2774
+ ref.current = callback;
2775
+ });
2776
+ return React.useCallback(function() {
2777
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2778
+ args[_key] = arguments[_key];
2779
+ }
2780
+ return ref.current == null ? void 0 : ref.current(...args);
2781
+ }, []);
2782
+ }
2783
+ var index = typeof document !== "undefined" ? useLayoutEffect : useEffect;
2784
+ let serverHandoffComplete = false;
2785
+ let count = 0;
2786
+ const genId = () => (
2787
+ // Ensure the id is unique with multiple independent versions of Floating UI
2788
+ // on <React 18
2789
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
2790
+ );
2791
+ function useFloatingId() {
2792
+ const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : void 0);
2793
+ index(() => {
2794
+ if (id == null) {
2795
+ setId(genId());
2796
+ }
2797
+ }, []);
2798
+ React.useEffect(() => {
2799
+ serverHandoffComplete = true;
2800
+ }, []);
2801
+ return id;
2802
+ }
2803
+ const useReactId = SafeReact.useId;
2804
+ const useId = useReactId || useFloatingId;
2805
+ let devMessageSet;
2806
+ if (process.env.NODE_ENV !== "production") {
2807
+ devMessageSet = /* @__PURE__ */ new Set();
2808
+ }
2809
+ function warn() {
2810
+ var _devMessageSet;
2811
+ for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
2812
+ messages[_key] = arguments[_key];
2813
+ }
2814
+ const message = "Floating UI: " + messages.join(" ");
2815
+ if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(message))) {
2816
+ var _devMessageSet2;
2817
+ (_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(message);
2818
+ console.warn(message);
2819
+ }
2820
+ }
2821
+ function error() {
2822
+ var _devMessageSet3;
2823
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2824
+ messages[_key2] = arguments[_key2];
2825
+ }
2826
+ const message = "Floating UI: " + messages.join(" ");
2827
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
2828
+ var _devMessageSet4;
2829
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
2830
+ console.error(message);
2831
+ }
2832
+ }
2833
+ function createPubSub() {
2834
+ const map = /* @__PURE__ */ new Map();
2835
+ return {
2836
+ emit(event, data) {
2837
+ var _map$get;
2838
+ (_map$get = map.get(event)) == null || _map$get.forEach((handler) => handler(data));
2839
+ },
2840
+ on(event, listener) {
2841
+ map.set(event, [...map.get(event) || [], listener]);
2842
+ },
2843
+ off(event, listener) {
2844
+ var _map$get2;
2845
+ map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter((l2) => l2 !== listener)) || []);
2846
+ }
2847
+ };
2848
+ }
2849
+ const FloatingNodeContext = /* @__PURE__ */ React.createContext(null);
2850
+ const FloatingTreeContext = /* @__PURE__ */ React.createContext(null);
2851
+ const useFloatingParentNodeId = () => {
2852
+ var _React$useContext;
2853
+ return ((_React$useContext = React.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
2854
+ };
2855
+ const useFloatingTree = () => React.useContext(FloatingTreeContext);
2856
+ function useFloatingRootContext(options2) {
2857
+ const {
2858
+ open = false,
2859
+ onOpenChange: onOpenChangeProp,
2860
+ elements: elementsProp
2861
+ } = options2;
2862
+ const floatingId = useId();
2863
+ const dataRef = React.useRef({});
2864
+ const [events] = React.useState(() => createPubSub());
2865
+ const nested = useFloatingParentNodeId() != null;
2866
+ if (process.env.NODE_ENV !== "production") {
2867
+ const optionDomReference = elementsProp.reference;
2868
+ if (optionDomReference && !isElement(optionDomReference)) {
2869
+ error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
2870
+ }
2871
+ }
2872
+ const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
2873
+ const onOpenChange = useEffectEvent((open2, event, reason) => {
2874
+ dataRef.current.openEvent = open2 ? event : void 0;
2875
+ events.emit("openchange", {
2876
+ open: open2,
2877
+ event,
2878
+ reason,
2879
+ nested
2880
+ });
2881
+ onOpenChangeProp == null || onOpenChangeProp(open2, event, reason);
2882
+ });
2883
+ const refs = React.useMemo(() => ({
2884
+ setPositionReference
2885
+ }), []);
2886
+ const elements = React.useMemo(() => ({
2887
+ reference: positionReference || elementsProp.reference || null,
2888
+ floating: elementsProp.floating || null,
2889
+ domReference: elementsProp.reference
2890
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
2891
+ return React.useMemo(() => ({
2892
+ dataRef,
2893
+ open,
2894
+ onOpenChange,
2895
+ elements,
2896
+ events,
2897
+ floatingId,
2898
+ refs
2899
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
2900
+ }
2901
+ function useFloating(options2) {
2902
+ if (options2 === void 0) {
2903
+ options2 = {};
2904
+ }
2905
+ const {
2906
+ nodeId
2907
+ } = options2;
2908
+ const internalRootContext = useFloatingRootContext({
2909
+ ...options2,
2910
+ elements: {
2911
+ reference: null,
2912
+ floating: null,
2913
+ ...options2.elements
2914
+ }
2915
+ });
2916
+ const rootContext = options2.rootContext || internalRootContext;
2917
+ const computedElements = rootContext.elements;
2918
+ const [_domReference, setDomReference] = React.useState(null);
2919
+ const [positionReference, _setPositionReference] = React.useState(null);
2920
+ const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
2921
+ const domReference = optionDomReference || _domReference;
2922
+ const domReferenceRef = React.useRef(null);
2923
+ const tree = useFloatingTree();
2924
+ index(() => {
2925
+ if (domReference) {
2926
+ domReferenceRef.current = domReference;
2927
+ }
2928
+ }, [domReference]);
2929
+ const position = useFloating$1({
2930
+ ...options2,
2931
+ elements: {
2932
+ ...computedElements,
2933
+ ...positionReference && {
2934
+ reference: positionReference
2935
+ }
2936
+ }
2937
+ });
2938
+ const setPositionReference = React.useCallback((node) => {
2939
+ const computedPositionReference = isElement(node) ? {
2940
+ getBoundingClientRect: () => node.getBoundingClientRect(),
2941
+ contextElement: node
2942
+ } : node;
2943
+ _setPositionReference(computedPositionReference);
2944
+ position.refs.setReference(computedPositionReference);
2945
+ }, [position.refs]);
2946
+ const setReference = React.useCallback((node) => {
2947
+ if (isElement(node) || node === null) {
2948
+ domReferenceRef.current = node;
2949
+ setDomReference(node);
2950
+ }
2951
+ if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
2952
+ // `null` to support `positionReference` + an unstable `reference`
2953
+ // callback ref.
2954
+ node !== null && !isElement(node)) {
2955
+ position.refs.setReference(node);
2956
+ }
2957
+ }, [position.refs]);
2958
+ const refs = React.useMemo(() => ({
2959
+ ...position.refs,
2960
+ setReference,
2961
+ setPositionReference,
2962
+ domReference: domReferenceRef
2963
+ }), [position.refs, setReference, setPositionReference]);
2964
+ const elements = React.useMemo(() => ({
2965
+ ...position.elements,
2966
+ domReference
2967
+ }), [position.elements, domReference]);
2968
+ const context = React.useMemo(() => ({
2969
+ ...position,
2970
+ ...rootContext,
2971
+ refs,
2972
+ elements,
2973
+ nodeId
2974
+ }), [position, refs, elements, nodeId, rootContext]);
2975
+ index(() => {
2976
+ rootContext.dataRef.current.floatingContext = context;
2977
+ const node = tree == null ? void 0 : tree.nodesRef.current.find((node2) => node2.id === nodeId);
2978
+ if (node) {
2979
+ node.context = context;
2980
+ }
2981
+ });
2982
+ return React.useMemo(() => ({
2983
+ ...position,
2984
+ context,
2985
+ refs,
2986
+ elements
2987
+ }), [position, refs, elements, context]);
2988
+ }
2989
+ const ACTIVE_KEY = "active";
2990
+ const SELECTED_KEY = "selected";
2991
+ function mergeProps(userProps, propsList, elementKey) {
2992
+ const map = /* @__PURE__ */ new Map();
2993
+ const isItem = elementKey === "item";
2994
+ let domUserProps = userProps;
2995
+ if (isItem && userProps) {
2996
+ const {
2997
+ [ACTIVE_KEY]: _2,
2998
+ [SELECTED_KEY]: __,
2999
+ ...validProps
3000
+ } = userProps;
3001
+ domUserProps = validProps;
3002
+ }
3003
+ return {
3004
+ ...elementKey === "floating" && {
3005
+ tabIndex: -1
3006
+ },
3007
+ ...domUserProps,
3008
+ ...propsList.map((value) => {
3009
+ const propsOrGetProps = value ? value[elementKey] : null;
3010
+ if (typeof propsOrGetProps === "function") {
3011
+ return userProps ? propsOrGetProps(userProps) : null;
3012
+ }
3013
+ return propsOrGetProps;
3014
+ }).concat(userProps).reduce((acc, props) => {
3015
+ if (!props) {
3016
+ return acc;
3017
+ }
3018
+ Object.entries(props).forEach((_ref) => {
3019
+ let [key, value] = _ref;
3020
+ if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
3021
+ return;
3022
+ }
3023
+ if (key.indexOf("on") === 0) {
3024
+ if (!map.has(key)) {
3025
+ map.set(key, []);
3026
+ }
3027
+ if (typeof value === "function") {
3028
+ var _map$get;
3029
+ (_map$get = map.get(key)) == null || _map$get.push(value);
3030
+ acc[key] = function() {
3031
+ var _map$get2;
3032
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3033
+ args[_key] = arguments[_key];
3034
+ }
3035
+ return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map((fn) => fn(...args)).find((val) => val !== void 0);
3036
+ };
3037
+ }
3038
+ } else {
3039
+ acc[key] = value;
3040
+ }
3041
+ });
3042
+ return acc;
3043
+ }, {})
3044
+ };
3045
+ }
3046
+ function useInteractions(propsList) {
3047
+ if (propsList === void 0) {
3048
+ propsList = [];
3049
+ }
3050
+ const referenceDeps = propsList.map((key) => key == null ? void 0 : key.reference);
3051
+ const floatingDeps = propsList.map((key) => key == null ? void 0 : key.floating);
3052
+ const itemDeps = propsList.map((key) => key == null ? void 0 : key.item);
3053
+ const getReferenceProps = React.useCallback(
3054
+ (userProps) => mergeProps(userProps, propsList, "reference"),
3055
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3056
+ referenceDeps
3057
+ );
3058
+ const getFloatingProps = React.useCallback(
3059
+ (userProps) => mergeProps(userProps, propsList, "floating"),
3060
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3061
+ floatingDeps
3062
+ );
3063
+ const getItemProps = React.useCallback(
3064
+ (userProps) => mergeProps(userProps, propsList, "item"),
3065
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3066
+ itemDeps
3067
+ );
3068
+ return React.useMemo(() => ({
3069
+ getReferenceProps,
3070
+ getFloatingProps,
3071
+ getItemProps
3072
+ }), [getReferenceProps, getFloatingProps, getItemProps]);
3073
+ }
3074
+ function getArgsWithCustomFloatingHeight(state, height) {
3075
+ return {
3076
+ ...state,
3077
+ rects: {
3078
+ ...state.rects,
3079
+ floating: {
3080
+ ...state.rects.floating,
3081
+ height
3082
+ }
3083
+ }
3084
+ };
3085
+ }
3086
+ const inner = (props) => ({
3087
+ name: "inner",
3088
+ options: props,
3089
+ async fn(state) {
3090
+ const {
3091
+ listRef,
3092
+ overflowRef,
3093
+ onFallbackChange,
3094
+ offset: innerOffset = 0,
3095
+ index: index2 = 0,
3096
+ minItemsVisible = 4,
3097
+ referenceOverflowThreshold = 0,
3098
+ scrollRef,
3099
+ ...detectOverflowOptions
3100
+ } = evaluate(props, state);
3101
+ const {
3102
+ rects,
3103
+ elements: {
3104
+ floating
3105
+ }
3106
+ } = state;
3107
+ const item = listRef.current[index2];
3108
+ if (process.env.NODE_ENV !== "production") {
3109
+ if (!state.placement.startsWith("bottom")) {
3110
+ warn('`placement` side must be "bottom" when using the `inner`', "middleware.");
3111
+ }
3112
+ }
3113
+ if (!item) {
3114
+ return {};
3115
+ }
3116
+ const nextArgs = {
3117
+ ...state,
3118
+ ...await offset(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)
3119
+ };
3120
+ const el = (scrollRef == null ? void 0 : scrollRef.current) || floating;
3121
+ const overflow = await detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, el.scrollHeight), detectOverflowOptions);
3122
+ const refOverflow = await detectOverflow(nextArgs, {
3123
+ ...detectOverflowOptions,
3124
+ elementContext: "reference"
3125
+ });
3126
+ const diffY = Math.max(0, overflow.top);
3127
+ const nextY = nextArgs.y + diffY;
3128
+ const maxHeight = Math.max(0, el.scrollHeight - diffY - Math.max(0, overflow.bottom));
3129
+ el.style.maxHeight = maxHeight + "px";
3130
+ el.scrollTop = diffY;
3131
+ if (onFallbackChange) {
3132
+ if (el.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, listRef.current.length - 1) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold) {
3133
+ ReactDOM.flushSync(() => onFallbackChange(true));
3134
+ } else {
3135
+ ReactDOM.flushSync(() => onFallbackChange(false));
3136
+ }
3137
+ }
3138
+ if (overflowRef) {
3139
+ overflowRef.current = await detectOverflow(getArgsWithCustomFloatingHeight({
3140
+ ...nextArgs,
3141
+ y: nextY
3142
+ }, el.offsetHeight), detectOverflowOptions);
3143
+ }
3144
+ return {
3145
+ y: nextY
3146
+ };
3147
+ }
3148
+ });
3149
+ function useInnerOffset(context, props) {
3150
+ const {
3151
+ open,
3152
+ elements
3153
+ } = context;
3154
+ const {
3155
+ enabled = true,
3156
+ overflowRef,
3157
+ scrollRef,
3158
+ onChange: unstable_onChange
3159
+ } = props;
3160
+ const onChange = useEffectEvent(unstable_onChange);
3161
+ const controlledScrollingRef = React.useRef(false);
3162
+ const prevScrollTopRef = React.useRef(null);
3163
+ const initialOverflowRef = React.useRef(null);
3164
+ React.useEffect(() => {
3165
+ if (!enabled) return;
3166
+ function onWheel(e2) {
3167
+ if (e2.ctrlKey || !el || overflowRef.current == null) {
3168
+ return;
3169
+ }
3170
+ const dY = e2.deltaY;
3171
+ const isAtTop = overflowRef.current.top >= -0.5;
3172
+ const isAtBottom = overflowRef.current.bottom >= -0.5;
3173
+ const remainingScroll = el.scrollHeight - el.clientHeight;
3174
+ const sign = dY < 0 ? -1 : 1;
3175
+ const method = dY < 0 ? "max" : "min";
3176
+ if (el.scrollHeight <= el.clientHeight) {
3177
+ return;
3178
+ }
3179
+ if (!isAtTop && dY > 0 || !isAtBottom && dY < 0) {
3180
+ e2.preventDefault();
3181
+ ReactDOM.flushSync(() => {
3182
+ onChange((d2) => d2 + Math[method](dY, remainingScroll * sign));
3183
+ });
3184
+ } else if (/firefox/i.test(getUserAgent())) {
3185
+ el.scrollTop += dY;
3186
+ }
3187
+ }
3188
+ const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating;
3189
+ if (open && el) {
3190
+ el.addEventListener("wheel", onWheel);
3191
+ requestAnimationFrame(() => {
3192
+ prevScrollTopRef.current = el.scrollTop;
3193
+ if (overflowRef.current != null) {
3194
+ initialOverflowRef.current = {
3195
+ ...overflowRef.current
3196
+ };
3197
+ }
3198
+ });
3199
+ return () => {
3200
+ prevScrollTopRef.current = null;
3201
+ initialOverflowRef.current = null;
3202
+ el.removeEventListener("wheel", onWheel);
3203
+ };
3204
+ }
3205
+ }, [enabled, open, elements.floating, overflowRef, scrollRef, onChange]);
3206
+ const floating = React.useMemo(() => ({
3207
+ onKeyDown() {
3208
+ controlledScrollingRef.current = true;
3209
+ },
3210
+ onWheel() {
3211
+ controlledScrollingRef.current = false;
3212
+ },
3213
+ onPointerMove() {
3214
+ controlledScrollingRef.current = false;
3215
+ },
3216
+ onScroll() {
3217
+ const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating;
3218
+ if (!overflowRef.current || !el || !controlledScrollingRef.current) {
3219
+ return;
3220
+ }
3221
+ if (prevScrollTopRef.current !== null) {
3222
+ const scrollDiff = el.scrollTop - prevScrollTopRef.current;
3223
+ if (overflowRef.current.bottom < -0.5 && scrollDiff < -1 || overflowRef.current.top < -0.5 && scrollDiff > 1) {
3224
+ ReactDOM.flushSync(() => onChange((d2) => d2 + scrollDiff));
3225
+ }
3226
+ }
3227
+ requestAnimationFrame(() => {
3228
+ prevScrollTopRef.current = el.scrollTop;
3229
+ });
3230
+ }
3231
+ }), [elements.floating, onChange, overflowRef, scrollRef]);
3232
+ return React.useMemo(() => enabled ? {
3233
+ floating
3234
+ } : {}, [enabled, floating]);
3235
+ }
3236
+ let y$1 = createContext({ styles: void 0, setReference: () => {
3237
+ }, setFloating: () => {
3238
+ }, getReferenceProps: () => ({}), getFloatingProps: () => ({}), slot: {} });
3239
+ y$1.displayName = "FloatingContext";
3240
+ let S$1 = createContext(null);
3241
+ S$1.displayName = "PlacementContext";
3242
+ function xe$1(e2) {
3243
+ return useMemo(() => e2 ? typeof e2 == "string" ? { to: e2 } : e2 : null, [e2]);
3244
+ }
3245
+ function ye() {
3246
+ return useContext(y$1).setReference;
3247
+ }
3248
+ function be() {
3249
+ let { getFloatingProps: e2, slot: t2 } = useContext(y$1);
3250
+ return useCallback((...n2) => Object.assign({}, e2(...n2), { "data-anchor": t2.anchor }), [e2, t2]);
3251
+ }
3252
+ function Re(e2 = null) {
3253
+ e2 === false && (e2 = null), typeof e2 == "string" && (e2 = { to: e2 });
3254
+ let t2 = useContext(S$1), n2 = useMemo(() => e2, [JSON.stringify(e2, typeof HTMLElement != "undefined" ? (r2, o2) => o2 instanceof HTMLElement ? o2.outerHTML : o2 : void 0)]);
3255
+ n$3(() => {
3256
+ t2 == null || t2(n2 != null ? n2 : null);
3257
+ }, [t2, n2]);
3258
+ let l2 = useContext(y$1);
3259
+ return useMemo(() => [l2.setFloating, e2 ? l2.styles : {}], [l2.setFloating, e2, l2.styles]);
3260
+ }
3261
+ let q = 4;
3262
+ function ve({ children: e2, enabled: t2 = true }) {
3263
+ let [n2, l2] = useState(null), [r2, o2] = useState(0), c2 = useRef(null), [u2, s2] = useState(null);
3264
+ pe(u2);
3265
+ let i2 = t2 && n2 !== null && u2 !== null, { to: F2 = "bottom", gap: C = 0, offset: M2 = 0, padding: p2 = 0, inner: P } = ce(n2, u2), [a3, f2 = "center"] = F2.split(" ");
3266
+ n$3(() => {
3267
+ i2 && o2(0);
3268
+ }, [i2]);
3269
+ let { refs: b, floatingStyles: w2, context: g2 } = useFloating({ open: i2, placement: a3 === "selection" ? f2 === "center" ? "bottom" : `bottom-${f2}` : f2 === "center" ? `${a3}` : `${a3}-${f2}`, strategy: "absolute", transform: false, middleware: [offset({ mainAxis: a3 === "selection" ? 0 : C, crossAxis: M2 }), shift({ padding: p2 }), a3 !== "selection" && flip({ padding: p2 }), a3 === "selection" && P ? inner({ ...P, padding: p2, overflowRef: c2, offset: r2, minItemsVisible: q, referenceOverflowThreshold: p2, onFallbackChange(h2) {
3270
+ var O, W2;
3271
+ if (!h2) return;
3272
+ let d2 = g2.elements.floating;
3273
+ if (!d2) return;
3274
+ let T2 = parseFloat(getComputedStyle(d2).scrollPaddingBottom) || 0, $ = Math.min(q, d2.childElementCount), B = 0, N2 = 0;
3275
+ for (let m2 of (W2 = (O = g2.elements.floating) == null ? void 0 : O.childNodes) != null ? W2 : []) if (m2 instanceof HTMLElement) {
3276
+ let x2 = m2.offsetTop, k = x2 + m2.clientHeight + T2, H2 = d2.scrollTop, U = H2 + d2.clientHeight;
3277
+ if (x2 >= H2 && k <= U) $--;
3278
+ else {
3279
+ N2 = Math.max(0, Math.min(k, U) - Math.max(x2, H2)), B = m2.clientHeight;
3280
+ break;
3281
+ }
3282
+ }
3283
+ $ >= 1 && o2((m2) => {
3284
+ let x2 = B * $ - N2 + T2;
3285
+ return m2 >= x2 ? m2 : x2;
3286
+ });
3287
+ } }) : null, size({ padding: p2, apply({ availableWidth: h2, availableHeight: d2, elements: T2 }) {
3288
+ Object.assign(T2.floating.style, { overflow: "auto", maxWidth: `${h2}px`, maxHeight: `min(var(--anchor-max-height, 100vh), ${d2}px)` });
3289
+ } })].filter(Boolean), whileElementsMounted: autoUpdate }), [I2 = a3, V2 = f2] = g2.placement.split("-");
3290
+ a3 === "selection" && (I2 = "selection");
3291
+ let G2 = useMemo(() => ({ anchor: [I2, V2].filter(Boolean).join(" ") }), [I2, V2]), K2 = useInnerOffset(g2, { overflowRef: c2, onChange: o2 }), { getReferenceProps: Q, getFloatingProps: X } = useInteractions([K2]), Y = o$2((h2) => {
3292
+ s2(h2), b.setFloating(h2);
3293
+ });
3294
+ return React.createElement(S$1.Provider, { value: l2 }, React.createElement(y$1.Provider, { value: { setFloating: Y, setReference: b.setReference, styles: w2, getReferenceProps: Q, getFloatingProps: X, slot: G2 } }, e2));
3295
+ }
3296
+ function pe(e2) {
3297
+ n$3(() => {
3298
+ if (!e2) return;
3299
+ let t2 = new MutationObserver(() => {
3300
+ let n2 = window.getComputedStyle(e2).maxHeight, l2 = parseFloat(n2);
3301
+ if (isNaN(l2)) return;
3302
+ let r2 = parseInt(n2);
3303
+ isNaN(r2) || l2 !== r2 && (e2.style.maxHeight = `${Math.ceil(l2)}px`);
3304
+ });
3305
+ return t2.observe(e2, { attributes: true, attributeFilter: ["style"] }), () => {
3306
+ t2.disconnect();
3307
+ };
3308
+ }, [e2]);
3309
+ }
3310
+ function ce(e2, t2) {
3311
+ var o2, c2, u2;
3312
+ let n2 = L((o2 = e2 == null ? void 0 : e2.gap) != null ? o2 : "var(--anchor-gap, 0)", t2), l2 = L((c2 = e2 == null ? void 0 : e2.offset) != null ? c2 : "var(--anchor-offset, 0)", t2), r2 = L((u2 = e2 == null ? void 0 : e2.padding) != null ? u2 : "var(--anchor-padding, 0)", t2);
3313
+ return { ...e2, gap: n2, offset: l2, padding: r2 };
3314
+ }
3315
+ function L(e2, t2, n2 = void 0) {
3316
+ let l2 = p$1(), r2 = o$2((s2, i2) => {
3317
+ if (s2 == null) return [n2, null];
3318
+ if (typeof s2 == "number") return [s2, null];
3319
+ if (typeof s2 == "string") {
3320
+ if (!i2) return [n2, null];
3321
+ let F2 = J$1(s2, i2);
3322
+ return [F2, (C) => {
3323
+ let M2 = D$1(s2);
3324
+ {
3325
+ let p2 = M2.map((P) => window.getComputedStyle(i2).getPropertyValue(P));
3326
+ l2.requestAnimationFrame(function P() {
3327
+ l2.nextFrame(P);
3328
+ let a3 = false;
3329
+ for (let [b, w2] of M2.entries()) {
3330
+ let g2 = window.getComputedStyle(i2).getPropertyValue(w2);
3331
+ if (p2[b] !== g2) {
3332
+ p2[b] = g2, a3 = true;
3333
+ break;
3334
+ }
3335
+ }
3336
+ if (!a3) return;
3337
+ let f2 = J$1(s2, i2);
3338
+ F2 !== f2 && (C(f2), F2 = f2);
3339
+ });
3340
+ }
3341
+ return l2.dispose;
3342
+ }];
3343
+ }
3344
+ return [n2, null];
3345
+ }), o2 = useMemo(() => r2(e2, t2)[0], [e2, t2]), [c2 = o2, u2] = useState();
3346
+ return n$3(() => {
3347
+ let [s2, i2] = r2(e2, t2);
3348
+ if (u2(s2), !!i2) return i2(u2);
3349
+ }, [e2, t2]), c2;
3350
+ }
3351
+ function D$1(e2) {
3352
+ let t2 = /var\((.*)\)/.exec(e2);
3353
+ if (t2) {
3354
+ let n2 = t2[1].indexOf(",");
3355
+ if (n2 === -1) return [t2[1]];
3356
+ let l2 = t2[1].slice(0, n2).trim(), r2 = t2[1].slice(n2 + 1).trim();
3357
+ return r2 ? [l2, ...D$1(r2)] : [l2];
3358
+ }
3359
+ return [];
3360
+ }
3361
+ function J$1(e2, t2) {
3362
+ let n2 = document.createElement("div");
3363
+ t2.appendChild(n2), n2.style.setProperty("margin-top", "0px", "important"), n2.style.setProperty("margin-top", e2, "important");
3364
+ let l2 = parseFloat(window.getComputedStyle(n2).marginTop) || 0;
3365
+ return t2.removeChild(n2), l2;
3366
+ }
3367
+ function f$1({ children: o2, freeze: e2 }) {
3368
+ let n2 = l$2(e2, o2);
3369
+ return React__default.createElement(React__default.Fragment, null, n2);
3370
+ }
3371
+ function l$2(o2, e2) {
3372
+ let [n2, t2] = useState(e2);
3373
+ return !o2 && n2 !== e2 && t2(e2), o2 ? n2 : e2;
3374
+ }
3375
+ let n = createContext(null);
3376
+ n.displayName = "OpenClosedContext";
3377
+ var i = ((e2) => (e2[e2.Open = 1] = "Open", e2[e2.Closed = 2] = "Closed", e2[e2.Closing = 4] = "Closing", e2[e2.Opening = 8] = "Opening", e2))(i || {});
3378
+ function u$1() {
3379
+ return useContext(n);
3380
+ }
3381
+ function c$2({ value: o2, children: t2 }) {
3382
+ return React__default.createElement(n.Provider, { value: o2 }, t2);
3383
+ }
3384
+ function t(n2) {
3385
+ function e2() {
3386
+ document.readyState !== "loading" && (n2(), document.removeEventListener("DOMContentLoaded", e2));
3387
+ }
3388
+ typeof window != "undefined" && typeof document != "undefined" && (document.addEventListener("DOMContentLoaded", e2), e2());
3389
+ }
3390
+ let r = [];
3391
+ t(() => {
3392
+ function e2(t2) {
3393
+ if (!(t2.target instanceof HTMLElement) || t2.target === document.body || r[0] === t2.target) return;
3394
+ let n2 = t2.target;
3395
+ n2 = n2.closest(f$6), r.unshift(n2 != null ? n2 : t2.target), r = r.filter((o2) => o2 != null && o2.isConnected), r.splice(10);
3396
+ }
3397
+ window.addEventListener("click", e2, { capture: true }), window.addEventListener("mousedown", e2, { capture: true }), window.addEventListener("focus", e2, { capture: true }), document.body.addEventListener("click", e2, { capture: true }), document.body.addEventListener("mousedown", e2, { capture: true }), document.body.addEventListener("focus", e2, { capture: true });
3398
+ });
3399
+ function u(l2) {
3400
+ throw new Error("Unexpected object: " + l2);
3401
+ }
3402
+ var c$1 = ((i2) => (i2[i2.First = 0] = "First", i2[i2.Previous = 1] = "Previous", i2[i2.Next = 2] = "Next", i2[i2.Last = 3] = "Last", i2[i2.Specific = 4] = "Specific", i2[i2.Nothing = 5] = "Nothing", i2))(c$1 || {});
3403
+ function f(l2, n2) {
3404
+ let t2 = n2.resolveItems();
3405
+ if (t2.length <= 0) return null;
3406
+ let r2 = n2.resolveActiveIndex(), s2 = r2 != null ? r2 : -1;
3407
+ switch (l2.focus) {
3408
+ case 0: {
3409
+ for (let e2 = 0; e2 < t2.length; ++e2) if (!n2.resolveDisabled(t2[e2], e2, t2)) return e2;
3410
+ return r2;
3411
+ }
3412
+ case 1: {
3413
+ s2 === -1 && (s2 = t2.length);
3414
+ for (let e2 = s2 - 1; e2 >= 0; --e2) if (!n2.resolveDisabled(t2[e2], e2, t2)) return e2;
3415
+ return r2;
3416
+ }
3417
+ case 2: {
3418
+ for (let e2 = s2 + 1; e2 < t2.length; ++e2) if (!n2.resolveDisabled(t2[e2], e2, t2)) return e2;
3419
+ return r2;
3420
+ }
3421
+ case 3: {
3422
+ for (let e2 = t2.length - 1; e2 >= 0; --e2) if (!n2.resolveDisabled(t2[e2], e2, t2)) return e2;
3423
+ return r2;
3424
+ }
3425
+ case 4: {
3426
+ for (let e2 = 0; e2 < t2.length; ++e2) if (n2.resolveId(t2[e2], e2, t2) === l2.id) return e2;
3427
+ return r2;
3428
+ }
3429
+ case 5:
3430
+ return null;
3431
+ default:
3432
+ u(l2);
3433
+ }
3434
+ }
3435
+ var g = ((f2) => (f2[f2.Left = 0] = "Left", f2[f2.Right = 2] = "Right", f2))(g || {});
3436
+ function c(t2) {
3437
+ let r2 = o$2(t2), e2 = useRef(false);
3438
+ useEffect(() => (e2.current = false, () => {
3439
+ e2.current = true, t$3(() => {
3440
+ e2.current && r2();
3441
+ });
3442
+ }), [r2]);
3443
+ }
3444
+ function s() {
3445
+ let r2 = typeof document == "undefined";
3446
+ return "useSyncExternalStore" in React ? ((o2) => o2.useSyncExternalStore)(React)(() => () => {
3447
+ }, () => false, () => !r2) : false;
3448
+ }
3449
+ function l$1() {
3450
+ let r2 = s(), [e2, n2] = React.useState(s$4.isHandoffComplete);
3451
+ return e2 && s$4.isHandoffComplete === false && n2(false), React.useEffect(() => {
3452
+ e2 !== true && n2(true);
3453
+ }, [e2]), React.useEffect(() => s$4.handoff(), []), r2 ? false : e2;
3454
+ }
3455
+ let e = createContext(false);
3456
+ function a2() {
3457
+ return useContext(e);
3458
+ }
3459
+ function D(p2) {
3460
+ let r2 = a2(), l2 = useContext(v), e2 = n$1(p2), [o2, n2] = useState(() => {
3461
+ var t2;
3462
+ if (!r2 && l2 !== null) return (t2 = l2.current) != null ? t2 : null;
3463
+ if (s$4.isServer) return null;
3464
+ let u2 = e2 == null ? void 0 : e2.getElementById("headlessui-portal-root");
3465
+ if (u2) return u2;
3466
+ if (e2 === null) return null;
3467
+ let a3 = e2.createElement("div");
3468
+ return a3.setAttribute("id", "headlessui-portal-root"), e2.body.appendChild(a3);
3469
+ });
3470
+ return useEffect(() => {
3471
+ o2 !== null && (e2 != null && e2.body.contains(o2) || e2 == null || e2.body.appendChild(o2));
3472
+ }, [o2, e2]), useEffect(() => {
3473
+ r2 || l2 !== null && n2(l2.current);
3474
+ }, [l2, n2, r2]), o2;
3475
+ }
3476
+ let M = Fragment, N = W$1(function(r2, l2) {
3477
+ let e2 = r2, o2 = useRef(null), n2 = y$3(T$1((i2) => {
3478
+ o2.current = i2;
3479
+ }), l2), u2 = n$1(o2), a3 = D(o2), [t2] = useState(() => {
3480
+ var i2;
3481
+ return s$4.isServer ? null : (i2 = u2 == null ? void 0 : u2.createElement("div")) != null ? i2 : null;
3482
+ }), s2 = useContext(y), b = l$1();
3483
+ return n$3(() => {
3484
+ !a3 || !t2 || a3.contains(t2) || (t2.setAttribute("data-headlessui-portal", ""), a3.appendChild(t2));
3485
+ }, [a3, t2]), n$3(() => {
3486
+ if (t2 && s2) return s2.register(t2);
3487
+ }, [s2, t2]), c(() => {
3488
+ var i2;
3489
+ !a3 || !t2 || (t2 instanceof Node && a3.contains(t2) && a3.removeChild(t2), a3.childNodes.length <= 0 && ((i2 = a3.parentElement) == null || i2.removeChild(a3)));
3490
+ }), b ? !a3 || !t2 ? null : createPortal(H({ ourProps: { ref: n2 }, theirProps: e2, slot: {}, defaultTag: M, name: "Portal" }), t2) : null;
3491
+ });
3492
+ function S(p2, r2) {
3493
+ let l2 = y$3(r2), { enabled: e2 = true, ...o2 } = p2;
3494
+ return e2 ? React__default.createElement(N, { ...o2, ref: l2 }) : H({ ourProps: { ref: l2 }, theirProps: o2, slot: {}, defaultTag: M, name: "Portal" });
3495
+ }
3496
+ let j = Fragment, v = createContext(null);
3497
+ function W(p2, r2) {
3498
+ let { target: l2, ...e2 } = p2, n2 = { ref: y$3(r2) };
3499
+ return React__default.createElement(v.Provider, { value: l2 }, H({ ourProps: n2, theirProps: e2, defaultTag: j, name: "Popover.Group" }));
3500
+ }
3501
+ let y = createContext(null);
3502
+ let I = W$1(S), J = W$1(W), te = Object.assign(I, { Group: J });
3503
+ var Co = ((e2) => (e2[e2.Open = 0] = "Open", e2[e2.Closed = 1] = "Closed", e2))(Co || {}), Ro = ((e2) => (e2[e2.Single = 0] = "Single", e2[e2.Multi = 1] = "Multi", e2))(Ro || {}), So = ((t2) => (t2[t2.Pointer = 0] = "Pointer", t2[t2.Focus = 1] = "Focus", t2[t2.Other = 2] = "Other", t2))(So || {}), Po = ((u2) => (u2[u2.OpenCombobox = 0] = "OpenCombobox", u2[u2.CloseCombobox = 1] = "CloseCombobox", u2[u2.GoToOption = 2] = "GoToOption", u2[u2.SetTyping = 3] = "SetTyping", u2[u2.RegisterOption = 4] = "RegisterOption", u2[u2.UnregisterOption = 5] = "UnregisterOption", u2[u2.SetActivationTrigger = 6] = "SetActivationTrigger", u2[u2.UpdateVirtualConfiguration = 7] = "UpdateVirtualConfiguration", u2))(Po || {});
3504
+ function Te(o2, r2 = (e2) => e2) {
3505
+ let e2 = o2.activeOptionIndex !== null ? o2.options[o2.activeOptionIndex] : null, t2 = r2(o2.options.slice()), c2 = t2.length > 0 && t2[0].dataRef.current.order !== null ? t2.sort((f2, s2) => f2.dataRef.current.order - s2.dataRef.current.order) : _(t2, (f2) => f2.dataRef.current.domRef.current), d2 = e2 ? c2.indexOf(e2) : null;
3506
+ return d2 === -1 && (d2 = null), { options: c2, activeOptionIndex: d2 };
3507
+ }
3508
+ let Ao = { [1](o2) {
3509
+ var r2;
3510
+ return (r2 = o2.dataRef.current) != null && r2.disabled || o2.comboboxState === 1 ? o2 : { ...o2, activeOptionIndex: null, comboboxState: 1, isTyping: false, activationTrigger: 2, __demoMode: false };
3511
+ }, [0](o2) {
3512
+ var r2, e2;
3513
+ if ((r2 = o2.dataRef.current) != null && r2.disabled || o2.comboboxState === 0) return o2;
3514
+ if ((e2 = o2.dataRef.current) != null && e2.value) {
3515
+ let t2 = o2.dataRef.current.calculateIndex(o2.dataRef.current.value);
3516
+ if (t2 !== -1) return { ...o2, activeOptionIndex: t2, comboboxState: 0, __demoMode: false };
3517
+ }
3518
+ return { ...o2, comboboxState: 0, __demoMode: false };
3519
+ }, [3](o2, r2) {
3520
+ return o2.isTyping === r2.isTyping ? o2 : { ...o2, isTyping: r2.isTyping };
3521
+ }, [2](o2, r2) {
3522
+ var d2, f$12, s2, u2, a3;
3523
+ if ((d2 = o2.dataRef.current) != null && d2.disabled || (f$12 = o2.dataRef.current) != null && f$12.optionsRef.current && !((s2 = o2.dataRef.current) != null && s2.optionsPropsRef.current.static) && o2.comboboxState === 1) return o2;
3524
+ if (o2.virtual) {
3525
+ let { options: n2, disabled: T2 } = o2.virtual, C = r2.focus === c$1.Specific ? r2.idx : f(r2, { resolveItems: () => n2, resolveActiveIndex: () => {
3526
+ var p2, L2;
3527
+ return (L2 = (p2 = o2.activeOptionIndex) != null ? p2 : n2.findIndex((M2) => !T2(M2))) != null ? L2 : null;
3528
+ }, resolveDisabled: T2, resolveId() {
3529
+ throw new Error("Function not implemented.");
3530
+ } }), _2 = (u2 = r2.trigger) != null ? u2 : 2;
3531
+ return o2.activeOptionIndex === C && o2.activationTrigger === _2 ? o2 : { ...o2, activeOptionIndex: C, activationTrigger: _2, isTyping: false, __demoMode: false };
3532
+ }
3533
+ let e2 = Te(o2);
3534
+ if (e2.activeOptionIndex === null) {
3535
+ let n2 = e2.options.findIndex((T2) => !T2.dataRef.current.disabled);
3536
+ n2 !== -1 && (e2.activeOptionIndex = n2);
3537
+ }
3538
+ let t2 = r2.focus === c$1.Specific ? r2.idx : f(r2, { resolveItems: () => e2.options, resolveActiveIndex: () => e2.activeOptionIndex, resolveId: (n2) => n2.id, resolveDisabled: (n2) => n2.dataRef.current.disabled }), c2 = (a3 = r2.trigger) != null ? a3 : 2;
3539
+ return o2.activeOptionIndex === t2 && o2.activationTrigger === c2 ? o2 : { ...o2, ...e2, isTyping: false, activeOptionIndex: t2, activationTrigger: c2, __demoMode: false };
3540
+ }, [4]: (o2, r2) => {
3541
+ var d2, f2, s2;
3542
+ if ((d2 = o2.dataRef.current) != null && d2.virtual) return { ...o2, options: [...o2.options, r2.payload] };
3543
+ let e2 = r2.payload, t2 = Te(o2, (u2) => (u2.push(e2), u2));
3544
+ o2.activeOptionIndex === null && (f2 = o2.dataRef.current) != null && f2.isSelected(r2.payload.dataRef.current.value) && (t2.activeOptionIndex = t2.options.indexOf(e2));
3545
+ let c2 = { ...o2, ...t2, activationTrigger: 2 };
3546
+ return (s2 = o2.dataRef.current) != null && s2.__demoMode && o2.dataRef.current.value === void 0 && (c2.activeOptionIndex = 0), c2;
3547
+ }, [5]: (o2, r2) => {
3548
+ var t2;
3549
+ if ((t2 = o2.dataRef.current) != null && t2.virtual) return { ...o2, options: o2.options.filter((c2) => c2.id !== r2.id) };
3550
+ let e2 = Te(o2, (c2) => {
3551
+ let d2 = c2.findIndex((f2) => f2.id === r2.id);
3552
+ return d2 !== -1 && c2.splice(d2, 1), c2;
3553
+ });
3554
+ return { ...o2, ...e2, activationTrigger: 2 };
3555
+ }, [6]: (o2, r2) => o2.activationTrigger === r2.trigger ? o2 : { ...o2, activationTrigger: r2.trigger }, [7]: (o2, r2) => {
3556
+ var t2, c2;
3557
+ if (o2.virtual === null) return { ...o2, virtual: { options: r2.options, disabled: (t2 = r2.disabled) != null ? t2 : () => false } };
3558
+ if (o2.virtual.options === r2.options && o2.virtual.disabled === r2.disabled) return o2;
3559
+ let e2 = o2.activeOptionIndex;
3560
+ if (o2.activeOptionIndex !== null) {
3561
+ let d2 = r2.options.indexOf(o2.virtual.options[o2.activeOptionIndex]);
3562
+ d2 !== -1 ? e2 = d2 : e2 = null;
3563
+ }
3564
+ return { ...o2, activeOptionIndex: e2, virtual: { options: r2.options, disabled: (c2 = r2.disabled) != null ? c2 : () => false } };
3565
+ } }, xe = createContext(null);
3566
+ xe.displayName = "ComboboxActionsContext";
3567
+ function re(o2) {
3568
+ let r2 = useContext(xe);
3569
+ if (r2 === null) {
3570
+ let e2 = new Error(`<${o2} /> is missing a parent <Combobox /> component.`);
3571
+ throw Error.captureStackTrace && Error.captureStackTrace(e2, re), e2;
3572
+ }
3573
+ return r2;
3574
+ }
3575
+ let Le = createContext(null);
3576
+ function Io(o2) {
3577
+ let r2 = oe("VirtualProvider"), { options: e2 } = r2.virtual, [t2, c2] = useMemo(() => {
3578
+ let a3 = r2.optionsRef.current;
3579
+ if (!a3) return [0, 0];
3580
+ let n2 = window.getComputedStyle(a3);
3581
+ return [parseFloat(n2.paddingBlockStart || n2.paddingTop), parseFloat(n2.paddingBlockEnd || n2.paddingBottom)];
3582
+ }, [r2.optionsRef.current]), d2 = useVirtualizer({ enabled: e2.length !== 0, scrollPaddingStart: t2, scrollPaddingEnd: c2, count: e2.length, estimateSize() {
3583
+ return 40;
3584
+ }, getScrollElement() {
3585
+ var a3;
3586
+ return (a3 = r2.optionsRef.current) != null ? a3 : null;
3587
+ }, overscan: 12 }), [f2, s2] = useState(0);
3588
+ n$3(() => {
3589
+ s2((a3) => a3 + 1);
3590
+ }, [e2]);
3591
+ let u2 = d2.getVirtualItems();
3592
+ return u2.length === 0 ? null : React__default.createElement(Le.Provider, { value: d2 }, React__default.createElement("div", { style: { position: "relative", width: "100%", height: `${d2.getTotalSize()}px` }, ref: (a3) => {
3593
+ if (a3) {
3594
+ if (typeof process != "undefined" && process.env.JEST_WORKER_ID !== void 0 || r2.activationTrigger === 0) return;
3595
+ r2.activeOptionIndex !== null && e2.length > r2.activeOptionIndex && d2.scrollToIndex(r2.activeOptionIndex);
3596
+ }
3597
+ } }, u2.map((a3) => {
3598
+ var n2;
3599
+ return React__default.createElement(Fragment, { key: a3.key }, React__default.cloneElement((n2 = o2.children) == null ? void 0 : n2.call(o2, { ...o2.slot, option: e2[a3.index] }), { key: `${f2}-${a3.key}`, "data-index": a3.index, "aria-setsize": e2.length, "aria-posinset": a3.index + 1, style: { position: "absolute", top: 0, left: 0, transform: `translateY(${a3.start}px)`, overflowAnchor: "none" } }));
3600
+ })));
3601
+ }
3602
+ let ie = createContext(null);
3603
+ ie.displayName = "ComboboxDataContext";
3604
+ function oe(o2) {
3605
+ let r2 = useContext(ie);
3606
+ if (r2 === null) {
3607
+ let e2 = new Error(`<${o2} /> is missing a parent <Combobox /> component.`);
3608
+ throw Error.captureStackTrace && Error.captureStackTrace(e2, oe), e2;
3609
+ }
3610
+ return r2;
3611
+ }
3612
+ function Eo(o2, r2) {
3613
+ return u$6(r2.type, Ao, o2, r2);
3614
+ }
3615
+ let _o = Fragment;
3616
+ function ho(o2, r2) {
3617
+ var ge, ve$1;
3618
+ let e2 = a$5(), { value: t2, defaultValue: c2, onChange: d2, form: f2, name: s2, by: u2, disabled: a3 = e2 || false, onClose: n2, __demoMode: T2 = false, multiple: C = false, immediate: _2 = false, virtual: p2 = null, nullable: L2, ...M2 } = o2, F2 = l$4(c2), [v2 = C ? [] : void 0, y2] = T$2(t2, d2, F2), [A2, R2] = useReducer(Eo, { dataRef: createRef(), comboboxState: T2 ? 0 : 1, isTyping: false, options: [], virtual: p2 ? { options: p2.options, disabled: (ge = p2.disabled) != null ? ge : () => false } : null, activeOptionIndex: null, activationTrigger: 2, __demoMode: T2 }), h2 = useRef(false), O = useRef({ static: false, hold: false }), G2 = useRef(null), J2 = useRef(null), Q = useRef(null), I2 = u$5(u2), B = o$2((b) => p2 ? u2 === null ? p2.options.indexOf(b) : p2.options.findIndex((g2) => I2(g2, b)) : A2.options.findIndex((g2) => I2(g2.dataRef.current.value, b))), k = useCallback((b) => u$6(i$12.mode, { [1]: () => v2.some((g2) => I2(g2, b)), [0]: () => I2(v2, b) }), [v2]), K2 = o$2((b) => A2.activeOptionIndex === B(b)), i$12 = useMemo(() => ({ ...A2, immediate: _2, optionsPropsRef: O, inputRef: G2, buttonRef: J2, optionsRef: Q, value: v2, defaultValue: F2, disabled: a3, mode: C ? 1 : 0, virtual: p2 ? A2.virtual : null, get activeOptionIndex() {
3619
+ if (h2.current && A2.activeOptionIndex === null && (p2 ? p2.options.length > 0 : A2.options.length > 0)) {
3620
+ if (p2) {
3621
+ let g2 = p2.options.findIndex((j2) => {
3622
+ var ue, Oe;
3623
+ return !((Oe = (ue = p2.disabled) == null ? void 0 : ue.call(p2, j2)) != null && Oe);
3624
+ });
3625
+ if (g2 !== -1) return g2;
3626
+ }
3627
+ let b = A2.options.findIndex((g2) => !g2.dataRef.current.disabled);
3628
+ if (b !== -1) return b;
3629
+ }
3630
+ return A2.activeOptionIndex;
3631
+ }, calculateIndex: B, compare: I2, isSelected: k, isActive: K2 }), [v2, F2, a3, C, T2, A2, p2]);
3632
+ n$3(() => {
3633
+ var b;
3634
+ p2 && R2({ type: 7, options: p2.options, disabled: (b = p2.disabled) != null ? b : null });
3635
+ }, [p2, p2 == null ? void 0 : p2.options, p2 == null ? void 0 : p2.disabled]), n$3(() => {
3636
+ A2.dataRef.current = i$12;
3637
+ }, [i$12]);
3638
+ let N2 = i$12.comboboxState === 0;
3639
+ F$2(N2, [i$12.buttonRef, i$12.inputRef, i$12.optionsRef], () => x2.closeCombobox());
3640
+ let q2 = useMemo(() => {
3641
+ var b, g2, j2;
3642
+ return { open: i$12.comboboxState === 0, disabled: a3, activeIndex: i$12.activeOptionIndex, activeOption: i$12.activeOptionIndex === null ? null : i$12.virtual ? i$12.virtual.options[(b = i$12.activeOptionIndex) != null ? b : 0] : (j2 = (g2 = i$12.options[i$12.activeOptionIndex]) == null ? void 0 : g2.dataRef.current.value) != null ? j2 : null, value: v2 };
3643
+ }, [i$12, a3, v2]), Y = o$2(() => {
3644
+ if (i$12.activeOptionIndex !== null) {
3645
+ if (x2.setIsTyping(false), i$12.virtual) S2(i$12.virtual.options[i$12.activeOptionIndex]);
3646
+ else {
3647
+ let { dataRef: b } = i$12.options[i$12.activeOptionIndex];
3648
+ S2(b.current.value);
3649
+ }
3650
+ x2.goToOption(c$1.Specific, i$12.activeOptionIndex);
3651
+ }
3652
+ }), E2 = o$2(() => {
3653
+ R2({ type: 0 }), h2.current = true;
3654
+ }), ae = o$2(() => {
3655
+ R2({ type: 1 }), h2.current = false, n2 == null || n2();
3656
+ }), le = o$2((b) => {
3657
+ R2({ type: 3, isTyping: b });
3658
+ }), l2 = o$2((b, g2, j2) => (h2.current = false, b === c$1.Specific ? R2({ type: 2, focus: c$1.Specific, idx: g2, trigger: j2 }) : R2({ type: 2, focus: b, trigger: j2 }))), U = o$2((b, g2) => (R2({ type: 4, payload: { id: b, dataRef: g2 } }), () => {
3659
+ i$12.isActive(g2.current.value) && (h2.current = true), R2({ type: 5, id: b });
3660
+ })), S2 = o$2((b) => u$6(i$12.mode, { [0]() {
3661
+ return y2 == null ? void 0 : y2(b);
3662
+ }, [1]() {
3663
+ let g2 = i$12.value.slice(), j2 = g2.findIndex((ue) => I2(ue, b));
3664
+ return j2 === -1 ? g2.push(b) : g2.splice(j2, 1), y2 == null ? void 0 : y2(g2);
3665
+ } })), H$1 = o$2((b) => {
3666
+ R2({ type: 6, trigger: b });
3667
+ }), x2 = useMemo(() => ({ onChange: S2, registerOption: U, goToOption: l2, setIsTyping: le, closeCombobox: ae, openCombobox: E2, setActivationTrigger: H$1, selectActiveOption: Y }), []), [w2, W2] = z(), we = r2 === null ? {} : { ref: r2 }, Be = useCallback(() => {
3668
+ if (F2 !== void 0) return y2 == null ? void 0 : y2(F2);
3669
+ }, [y2, F2]);
3670
+ return React__default.createElement(W2, { value: w2, props: { htmlFor: (ve$1 = i$12.inputRef.current) == null ? void 0 : ve$1.id }, slot: { open: i$12.comboboxState === 0, disabled: a3 } }, React__default.createElement(ve, null, React__default.createElement(xe.Provider, { value: x2 }, React__default.createElement(ie.Provider, { value: i$12 }, React__default.createElement(c$2, { value: u$6(i$12.comboboxState, { [0]: i.Open, [1]: i.Closed }) }, s2 != null && React__default.createElement(j$1, { disabled: a3, data: v2 != null ? { [s2]: v2 } : {}, form: f2, onReset: Be }), H({ ourProps: we, theirProps: M2, slot: q2, defaultTag: _o, name: "Combobox" }))))));
3671
+ }
3672
+ let Do = "input";
3673
+ function Mo(o2, r$12) {
3674
+ var q2, Y, E2, ae, le;
3675
+ let e2 = oe("Combobox.Input"), t2 = re("Combobox.Input"), c2 = useId$1(), d2 = u$7(), { id: f2 = d2 || `headlessui-combobox-input-${c2}`, onChange: s2, displayValue: u2, disabled: a3 = e2.disabled || false, autoFocus: n2 = false, type: T2 = "text", ...C } = o2, _2 = y$3(e2.inputRef, r$12, ye()), p2 = n$1(e2.inputRef), L2 = p$1(), M2 = o$2(() => {
3676
+ t2.onChange(null), e2.optionsRef.current && (e2.optionsRef.current.scrollTop = 0), t2.goToOption(c$1.Nothing);
3677
+ }), F2 = useMemo(() => {
3678
+ var l2;
3679
+ return typeof u2 == "function" && e2.value !== void 0 ? (l2 = u2(e2.value)) != null ? l2 : "" : typeof e2.value == "string" ? e2.value : "";
3680
+ }, [e2.value, u2]);
3681
+ m(([l2, U], [S2, H2]) => {
3682
+ if (e2.isTyping) return;
3683
+ let x2 = e2.inputRef.current;
3684
+ x2 && ((H2 === 0 && U === 1 || l2 !== S2) && (x2.value = l2), requestAnimationFrame(() => {
3685
+ if (e2.isTyping || !x2 || (p2 == null ? void 0 : p2.activeElement) !== x2) return;
3686
+ let { selectionStart: w2, selectionEnd: W2 } = x2;
3687
+ Math.abs((W2 != null ? W2 : 0) - (w2 != null ? w2 : 0)) === 0 && w2 === 0 && x2.setSelectionRange(x2.value.length, x2.value.length);
3688
+ }));
3689
+ }, [F2, e2.comboboxState, p2, e2.isTyping]), m(([l2], [U]) => {
3690
+ if (l2 === 0 && U === 1) {
3691
+ if (e2.isTyping) return;
3692
+ let S2 = e2.inputRef.current;
3693
+ if (!S2) return;
3694
+ let H2 = S2.value, { selectionStart: x2, selectionEnd: w2, selectionDirection: W2 } = S2;
3695
+ S2.value = "", S2.value = H2, W2 !== null ? S2.setSelectionRange(x2, w2, W2) : S2.setSelectionRange(x2, w2);
3696
+ }
3697
+ }, [e2.comboboxState]);
3698
+ let v2 = useRef(false), y2 = o$2(() => {
3699
+ v2.current = true;
3700
+ }), A2 = o$2(() => {
3701
+ L2.nextFrame(() => {
3702
+ v2.current = false;
3703
+ });
3704
+ }), R2 = o$2((l2) => {
3705
+ switch (t2.setIsTyping(true), l2.key) {
3706
+ case o$3.Enter:
3707
+ if (e2.comboboxState !== 0 || v2.current) return;
3708
+ if (l2.preventDefault(), l2.stopPropagation(), e2.activeOptionIndex === null) {
3709
+ t2.closeCombobox();
3710
+ return;
3711
+ }
3712
+ t2.selectActiveOption(), e2.mode === 0 && t2.closeCombobox();
3713
+ break;
3714
+ case o$3.ArrowDown:
3715
+ return l2.preventDefault(), l2.stopPropagation(), u$6(e2.comboboxState, { [0]: () => t2.goToOption(c$1.Next), [1]: () => t2.openCombobox() });
3716
+ case o$3.ArrowUp:
3717
+ return l2.preventDefault(), l2.stopPropagation(), u$6(e2.comboboxState, { [0]: () => t2.goToOption(c$1.Previous), [1]: () => {
3718
+ flushSync(() => t2.openCombobox()), e2.value || t2.goToOption(c$1.Last);
3719
+ } });
3720
+ case o$3.Home:
3721
+ if (l2.shiftKey) break;
3722
+ return l2.preventDefault(), l2.stopPropagation(), t2.goToOption(c$1.First);
3723
+ case o$3.PageUp:
3724
+ return l2.preventDefault(), l2.stopPropagation(), t2.goToOption(c$1.First);
3725
+ case o$3.End:
3726
+ if (l2.shiftKey) break;
3727
+ return l2.preventDefault(), l2.stopPropagation(), t2.goToOption(c$1.Last);
3728
+ case o$3.PageDown:
3729
+ return l2.preventDefault(), l2.stopPropagation(), t2.goToOption(c$1.Last);
3730
+ case o$3.Escape:
3731
+ return e2.comboboxState !== 0 ? void 0 : (l2.preventDefault(), e2.optionsRef.current && !e2.optionsPropsRef.current.static && l2.stopPropagation(), e2.mode === 0 && e2.value === null && M2(), t2.closeCombobox());
3732
+ case o$3.Tab:
3733
+ if (e2.comboboxState !== 0) return;
3734
+ e2.mode === 0 && e2.activationTrigger !== 1 && t2.selectActiveOption(), t2.closeCombobox();
3735
+ break;
3736
+ }
3737
+ }), h2 = o$2((l2) => {
3738
+ s2 == null || s2(l2), e2.mode === 0 && l2.target.value === "" && M2(), t2.openCombobox();
3739
+ }), O = o$2((l2) => {
3740
+ var S2, H2, x2;
3741
+ let U = (S2 = l2.relatedTarget) != null ? S2 : r.find((w2) => w2 !== l2.currentTarget);
3742
+ if (!((H2 = e2.optionsRef.current) != null && H2.contains(U)) && !((x2 = e2.buttonRef.current) != null && x2.contains(U)) && e2.comboboxState === 0) return l2.preventDefault(), e2.mode === 0 && e2.value === null && M2(), t2.closeCombobox();
3743
+ }), G$1 = o$2((l2) => {
3744
+ var S2, H2, x2;
3745
+ let U = (S2 = l2.relatedTarget) != null ? S2 : r.find((w2) => w2 !== l2.currentTarget);
3746
+ (H2 = e2.buttonRef.current) != null && H2.contains(U) || (x2 = e2.optionsRef.current) != null && x2.contains(U) || e2.disabled || e2.immediate && e2.comboboxState !== 0 && L2.microTask(() => {
3747
+ flushSync(() => t2.openCombobox()), t2.setActivationTrigger(1);
3748
+ });
3749
+ }), J2 = I$1(), Q = G(), { isFocused: I2, focusProps: B } = $f7dceffc5ad7768b$export$4e328f61c538687f({ autoFocus: n2 }), { isHovered: k, hoverProps: K2 } = $6179b936705e76d3$export$ae780daf29e6d456({ isDisabled: a3 }), i2 = useMemo(() => ({ open: e2.comboboxState === 0, disabled: a3, hover: k, focus: I2, autofocus: n2 }), [e2, k, I2, n2, a3]), N2 = D$3({ ref: _2, id: f2, role: "combobox", type: T2, "aria-controls": (q2 = e2.optionsRef.current) == null ? void 0 : q2.id, "aria-expanded": e2.comboboxState === 0, "aria-activedescendant": e2.activeOptionIndex === null ? void 0 : e2.virtual ? (Y = e2.options.find((l2) => !l2.dataRef.current.disabled && e2.compare(l2.dataRef.current.value, e2.virtual.options[e2.activeOptionIndex]))) == null ? void 0 : Y.id : (E2 = e2.options[e2.activeOptionIndex]) == null ? void 0 : E2.id, "aria-labelledby": J2, "aria-describedby": Q, "aria-autocomplete": "list", defaultValue: (le = (ae = o2.defaultValue) != null ? ae : e2.defaultValue !== void 0 ? u2 == null ? void 0 : u2(e2.defaultValue) : null) != null ? le : e2.defaultValue, disabled: a3 || void 0, autoFocus: n2, onCompositionStart: y2, onCompositionEnd: A2, onKeyDown: R2, onChange: h2, onFocus: G$1, onBlur: O }, B, K2);
3750
+ return H({ ourProps: N2, theirProps: C, slot: i2, defaultTag: Do, name: "Combobox.Input" });
3751
+ }
3752
+ let Fo = "button";
3753
+ function Vo(o2, r2) {
3754
+ var h2;
3755
+ let e2 = oe("Combobox.Button"), t2 = re("Combobox.Button"), c2 = y$3(e2.buttonRef, r2), d2 = useId$1(), { id: f2 = `headlessui-combobox-button-${d2}`, disabled: s2 = e2.disabled || false, autoFocus: u2 = false, ...a3 } = o2, n2 = f$3(e2.inputRef), T$12 = o$2((O) => {
3756
+ switch (O.key) {
3757
+ case o$3.Space:
3758
+ case o$3.Enter:
3759
+ O.preventDefault(), O.stopPropagation(), e2.comboboxState === 1 && flushSync(() => t2.openCombobox()), n2();
3760
+ return;
3761
+ case o$3.ArrowDown:
3762
+ O.preventDefault(), O.stopPropagation(), e2.comboboxState === 1 && (flushSync(() => t2.openCombobox()), e2.value || t2.goToOption(c$1.First)), n2();
3763
+ return;
3764
+ case o$3.ArrowUp:
3765
+ O.preventDefault(), O.stopPropagation(), e2.comboboxState === 1 && (flushSync(() => t2.openCombobox()), e2.value || t2.goToOption(c$1.Last)), n2();
3766
+ return;
3767
+ case o$3.Escape:
3768
+ if (e2.comboboxState !== 0) return;
3769
+ O.preventDefault(), e2.optionsRef.current && !e2.optionsPropsRef.current.static && O.stopPropagation(), flushSync(() => t2.closeCombobox()), n2();
3770
+ return;
3771
+ default:
3772
+ return;
3773
+ }
3774
+ }), C = o$2((O) => {
3775
+ O.preventDefault(), !r$2(O.currentTarget) && (O.button === g.Left && (e2.comboboxState === 0 ? t2.closeCombobox() : t2.openCombobox()), n2());
3776
+ }), _2 = I$1([f2]), { isFocusVisible: p2, focusProps: L2 } = $f7dceffc5ad7768b$export$4e328f61c538687f({ autoFocus: u2 }), { isHovered: M2, hoverProps: F2 } = $6179b936705e76d3$export$ae780daf29e6d456({ isDisabled: s2 }), { pressed: v2, pressProps: y2 } = w({ disabled: s2 }), A2 = useMemo(() => ({ open: e2.comboboxState === 0, active: v2 || e2.comboboxState === 0, disabled: s2, value: e2.value, hover: M2, focus: p2 }), [e2, M2, p2, v2, s2]), R2 = D$3({ ref: c2, id: f2, type: T(o2, e2.buttonRef), tabIndex: -1, "aria-haspopup": "listbox", "aria-controls": (h2 = e2.optionsRef.current) == null ? void 0 : h2.id, "aria-expanded": e2.comboboxState === 0, "aria-labelledby": _2, disabled: s2 || void 0, autoFocus: u2, onMouseDown: C, onKeyDown: T$12 }, L2, F2, y2);
3777
+ return H({ ourProps: R2, theirProps: a3, slot: A2, defaultTag: Fo, name: "Combobox.Button" });
3778
+ }
3779
+ let Lo = "div", wo = M$2.RenderStrategy | M$2.Static;
3780
+ function Bo(o2, r2) {
3781
+ var N2, q2, Y;
3782
+ let e2 = useId$1(), { id: t2 = `headlessui-combobox-options-${e2}`, hold: c2 = false, anchor: d2, portal: f2 = false, modal: s2 = true, transition: u2 = false, ...a3 } = o2, n2 = oe("Combobox.Options"), T2 = re("Combobox.Options"), C = xe$1(d2);
3783
+ C && (f2 = true);
3784
+ let [_2, p2] = Re(C), L2 = be(), M2 = y$3(n2.optionsRef, r2, C ? _2 : null), F$12 = n$1(n2.optionsRef), v2 = u$1(), [y2, A$12] = V(u2, n2.optionsRef, v2 !== null ? (v2 & i.Open) === i.Open : n2.comboboxState === 0);
3785
+ m$2(y2, n2.inputRef, T2.closeCombobox);
3786
+ let R2 = n2.__demoMode ? false : s2 && n2.comboboxState === 0;
3787
+ f$2(R2, F$12);
3788
+ let h2 = n2.__demoMode ? false : s2 && n2.comboboxState === 0;
3789
+ y$2(h2, { allowed: o$2(() => [n2.inputRef.current, n2.buttonRef.current, n2.optionsRef.current]) }), n$3(() => {
3790
+ var E2;
3791
+ n2.optionsPropsRef.current.static = (E2 = o2.static) != null ? E2 : false;
3792
+ }, [n2.optionsPropsRef, o2.static]), n$3(() => {
3793
+ n2.optionsPropsRef.current.hold = c2;
3794
+ }, [n2.optionsPropsRef, c2]), F(n2.comboboxState === 0, { container: n2.optionsRef.current, accept(E2) {
3795
+ return E2.getAttribute("role") === "option" ? NodeFilter.FILTER_REJECT : E2.hasAttribute("role") ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
3796
+ }, walk(E2) {
3797
+ E2.setAttribute("role", "none");
3798
+ } });
3799
+ let O = I$1([(N2 = n2.buttonRef.current) == null ? void 0 : N2.id]), G2 = useMemo(() => ({ open: n2.comboboxState === 0, option: void 0 }), [n2.comboboxState]), J2 = o$2(() => {
3800
+ T2.setActivationTrigger(0);
3801
+ }), Q = o$2((E2) => {
3802
+ E2.preventDefault(), T2.setActivationTrigger(0);
3803
+ }), I2 = D$3(C ? L2() : {}, { "aria-labelledby": O, role: "listbox", "aria-multiselectable": n2.mode === 1 ? true : void 0, id: t2, ref: M2, style: { ...a3.style, ...p2, "--input-width": f$5(n2.inputRef, true).width, "--button-width": f$5(n2.buttonRef, true).width }, onWheel: n2.activationTrigger === 0 ? void 0 : J2, onMouseDown: Q, ...A(A$12) }), B = y2 && n2.comboboxState === 1, k = l$2(B, (q2 = n2.virtual) == null ? void 0 : q2.options), K2 = l$2(B, n2.value), i$12 = o$2((E2) => n2.compare(K2, E2));
3804
+ if (n2.virtual) {
3805
+ if (k === void 0) throw new Error("Missing `options` in virtual mode");
3806
+ Object.assign(a3, { children: React__default.createElement(ie.Provider, { value: k !== n2.virtual.options ? { ...n2, virtual: { ...n2.virtual, options: k } } : n2 }, React__default.createElement(Io, { slot: G2 }, a3.children)) });
3807
+ }
3808
+ return React__default.createElement(te, { enabled: f2 ? o2.static || y2 : false }, React__default.createElement(ie.Provider, { value: n2.mode === 1 ? n2 : { ...n2, isSelected: i$12 } }, H({ ourProps: I2, theirProps: { ...a3, children: React__default.createElement(f$1, { freeze: B }, typeof a3.children == "function" ? (Y = a3.children) == null ? void 0 : Y.call(a3, G2) : a3.children) }, slot: G2, defaultTag: Lo, features: wo, visible: y2, name: "Combobox.Options" })));
3809
+ }
3810
+ let ko = "div";
3811
+ function No(o2, r2) {
3812
+ var I2, B, k, K2;
3813
+ let e2 = oe("Combobox.Option"), t2 = re("Combobox.Option"), c2 = useId$1(), { id: d2 = `headlessui-combobox-option-${c2}`, value: f2, disabled: s2 = (k = (B = (I2 = e2.virtual) == null ? void 0 : I2.disabled) == null ? void 0 : B.call(I2, f2)) != null ? k : false, order: u2 = null, ...a3 } = o2, n2 = f$3(e2.inputRef), T2 = e2.virtual ? e2.activeOptionIndex === e2.calculateIndex(f2) : e2.activeOptionIndex === null ? false : ((K2 = e2.options[e2.activeOptionIndex]) == null ? void 0 : K2.id) === d2, C = e2.isSelected(f2), _2 = useRef(null), p2 = s$3({ disabled: s2, value: f2, domRef: _2, order: u2 }), L2 = useContext(Le), M2 = y$3(r2, _2, L2 ? L2.measureElement : null), F2 = o$2(() => {
3814
+ t2.setIsTyping(false), t2.onChange(f2);
3815
+ });
3816
+ n$3(() => t2.registerOption(d2, p2), [p2, d2]);
3817
+ let v2 = useRef(!(e2.virtual || e2.__demoMode));
3818
+ n$3(() => {
3819
+ if (!e2.virtual && !e2.__demoMode) return o$1().requestAnimationFrame(() => {
3820
+ v2.current = true;
3821
+ });
3822
+ }, [e2.virtual, e2.__demoMode]), n$3(() => {
3823
+ if (v2.current && e2.comboboxState === 0 && T2 && e2.activationTrigger !== 0) return o$1().requestAnimationFrame(() => {
3824
+ var i2, N2;
3825
+ (N2 = (i2 = _2.current) == null ? void 0 : i2.scrollIntoView) == null || N2.call(i2, { block: "nearest" });
3826
+ });
3827
+ }, [_2, T2, e2.comboboxState, e2.activationTrigger, e2.activeOptionIndex]);
3828
+ let y2 = o$2((i2) => {
3829
+ i2.preventDefault(), i2.button === g.Left && (s2 || (F2(), n$2() || requestAnimationFrame(() => n2()), e2.mode === 0 && t2.closeCombobox()));
3830
+ }), A2 = o$2(() => {
3831
+ if (s2) return t2.goToOption(c$1.Nothing);
3832
+ let i2 = e2.calculateIndex(f2);
3833
+ t2.goToOption(c$1.Specific, i2);
3834
+ }), R2 = u$2(), h2 = o$2((i2) => R2.update(i2)), O = o$2((i2) => {
3835
+ if (!R2.wasMoved(i2) || s2 || T2) return;
3836
+ let N2 = e2.calculateIndex(f2);
3837
+ t2.goToOption(c$1.Specific, N2, 0);
3838
+ }), G2 = o$2((i2) => {
3839
+ R2.wasMoved(i2) && (s2 || T2 && (e2.optionsPropsRef.current.hold || t2.goToOption(c$1.Nothing)));
3840
+ }), J2 = useMemo(() => ({ active: T2, focus: T2, selected: C, disabled: s2 }), [T2, C, s2]);
3841
+ return H({ ourProps: { id: d2, ref: M2, role: "option", tabIndex: s2 === true ? void 0 : -1, "aria-disabled": s2 === true ? true : void 0, "aria-selected": C, disabled: void 0, onMouseDown: y2, onFocus: A2, onPointerEnter: h2, onMouseEnter: h2, onPointerMove: O, onMouseMove: O, onPointerLeave: G2, onMouseLeave: G2 }, theirProps: a3, slot: J2, defaultTag: ko, name: "Combobox.Option" });
3842
+ }
3843
+ let Uo = W$1(ho), Ho = W$1(Vo), Go = W$1(Mo), jo = K, zo = W$1(Bo), Ko = W$1(No), Nt = Object.assign(Uo, { Input: Go, Button: Ho, Label: jo, Options: zo, Option: Ko });
3844
+ const container = "_container_xswn2_6";
3845
+ const full = "_full_xswn2_20";
3846
+ const placeholder = "_placeholder_xswn2_28";
3847
+ const input = "_input_xswn2_43";
3848
+ const button = "_button_xswn2_61";
3849
+ const options = "_options_xswn2_69";
3850
+ const option = "_option_xswn2_69";
3851
+ const l = "_l_xswn2_118";
3852
+ const xxl = "_xxl_xswn2_128";
3853
+ const cls = {
3854
+ "select-search": "_select-search_xswn2_2",
3855
+ container,
3856
+ "container-open": "_container-open_xswn2_16",
3857
+ full,
3858
+ "selectorIcon-open": "_selectorIcon-open_xswn2_24",
3859
+ placeholder,
3860
+ "placeholder-top": "_placeholder-top_xswn2_37",
3861
+ input,
3862
+ "input-container": "_input-container_xswn2_55",
3863
+ button,
3864
+ options,
3865
+ option,
3866
+ "option-active": "_option-active_xswn2_103",
3867
+ "option-inner": "_option-inner_xswn2_106",
3868
+ "no-options": "_no-options_xswn2_113",
3869
+ l,
3870
+ xxl,
3871
+ "selected-icon": "_selected-icon_xswn2_138"
3872
+ };
3873
+ const SelectSearch = forwardRef(
3874
+ ({ items, placeholder: placeholder2, size: size2 = ESelectSearchSize.L, onChange, value, full: full2 }, ref) => {
3875
+ const [searchValue, setSearchValue] = useState("");
3876
+ const [isItemSelected, setIsItemSelected] = useState(false);
3877
+ const isMobile = useMediaQuery(EMediaQuery.XSS);
3878
+ const filteredItems = useMemo(() => {
3879
+ return searchValue.trim().toLowerCase() ? items.filter(
3880
+ (item) => item.name.toLowerCase().includes(searchValue.toLowerCase())
3881
+ ) : items;
3882
+ }, [searchValue, items]);
3883
+ const handleOneChange = (newValue) => {
3884
+ onChange == null ? void 0 : onChange(newValue);
3885
+ setIsItemSelected(!!newValue);
3886
+ };
3887
+ return /* @__PURE__ */ jsx(
3888
+ Nt,
3889
+ {
3890
+ as: "div",
3891
+ onChange: handleOneChange,
3892
+ value,
3893
+ className: classNames(cls["select-search"], { [cls.full]: full2 }),
3894
+ ref,
3895
+ children: ({ open }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
3896
+ /* @__PURE__ */ jsxs(
3897
+ "div",
3898
+ {
3899
+ className: classNames(cls.container, cls[size2], {
3900
+ [cls["container-open"]]: open
3901
+ }),
3902
+ children: [
3903
+ /* @__PURE__ */ jsxs("div", { className: cls["input-container"], children: [
3904
+ /* @__PURE__ */ jsx(
3905
+ Go,
3906
+ {
3907
+ className: cls.input,
3908
+ onChange: (event) => setSearchValue(event.target.value),
3909
+ displayValue: (item) => item == null ? void 0 : item.name
3910
+ }
3911
+ ),
3912
+ /* @__PURE__ */ jsx(
3913
+ "span",
3914
+ {
3915
+ className: classNames(cls.placeholder, {
3916
+ [cls["placeholder-top"]]: isItemSelected || open || searchValue
3917
+ }),
3918
+ children: placeholder2
3919
+ }
3920
+ )
3921
+ ] }),
3922
+ /* @__PURE__ */ jsx(Ho, { className: cls.button, children: /* @__PURE__ */ jsx(
3923
+ Icon,
3924
+ {
3925
+ iconName: isMobile ? "DropdownArrowBottom16px" : "DropdownArrowDown24px",
3926
+ className: classNames(cls["selector-icon"], {
3927
+ [cls["selector-icon-open"]]: open
3928
+ })
3929
+ }
3930
+ ) })
3931
+ ]
3932
+ }
3933
+ ),
3934
+ /* @__PURE__ */ jsx(zo, { className: classNames(cls.options, cls[size2]), children: !items.length ? /* @__PURE__ */ jsx("div", { className: cls["no-options"], children: "Нет данных" }) : !filteredItems.length && searchValue.trim() ? /* @__PURE__ */ jsx("div", { className: cls["no-options"], children: "Ничего не найдено" }) : filteredItems.map((item) => /* @__PURE__ */ jsx(
3935
+ Ko,
3936
+ {
3937
+ value: item,
3938
+ className: ({ focus }) => classNames(cls.option, {
3939
+ [cls["option-active"]]: focus
3940
+ }),
3941
+ children: ({ selected }) => /* @__PURE__ */ jsxs("div", { className: cls["option-inner"], children: [
3942
+ /* @__PURE__ */ jsx("span", { className: cls["option-text"], children: item.name }),
3943
+ selected && /* @__PURE__ */ jsx(
3944
+ Icon,
3945
+ {
3946
+ iconName: "Done16px",
3947
+ className: cls["selected-icon"]
3948
+ }
3949
+ )
3950
+ ] })
3951
+ },
3952
+ item.id
3953
+ )) })
3954
+ ] })
3955
+ }
3956
+ );
3957
+ }
3958
+ );
3959
+ export {
3960
+ SelectSearch
3961
+ };