mimir-ui-kit 1.14.5 → 1.15.0

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