mimir-ui-kit 1.37.16 → 1.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/dist/assets/Dropdown.css +1 -0
  2. package/dist/assets/Slider.css +1 -1
  3. package/dist/close-provider-CEutdhG8.js +9 -0
  4. package/dist/combobox-CVtJDVoZ.js +980 -0
  5. package/dist/components/Accordion/Accordion.js +91 -95
  6. package/dist/components/CheckboxMimir/CheckboxMimir.js +4 -4
  7. package/dist/components/Drawer/Drawer.d.ts +5 -1
  8. package/dist/components/Drawer/Drawer.js +45 -44
  9. package/dist/components/Dropdown/Dropdown.d.ts +45 -0
  10. package/dist/components/Dropdown/Dropdown.js +333 -0
  11. package/dist/components/Dropdown/index.d.ts +1 -0
  12. package/dist/components/Dropdown/index.js +4 -0
  13. package/dist/components/MultiSelectSearch/MultiSelectSearch.js +18 -18
  14. package/dist/components/RadioGroup/RadioGroup.js +3 -3
  15. package/dist/components/SelectSearch/SelectSearch.js +21 -21
  16. package/dist/components/Slider/Slider.d.ts +19 -1
  17. package/dist/components/Slider/Slider.js +570 -533
  18. package/dist/components/Slider/constants.d.ts +4 -0
  19. package/dist/components/Slider/constants.js +4 -0
  20. package/dist/components/Slider/index.d.ts +1 -0
  21. package/dist/components/Slider/index.js +2 -0
  22. package/dist/components/Switcher/Switcher.js +4 -4
  23. package/dist/components/TabTrail/TabTrail.js +4 -4
  24. package/dist/components/index.d.ts +2 -1
  25. package/dist/components/index.js +121 -117
  26. package/dist/{field-C1kt7aNM.js → field-FJ34aSs4.js} +2 -2
  27. package/dist/{focus-management-DOYCPyGg.js → focus-management-DE4t_lW3.js} +2 -1
  28. package/dist/{hidden-PvGXrYUY.js → hidden-DbgtYPOH.js} +1 -1
  29. package/dist/index.js +149 -145
  30. package/dist/{keyboard-mgWkd2Vh.js → keyboard-B0lm_zyn.js} +111 -114
  31. package/dist/{label-D4GFpe5F.js → label-y3ANLTNC.js} +2 -2
  32. package/dist/open-closed-CdldUPoq.js +86 -0
  33. package/dist/portal-WDFNoIMz.js +1908 -0
  34. package/dist/{use-active-press-CqLGIFz7.js → use-active-press-86hajhdd.js} +1 -1
  35. package/package.json +1 -1
  36. package/dist/combobox-BpYucpxz.js +0 -2896
  37. package/dist/open-closed-D2VjDhAN.js +0 -86
@@ -1,2896 +0,0 @@
1
- import { n as U, u as wt, d as Te, s as Pe, o as M, p as Zt, t as An, e as Le, W as me, y as Oe, T as $n, H as pe, M as At, a as Re, $ as en, b as tn, D as yt, I as Dn, c as Z } from "./keyboard-mgWkd2Vh.js";
2
- import * as w from "react";
3
- import j, { useReducer as nn, useMemo as X, useSyncExternalStore as Fn, useId as Be, useEffect as oe, useCallback as Ne, useRef as J, useLayoutEffect as on, createContext as he, useContext as le, useState as ce, Fragment as tt, createRef as Ln } from "react";
4
- import * as Xe from "react-dom";
5
- import { flushSync as xe, createPortal as _n } from "react-dom";
6
- import { w as Nn } from "./use-active-press-CqLGIFz7.js";
7
- import { u as kn } from "./use-by-comparator-CVuf9KBq.js";
8
- import { K as zn, a as Hn, b as Vn, T as Bn, z as Wn, j as jn, u as Un, I as Et, G as Yn } from "./label-D4GFpe5F.js";
9
- import { A as qn, h as Kn, f as Gn, _ as Xn } from "./focus-management-DOYCPyGg.js";
10
- import { e as Jn } from "./use-resolve-button-type-DhFdPxnv.js";
11
- import { c as Qn, i as Je, u as Zn, x as eo, R as to } from "./open-closed-D2VjDhAN.js";
12
- import { r as no } from "./bugs-diTMAGNw.js";
13
- function Se(e, t, n) {
14
- let o = n.initialDeps ?? [], i;
15
- return () => {
16
- var r, s, l, a;
17
- let u;
18
- n.key && ((r = n.debug) != null && r.call(n)) && (u = Date.now());
19
- const c = e();
20
- if (!(c.length !== o.length || c.some((f, m) => o[m] !== f)))
21
- return i;
22
- o = c;
23
- let p;
24
- if (n.key && ((s = n.debug) != null && s.call(n)) && (p = Date.now()), i = t(...c), n.key && ((l = n.debug) != null && l.call(n))) {
25
- const f = Math.round((Date.now() - u) * 100) / 100, m = Math.round((Date.now() - p) * 100) / 100, h = m / 16, g = (v, y) => {
26
- for (v = String(v); v.length < y; )
27
- v = " " + v;
28
- return v;
29
- };
30
- console.info(
31
- `%c⏱ ${g(m, 5)} /${g(f, 5)} ms`,
32
- `
33
- font-size: .6rem;
34
- font-weight: bold;
35
- color: hsl(${Math.max(
36
- 0,
37
- Math.min(120 - 120 * h, 120)
38
- )}deg 100% 31%);`,
39
- n == null ? void 0 : n.key
40
- );
41
- }
42
- return (a = n == null ? void 0 : n.onChange) == null || a.call(n, i), i;
43
- };
44
- }
45
- function st(e, t) {
46
- if (e === void 0)
47
- throw new Error("Unexpected undefined");
48
- return e;
49
- }
50
- const oo = (e, t) => Math.abs(e - t) < 1, io = (e, t, n) => {
51
- let o;
52
- return function(...i) {
53
- e.clearTimeout(o), o = e.setTimeout(() => t.apply(this, i), n);
54
- };
55
- }, ro = (e) => e, lo = (e) => {
56
- const t = Math.max(e.startIndex - e.overscan, 0), n = Math.min(e.endIndex + e.overscan, e.count - 1), o = [];
57
- for (let i = t; i <= n; i++)
58
- o.push(i);
59
- return o;
60
- }, so = (e, t) => {
61
- const n = e.scrollElement;
62
- if (!n)
63
- return;
64
- const o = e.targetWindow;
65
- if (!o)
66
- return;
67
- const i = (s) => {
68
- const { width: l, height: a } = s;
69
- t({ width: Math.round(l), height: Math.round(a) });
70
- };
71
- if (i(n.getBoundingClientRect()), !o.ResizeObserver)
72
- return () => {
73
- };
74
- const r = new o.ResizeObserver((s) => {
75
- const l = s[0];
76
- if (l != null && l.borderBoxSize) {
77
- const a = l.borderBoxSize[0];
78
- if (a) {
79
- i({ width: a.inlineSize, height: a.blockSize });
80
- return;
81
- }
82
- }
83
- i(n.getBoundingClientRect());
84
- });
85
- return r.observe(n, { box: "border-box" }), () => {
86
- r.unobserve(n);
87
- };
88
- }, $t = {
89
- passive: !0
90
- }, ao = typeof window > "u" ? !0 : "onscrollend" in window, co = (e, t) => {
91
- const n = e.scrollElement;
92
- if (!n)
93
- return;
94
- const o = e.targetWindow;
95
- if (!o)
96
- return;
97
- let i = 0;
98
- const r = ao ? () => {
99
- } : io(
100
- o,
101
- () => {
102
- t(i, !1);
103
- },
104
- e.options.isScrollingResetDelay
105
- ), s = (u) => () => {
106
- const { horizontal: c, isRtl: d } = e.options;
107
- i = c ? n.scrollLeft * (d && -1 || 1) : n.scrollTop, r(), t(i, u);
108
- }, l = s(!0), a = s(!1);
109
- return a(), n.addEventListener("scroll", l, $t), n.addEventListener("scrollend", a, $t), () => {
110
- n.removeEventListener("scroll", l), n.removeEventListener("scrollend", a);
111
- };
112
- }, uo = (e, t, n) => {
113
- if (t != null && t.borderBoxSize) {
114
- const o = t.borderBoxSize[0];
115
- if (o)
116
- return Math.round(
117
- o[n.options.horizontal ? "inlineSize" : "blockSize"]
118
- );
119
- }
120
- return Math.round(
121
- e.getBoundingClientRect()[n.options.horizontal ? "width" : "height"]
122
- );
123
- }, fo = (e, {
124
- adjustments: t = 0,
125
- behavior: n
126
- }, o) => {
127
- var i, r;
128
- const s = e + t;
129
- (r = (i = o.scrollElement) == null ? void 0 : i.scrollTo) == null || r.call(i, {
130
- [o.options.horizontal ? "left" : "top"]: s,
131
- behavior: n
132
- });
133
- };
134
- class mo {
135
- constructor(t) {
136
- this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollToIndexTimeoutId = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
137
- let n = null;
138
- const o = () => n || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : n = new this.targetWindow.ResizeObserver((i) => {
139
- i.forEach((r) => {
140
- this._measureElement(r.target, r);
141
- });
142
- }));
143
- return {
144
- disconnect: () => {
145
- var i;
146
- (i = o()) == null || i.disconnect(), n = null;
147
- },
148
- observe: (i) => {
149
- var r;
150
- return (r = o()) == null ? void 0 : r.observe(i, { box: "border-box" });
151
- },
152
- unobserve: (i) => {
153
- var r;
154
- return (r = o()) == null ? void 0 : r.unobserve(i);
155
- }
156
- };
157
- })(), this.range = null, this.setOptions = (n) => {
158
- Object.entries(n).forEach(([o, i]) => {
159
- typeof i > "u" && delete n[o];
160
- }), this.options = {
161
- debug: !1,
162
- initialOffset: 0,
163
- overscan: 1,
164
- paddingStart: 0,
165
- paddingEnd: 0,
166
- scrollPaddingStart: 0,
167
- scrollPaddingEnd: 0,
168
- horizontal: !1,
169
- getItemKey: ro,
170
- rangeExtractor: lo,
171
- onChange: () => {
172
- },
173
- measureElement: uo,
174
- initialRect: { width: 0, height: 0 },
175
- scrollMargin: 0,
176
- gap: 0,
177
- indexAttribute: "data-index",
178
- initialMeasurementsCache: [],
179
- lanes: 1,
180
- isScrollingResetDelay: 150,
181
- enabled: !0,
182
- isRtl: !1,
183
- ...n
184
- };
185
- }, this.notify = (n) => {
186
- var o, i;
187
- (i = (o = this.options).onChange) == null || i.call(o, this, n);
188
- }, this.maybeNotify = Se(
189
- () => (this.calculateRange(), [
190
- this.isScrolling,
191
- this.range ? this.range.startIndex : null,
192
- this.range ? this.range.endIndex : null
193
- ]),
194
- (n) => {
195
- this.notify(n);
196
- },
197
- {
198
- key: process.env.NODE_ENV !== "production" && "maybeNotify",
199
- debug: () => this.options.debug,
200
- initialDeps: [
201
- this.isScrolling,
202
- this.range ? this.range.startIndex : null,
203
- this.range ? this.range.endIndex : null
204
- ]
205
- }
206
- ), this.cleanup = () => {
207
- this.unsubs.filter(Boolean).forEach((n) => n()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
208
- }, this._didMount = () => () => {
209
- this.cleanup();
210
- }, this._willUpdate = () => {
211
- var n;
212
- const o = this.options.enabled ? this.options.getScrollElement() : null;
213
- if (this.scrollElement !== o) {
214
- if (this.cleanup(), !o) {
215
- this.maybeNotify();
216
- return;
217
- }
218
- this.scrollElement = o, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((n = this.scrollElement) == null ? void 0 : n.window) ?? null, this.elementsCache.forEach((i) => {
219
- this.observer.observe(i);
220
- }), this._scrollToOffset(this.getScrollOffset(), {
221
- adjustments: void 0,
222
- behavior: void 0
223
- }), this.unsubs.push(
224
- this.options.observeElementRect(this, (i) => {
225
- this.scrollRect = i, this.maybeNotify();
226
- })
227
- ), this.unsubs.push(
228
- this.options.observeElementOffset(this, (i, r) => {
229
- this.scrollAdjustments = 0, this.scrollDirection = r ? this.getScrollOffset() < i ? "forward" : "backward" : null, this.scrollOffset = i, this.isScrolling = r, this.maybeNotify();
230
- })
231
- );
232
- }
233
- }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (n, o) => {
234
- const i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
235
- for (let s = o - 1; s >= 0; s--) {
236
- const l = n[s];
237
- if (i.has(l.lane))
238
- continue;
239
- const a = r.get(
240
- l.lane
241
- );
242
- if (a == null || l.end > a.end ? r.set(l.lane, l) : l.end < a.end && i.set(l.lane, !0), i.size === this.options.lanes)
243
- break;
244
- }
245
- return r.size === this.options.lanes ? Array.from(r.values()).sort((s, l) => s.end === l.end ? s.index - l.index : s.end - l.end)[0] : void 0;
246
- }, this.getMeasurementOptions = Se(
247
- () => [
248
- this.options.count,
249
- this.options.paddingStart,
250
- this.options.scrollMargin,
251
- this.options.getItemKey,
252
- this.options.enabled
253
- ],
254
- (n, o, i, r, s) => (this.pendingMeasuredCacheIndexes = [], {
255
- count: n,
256
- paddingStart: o,
257
- scrollMargin: i,
258
- getItemKey: r,
259
- enabled: s
260
- }),
261
- {
262
- key: !1
263
- }
264
- ), this.getMeasurements = Se(
265
- () => [this.getMeasurementOptions(), this.itemSizeCache],
266
- ({ count: n, paddingStart: o, scrollMargin: i, getItemKey: r, enabled: s }, l) => {
267
- if (!s)
268
- return this.measurementsCache = [], this.itemSizeCache.clear(), [];
269
- this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((c) => {
270
- this.itemSizeCache.set(c.key, c.size);
271
- }));
272
- const a = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
273
- this.pendingMeasuredCacheIndexes = [];
274
- const u = this.measurementsCache.slice(0, a);
275
- for (let c = a; c < n; c++) {
276
- const d = r(c), p = this.options.lanes === 1 ? u[c - 1] : this.getFurthestMeasurement(u, c), f = p ? p.end + this.options.gap : o + i, m = l.get(d), h = typeof m == "number" ? m : this.options.estimateSize(c), g = f + h, v = p ? p.lane : c % this.options.lanes;
277
- u[c] = {
278
- index: c,
279
- start: f,
280
- size: h,
281
- end: g,
282
- key: d,
283
- lane: v
284
- };
285
- }
286
- return this.measurementsCache = u, u;
287
- },
288
- {
289
- key: process.env.NODE_ENV !== "production" && "getMeasurements",
290
- debug: () => this.options.debug
291
- }
292
- ), this.calculateRange = Se(
293
- () => [this.getMeasurements(), this.getSize(), this.getScrollOffset()],
294
- (n, o, i) => this.range = n.length > 0 && o > 0 ? po({
295
- measurements: n,
296
- outerSize: o,
297
- scrollOffset: i
298
- }) : null,
299
- {
300
- key: process.env.NODE_ENV !== "production" && "calculateRange",
301
- debug: () => this.options.debug
302
- }
303
- ), this.getIndexes = Se(
304
- () => [
305
- this.options.rangeExtractor,
306
- this.calculateRange(),
307
- this.options.overscan,
308
- this.options.count
309
- ],
310
- (n, o, i, r) => o === null ? [] : n({
311
- startIndex: o.startIndex,
312
- endIndex: o.endIndex,
313
- overscan: i,
314
- count: r
315
- }),
316
- {
317
- key: process.env.NODE_ENV !== "production" && "getIndexes",
318
- debug: () => this.options.debug
319
- }
320
- ), this.indexFromElement = (n) => {
321
- const o = this.options.indexAttribute, i = n.getAttribute(o);
322
- return i ? parseInt(i, 10) : (console.warn(
323
- `Missing attribute name '${o}={index}' on measured element.`
324
- ), -1);
325
- }, this._measureElement = (n, o) => {
326
- const i = this.indexFromElement(n), r = this.measurementsCache[i];
327
- if (!r)
328
- return;
329
- const s = r.key, l = this.elementsCache.get(s);
330
- l !== n && (l && this.observer.unobserve(l), this.observer.observe(n), this.elementsCache.set(s, n)), n.isConnected && this.resizeItem(i, this.options.measureElement(n, o, this));
331
- }, this.resizeItem = (n, o) => {
332
- const i = this.measurementsCache[n];
333
- if (!i)
334
- return;
335
- const r = this.itemSizeCache.get(i.key) ?? i.size, s = o - r;
336
- s !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(i, s, this) : i.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", s), this._scrollToOffset(this.getScrollOffset(), {
337
- adjustments: this.scrollAdjustments += s,
338
- behavior: void 0
339
- })), this.pendingMeasuredCacheIndexes.push(i.index), this.itemSizeCache = new Map(this.itemSizeCache.set(i.key, o)), this.notify(!1));
340
- }, this.measureElement = (n) => {
341
- if (!n) {
342
- this.elementsCache.forEach((o, i) => {
343
- o.isConnected || (this.observer.unobserve(o), this.elementsCache.delete(i));
344
- });
345
- return;
346
- }
347
- this._measureElement(n, void 0);
348
- }, this.getVirtualItems = Se(
349
- () => [this.getIndexes(), this.getMeasurements()],
350
- (n, o) => {
351
- const i = [];
352
- for (let r = 0, s = n.length; r < s; r++) {
353
- const l = n[r], a = o[l];
354
- i.push(a);
355
- }
356
- return i;
357
- },
358
- {
359
- key: process.env.NODE_ENV !== "production" && "getVirtualItems",
360
- debug: () => this.options.debug
361
- }
362
- ), this.getVirtualItemForOffset = (n) => {
363
- const o = this.getMeasurements();
364
- if (o.length !== 0)
365
- return st(
366
- o[rn(
367
- 0,
368
- o.length - 1,
369
- (i) => st(o[i]).start,
370
- n
371
- )]
372
- );
373
- }, this.getOffsetForAlignment = (n, o) => {
374
- const i = this.getSize(), r = this.getScrollOffset();
375
- o === "auto" && (n <= r ? o = "start" : n >= r + i ? o = "end" : o = "start"), o === "start" ? n = n : o === "end" ? n = n - i : o === "center" && (n = n - i / 2);
376
- const s = this.options.horizontal ? "scrollWidth" : "scrollHeight", a = (this.scrollElement ? "document" in this.scrollElement ? this.scrollElement.document.documentElement[s] : this.scrollElement[s] : 0) - i;
377
- return Math.max(Math.min(a, n), 0);
378
- }, this.getOffsetForIndex = (n, o = "auto") => {
379
- n = Math.max(0, Math.min(n, this.options.count - 1));
380
- const i = this.measurementsCache[n];
381
- if (!i)
382
- return;
383
- const r = this.getSize(), s = this.getScrollOffset();
384
- if (o === "auto")
385
- if (i.end >= s + r - this.options.scrollPaddingEnd)
386
- o = "end";
387
- else if (i.start <= s + this.options.scrollPaddingStart)
388
- o = "start";
389
- else
390
- return [s, o];
391
- const l = o === "end" ? i.end + this.options.scrollPaddingEnd : i.start - this.options.scrollPaddingStart;
392
- return [this.getOffsetForAlignment(l, o), o];
393
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.cancelScrollToIndex = () => {
394
- this.scrollToIndexTimeoutId !== null && this.targetWindow && (this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId), this.scrollToIndexTimeoutId = null);
395
- }, this.scrollToOffset = (n, { align: o = "start", behavior: i } = {}) => {
396
- this.cancelScrollToIndex(), i === "smooth" && this.isDynamicMode() && console.warn(
397
- "The `smooth` scroll behavior is not fully supported with dynamic size."
398
- ), this._scrollToOffset(this.getOffsetForAlignment(n, o), {
399
- adjustments: void 0,
400
- behavior: i
401
- });
402
- }, this.scrollToIndex = (n, { align: o = "auto", behavior: i } = {}) => {
403
- n = Math.max(0, Math.min(n, this.options.count - 1)), this.cancelScrollToIndex(), i === "smooth" && this.isDynamicMode() && console.warn(
404
- "The `smooth` scroll behavior is not fully supported with dynamic size."
405
- );
406
- const r = this.getOffsetForIndex(n, o);
407
- if (!r) return;
408
- const [s, l] = r;
409
- this._scrollToOffset(s, { adjustments: void 0, behavior: i }), i !== "smooth" && this.isDynamicMode() && this.targetWindow && (this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
410
- if (this.scrollToIndexTimeoutId = null, this.elementsCache.has(
411
- this.options.getItemKey(n)
412
- )) {
413
- const [u] = st(
414
- this.getOffsetForIndex(n, l)
415
- );
416
- oo(u, this.getScrollOffset()) || this.scrollToIndex(n, { align: l, behavior: i });
417
- } else
418
- this.scrollToIndex(n, { align: l, behavior: i });
419
- }));
420
- }, this.scrollBy = (n, { behavior: o } = {}) => {
421
- this.cancelScrollToIndex(), o === "smooth" && this.isDynamicMode() && console.warn(
422
- "The `smooth` scroll behavior is not fully supported with dynamic size."
423
- ), this._scrollToOffset(this.getScrollOffset() + n, {
424
- adjustments: void 0,
425
- behavior: o
426
- });
427
- }, this.getTotalSize = () => {
428
- var n;
429
- const o = this.getMeasurements();
430
- let i;
431
- return o.length === 0 ? i = this.options.paddingStart : i = this.options.lanes === 1 ? ((n = o[o.length - 1]) == null ? void 0 : n.end) ?? 0 : Math.max(
432
- ...o.slice(-this.options.lanes).map((r) => r.end)
433
- ), Math.max(
434
- i - this.options.scrollMargin + this.options.paddingEnd,
435
- 0
436
- );
437
- }, this._scrollToOffset = (n, {
438
- adjustments: o,
439
- behavior: i
440
- }) => {
441
- this.options.scrollToFn(n, { behavior: i, adjustments: o }, this);
442
- }, this.measure = () => {
443
- this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
444
- }, this.setOptions(t);
445
- }
446
- }
447
- const rn = (e, t, n, o) => {
448
- for (; e <= t; ) {
449
- const i = (e + t) / 2 | 0, r = n(i);
450
- if (r < o)
451
- e = i + 1;
452
- else if (r > o)
453
- t = i - 1;
454
- else
455
- return i;
456
- }
457
- return e > 0 ? e - 1 : 0;
458
- };
459
- function po({
460
- measurements: e,
461
- outerSize: t,
462
- scrollOffset: n
463
- }) {
464
- const o = e.length - 1, r = rn(0, o, (l) => e[l].start, n);
465
- let s = r;
466
- for (; s < o && e[s].end < n + t; )
467
- s++;
468
- return { startIndex: r, endIndex: s };
469
- }
470
- const ho = typeof document < "u" ? w.useLayoutEffect : w.useEffect;
471
- function go(e) {
472
- const t = w.useReducer(() => ({}), {})[1], n = {
473
- ...e,
474
- onChange: (i, r) => {
475
- var s;
476
- r ? xe(t) : t(), (s = e.onChange) == null || s.call(e, i, r);
477
- }
478
- }, [o] = w.useState(
479
- () => new mo(n)
480
- );
481
- return o.setOptions(n), w.useEffect(() => o._didMount(), []), ho(() => o._willUpdate()), o;
482
- }
483
- function vo(e) {
484
- return go({
485
- observeElementRect: so,
486
- observeElementOffset: co,
487
- scrollToFn: fo,
488
- ...e
489
- });
490
- }
491
- function bo(e) {
492
- if (e === null) return { width: 0, height: 0 };
493
- let { width: t, height: n } = e.getBoundingClientRect();
494
- return { width: t, height: n };
495
- }
496
- function Dt(e, t = !1) {
497
- let [n, o] = nn(() => ({}), {}), i = X(() => bo(e), [e, n]);
498
- return U(() => {
499
- if (!e) return;
500
- let r = new ResizeObserver(o);
501
- return r.observe(e), () => {
502
- r.disconnect();
503
- };
504
- }, [e]), t ? { width: `${i.width}px`, height: `${i.height}px` } : i;
505
- }
506
- let xo = class extends Map {
507
- constructor(t) {
508
- super(), this.factory = t;
509
- }
510
- get(t) {
511
- let n = super.get(t);
512
- return n === void 0 && (n = this.factory(t), this.set(t, n)), n;
513
- }
514
- };
515
- function ln(e, t) {
516
- let n = e(), o = /* @__PURE__ */ new Set();
517
- return { getSnapshot() {
518
- return n;
519
- }, subscribe(i) {
520
- return o.add(i), () => o.delete(i);
521
- }, dispatch(i, ...r) {
522
- let s = t[i].call(n, ...r);
523
- s && (n = s, o.forEach((l) => l()));
524
- } };
525
- }
526
- function sn(e) {
527
- return Fn(e.subscribe, e.getSnapshot, e.getSnapshot);
528
- }
529
- let wo = new xo(() => ln(() => [], { ADD(e) {
530
- return this.includes(e) ? this : [...this, e];
531
- }, REMOVE(e) {
532
- let t = this.indexOf(e);
533
- if (t === -1) return this;
534
- let n = this.slice();
535
- return n.splice(t, 1), n;
536
- } }));
537
- function Ot(e, t) {
538
- let n = wo.get(t), o = Be(), i = sn(n);
539
- if (U(() => {
540
- if (e) return n.dispatch("ADD", o), () => n.dispatch("REMOVE", o);
541
- }, [n, e]), !e) return !1;
542
- let r = i.indexOf(o), s = i.length;
543
- return r === -1 && (r = s, s += 1), r === s - 1;
544
- }
545
- let pt = /* @__PURE__ */ new Map(), _e = /* @__PURE__ */ new Map();
546
- function Ft(e) {
547
- var t;
548
- let n = (t = _e.get(e)) != null ? t : 0;
549
- return _e.set(e, n + 1), n !== 0 ? () => Lt(e) : (pt.set(e, { "aria-hidden": e.getAttribute("aria-hidden"), inert: e.inert }), e.setAttribute("aria-hidden", "true"), e.inert = !0, () => Lt(e));
550
- }
551
- function Lt(e) {
552
- var t;
553
- let n = (t = _e.get(e)) != null ? t : 1;
554
- if (n === 1 ? _e.delete(e) : _e.set(e, n - 1), n !== 1) return;
555
- let o = pt.get(e);
556
- o && (o["aria-hidden"] === null ? e.removeAttribute("aria-hidden") : e.setAttribute("aria-hidden", o["aria-hidden"]), e.inert = o.inert, pt.delete(e));
557
- }
558
- function yo(e, { allowed: t, disallowed: n } = {}) {
559
- let o = Ot(e, "inert-others");
560
- U(() => {
561
- var i, r;
562
- if (!o) return;
563
- let s = Te();
564
- for (let a of (i = n == null ? void 0 : n()) != null ? i : []) a && s.add(Ft(a));
565
- let l = (r = t == null ? void 0 : t()) != null ? r : [];
566
- for (let a of l) {
567
- if (!a) continue;
568
- let u = wt(a);
569
- if (!u) continue;
570
- let c = a.parentElement;
571
- for (; c && c !== u.body; ) {
572
- for (let d of c.children) l.some((p) => d.contains(p)) || s.add(Ft(d));
573
- c = c.parentElement;
574
- }
575
- }
576
- return s.dispose;
577
- }, [o, t, n]);
578
- }
579
- function Eo(e, t, n) {
580
- let o = Pe((i) => {
581
- let r = i.getBoundingClientRect();
582
- r.x === 0 && r.y === 0 && r.width === 0 && r.height === 0 && n();
583
- });
584
- oe(() => {
585
- if (!e) return;
586
- let i = t === null ? null : t instanceof HTMLElement ? t : t.current;
587
- if (!i) return;
588
- let r = Te();
589
- if (typeof ResizeObserver < "u") {
590
- let s = new ResizeObserver(() => o.current(i));
591
- s.observe(i), r.add(() => s.disconnect());
592
- }
593
- if (typeof IntersectionObserver < "u") {
594
- let s = new IntersectionObserver(() => o.current(i));
595
- s.observe(i), r.add(() => s.disconnect());
596
- }
597
- return () => r.dispose();
598
- }, [t, o, e]);
599
- }
600
- function an() {
601
- return /iPhone/gi.test(window.navigator.platform) || /Mac/gi.test(window.navigator.platform) && window.navigator.maxTouchPoints > 0;
602
- }
603
- function Oo() {
604
- return /Android/gi.test(window.navigator.userAgent);
605
- }
606
- function cn() {
607
- return an() || Oo();
608
- }
609
- function Fe(e, t, n, o) {
610
- let i = Pe(n);
611
- oe(() => {
612
- if (!e) return;
613
- function r(s) {
614
- i.current(s);
615
- }
616
- return document.addEventListener(t, r, o), () => document.removeEventListener(t, r, o);
617
- }, [e, t, o]);
618
- }
619
- function So(e, t, n, o) {
620
- let i = Pe(n);
621
- oe(() => {
622
- if (!e) return;
623
- function r(s) {
624
- i.current(s);
625
- }
626
- return window.addEventListener(t, r, o), () => window.removeEventListener(t, r, o);
627
- }, [e, t, o]);
628
- }
629
- const _t = 30;
630
- function Ro(e, t, n) {
631
- let o = Ot(e, "outside-click"), i = Pe(n), r = Ne(function(a, u) {
632
- if (a.defaultPrevented) return;
633
- let c = u(a);
634
- if (c === null || !c.getRootNode().contains(c) || !c.isConnected) return;
635
- let d = function p(f) {
636
- return typeof f == "function" ? p(f()) : Array.isArray(f) || f instanceof Set ? f : [f];
637
- }(t);
638
- for (let p of d) if (p !== null && (p.contains(c) || a.composed && a.composedPath().includes(p))) return;
639
- return !qn(c, Kn.Loose) && c.tabIndex !== -1 && a.preventDefault(), i.current(a, c);
640
- }, [i, t]), s = J(null);
641
- Fe(o, "pointerdown", (a) => {
642
- var u, c;
643
- s.current = ((c = (u = a.composedPath) == null ? void 0 : u.call(a)) == null ? void 0 : c[0]) || a.target;
644
- }, !0), Fe(o, "mousedown", (a) => {
645
- var u, c;
646
- s.current = ((c = (u = a.composedPath) == null ? void 0 : u.call(a)) == null ? void 0 : c[0]) || a.target;
647
- }, !0), Fe(o, "click", (a) => {
648
- cn() || s.current && (r(a, () => s.current), s.current = null);
649
- }, !0);
650
- let l = J({ x: 0, y: 0 });
651
- Fe(o, "touchstart", (a) => {
652
- l.current.x = a.touches[0].clientX, l.current.y = a.touches[0].clientY;
653
- }, !0), Fe(o, "touchend", (a) => {
654
- let u = { x: a.changedTouches[0].clientX, y: a.changedTouches[0].clientY };
655
- if (!(Math.abs(u.x - l.current.x) >= _t || Math.abs(u.y - l.current.y) >= _t)) return r(a, () => a.target instanceof HTMLElement ? a.target : null);
656
- }, !0), So(o, "blur", (a) => r(a, () => window.document.activeElement instanceof HTMLIFrameElement ? window.document.activeElement : null), !0);
657
- }
658
- function nt(...e) {
659
- return X(() => wt(...e), [...e]);
660
- }
661
- function Co(e, t, n, o) {
662
- let i = Pe(n);
663
- oe(() => {
664
- e = e ?? window;
665
- function r(s) {
666
- i.current(s);
667
- }
668
- return e.addEventListener(t, r, o), () => e.removeEventListener(t, r, o);
669
- }, [e, t, o]);
670
- }
671
- function un(e) {
672
- let t = J({ value: "", selectionStart: null, selectionEnd: null });
673
- return Co(e, "blur", (n) => {
674
- let o = n.target;
675
- o instanceof HTMLInputElement && (t.current = { value: o.value, selectionStart: o.selectionStart, selectionEnd: o.selectionEnd });
676
- }), M(() => {
677
- if (document.activeElement !== e && e instanceof HTMLInputElement && e.isConnected) {
678
- if (e.focus({ preventScroll: !0 }), e.value !== t.current.value) e.setSelectionRange(e.value.length, e.value.length);
679
- else {
680
- let { selectionStart: n, selectionEnd: o } = t.current;
681
- n !== null && o !== null && e.setSelectionRange(n, o);
682
- }
683
- t.current = { value: "", selectionStart: null, selectionEnd: null };
684
- }
685
- });
686
- }
687
- function To() {
688
- let e;
689
- return { before({ doc: t }) {
690
- var n;
691
- let o = t.documentElement, i = (n = t.defaultView) != null ? n : window;
692
- e = Math.max(0, i.innerWidth - o.clientWidth);
693
- }, after({ doc: t, d: n }) {
694
- let o = t.documentElement, i = Math.max(0, o.clientWidth - o.offsetWidth), r = Math.max(0, e - i);
695
- n.style(o, "paddingRight", `${r}px`);
696
- } };
697
- }
698
- function Io() {
699
- return an() ? { before({ doc: e, d: t, meta: n }) {
700
- function o(i) {
701
- return n.containers.flatMap((r) => r()).some((r) => r.contains(i));
702
- }
703
- t.microTask(() => {
704
- var i;
705
- if (window.getComputedStyle(e.documentElement).scrollBehavior !== "auto") {
706
- let l = Te();
707
- l.style(e.documentElement, "scrollBehavior", "auto"), t.add(() => t.microTask(() => l.dispose()));
708
- }
709
- let r = (i = window.scrollY) != null ? i : window.pageYOffset, s = null;
710
- t.addEventListener(e, "click", (l) => {
711
- if (l.target instanceof HTMLElement) try {
712
- let a = l.target.closest("a");
713
- if (!a) return;
714
- let { hash: u } = new URL(a.href), c = e.querySelector(u);
715
- c && !o(c) && (s = c);
716
- } catch {
717
- }
718
- }, !0), t.addEventListener(e, "touchstart", (l) => {
719
- if (l.target instanceof HTMLElement) if (o(l.target)) {
720
- let a = l.target;
721
- for (; a.parentElement && o(a.parentElement); ) a = a.parentElement;
722
- t.style(a, "overscrollBehavior", "contain");
723
- } else t.style(l.target, "touchAction", "none");
724
- }), t.addEventListener(e, "touchmove", (l) => {
725
- if (l.target instanceof HTMLElement) {
726
- if (l.target.tagName === "INPUT") return;
727
- if (o(l.target)) {
728
- let a = l.target;
729
- for (; a.parentElement && a.dataset.headlessuiPortal !== "" && !(a.scrollHeight > a.clientHeight || a.scrollWidth > a.clientWidth); ) a = a.parentElement;
730
- a.dataset.headlessuiPortal === "" && l.preventDefault();
731
- } else l.preventDefault();
732
- }
733
- }, { passive: !1 }), t.add(() => {
734
- var l;
735
- let a = (l = window.scrollY) != null ? l : window.pageYOffset;
736
- r !== a && window.scrollTo(0, r), s && s.isConnected && (s.scrollIntoView({ block: "nearest" }), s = null);
737
- });
738
- });
739
- } } : {};
740
- }
741
- function Mo() {
742
- return { before({ doc: e, d: t }) {
743
- t.style(e.documentElement, "overflow", "hidden");
744
- } };
745
- }
746
- function Po(e) {
747
- let t = {};
748
- for (let n of e) Object.assign(t, n(t));
749
- return t;
750
- }
751
- let we = ln(() => /* @__PURE__ */ new Map(), { PUSH(e, t) {
752
- var n;
753
- let o = (n = this.get(e)) != null ? n : { doc: e, count: 0, d: Te(), meta: /* @__PURE__ */ new Set() };
754
- return o.count++, o.meta.add(t), this.set(e, o), this;
755
- }, POP(e, t) {
756
- let n = this.get(e);
757
- return n && (n.count--, n.meta.delete(t)), this;
758
- }, SCROLL_PREVENT({ doc: e, d: t, meta: n }) {
759
- let o = { doc: e, d: t, meta: Po(n) }, i = [Io(), To(), Mo()];
760
- i.forEach(({ before: r }) => r == null ? void 0 : r(o)), i.forEach(({ after: r }) => r == null ? void 0 : r(o));
761
- }, SCROLL_ALLOW({ d: e }) {
762
- e.dispose();
763
- }, TEARDOWN({ doc: e }) {
764
- this.delete(e);
765
- } });
766
- we.subscribe(() => {
767
- let e = we.getSnapshot(), t = /* @__PURE__ */ new Map();
768
- for (let [n] of e) t.set(n, n.documentElement.style.overflow);
769
- for (let n of e.values()) {
770
- let o = t.get(n.doc) === "hidden", i = n.count !== 0;
771
- (i && !o || !i && o) && we.dispatch(n.count > 0 ? "SCROLL_PREVENT" : "SCROLL_ALLOW", n), n.count === 0 && we.dispatch("TEARDOWN", n);
772
- }
773
- });
774
- function Ao(e, t, n = () => ({ containers: [] })) {
775
- let o = sn(we), i = t ? o.get(t) : void 0, r = i ? i.count > 0 : !1;
776
- return U(() => {
777
- if (!(!t || !e)) return we.dispatch("PUSH", t, n), () => we.dispatch("POP", t, n);
778
- }, [e, t]), r;
779
- }
780
- function $o(e, t, n = () => [document.body]) {
781
- let o = Ot(e, "scroll-lock");
782
- Ao(o, t, (i) => {
783
- var r;
784
- return { containers: [...(r = i.containers) != null ? r : [], n] };
785
- });
786
- }
787
- function Nt(e) {
788
- return [e.screenX, e.screenY];
789
- }
790
- function Do() {
791
- let e = J([-1, -1]);
792
- return { wasMoved(t) {
793
- let n = Nt(t);
794
- return e.current[0] === n[0] && e.current[1] === n[1] ? !1 : (e.current = n, !0);
795
- }, update(t) {
796
- e.current = Nt(t);
797
- } };
798
- }
799
- function Fo(e, { container: t, accept: n, walk: o }) {
800
- let i = J(n), r = J(o);
801
- oe(() => {
802
- i.current = n, r.current = o;
803
- }, [n, o]), U(() => {
804
- if (!t || !e) return;
805
- let s = wt(t);
806
- if (!s) return;
807
- let l = i.current, a = r.current, u = Object.assign((d) => l(d), { acceptNode: l }), c = s.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, u, !1);
808
- for (; c.nextNode(); ) a(c.currentNode);
809
- }, [t, e, i, r]);
810
- }
811
- function kt(e, t) {
812
- let n = J([]), o = M(e);
813
- oe(() => {
814
- let i = [...n.current];
815
- for (let [r, s] of t.entries()) if (n.current[r] !== s) {
816
- let l = o(t, i);
817
- return n.current = t, l;
818
- }
819
- }, [o, ...t]);
820
- }
821
- function ot() {
822
- return typeof window < "u";
823
- }
824
- function Ae(e) {
825
- return fn(e) ? (e.nodeName || "").toLowerCase() : "#document";
826
- }
827
- function ee(e) {
828
- var t;
829
- return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
830
- }
831
- function ae(e) {
832
- var t;
833
- return (t = (fn(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
834
- }
835
- function fn(e) {
836
- return ot() ? e instanceof Node || e instanceof ee(e).Node : !1;
837
- }
838
- function G(e) {
839
- return ot() ? e instanceof Element || e instanceof ee(e).Element : !1;
840
- }
841
- function se(e) {
842
- return ot() ? e instanceof HTMLElement || e instanceof ee(e).HTMLElement : !1;
843
- }
844
- function zt(e) {
845
- return !ot() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof ee(e).ShadowRoot;
846
- }
847
- function We(e) {
848
- const {
849
- overflow: t,
850
- overflowX: n,
851
- overflowY: o,
852
- display: i
853
- } = ie(e);
854
- return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !["inline", "contents"].includes(i);
855
- }
856
- function Lo(e) {
857
- return ["table", "td", "th"].includes(Ae(e));
858
- }
859
- function it(e) {
860
- return [":popover-open", ":modal"].some((t) => {
861
- try {
862
- return e.matches(t);
863
- } catch {
864
- return !1;
865
- }
866
- });
867
- }
868
- function St(e) {
869
- const t = Rt(), n = G(e) ? ie(e) : e;
870
- return n.transform !== "none" || n.perspective !== "none" || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || ["transform", "perspective", "filter"].some((o) => (n.willChange || "").includes(o)) || ["paint", "layout", "strict", "content"].some((o) => (n.contain || "").includes(o));
871
- }
872
- function _o(e) {
873
- let t = ue(e);
874
- for (; se(t) && !Ie(t); ) {
875
- if (St(t))
876
- return t;
877
- if (it(t))
878
- return null;
879
- t = ue(t);
880
- }
881
- return null;
882
- }
883
- function Rt() {
884
- return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
885
- }
886
- function Ie(e) {
887
- return ["html", "body", "#document"].includes(Ae(e));
888
- }
889
- function ie(e) {
890
- return ee(e).getComputedStyle(e);
891
- }
892
- function rt(e) {
893
- return G(e) ? {
894
- scrollLeft: e.scrollLeft,
895
- scrollTop: e.scrollTop
896
- } : {
897
- scrollLeft: e.scrollX,
898
- scrollTop: e.scrollY
899
- };
900
- }
901
- function ue(e) {
902
- if (Ae(e) === "html")
903
- return e;
904
- const t = (
905
- // Step into the shadow DOM of the parent of a slotted node.
906
- e.assignedSlot || // DOM Element detected.
907
- e.parentNode || // ShadowRoot detected.
908
- zt(e) && e.host || // Fallback.
909
- ae(e)
910
- );
911
- return zt(t) ? t.host : t;
912
- }
913
- function dn(e) {
914
- const t = ue(e);
915
- return Ie(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : se(t) && We(t) ? t : dn(t);
916
- }
917
- function ke(e, t, n) {
918
- var o;
919
- t === void 0 && (t = []), n === void 0 && (n = !0);
920
- const i = dn(e), r = i === ((o = e.ownerDocument) == null ? void 0 : o.body), s = ee(i);
921
- if (r) {
922
- const l = ht(s);
923
- return t.concat(s, s.visualViewport || [], We(i) ? i : [], l && n ? ke(l) : []);
924
- }
925
- return t.concat(i, ke(i, [], n));
926
- }
927
- function ht(e) {
928
- return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
929
- }
930
- function No() {
931
- const e = navigator.userAgentData;
932
- return e && Array.isArray(e.brands) ? e.brands.map((t) => {
933
- let {
934
- brand: n,
935
- version: o
936
- } = t;
937
- return n + "/" + o;
938
- }).join(" ") : navigator.userAgent;
939
- }
940
- const Me = Math.min, K = Math.max, ze = Math.round, Ke = Math.floor, fe = (e) => ({
941
- x: e,
942
- y: e
943
- }), ko = {
944
- left: "right",
945
- right: "left",
946
- bottom: "top",
947
- top: "bottom"
948
- }, zo = {
949
- start: "end",
950
- end: "start"
951
- };
952
- function Ht(e, t, n) {
953
- return K(e, Me(t, n));
954
- }
955
- function $e(e, t) {
956
- return typeof e == "function" ? e(t) : e;
957
- }
958
- function de(e) {
959
- return e.split("-")[0];
960
- }
961
- function je(e) {
962
- return e.split("-")[1];
963
- }
964
- function mn(e) {
965
- return e === "x" ? "y" : "x";
966
- }
967
- function pn(e) {
968
- return e === "y" ? "height" : "width";
969
- }
970
- function ye(e) {
971
- return ["top", "bottom"].includes(de(e)) ? "y" : "x";
972
- }
973
- function hn(e) {
974
- return mn(ye(e));
975
- }
976
- function Ho(e, t, n) {
977
- n === void 0 && (n = !1);
978
- const o = je(e), i = hn(e), r = pn(i);
979
- let s = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
980
- return t.reference[r] > t.floating[r] && (s = Qe(s)), [s, Qe(s)];
981
- }
982
- function Vo(e) {
983
- const t = Qe(e);
984
- return [gt(e), t, gt(t)];
985
- }
986
- function gt(e) {
987
- return e.replace(/start|end/g, (t) => zo[t]);
988
- }
989
- function Bo(e, t, n) {
990
- const o = ["left", "right"], i = ["right", "left"], r = ["top", "bottom"], s = ["bottom", "top"];
991
- switch (e) {
992
- case "top":
993
- case "bottom":
994
- return n ? t ? i : o : t ? o : i;
995
- case "left":
996
- case "right":
997
- return t ? r : s;
998
- default:
999
- return [];
1000
- }
1001
- }
1002
- function Wo(e, t, n, o) {
1003
- const i = je(e);
1004
- let r = Bo(de(e), n === "start", o);
1005
- return i && (r = r.map((s) => s + "-" + i), t && (r = r.concat(r.map(gt)))), r;
1006
- }
1007
- function Qe(e) {
1008
- return e.replace(/left|right|bottom|top/g, (t) => ko[t]);
1009
- }
1010
- function jo(e) {
1011
- return {
1012
- top: 0,
1013
- right: 0,
1014
- bottom: 0,
1015
- left: 0,
1016
- ...e
1017
- };
1018
- }
1019
- function Uo(e) {
1020
- return typeof e != "number" ? jo(e) : {
1021
- top: e,
1022
- right: e,
1023
- bottom: e,
1024
- left: e
1025
- };
1026
- }
1027
- function Ze(e) {
1028
- const {
1029
- x: t,
1030
- y: n,
1031
- width: o,
1032
- height: i
1033
- } = e;
1034
- return {
1035
- width: o,
1036
- height: i,
1037
- top: n,
1038
- left: t,
1039
- right: t + o,
1040
- bottom: n + i,
1041
- x: t,
1042
- y: n
1043
- };
1044
- }
1045
- function Vt(e, t, n) {
1046
- let {
1047
- reference: o,
1048
- floating: i
1049
- } = e;
1050
- const r = ye(t), s = hn(t), l = pn(s), a = de(t), u = r === "y", c = o.x + o.width / 2 - i.width / 2, d = o.y + o.height / 2 - i.height / 2, p = o[l] / 2 - i[l] / 2;
1051
- let f;
1052
- switch (a) {
1053
- case "top":
1054
- f = {
1055
- x: c,
1056
- y: o.y - i.height
1057
- };
1058
- break;
1059
- case "bottom":
1060
- f = {
1061
- x: c,
1062
- y: o.y + o.height
1063
- };
1064
- break;
1065
- case "right":
1066
- f = {
1067
- x: o.x + o.width,
1068
- y: d
1069
- };
1070
- break;
1071
- case "left":
1072
- f = {
1073
- x: o.x - i.width,
1074
- y: d
1075
- };
1076
- break;
1077
- default:
1078
- f = {
1079
- x: o.x,
1080
- y: o.y
1081
- };
1082
- }
1083
- switch (je(t)) {
1084
- case "start":
1085
- f[s] -= p * (n && u ? -1 : 1);
1086
- break;
1087
- case "end":
1088
- f[s] += p * (n && u ? -1 : 1);
1089
- break;
1090
- }
1091
- return f;
1092
- }
1093
- const Yo = async (e, t, n) => {
1094
- const {
1095
- placement: o = "bottom",
1096
- strategy: i = "absolute",
1097
- middleware: r = [],
1098
- platform: s
1099
- } = n, l = r.filter(Boolean), a = await (s.isRTL == null ? void 0 : s.isRTL(t));
1100
- let u = await s.getElementRects({
1101
- reference: e,
1102
- floating: t,
1103
- strategy: i
1104
- }), {
1105
- x: c,
1106
- y: d
1107
- } = Vt(u, o, a), p = o, f = {}, m = 0;
1108
- for (let h = 0; h < l.length; h++) {
1109
- const {
1110
- name: g,
1111
- fn: v
1112
- } = l[h], {
1113
- x: y,
1114
- y: b,
1115
- data: E,
1116
- reset: O
1117
- } = await v({
1118
- x: c,
1119
- y: d,
1120
- initialPlacement: o,
1121
- placement: p,
1122
- strategy: i,
1123
- middlewareData: f,
1124
- rects: u,
1125
- platform: s,
1126
- elements: {
1127
- reference: e,
1128
- floating: t
1129
- }
1130
- });
1131
- c = y ?? c, d = b ?? d, f = {
1132
- ...f,
1133
- [g]: {
1134
- ...f[g],
1135
- ...E
1136
- }
1137
- }, O && m <= 50 && (m++, typeof O == "object" && (O.placement && (p = O.placement), O.rects && (u = O.rects === !0 ? await s.getElementRects({
1138
- reference: e,
1139
- floating: t,
1140
- strategy: i
1141
- }) : O.rects), {
1142
- x: c,
1143
- y: d
1144
- } = Vt(u, p, a)), h = -1);
1145
- }
1146
- return {
1147
- x: c,
1148
- y: d,
1149
- placement: p,
1150
- strategy: i,
1151
- middlewareData: f
1152
- };
1153
- };
1154
- async function lt(e, t) {
1155
- var n;
1156
- t === void 0 && (t = {});
1157
- const {
1158
- x: o,
1159
- y: i,
1160
- platform: r,
1161
- rects: s,
1162
- elements: l,
1163
- strategy: a
1164
- } = e, {
1165
- boundary: u = "clippingAncestors",
1166
- rootBoundary: c = "viewport",
1167
- elementContext: d = "floating",
1168
- altBoundary: p = !1,
1169
- padding: f = 0
1170
- } = $e(t, e), m = Uo(f), g = l[p ? d === "floating" ? "reference" : "floating" : d], v = Ze(await r.getClippingRect({
1171
- element: (n = await (r.isElement == null ? void 0 : r.isElement(g))) == null || n ? g : g.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(l.floating)),
1172
- boundary: u,
1173
- rootBoundary: c,
1174
- strategy: a
1175
- })), y = d === "floating" ? {
1176
- x: o,
1177
- y: i,
1178
- width: s.floating.width,
1179
- height: s.floating.height
1180
- } : s.reference, b = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(l.floating)), E = await (r.isElement == null ? void 0 : r.isElement(b)) ? await (r.getScale == null ? void 0 : r.getScale(b)) || {
1181
- x: 1,
1182
- y: 1
1183
- } : {
1184
- x: 1,
1185
- y: 1
1186
- }, O = Ze(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
1187
- elements: l,
1188
- rect: y,
1189
- offsetParent: b,
1190
- strategy: a
1191
- }) : y);
1192
- return {
1193
- top: (v.top - O.top + m.top) / E.y,
1194
- bottom: (O.bottom - v.bottom + m.bottom) / E.y,
1195
- left: (v.left - O.left + m.left) / E.x,
1196
- right: (O.right - v.right + m.right) / E.x
1197
- };
1198
- }
1199
- const qo = function(e) {
1200
- return e === void 0 && (e = {}), {
1201
- name: "flip",
1202
- options: e,
1203
- async fn(t) {
1204
- var n, o;
1205
- const {
1206
- placement: i,
1207
- middlewareData: r,
1208
- rects: s,
1209
- initialPlacement: l,
1210
- platform: a,
1211
- elements: u
1212
- } = t, {
1213
- mainAxis: c = !0,
1214
- crossAxis: d = !0,
1215
- fallbackPlacements: p,
1216
- fallbackStrategy: f = "bestFit",
1217
- fallbackAxisSideDirection: m = "none",
1218
- flipAlignment: h = !0,
1219
- ...g
1220
- } = $e(e, t);
1221
- if ((n = r.arrow) != null && n.alignmentOffset)
1222
- return {};
1223
- const v = de(i), y = ye(l), b = de(l) === l, E = await (a.isRTL == null ? void 0 : a.isRTL(u.floating)), O = p || (b || !h ? [Qe(l)] : Vo(l)), C = m !== "none";
1224
- !p && C && O.push(...Wo(l, h, m, E));
1225
- const T = [l, ...O], S = await lt(t, g), L = [];
1226
- let A = ((o = r.flip) == null ? void 0 : o.overflows) || [];
1227
- if (c && L.push(S[v]), d) {
1228
- const x = Ho(i, s, E);
1229
- L.push(S[x[0]], S[x[1]]);
1230
- }
1231
- if (A = [...A, {
1232
- placement: i,
1233
- overflows: L
1234
- }], !L.every((x) => x <= 0)) {
1235
- var D, k;
1236
- const x = (((D = r.flip) == null ? void 0 : D.index) || 0) + 1, B = T[x];
1237
- if (B)
1238
- return {
1239
- data: {
1240
- index: x,
1241
- overflows: A
1242
- },
1243
- reset: {
1244
- placement: B
1245
- }
1246
- };
1247
- let _ = (k = A.filter((z) => z.overflows[0] <= 0).sort((z, P) => z.overflows[1] - P.overflows[1])[0]) == null ? void 0 : k.placement;
1248
- if (!_)
1249
- switch (f) {
1250
- case "bestFit": {
1251
- var F;
1252
- const z = (F = A.filter((P) => {
1253
- if (C) {
1254
- const $ = ye(P.placement);
1255
- return $ === y || // Create a bias to the `y` side axis due to horizontal
1256
- // reading directions favoring greater width.
1257
- $ === "y";
1258
- }
1259
- return !0;
1260
- }).map((P) => [P.placement, P.overflows.filter(($) => $ > 0).reduce(($, H) => $ + H, 0)]).sort((P, $) => P[1] - $[1])[0]) == null ? void 0 : F[0];
1261
- z && (_ = z);
1262
- break;
1263
- }
1264
- case "initialPlacement":
1265
- _ = l;
1266
- break;
1267
- }
1268
- if (i !== _)
1269
- return {
1270
- reset: {
1271
- placement: _
1272
- }
1273
- };
1274
- }
1275
- return {};
1276
- }
1277
- };
1278
- };
1279
- async function Ko(e, t) {
1280
- const {
1281
- placement: n,
1282
- platform: o,
1283
- elements: i
1284
- } = e, r = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), s = de(n), l = je(n), a = ye(n) === "y", u = ["left", "top"].includes(s) ? -1 : 1, c = r && a ? -1 : 1, d = $e(t, e);
1285
- let {
1286
- mainAxis: p,
1287
- crossAxis: f,
1288
- alignmentAxis: m
1289
- } = typeof d == "number" ? {
1290
- mainAxis: d,
1291
- crossAxis: 0,
1292
- alignmentAxis: null
1293
- } : {
1294
- mainAxis: d.mainAxis || 0,
1295
- crossAxis: d.crossAxis || 0,
1296
- alignmentAxis: d.alignmentAxis
1297
- };
1298
- return l && typeof m == "number" && (f = l === "end" ? m * -1 : m), a ? {
1299
- x: f * c,
1300
- y: p * u
1301
- } : {
1302
- x: p * u,
1303
- y: f * c
1304
- };
1305
- }
1306
- const Go = function(e) {
1307
- return e === void 0 && (e = 0), {
1308
- name: "offset",
1309
- options: e,
1310
- async fn(t) {
1311
- var n, o;
1312
- const {
1313
- x: i,
1314
- y: r,
1315
- placement: s,
1316
- middlewareData: l
1317
- } = t, a = await Ko(t, e);
1318
- return s === ((n = l.offset) == null ? void 0 : n.placement) && (o = l.arrow) != null && o.alignmentOffset ? {} : {
1319
- x: i + a.x,
1320
- y: r + a.y,
1321
- data: {
1322
- ...a,
1323
- placement: s
1324
- }
1325
- };
1326
- }
1327
- };
1328
- }, Xo = function(e) {
1329
- return e === void 0 && (e = {}), {
1330
- name: "shift",
1331
- options: e,
1332
- async fn(t) {
1333
- const {
1334
- x: n,
1335
- y: o,
1336
- placement: i
1337
- } = t, {
1338
- mainAxis: r = !0,
1339
- crossAxis: s = !1,
1340
- limiter: l = {
1341
- fn: (g) => {
1342
- let {
1343
- x: v,
1344
- y
1345
- } = g;
1346
- return {
1347
- x: v,
1348
- y
1349
- };
1350
- }
1351
- },
1352
- ...a
1353
- } = $e(e, t), u = {
1354
- x: n,
1355
- y: o
1356
- }, c = await lt(t, a), d = ye(de(i)), p = mn(d);
1357
- let f = u[p], m = u[d];
1358
- if (r) {
1359
- const g = p === "y" ? "top" : "left", v = p === "y" ? "bottom" : "right", y = f + c[g], b = f - c[v];
1360
- f = Ht(y, f, b);
1361
- }
1362
- if (s) {
1363
- const g = d === "y" ? "top" : "left", v = d === "y" ? "bottom" : "right", y = m + c[g], b = m - c[v];
1364
- m = Ht(y, m, b);
1365
- }
1366
- const h = l.fn({
1367
- ...t,
1368
- [p]: f,
1369
- [d]: m
1370
- });
1371
- return {
1372
- ...h,
1373
- data: {
1374
- x: h.x - n,
1375
- y: h.y - o,
1376
- enabled: {
1377
- [p]: r,
1378
- [d]: s
1379
- }
1380
- }
1381
- };
1382
- }
1383
- };
1384
- }, Jo = function(e) {
1385
- return e === void 0 && (e = {}), {
1386
- name: "size",
1387
- options: e,
1388
- async fn(t) {
1389
- var n, o;
1390
- const {
1391
- placement: i,
1392
- rects: r,
1393
- platform: s,
1394
- elements: l
1395
- } = t, {
1396
- apply: a = () => {
1397
- },
1398
- ...u
1399
- } = $e(e, t), c = await lt(t, u), d = de(i), p = je(i), f = ye(i) === "y", {
1400
- width: m,
1401
- height: h
1402
- } = r.floating;
1403
- let g, v;
1404
- d === "top" || d === "bottom" ? (g = d, v = p === (await (s.isRTL == null ? void 0 : s.isRTL(l.floating)) ? "start" : "end") ? "left" : "right") : (v = d, g = p === "end" ? "top" : "bottom");
1405
- const y = h - c.top - c.bottom, b = m - c.left - c.right, E = Me(h - c[g], y), O = Me(m - c[v], b), C = !t.middlewareData.shift;
1406
- let T = E, S = O;
1407
- if ((n = t.middlewareData.shift) != null && n.enabled.x && (S = b), (o = t.middlewareData.shift) != null && o.enabled.y && (T = y), C && !p) {
1408
- const A = K(c.left, 0), D = K(c.right, 0), k = K(c.top, 0), F = K(c.bottom, 0);
1409
- f ? S = m - 2 * (A !== 0 || D !== 0 ? A + D : K(c.left, c.right)) : T = h - 2 * (k !== 0 || F !== 0 ? k + F : K(c.top, c.bottom));
1410
- }
1411
- await a({
1412
- ...t,
1413
- availableWidth: S,
1414
- availableHeight: T
1415
- });
1416
- const L = await s.getDimensions(l.floating);
1417
- return m !== L.width || h !== L.height ? {
1418
- reset: {
1419
- rects: !0
1420
- }
1421
- } : {};
1422
- }
1423
- };
1424
- };
1425
- function gn(e) {
1426
- const t = ie(e);
1427
- let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
1428
- const i = se(e), r = i ? e.offsetWidth : n, s = i ? e.offsetHeight : o, l = ze(n) !== r || ze(o) !== s;
1429
- return l && (n = r, o = s), {
1430
- width: n,
1431
- height: o,
1432
- $: l
1433
- };
1434
- }
1435
- function Ct(e) {
1436
- return G(e) ? e : e.contextElement;
1437
- }
1438
- function Ce(e) {
1439
- const t = Ct(e);
1440
- if (!se(t))
1441
- return fe(1);
1442
- const n = t.getBoundingClientRect(), {
1443
- width: o,
1444
- height: i,
1445
- $: r
1446
- } = gn(t);
1447
- let s = (r ? ze(n.width) : n.width) / o, l = (r ? ze(n.height) : n.height) / i;
1448
- return (!s || !Number.isFinite(s)) && (s = 1), (!l || !Number.isFinite(l)) && (l = 1), {
1449
- x: s,
1450
- y: l
1451
- };
1452
- }
1453
- const Qo = /* @__PURE__ */ fe(0);
1454
- function vn(e) {
1455
- const t = ee(e);
1456
- return !Rt() || !t.visualViewport ? Qo : {
1457
- x: t.visualViewport.offsetLeft,
1458
- y: t.visualViewport.offsetTop
1459
- };
1460
- }
1461
- function Zo(e, t, n) {
1462
- return t === void 0 && (t = !1), !n || t && n !== ee(e) ? !1 : t;
1463
- }
1464
- function Ee(e, t, n, o) {
1465
- t === void 0 && (t = !1), n === void 0 && (n = !1);
1466
- const i = e.getBoundingClientRect(), r = Ct(e);
1467
- let s = fe(1);
1468
- t && (o ? G(o) && (s = Ce(o)) : s = Ce(e));
1469
- const l = Zo(r, n, o) ? vn(r) : fe(0);
1470
- let a = (i.left + l.x) / s.x, u = (i.top + l.y) / s.y, c = i.width / s.x, d = i.height / s.y;
1471
- if (r) {
1472
- const p = ee(r), f = o && G(o) ? ee(o) : o;
1473
- let m = p, h = ht(m);
1474
- for (; h && o && f !== m; ) {
1475
- const g = Ce(h), v = h.getBoundingClientRect(), y = ie(h), b = v.left + (h.clientLeft + parseFloat(y.paddingLeft)) * g.x, E = v.top + (h.clientTop + parseFloat(y.paddingTop)) * g.y;
1476
- a *= g.x, u *= g.y, c *= g.x, d *= g.y, a += b, u += E, m = ee(h), h = ht(m);
1477
- }
1478
- }
1479
- return Ze({
1480
- width: c,
1481
- height: d,
1482
- x: a,
1483
- y: u
1484
- });
1485
- }
1486
- function ei(e) {
1487
- let {
1488
- elements: t,
1489
- rect: n,
1490
- offsetParent: o,
1491
- strategy: i
1492
- } = e;
1493
- const r = i === "fixed", s = ae(o), l = t ? it(t.floating) : !1;
1494
- if (o === s || l && r)
1495
- return n;
1496
- let a = {
1497
- scrollLeft: 0,
1498
- scrollTop: 0
1499
- }, u = fe(1);
1500
- const c = fe(0), d = se(o);
1501
- if ((d || !d && !r) && ((Ae(o) !== "body" || We(s)) && (a = rt(o)), se(o))) {
1502
- const p = Ee(o);
1503
- u = Ce(o), c.x = p.x + o.clientLeft, c.y = p.y + o.clientTop;
1504
- }
1505
- return {
1506
- width: n.width * u.x,
1507
- height: n.height * u.y,
1508
- x: n.x * u.x - a.scrollLeft * u.x + c.x,
1509
- y: n.y * u.y - a.scrollTop * u.y + c.y
1510
- };
1511
- }
1512
- function ti(e) {
1513
- return Array.from(e.getClientRects());
1514
- }
1515
- function vt(e, t) {
1516
- const n = rt(e).scrollLeft;
1517
- return t ? t.left + n : Ee(ae(e)).left + n;
1518
- }
1519
- function ni(e) {
1520
- const t = ae(e), n = rt(e), o = e.ownerDocument.body, i = K(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), r = K(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
1521
- let s = -n.scrollLeft + vt(e);
1522
- const l = -n.scrollTop;
1523
- return ie(o).direction === "rtl" && (s += K(t.clientWidth, o.clientWidth) - i), {
1524
- width: i,
1525
- height: r,
1526
- x: s,
1527
- y: l
1528
- };
1529
- }
1530
- function oi(e, t) {
1531
- const n = ee(e), o = ae(e), i = n.visualViewport;
1532
- let r = o.clientWidth, s = o.clientHeight, l = 0, a = 0;
1533
- if (i) {
1534
- r = i.width, s = i.height;
1535
- const u = Rt();
1536
- (!u || u && t === "fixed") && (l = i.offsetLeft, a = i.offsetTop);
1537
- }
1538
- return {
1539
- width: r,
1540
- height: s,
1541
- x: l,
1542
- y: a
1543
- };
1544
- }
1545
- function ii(e, t) {
1546
- const n = Ee(e, !0, t === "fixed"), o = n.top + e.clientTop, i = n.left + e.clientLeft, r = se(e) ? Ce(e) : fe(1), s = e.clientWidth * r.x, l = e.clientHeight * r.y, a = i * r.x, u = o * r.y;
1547
- return {
1548
- width: s,
1549
- height: l,
1550
- x: a,
1551
- y: u
1552
- };
1553
- }
1554
- function Bt(e, t, n) {
1555
- let o;
1556
- if (t === "viewport")
1557
- o = oi(e, n);
1558
- else if (t === "document")
1559
- o = ni(ae(e));
1560
- else if (G(t))
1561
- o = ii(t, n);
1562
- else {
1563
- const i = vn(e);
1564
- o = {
1565
- ...t,
1566
- x: t.x - i.x,
1567
- y: t.y - i.y
1568
- };
1569
- }
1570
- return Ze(o);
1571
- }
1572
- function bn(e, t) {
1573
- const n = ue(e);
1574
- return n === t || !G(n) || Ie(n) ? !1 : ie(n).position === "fixed" || bn(n, t);
1575
- }
1576
- function ri(e, t) {
1577
- const n = t.get(e);
1578
- if (n)
1579
- return n;
1580
- let o = ke(e, [], !1).filter((l) => G(l) && Ae(l) !== "body"), i = null;
1581
- const r = ie(e).position === "fixed";
1582
- let s = r ? ue(e) : e;
1583
- for (; G(s) && !Ie(s); ) {
1584
- const l = ie(s), a = St(s);
1585
- !a && l.position === "fixed" && (i = null), (r ? !a && !i : !a && l.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || We(s) && !a && bn(e, s)) ? o = o.filter((c) => c !== s) : i = l, s = ue(s);
1586
- }
1587
- return t.set(e, o), o;
1588
- }
1589
- function li(e) {
1590
- let {
1591
- element: t,
1592
- boundary: n,
1593
- rootBoundary: o,
1594
- strategy: i
1595
- } = e;
1596
- const s = [...n === "clippingAncestors" ? it(t) ? [] : ri(t, this._c) : [].concat(n), o], l = s[0], a = s.reduce((u, c) => {
1597
- const d = Bt(t, c, i);
1598
- return u.top = K(d.top, u.top), u.right = Me(d.right, u.right), u.bottom = Me(d.bottom, u.bottom), u.left = K(d.left, u.left), u;
1599
- }, Bt(t, l, i));
1600
- return {
1601
- width: a.right - a.left,
1602
- height: a.bottom - a.top,
1603
- x: a.left,
1604
- y: a.top
1605
- };
1606
- }
1607
- function si(e) {
1608
- const {
1609
- width: t,
1610
- height: n
1611
- } = gn(e);
1612
- return {
1613
- width: t,
1614
- height: n
1615
- };
1616
- }
1617
- function ai(e, t, n) {
1618
- const o = se(t), i = ae(t), r = n === "fixed", s = Ee(e, !0, r, t);
1619
- let l = {
1620
- scrollLeft: 0,
1621
- scrollTop: 0
1622
- };
1623
- const a = fe(0);
1624
- if (o || !o && !r)
1625
- if ((Ae(t) !== "body" || We(i)) && (l = rt(t)), o) {
1626
- const f = Ee(t, !0, r, t);
1627
- a.x = f.x + t.clientLeft, a.y = f.y + t.clientTop;
1628
- } else i && (a.x = vt(i));
1629
- let u = 0, c = 0;
1630
- if (i && !o && !r) {
1631
- const f = i.getBoundingClientRect();
1632
- c = f.top + l.scrollTop, u = f.left + l.scrollLeft - // RTL <body> scrollbar.
1633
- vt(i, f);
1634
- }
1635
- const d = s.left + l.scrollLeft - a.x - u, p = s.top + l.scrollTop - a.y - c;
1636
- return {
1637
- x: d,
1638
- y: p,
1639
- width: s.width,
1640
- height: s.height
1641
- };
1642
- }
1643
- function at(e) {
1644
- return ie(e).position === "static";
1645
- }
1646
- function Wt(e, t) {
1647
- if (!se(e) || ie(e).position === "fixed")
1648
- return null;
1649
- if (t)
1650
- return t(e);
1651
- let n = e.offsetParent;
1652
- return ae(e) === n && (n = n.ownerDocument.body), n;
1653
- }
1654
- function xn(e, t) {
1655
- const n = ee(e);
1656
- if (it(e))
1657
- return n;
1658
- if (!se(e)) {
1659
- let i = ue(e);
1660
- for (; i && !Ie(i); ) {
1661
- if (G(i) && !at(i))
1662
- return i;
1663
- i = ue(i);
1664
- }
1665
- return n;
1666
- }
1667
- let o = Wt(e, t);
1668
- for (; o && Lo(o) && at(o); )
1669
- o = Wt(o, t);
1670
- return o && Ie(o) && at(o) && !St(o) ? n : o || _o(e) || n;
1671
- }
1672
- const ci = async function(e) {
1673
- const t = this.getOffsetParent || xn, n = this.getDimensions, o = await n(e.floating);
1674
- return {
1675
- reference: ai(e.reference, await t(e.floating), e.strategy),
1676
- floating: {
1677
- x: 0,
1678
- y: 0,
1679
- width: o.width,
1680
- height: o.height
1681
- }
1682
- };
1683
- };
1684
- function ui(e) {
1685
- return ie(e).direction === "rtl";
1686
- }
1687
- const fi = {
1688
- convertOffsetParentRelativeRectToViewportRelativeRect: ei,
1689
- getDocumentElement: ae,
1690
- getClippingRect: li,
1691
- getOffsetParent: xn,
1692
- getElementRects: ci,
1693
- getClientRects: ti,
1694
- getDimensions: si,
1695
- getScale: Ce,
1696
- isElement: G,
1697
- isRTL: ui
1698
- };
1699
- function di(e, t) {
1700
- let n = null, o;
1701
- const i = ae(e);
1702
- function r() {
1703
- var l;
1704
- clearTimeout(o), (l = n) == null || l.disconnect(), n = null;
1705
- }
1706
- function s(l, a) {
1707
- l === void 0 && (l = !1), a === void 0 && (a = 1), r();
1708
- const {
1709
- left: u,
1710
- top: c,
1711
- width: d,
1712
- height: p
1713
- } = e.getBoundingClientRect();
1714
- if (l || t(), !d || !p)
1715
- return;
1716
- const f = Ke(c), m = Ke(i.clientWidth - (u + d)), h = Ke(i.clientHeight - (c + p)), g = Ke(u), y = {
1717
- rootMargin: -f + "px " + -m + "px " + -h + "px " + -g + "px",
1718
- threshold: K(0, Me(1, a)) || 1
1719
- };
1720
- let b = !0;
1721
- function E(O) {
1722
- const C = O[0].intersectionRatio;
1723
- if (C !== a) {
1724
- if (!b)
1725
- return s();
1726
- C ? s(!1, C) : o = setTimeout(() => {
1727
- s(!1, 1e-7);
1728
- }, 1e3);
1729
- }
1730
- b = !1;
1731
- }
1732
- try {
1733
- n = new IntersectionObserver(E, {
1734
- ...y,
1735
- // Handle <iframe>s
1736
- root: i.ownerDocument
1737
- });
1738
- } catch {
1739
- n = new IntersectionObserver(E, y);
1740
- }
1741
- n.observe(e);
1742
- }
1743
- return s(!0), r;
1744
- }
1745
- function mi(e, t, n, o) {
1746
- o === void 0 && (o = {});
1747
- const {
1748
- ancestorScroll: i = !0,
1749
- ancestorResize: r = !0,
1750
- elementResize: s = typeof ResizeObserver == "function",
1751
- layoutShift: l = typeof IntersectionObserver == "function",
1752
- animationFrame: a = !1
1753
- } = o, u = Ct(e), c = i || r ? [...u ? ke(u) : [], ...ke(t)] : [];
1754
- c.forEach((v) => {
1755
- i && v.addEventListener("scroll", n, {
1756
- passive: !0
1757
- }), r && v.addEventListener("resize", n);
1758
- });
1759
- const d = u && l ? di(u, n) : null;
1760
- let p = -1, f = null;
1761
- s && (f = new ResizeObserver((v) => {
1762
- let [y] = v;
1763
- y && y.target === u && f && (f.unobserve(t), cancelAnimationFrame(p), p = requestAnimationFrame(() => {
1764
- var b;
1765
- (b = f) == null || b.observe(t);
1766
- })), n();
1767
- }), u && !a && f.observe(u), f.observe(t));
1768
- let m, h = a ? Ee(e) : null;
1769
- a && g();
1770
- function g() {
1771
- const v = Ee(e);
1772
- h && (v.x !== h.x || v.y !== h.y || v.width !== h.width || v.height !== h.height) && n(), h = v, m = requestAnimationFrame(g);
1773
- }
1774
- return n(), () => {
1775
- var v;
1776
- c.forEach((y) => {
1777
- i && y.removeEventListener("scroll", n), r && y.removeEventListener("resize", n);
1778
- }), d == null || d(), (v = f) == null || v.disconnect(), f = null, a && cancelAnimationFrame(m);
1779
- };
1780
- }
1781
- const ct = lt, pi = Go, hi = Xo, gi = qo, vi = Jo, bi = (e, t, n) => {
1782
- const o = /* @__PURE__ */ new Map(), i = {
1783
- platform: fi,
1784
- ...n
1785
- }, r = {
1786
- ...i.platform,
1787
- _c: o
1788
- };
1789
- return Yo(e, t, {
1790
- ...i,
1791
- platform: r
1792
- });
1793
- };
1794
- var Ge = typeof document < "u" ? on : oe;
1795
- function et(e, t) {
1796
- if (e === t)
1797
- return !0;
1798
- if (typeof e != typeof t)
1799
- return !1;
1800
- if (typeof e == "function" && e.toString() === t.toString())
1801
- return !0;
1802
- let n, o, i;
1803
- if (e && t && typeof e == "object") {
1804
- if (Array.isArray(e)) {
1805
- if (n = e.length, n !== t.length) return !1;
1806
- for (o = n; o-- !== 0; )
1807
- if (!et(e[o], t[o]))
1808
- return !1;
1809
- return !0;
1810
- }
1811
- if (i = Object.keys(e), n = i.length, n !== Object.keys(t).length)
1812
- return !1;
1813
- for (o = n; o-- !== 0; )
1814
- if (!{}.hasOwnProperty.call(t, i[o]))
1815
- return !1;
1816
- for (o = n; o-- !== 0; ) {
1817
- const r = i[o];
1818
- if (!(r === "_owner" && e.$$typeof) && !et(e[r], t[r]))
1819
- return !1;
1820
- }
1821
- return !0;
1822
- }
1823
- return e !== e && t !== t;
1824
- }
1825
- function wn(e) {
1826
- return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
1827
- }
1828
- function jt(e, t) {
1829
- const n = wn(e);
1830
- return Math.round(t * n) / n;
1831
- }
1832
- function ut(e) {
1833
- const t = w.useRef(e);
1834
- return Ge(() => {
1835
- t.current = e;
1836
- }), t;
1837
- }
1838
- function xi(e) {
1839
- e === void 0 && (e = {});
1840
- const {
1841
- placement: t = "bottom",
1842
- strategy: n = "absolute",
1843
- middleware: o = [],
1844
- platform: i,
1845
- elements: {
1846
- reference: r,
1847
- floating: s
1848
- } = {},
1849
- transform: l = !0,
1850
- whileElementsMounted: a,
1851
- open: u
1852
- } = e, [c, d] = w.useState({
1853
- x: 0,
1854
- y: 0,
1855
- strategy: n,
1856
- placement: t,
1857
- middlewareData: {},
1858
- isPositioned: !1
1859
- }), [p, f] = w.useState(o);
1860
- et(p, o) || f(o);
1861
- const [m, h] = w.useState(null), [g, v] = w.useState(null), y = w.useCallback((P) => {
1862
- P !== C.current && (C.current = P, h(P));
1863
- }, []), b = w.useCallback((P) => {
1864
- P !== T.current && (T.current = P, v(P));
1865
- }, []), E = r || m, O = s || g, C = w.useRef(null), T = w.useRef(null), S = w.useRef(c), L = a != null, A = ut(a), D = ut(i), k = ut(u), F = w.useCallback(() => {
1866
- if (!C.current || !T.current)
1867
- return;
1868
- const P = {
1869
- placement: t,
1870
- strategy: n,
1871
- middleware: p
1872
- };
1873
- D.current && (P.platform = D.current), bi(C.current, T.current, P).then(($) => {
1874
- const H = {
1875
- ...$,
1876
- // The floating element's position may be recomputed while it's closed
1877
- // but still mounted (such as when transitioning out). To ensure
1878
- // `isPositioned` will be `false` initially on the next open, avoid
1879
- // setting it to `true` when `open === false` (must be specified).
1880
- isPositioned: k.current !== !1
1881
- };
1882
- x.current && !et(S.current, H) && (S.current = H, Xe.flushSync(() => {
1883
- d(H);
1884
- }));
1885
- });
1886
- }, [p, t, n, D, k]);
1887
- Ge(() => {
1888
- u === !1 && S.current.isPositioned && (S.current.isPositioned = !1, d((P) => ({
1889
- ...P,
1890
- isPositioned: !1
1891
- })));
1892
- }, [u]);
1893
- const x = w.useRef(!1);
1894
- Ge(() => (x.current = !0, () => {
1895
- x.current = !1;
1896
- }), []), Ge(() => {
1897
- if (E && (C.current = E), O && (T.current = O), E && O) {
1898
- if (A.current)
1899
- return A.current(E, O, F);
1900
- F();
1901
- }
1902
- }, [E, O, F, A, L]);
1903
- const B = w.useMemo(() => ({
1904
- reference: C,
1905
- floating: T,
1906
- setReference: y,
1907
- setFloating: b
1908
- }), [y, b]), _ = w.useMemo(() => ({
1909
- reference: E,
1910
- floating: O
1911
- }), [E, O]), z = w.useMemo(() => {
1912
- const P = {
1913
- position: n,
1914
- left: 0,
1915
- top: 0
1916
- };
1917
- if (!_.floating)
1918
- return P;
1919
- const $ = jt(_.floating, c.x), H = jt(_.floating, c.y);
1920
- return l ? {
1921
- ...P,
1922
- transform: "translate(" + $ + "px, " + H + "px)",
1923
- ...wn(_.floating) >= 1.5 && {
1924
- willChange: "transform"
1925
- }
1926
- } : {
1927
- position: n,
1928
- left: $,
1929
- top: H
1930
- };
1931
- }, [n, l, _.floating, c.x, c.y]);
1932
- return w.useMemo(() => ({
1933
- ...c,
1934
- update: F,
1935
- refs: B,
1936
- elements: _,
1937
- floatingStyles: z
1938
- }), [c, F, B, _, z]);
1939
- }
1940
- const yn = (e, t) => ({
1941
- ...pi(e),
1942
- options: [e, t]
1943
- }), wi = (e, t) => ({
1944
- ...hi(e),
1945
- options: [e, t]
1946
- }), yi = (e, t) => ({
1947
- ...gi(e),
1948
- options: [e, t]
1949
- }), Ei = (e, t) => ({
1950
- ...vi(e),
1951
- options: [e, t]
1952
- }), En = {
1953
- ...w
1954
- }, Oi = En.useInsertionEffect, Si = Oi || ((e) => e());
1955
- function On(e) {
1956
- const t = w.useRef(() => {
1957
- if (process.env.NODE_ENV !== "production")
1958
- throw new Error("Cannot call an event handler while rendering.");
1959
- });
1960
- return Si(() => {
1961
- t.current = e;
1962
- }), w.useCallback(function() {
1963
- for (var n = arguments.length, o = new Array(n), i = 0; i < n; i++)
1964
- o[i] = arguments[i];
1965
- return t.current == null ? void 0 : t.current(...o);
1966
- }, []);
1967
- }
1968
- var bt = typeof document < "u" ? on : oe;
1969
- let Ut = !1, Ri = 0;
1970
- const Yt = () => (
1971
- // Ensure the id is unique with multiple independent versions of Floating UI
1972
- // on <React 18
1973
- "floating-ui-" + Math.random().toString(36).slice(2, 6) + Ri++
1974
- );
1975
- function Ci() {
1976
- const [e, t] = w.useState(() => Ut ? Yt() : void 0);
1977
- return bt(() => {
1978
- e == null && t(Yt());
1979
- }, []), w.useEffect(() => {
1980
- Ut = !0;
1981
- }, []), e;
1982
- }
1983
- const Ti = En.useId, Ii = Ti || Ci;
1984
- let He;
1985
- process.env.NODE_ENV !== "production" && (He = /* @__PURE__ */ new Set());
1986
- function Mi() {
1987
- for (var e, t = arguments.length, n = new Array(t), o = 0; o < t; o++)
1988
- n[o] = arguments[o];
1989
- const i = "Floating UI: " + n.join(" ");
1990
- if (!((e = He) != null && e.has(i))) {
1991
- var r;
1992
- (r = He) == null || r.add(i), console.warn(i);
1993
- }
1994
- }
1995
- function Pi() {
1996
- for (var e, t = arguments.length, n = new Array(t), o = 0; o < t; o++)
1997
- n[o] = arguments[o];
1998
- const i = "Floating UI: " + n.join(" ");
1999
- if (!((e = He) != null && e.has(i))) {
2000
- var r;
2001
- (r = He) == null || r.add(i), console.error(i);
2002
- }
2003
- }
2004
- function Ai() {
2005
- const e = /* @__PURE__ */ new Map();
2006
- return {
2007
- emit(t, n) {
2008
- var o;
2009
- (o = e.get(t)) == null || o.forEach((i) => i(n));
2010
- },
2011
- on(t, n) {
2012
- e.set(t, [...e.get(t) || [], n]);
2013
- },
2014
- off(t, n) {
2015
- var o;
2016
- e.set(t, ((o = e.get(t)) == null ? void 0 : o.filter((i) => i !== n)) || []);
2017
- }
2018
- };
2019
- }
2020
- const $i = /* @__PURE__ */ w.createContext(null), Di = /* @__PURE__ */ w.createContext(null), Fi = () => {
2021
- var e;
2022
- return ((e = w.useContext($i)) == null ? void 0 : e.id) || null;
2023
- }, Li = () => w.useContext(Di), _i = "data-floating-ui-focusable";
2024
- function Ni(e) {
2025
- const {
2026
- open: t = !1,
2027
- onOpenChange: n,
2028
- elements: o
2029
- } = e, i = Ii(), r = w.useRef({}), [s] = w.useState(() => Ai()), l = Fi() != null;
2030
- if (process.env.NODE_ENV !== "production") {
2031
- const f = o.reference;
2032
- f && !G(f) && Pi("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
2033
- }
2034
- const [a, u] = w.useState(o.reference), c = On((f, m, h) => {
2035
- r.current.openEvent = f ? m : void 0, s.emit("openchange", {
2036
- open: f,
2037
- event: m,
2038
- reason: h,
2039
- nested: l
2040
- }), n == null || n(f, m, h);
2041
- }), d = w.useMemo(() => ({
2042
- setPositionReference: u
2043
- }), []), p = w.useMemo(() => ({
2044
- reference: a || o.reference || null,
2045
- floating: o.floating || null,
2046
- domReference: o.reference
2047
- }), [a, o.reference, o.floating]);
2048
- return w.useMemo(() => ({
2049
- dataRef: r,
2050
- open: t,
2051
- onOpenChange: c,
2052
- elements: p,
2053
- events: s,
2054
- floatingId: i,
2055
- refs: d
2056
- }), [t, c, p, s, i, d]);
2057
- }
2058
- function ki(e) {
2059
- e === void 0 && (e = {});
2060
- const {
2061
- nodeId: t
2062
- } = e, n = Ni({
2063
- ...e,
2064
- elements: {
2065
- reference: null,
2066
- floating: null,
2067
- ...e.elements
2068
- }
2069
- }), o = e.rootContext || n, i = o.elements, [r, s] = w.useState(null), [l, a] = w.useState(null), c = (i == null ? void 0 : i.reference) || r, d = w.useRef(null), p = Li();
2070
- bt(() => {
2071
- c && (d.current = c);
2072
- }, [c]);
2073
- const f = xi({
2074
- ...e,
2075
- elements: {
2076
- ...i,
2077
- ...l && {
2078
- reference: l
2079
- }
2080
- }
2081
- }), m = w.useCallback((b) => {
2082
- const E = G(b) ? {
2083
- getBoundingClientRect: () => b.getBoundingClientRect(),
2084
- contextElement: b
2085
- } : b;
2086
- a(E), f.refs.setReference(E);
2087
- }, [f.refs]), h = w.useCallback((b) => {
2088
- (G(b) || b === null) && (d.current = b, s(b)), (G(f.refs.reference.current) || f.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
2089
- // `null` to support `positionReference` + an unstable `reference`
2090
- // callback ref.
2091
- b !== null && !G(b)) && f.refs.setReference(b);
2092
- }, [f.refs]), g = w.useMemo(() => ({
2093
- ...f.refs,
2094
- setReference: h,
2095
- setPositionReference: m,
2096
- domReference: d
2097
- }), [f.refs, h, m]), v = w.useMemo(() => ({
2098
- ...f.elements,
2099
- domReference: c
2100
- }), [f.elements, c]), y = w.useMemo(() => ({
2101
- ...f,
2102
- ...o,
2103
- refs: g,
2104
- elements: v,
2105
- nodeId: t
2106
- }), [f, g, v, t, o]);
2107
- return bt(() => {
2108
- o.dataRef.current.floatingContext = y;
2109
- const b = p == null ? void 0 : p.nodesRef.current.find((E) => E.id === t);
2110
- b && (b.context = y);
2111
- }), w.useMemo(() => ({
2112
- ...f,
2113
- context: y,
2114
- refs: g,
2115
- elements: v
2116
- }), [f, g, v, y]);
2117
- }
2118
- const qt = "active", Kt = "selected";
2119
- function ft(e, t, n) {
2120
- const o = /* @__PURE__ */ new Map(), i = n === "item";
2121
- let r = e;
2122
- if (i && e) {
2123
- const {
2124
- [qt]: s,
2125
- [Kt]: l,
2126
- ...a
2127
- } = e;
2128
- r = a;
2129
- }
2130
- return {
2131
- ...n === "floating" && {
2132
- tabIndex: -1,
2133
- [_i]: ""
2134
- },
2135
- ...r,
2136
- ...t.map((s) => {
2137
- const l = s ? s[n] : null;
2138
- return typeof l == "function" ? e ? l(e) : null : l;
2139
- }).concat(e).reduce((s, l) => (l && Object.entries(l).forEach((a) => {
2140
- let [u, c] = a;
2141
- if (!(i && [qt, Kt].includes(u)))
2142
- if (u.indexOf("on") === 0) {
2143
- if (o.has(u) || o.set(u, []), typeof c == "function") {
2144
- var d;
2145
- (d = o.get(u)) == null || d.push(c), s[u] = function() {
2146
- for (var p, f = arguments.length, m = new Array(f), h = 0; h < f; h++)
2147
- m[h] = arguments[h];
2148
- return (p = o.get(u)) == null ? void 0 : p.map((g) => g(...m)).find((g) => g !== void 0);
2149
- };
2150
- }
2151
- } else
2152
- s[u] = c;
2153
- }), s), {})
2154
- };
2155
- }
2156
- function zi(e) {
2157
- e === void 0 && (e = []);
2158
- const t = e.map((l) => l == null ? void 0 : l.reference), n = e.map((l) => l == null ? void 0 : l.floating), o = e.map((l) => l == null ? void 0 : l.item), i = w.useCallback(
2159
- (l) => ft(l, e, "reference"),
2160
- // eslint-disable-next-line react-hooks/exhaustive-deps
2161
- t
2162
- ), r = w.useCallback(
2163
- (l) => ft(l, e, "floating"),
2164
- // eslint-disable-next-line react-hooks/exhaustive-deps
2165
- n
2166
- ), s = w.useCallback(
2167
- (l) => ft(l, e, "item"),
2168
- // eslint-disable-next-line react-hooks/exhaustive-deps
2169
- o
2170
- );
2171
- return w.useMemo(() => ({
2172
- getReferenceProps: i,
2173
- getFloatingProps: r,
2174
- getItemProps: s
2175
- }), [i, r, s]);
2176
- }
2177
- function Gt(e, t) {
2178
- return {
2179
- ...e,
2180
- rects: {
2181
- ...e.rects,
2182
- floating: {
2183
- ...e.rects.floating,
2184
- height: t
2185
- }
2186
- }
2187
- };
2188
- }
2189
- const Hi = (e) => ({
2190
- name: "inner",
2191
- options: e,
2192
- async fn(t) {
2193
- const {
2194
- listRef: n,
2195
- overflowRef: o,
2196
- onFallbackChange: i,
2197
- offset: r = 0,
2198
- index: s = 0,
2199
- minItemsVisible: l = 4,
2200
- referenceOverflowThreshold: a = 0,
2201
- scrollRef: u,
2202
- ...c
2203
- } = $e(e, t), {
2204
- rects: d,
2205
- elements: {
2206
- floating: p
2207
- }
2208
- } = t, f = n.current[s], m = (u == null ? void 0 : u.current) || p, h = p.clientTop || m.clientTop, g = p.clientTop !== 0, v = m.clientTop !== 0, y = p === m;
2209
- if (process.env.NODE_ENV !== "production" && (t.placement.startsWith("bottom") || Mi('`placement` side must be "bottom" when using the `inner`', "middleware.")), !f)
2210
- return {};
2211
- const b = {
2212
- ...t,
2213
- ...await yn(-f.offsetTop - p.clientTop - d.reference.height / 2 - f.offsetHeight / 2 - r).fn(t)
2214
- }, E = await ct(Gt(b, m.scrollHeight + h + p.clientTop), c), O = await ct(b, {
2215
- ...c,
2216
- elementContext: "reference"
2217
- }), C = K(0, E.top), T = b.y + C, S = ze(K(0, m.scrollHeight + (g && y || v ? h * 2 : 0) - C - K(0, E.bottom)));
2218
- if (m.style.maxHeight = S + "px", m.scrollTop = C, i) {
2219
- const L = m.scrollHeight > m.offsetHeight && m.offsetHeight < f.offsetHeight * l - 1 || O.top >= -a || O.bottom >= -a;
2220
- Xe.flushSync(() => i(L));
2221
- }
2222
- return o && (o.current = await ct(Gt({
2223
- ...b,
2224
- y: T
2225
- }, m.offsetHeight + h + p.clientTop), c)), {
2226
- y: T
2227
- };
2228
- }
2229
- });
2230
- function Vi(e, t) {
2231
- const {
2232
- open: n,
2233
- elements: o
2234
- } = e, {
2235
- enabled: i = !0,
2236
- overflowRef: r,
2237
- scrollRef: s,
2238
- onChange: l
2239
- } = t, a = On(l), u = w.useRef(!1), c = w.useRef(null), d = w.useRef(null);
2240
- w.useEffect(() => {
2241
- if (!i) return;
2242
- function f(h) {
2243
- if (h.ctrlKey || !m || r.current == null)
2244
- return;
2245
- const g = h.deltaY, v = r.current.top >= -0.5, y = r.current.bottom >= -0.5, b = m.scrollHeight - m.clientHeight, E = g < 0 ? -1 : 1, O = g < 0 ? "max" : "min";
2246
- m.scrollHeight <= m.clientHeight || (!v && g > 0 || !y && g < 0 ? (h.preventDefault(), Xe.flushSync(() => {
2247
- a((C) => C + Math[O](g, b * E));
2248
- })) : /firefox/i.test(No()) && (m.scrollTop += g));
2249
- }
2250
- const m = (s == null ? void 0 : s.current) || o.floating;
2251
- if (n && m)
2252
- return m.addEventListener("wheel", f), requestAnimationFrame(() => {
2253
- c.current = m.scrollTop, r.current != null && (d.current = {
2254
- ...r.current
2255
- });
2256
- }), () => {
2257
- c.current = null, d.current = null, m.removeEventListener("wheel", f);
2258
- };
2259
- }, [i, n, o.floating, r, s, a]);
2260
- const p = w.useMemo(() => ({
2261
- onKeyDown() {
2262
- u.current = !0;
2263
- },
2264
- onWheel() {
2265
- u.current = !1;
2266
- },
2267
- onPointerMove() {
2268
- u.current = !1;
2269
- },
2270
- onScroll() {
2271
- const f = (s == null ? void 0 : s.current) || o.floating;
2272
- if (!(!r.current || !f || !u.current)) {
2273
- if (c.current !== null) {
2274
- const m = f.scrollTop - c.current;
2275
- (r.current.bottom < -0.5 && m < -1 || r.current.top < -0.5 && m > 1) && Xe.flushSync(() => a((h) => h + m));
2276
- }
2277
- requestAnimationFrame(() => {
2278
- c.current = f.scrollTop;
2279
- });
2280
- }
2281
- }
2282
- }), [o.floating, a, r, s]);
2283
- return w.useMemo(() => i ? {
2284
- floating: p
2285
- } : {}, [i, p]);
2286
- }
2287
- let Ue = he({ styles: void 0, setReference: () => {
2288
- }, setFloating: () => {
2289
- }, getReferenceProps: () => ({}), getFloatingProps: () => ({}), slot: {} });
2290
- Ue.displayName = "FloatingContext";
2291
- let Tt = he(null);
2292
- Tt.displayName = "PlacementContext";
2293
- function Bi(e) {
2294
- return X(() => e ? typeof e == "string" ? { to: e } : e : null, [e]);
2295
- }
2296
- function Wi() {
2297
- return le(Ue).setReference;
2298
- }
2299
- function ji() {
2300
- let { getFloatingProps: e, slot: t } = le(Ue);
2301
- return Ne((...n) => Object.assign({}, e(...n), { "data-anchor": t.anchor }), [e, t]);
2302
- }
2303
- function Ui(e = null) {
2304
- e === !1 && (e = null), typeof e == "string" && (e = { to: e });
2305
- let t = le(Tt), n = X(() => e, [JSON.stringify(e, (i, r) => {
2306
- var s;
2307
- return (s = r == null ? void 0 : r.outerHTML) != null ? s : r;
2308
- })]);
2309
- U(() => {
2310
- t == null || t(n ?? null);
2311
- }, [t, n]);
2312
- let o = le(Ue);
2313
- return X(() => [o.setFloating, e ? o.styles : {}], [o.setFloating, e, o.styles]);
2314
- }
2315
- let Xt = 4;
2316
- function Yi({ children: e, enabled: t = !0 }) {
2317
- let [n, o] = ce(null), [i, r] = ce(0), s = J(null), [l, a] = ce(null);
2318
- qi(l);
2319
- let u = t && n !== null && l !== null, { to: c = "bottom", gap: d = 0, offset: p = 0, padding: f = 0, inner: m } = Ki(n, l), [h, g = "center"] = c.split(" ");
2320
- U(() => {
2321
- u && r(0);
2322
- }, [u]);
2323
- let { refs: v, floatingStyles: y, context: b } = ki({ open: u, placement: h === "selection" ? g === "center" ? "bottom" : `bottom-${g}` : g === "center" ? `${h}` : `${h}-${g}`, strategy: "absolute", transform: !1, middleware: [yn({ mainAxis: h === "selection" ? 0 : d, crossAxis: p }), wi({ padding: f }), h !== "selection" && yi({ padding: f }), h === "selection" && m ? Hi({ ...m, padding: f, overflowRef: s, offset: i, minItemsVisible: Xt, referenceOverflowThreshold: f, onFallbackChange(D) {
2324
- var k, F;
2325
- if (!D) return;
2326
- let x = b.elements.floating;
2327
- if (!x) return;
2328
- let B = parseFloat(getComputedStyle(x).scrollPaddingBottom) || 0, _ = Math.min(Xt, x.childElementCount), z = 0, P = 0;
2329
- for (let $ of (F = (k = b.elements.floating) == null ? void 0 : k.childNodes) != null ? F : []) if ($ instanceof HTMLElement) {
2330
- let H = $.offsetTop, Y = H + $.clientHeight + B, ge = x.scrollTop, R = ge + x.clientHeight;
2331
- if (H >= ge && Y <= R) _--;
2332
- else {
2333
- P = Math.max(0, Math.min(Y, R) - Math.max(H, ge)), z = $.clientHeight;
2334
- break;
2335
- }
2336
- }
2337
- _ >= 1 && r(($) => {
2338
- let H = z * _ - P + B;
2339
- return $ >= H ? $ : H;
2340
- });
2341
- } }) : null, Ei({ padding: f, apply({ availableWidth: D, availableHeight: k, elements: F }) {
2342
- Object.assign(F.floating.style, { overflow: "auto", maxWidth: `${D}px`, maxHeight: `min(var(--anchor-max-height, 100vh), ${k}px)` });
2343
- } })].filter(Boolean), whileElementsMounted: mi }), [E = h, O = g] = b.placement.split("-");
2344
- h === "selection" && (E = "selection");
2345
- let C = X(() => ({ anchor: [E, O].filter(Boolean).join(" ") }), [E, O]), T = Vi(b, { overflowRef: s, onChange: r }), { getReferenceProps: S, getFloatingProps: L } = zi([T]), A = M((D) => {
2346
- a(D), v.setFloating(D);
2347
- });
2348
- return w.createElement(Tt.Provider, { value: o }, w.createElement(Ue.Provider, { value: { setFloating: A, setReference: v.setReference, styles: y, getReferenceProps: S, getFloatingProps: L, slot: C } }, e));
2349
- }
2350
- function qi(e) {
2351
- U(() => {
2352
- if (!e) return;
2353
- let t = new MutationObserver(() => {
2354
- let n = window.getComputedStyle(e).maxHeight, o = parseFloat(n);
2355
- if (isNaN(o)) return;
2356
- let i = parseInt(n);
2357
- isNaN(i) || o !== i && (e.style.maxHeight = `${Math.ceil(o)}px`);
2358
- });
2359
- return t.observe(e, { attributes: !0, attributeFilter: ["style"] }), () => {
2360
- t.disconnect();
2361
- };
2362
- }, [e]);
2363
- }
2364
- function Ki(e, t) {
2365
- var n, o, i;
2366
- let r = dt((n = e == null ? void 0 : e.gap) != null ? n : "var(--anchor-gap, 0)", t), s = dt((o = e == null ? void 0 : e.offset) != null ? o : "var(--anchor-offset, 0)", t), l = dt((i = e == null ? void 0 : e.padding) != null ? i : "var(--anchor-padding, 0)", t);
2367
- return { ...e, gap: r, offset: s, padding: l };
2368
- }
2369
- function dt(e, t, n = void 0) {
2370
- let o = Zt(), i = M((a, u) => {
2371
- if (a == null) return [n, null];
2372
- if (typeof a == "number") return [a, null];
2373
- if (typeof a == "string") {
2374
- if (!u) return [n, null];
2375
- let c = Jt(a, u);
2376
- return [c, (d) => {
2377
- let p = Sn(a);
2378
- {
2379
- let f = p.map((m) => window.getComputedStyle(u).getPropertyValue(m));
2380
- o.requestAnimationFrame(function m() {
2381
- o.nextFrame(m);
2382
- let h = !1;
2383
- for (let [v, y] of p.entries()) {
2384
- let b = window.getComputedStyle(u).getPropertyValue(y);
2385
- if (f[v] !== b) {
2386
- f[v] = b, h = !0;
2387
- break;
2388
- }
2389
- }
2390
- if (!h) return;
2391
- let g = Jt(a, u);
2392
- c !== g && (d(g), c = g);
2393
- });
2394
- }
2395
- return o.dispose;
2396
- }];
2397
- }
2398
- return [n, null];
2399
- }), r = X(() => i(e, t)[0], [e, t]), [s = r, l] = ce();
2400
- return U(() => {
2401
- let [a, u] = i(e, t);
2402
- if (l(a), !!u) return u(l);
2403
- }, [e, t]), s;
2404
- }
2405
- function Sn(e) {
2406
- let t = /var\((.*)\)/.exec(e);
2407
- if (t) {
2408
- let n = t[1].indexOf(",");
2409
- if (n === -1) return [t[1]];
2410
- let o = t[1].slice(0, n).trim(), i = t[1].slice(n + 1).trim();
2411
- return i ? [o, ...Sn(i)] : [o];
2412
- }
2413
- return [];
2414
- }
2415
- function Jt(e, t) {
2416
- let n = document.createElement("div");
2417
- t.appendChild(n), n.style.setProperty("margin-top", "0px", "important"), n.style.setProperty("margin-top", e, "important");
2418
- let o = parseFloat(window.getComputedStyle(n).marginTop) || 0;
2419
- return t.removeChild(n), o;
2420
- }
2421
- function Gi({ children: e, freeze: t }) {
2422
- let n = xt(t, e);
2423
- return j.createElement(j.Fragment, null, n);
2424
- }
2425
- function xt(e, t) {
2426
- let [n, o] = ce(t);
2427
- return !e && n !== t && o(t), e ? n : t;
2428
- }
2429
- function Xi(e) {
2430
- function t() {
2431
- document.readyState !== "loading" && (e(), document.removeEventListener("DOMContentLoaded", t));
2432
- }
2433
- typeof window < "u" && typeof document < "u" && (document.addEventListener("DOMContentLoaded", t), t());
2434
- }
2435
- let be = [];
2436
- Xi(() => {
2437
- function e(t) {
2438
- if (!(t.target instanceof HTMLElement) || t.target === document.body || be[0] === t.target) return;
2439
- let n = t.target;
2440
- n = n.closest(Gn), be.unshift(n ?? t.target), be = be.filter((o) => o != null && o.isConnected), be.splice(10);
2441
- }
2442
- window.addEventListener("click", e, { capture: !0 }), window.addEventListener("mousedown", e, { capture: !0 }), window.addEventListener("focus", e, { capture: !0 }), document.body.addEventListener("click", e, { capture: !0 }), document.body.addEventListener("mousedown", e, { capture: !0 }), document.body.addEventListener("focus", e, { capture: !0 });
2443
- });
2444
- function Ji(e) {
2445
- throw new Error("Unexpected object: " + e);
2446
- }
2447
- var V = ((e) => (e[e.First = 0] = "First", e[e.Previous = 1] = "Previous", e[e.Next = 2] = "Next", e[e.Last = 3] = "Last", e[e.Specific = 4] = "Specific", e[e.Nothing = 5] = "Nothing", e))(V || {});
2448
- function Qt(e, t) {
2449
- let n = t.resolveItems();
2450
- if (n.length <= 0) return null;
2451
- let o = t.resolveActiveIndex(), i = o ?? -1;
2452
- switch (e.focus) {
2453
- case 0: {
2454
- for (let r = 0; r < n.length; ++r) if (!t.resolveDisabled(n[r], r, n)) return r;
2455
- return o;
2456
- }
2457
- case 1: {
2458
- i === -1 && (i = n.length);
2459
- for (let r = i - 1; r >= 0; --r) if (!t.resolveDisabled(n[r], r, n)) return r;
2460
- return o;
2461
- }
2462
- case 2: {
2463
- for (let r = i + 1; r < n.length; ++r) if (!t.resolveDisabled(n[r], r, n)) return r;
2464
- return o;
2465
- }
2466
- case 3: {
2467
- for (let r = n.length - 1; r >= 0; --r) if (!t.resolveDisabled(n[r], r, n)) return r;
2468
- return o;
2469
- }
2470
- case 4: {
2471
- for (let r = 0; r < n.length; ++r) if (t.resolveId(n[r], r, n) === e.id) return r;
2472
- return o;
2473
- }
2474
- case 5:
2475
- return null;
2476
- default:
2477
- Ji(e);
2478
- }
2479
- }
2480
- var It = ((e) => (e[e.Left = 0] = "Left", e[e.Right = 2] = "Right", e))(It || {});
2481
- function Qi(e) {
2482
- let t = M(e), n = J(!1);
2483
- oe(() => (n.current = !1, () => {
2484
- n.current = !0, An(() => {
2485
- n.current && t();
2486
- });
2487
- }), [t]);
2488
- }
2489
- function Zi() {
2490
- let e = typeof document > "u";
2491
- return "useSyncExternalStore" in w ? ((t) => t.useSyncExternalStore)(w)(() => () => {
2492
- }, () => !1, () => !e) : !1;
2493
- }
2494
- function er() {
2495
- let e = Zi(), [t, n] = w.useState(Le.isHandoffComplete);
2496
- return t && Le.isHandoffComplete === !1 && n(!1), w.useEffect(() => {
2497
- t !== !0 && n(!0);
2498
- }, [t]), w.useEffect(() => Le.handoff(), []), e ? !1 : t;
2499
- }
2500
- let tr = he(!1);
2501
- function nr() {
2502
- return le(tr);
2503
- }
2504
- function or(e) {
2505
- let t = nr(), n = le(Cn), o = nt(e), [i, r] = ce(() => {
2506
- var s;
2507
- if (!t && n !== null) return (s = n.current) != null ? s : null;
2508
- if (Le.isServer) return null;
2509
- let l = o == null ? void 0 : o.getElementById("headlessui-portal-root");
2510
- if (l) return l;
2511
- if (o === null) return null;
2512
- let a = o.createElement("div");
2513
- return a.setAttribute("id", "headlessui-portal-root"), o.body.appendChild(a);
2514
- });
2515
- return oe(() => {
2516
- i !== null && (o != null && o.body.contains(i) || o == null || o.body.appendChild(i));
2517
- }, [i, o]), oe(() => {
2518
- t || n !== null && r(n.current);
2519
- }, [n, r, t]), i;
2520
- }
2521
- let Rn = tt, ir = me(function(e, t) {
2522
- let n = e, o = J(null), i = Oe($n((c) => {
2523
- o.current = c;
2524
- }), t), r = nt(o), s = or(o), [l] = ce(() => {
2525
- var c;
2526
- return Le.isServer ? null : (c = r == null ? void 0 : r.createElement("div")) != null ? c : null;
2527
- }), a = le(ar), u = er();
2528
- return U(() => {
2529
- !s || !l || s.contains(l) || (l.setAttribute("data-headlessui-portal", ""), s.appendChild(l));
2530
- }, [s, l]), U(() => {
2531
- if (l && a) return a.register(l);
2532
- }, [a, l]), Qi(() => {
2533
- var c;
2534
- !s || !l || (l instanceof Node && s.contains(l) && s.removeChild(l), s.childNodes.length <= 0 && ((c = s.parentElement) == null || c.removeChild(s)));
2535
- }), u ? !s || !l ? null : _n(pe({ ourProps: { ref: i }, theirProps: n, slot: {}, defaultTag: Rn, name: "Portal" }), l) : null;
2536
- });
2537
- function rr(e, t) {
2538
- let n = Oe(t), { enabled: o = !0, ...i } = e;
2539
- return o ? j.createElement(ir, { ...i, ref: n }) : pe({ ourProps: { ref: n }, theirProps: i, slot: {}, defaultTag: Rn, name: "Portal" });
2540
- }
2541
- let lr = tt, Cn = he(null);
2542
- function sr(e, t) {
2543
- let { target: n, ...o } = e, i = { ref: Oe(t) };
2544
- return j.createElement(Cn.Provider, { value: n }, pe({ ourProps: i, theirProps: o, defaultTag: lr, name: "Popover.Group" }));
2545
- }
2546
- let ar = he(null), cr = me(rr), ur = me(sr), fr = Object.assign(cr, { Group: ur });
2547
- var dr = ((e) => (e[e.Open = 0] = "Open", e[e.Closed = 1] = "Closed", e))(dr || {}), mr = ((e) => (e[e.Single = 0] = "Single", e[e.Multi = 1] = "Multi", e))(mr || {}), pr = ((e) => (e[e.Pointer = 0] = "Pointer", e[e.Focus = 1] = "Focus", e[e.Other = 2] = "Other", e))(pr || {}), hr = ((e) => (e[e.OpenCombobox = 0] = "OpenCombobox", e[e.CloseCombobox = 1] = "CloseCombobox", e[e.GoToOption = 2] = "GoToOption", e[e.SetTyping = 3] = "SetTyping", e[e.RegisterOption = 4] = "RegisterOption", e[e.UnregisterOption = 5] = "UnregisterOption", e[e.SetActivationTrigger = 6] = "SetActivationTrigger", e[e.UpdateVirtualConfiguration = 7] = "UpdateVirtualConfiguration", e[e.SetInputElement = 8] = "SetInputElement", e[e.SetButtonElement = 9] = "SetButtonElement", e[e.SetOptionsElement = 10] = "SetOptionsElement", e))(hr || {});
2548
- function mt(e, t = (n) => n) {
2549
- let n = e.activeOptionIndex !== null ? e.options[e.activeOptionIndex] : null, o = t(e.options.slice()), i = o.length > 0 && o[0].dataRef.current.order !== null ? o.sort((s, l) => s.dataRef.current.order - l.dataRef.current.order) : Xn(o, (s) => s.dataRef.current.domRef.current), r = n ? i.indexOf(n) : null;
2550
- return r === -1 && (r = null), { options: i, activeOptionIndex: r };
2551
- }
2552
- let gr = { 1(e) {
2553
- var t;
2554
- return (t = e.dataRef.current) != null && t.disabled || e.comboboxState === 1 ? e : { ...e, activeOptionIndex: null, comboboxState: 1, isTyping: !1, activationTrigger: 2, __demoMode: !1 };
2555
- }, 0(e) {
2556
- var t, n;
2557
- if ((t = e.dataRef.current) != null && t.disabled || e.comboboxState === 0) return e;
2558
- if ((n = e.dataRef.current) != null && n.value) {
2559
- let o = e.dataRef.current.calculateIndex(e.dataRef.current.value);
2560
- if (o !== -1) return { ...e, activeOptionIndex: o, comboboxState: 0, __demoMode: !1 };
2561
- }
2562
- return { ...e, comboboxState: 0, __demoMode: !1 };
2563
- }, 3(e, t) {
2564
- return e.isTyping === t.isTyping ? e : { ...e, isTyping: t.isTyping };
2565
- }, 2(e, t) {
2566
- var n, o, i, r;
2567
- if ((n = e.dataRef.current) != null && n.disabled || e.optionsElement && !((o = e.dataRef.current) != null && o.optionsPropsRef.current.static) && e.comboboxState === 1) return e;
2568
- if (e.virtual) {
2569
- let { options: u, disabled: c } = e.virtual, d = t.focus === V.Specific ? t.idx : Qt(t, { resolveItems: () => u, resolveActiveIndex: () => {
2570
- var f, m;
2571
- return (m = (f = e.activeOptionIndex) != null ? f : u.findIndex((h) => !c(h))) != null ? m : null;
2572
- }, resolveDisabled: c, resolveId() {
2573
- throw new Error("Function not implemented.");
2574
- } }), p = (i = t.trigger) != null ? i : 2;
2575
- return e.activeOptionIndex === d && e.activationTrigger === p ? e : { ...e, activeOptionIndex: d, activationTrigger: p, isTyping: !1, __demoMode: !1 };
2576
- }
2577
- let s = mt(e);
2578
- if (s.activeOptionIndex === null) {
2579
- let u = s.options.findIndex((c) => !c.dataRef.current.disabled);
2580
- u !== -1 && (s.activeOptionIndex = u);
2581
- }
2582
- let l = t.focus === V.Specific ? t.idx : Qt(t, { resolveItems: () => s.options, resolveActiveIndex: () => s.activeOptionIndex, resolveId: (u) => u.id, resolveDisabled: (u) => u.dataRef.current.disabled }), a = (r = t.trigger) != null ? r : 2;
2583
- return e.activeOptionIndex === l && e.activationTrigger === a ? e : { ...e, ...s, isTyping: !1, activeOptionIndex: l, activationTrigger: a, __demoMode: !1 };
2584
- }, 4: (e, t) => {
2585
- var n, o, i;
2586
- if ((n = e.dataRef.current) != null && n.virtual) return { ...e, options: [...e.options, t.payload] };
2587
- let r = t.payload, s = mt(e, (a) => (a.push(r), a));
2588
- e.activeOptionIndex === null && (o = e.dataRef.current) != null && o.isSelected(t.payload.dataRef.current.value) && (s.activeOptionIndex = s.options.indexOf(r));
2589
- let l = { ...e, ...s, activationTrigger: 2 };
2590
- return (i = e.dataRef.current) != null && i.__demoMode && e.dataRef.current.value === void 0 && (l.activeOptionIndex = 0), l;
2591
- }, 5: (e, t) => {
2592
- var n;
2593
- if ((n = e.dataRef.current) != null && n.virtual) return { ...e, options: e.options.filter((i) => i.id !== t.id) };
2594
- let o = mt(e, (i) => {
2595
- let r = i.findIndex((s) => s.id === t.id);
2596
- return r !== -1 && i.splice(r, 1), i;
2597
- });
2598
- return { ...e, ...o, activationTrigger: 2 };
2599
- }, 6: (e, t) => e.activationTrigger === t.trigger ? e : { ...e, activationTrigger: t.trigger }, 7: (e, t) => {
2600
- var n, o;
2601
- if (e.virtual === null) return { ...e, virtual: { options: t.options, disabled: (n = t.disabled) != null ? n : () => !1 } };
2602
- if (e.virtual.options === t.options && e.virtual.disabled === t.disabled) return e;
2603
- let i = e.activeOptionIndex;
2604
- if (e.activeOptionIndex !== null) {
2605
- let r = t.options.indexOf(e.virtual.options[e.activeOptionIndex]);
2606
- r !== -1 ? i = r : i = null;
2607
- }
2608
- return { ...e, activeOptionIndex: i, virtual: { options: t.options, disabled: (o = t.disabled) != null ? o : () => !1 } };
2609
- }, 8: (e, t) => e.inputElement === t.element ? e : { ...e, inputElement: t.element }, 9: (e, t) => e.buttonElement === t.element ? e : { ...e, buttonElement: t.element }, 10: (e, t) => e.optionsElement === t.element ? e : { ...e, optionsElement: t.element } }, Mt = he(null);
2610
- Mt.displayName = "ComboboxActionsContext";
2611
- function Ye(e) {
2612
- let t = le(Mt);
2613
- if (t === null) {
2614
- let n = new Error(`<${e} /> is missing a parent <Combobox /> component.`);
2615
- throw Error.captureStackTrace && Error.captureStackTrace(n, Ye), n;
2616
- }
2617
- return t;
2618
- }
2619
- let Tn = he(null);
2620
- function vr(e) {
2621
- let t = De("VirtualProvider"), { options: n } = t.virtual, [o, i] = X(() => {
2622
- let u = t.optionsElement;
2623
- if (!u) return [0, 0];
2624
- let c = window.getComputedStyle(u);
2625
- return [parseFloat(c.paddingBlockStart || c.paddingTop), parseFloat(c.paddingBlockEnd || c.paddingBottom)];
2626
- }, [t.optionsElement]), r = vo({ enabled: n.length !== 0, scrollPaddingStart: o, scrollPaddingEnd: i, count: n.length, estimateSize() {
2627
- return 40;
2628
- }, getScrollElement() {
2629
- return t.optionsElement;
2630
- }, overscan: 12 }), [s, l] = ce(0);
2631
- U(() => {
2632
- l((u) => u + 1);
2633
- }, [n]);
2634
- let a = r.getVirtualItems();
2635
- return a.length === 0 ? null : j.createElement(Tn.Provider, { value: r }, j.createElement("div", { style: { position: "relative", width: "100%", height: `${r.getTotalSize()}px` }, ref: (u) => {
2636
- u && t.activationTrigger !== 0 && t.activeOptionIndex !== null && n.length > t.activeOptionIndex && r.scrollToIndex(t.activeOptionIndex);
2637
- } }, a.map((u) => {
2638
- var c;
2639
- return j.createElement(tt, { key: u.key }, j.cloneElement((c = e.children) == null ? void 0 : c.call(e, { ...e.slot, option: n[u.index] }), { key: `${s}-${u.key}`, "data-index": u.index, "aria-setsize": n.length, "aria-posinset": u.index + 1, style: { position: "absolute", top: 0, left: 0, transform: `translateY(${u.start}px)`, overflowAnchor: "none" } }));
2640
- })));
2641
- }
2642
- let Ve = he(null);
2643
- Ve.displayName = "ComboboxDataContext";
2644
- function De(e) {
2645
- let t = le(Ve);
2646
- if (t === null) {
2647
- let n = new Error(`<${e} /> is missing a parent <Combobox /> component.`);
2648
- throw Error.captureStackTrace && Error.captureStackTrace(n, De), n;
2649
- }
2650
- return t;
2651
- }
2652
- function br(e, t) {
2653
- return Re(t.type, gr, e, t);
2654
- }
2655
- let xr = tt;
2656
- function wr(e, t) {
2657
- var n, o;
2658
- let i = Hn(), { value: r, defaultValue: s, onChange: l, form: a, name: u, by: c, disabled: d = i || !1, onClose: p, __demoMode: f = !1, multiple: m = !1, immediate: h = !1, virtual: g = null, nullable: v, ...y } = e, b = Vn(s), [E = m ? [] : void 0, O] = Bn(r, l, b), [C, T] = nn(br, { dataRef: Ln(), comboboxState: f ? 0 : 1, isTyping: !1, options: [], virtual: g ? { options: g.options, disabled: (n = g.disabled) != null ? n : () => !1 } : null, activeOptionIndex: null, activationTrigger: 2, inputElement: null, buttonElement: null, optionsElement: null, __demoMode: f }), S = J(!1), L = J({ static: !1, hold: !1 }), A = kn(c), D = M((I) => g ? c === null ? g.options.indexOf(I) : g.options.findIndex((N) => A(N, I)) : C.options.findIndex((N) => A(N.dataRef.current.value, I))), k = Ne((I) => Re(x.mode, { 1: () => E.some((N) => A(N, I)), 0: () => A(E, I) }), [E]), F = M((I) => C.activeOptionIndex === D(I)), x = X(() => ({ ...C, immediate: h, optionsPropsRef: L, value: E, defaultValue: b, disabled: d, mode: m ? 1 : 0, virtual: g ? C.virtual : null, get activeOptionIndex() {
2659
- if (S.current && C.activeOptionIndex === null && (g ? g.options.length > 0 : C.options.length > 0)) {
2660
- if (g) {
2661
- let N = g.options.findIndex((re) => {
2662
- var qe, Pt;
2663
- return !((Pt = (qe = g.disabled) == null ? void 0 : qe.call(g, re)) != null && Pt);
2664
- });
2665
- if (N !== -1) return N;
2666
- }
2667
- let I = C.options.findIndex((N) => !N.dataRef.current.disabled);
2668
- if (I !== -1) return I;
2669
- }
2670
- return C.activeOptionIndex;
2671
- }, calculateIndex: D, compare: A, isSelected: k, isActive: F }), [E, b, d, m, f, C, g]);
2672
- U(() => {
2673
- var I;
2674
- g && T({ type: 7, options: g.options, disabled: (I = g.disabled) != null ? I : null });
2675
- }, [g, g == null ? void 0 : g.options, g == null ? void 0 : g.disabled]), U(() => {
2676
- C.dataRef.current = x;
2677
- }, [x]);
2678
- let B = x.comboboxState === 0;
2679
- Ro(B, [x.buttonElement, x.inputElement, x.optionsElement], () => Q.closeCombobox());
2680
- let _ = X(() => {
2681
- var I, N, re;
2682
- return { open: x.comboboxState === 0, disabled: d, activeIndex: x.activeOptionIndex, activeOption: x.activeOptionIndex === null ? null : x.virtual ? x.virtual.options[(I = x.activeOptionIndex) != null ? I : 0] : (re = (N = x.options[x.activeOptionIndex]) == null ? void 0 : N.dataRef.current.value) != null ? re : null, value: E };
2683
- }, [x, d, E]), z = M(() => {
2684
- if (x.activeOptionIndex !== null) {
2685
- if (Q.setIsTyping(!1), x.virtual) R(x.virtual.options[x.activeOptionIndex]);
2686
- else {
2687
- let { dataRef: I } = x.options[x.activeOptionIndex];
2688
- R(I.current.value);
2689
- }
2690
- Q.goToOption(V.Specific, x.activeOptionIndex);
2691
- }
2692
- }), P = M(() => {
2693
- T({ type: 0 }), S.current = !0;
2694
- }), $ = M(() => {
2695
- T({ type: 1 }), S.current = !1, p == null || p();
2696
- }), H = M((I) => {
2697
- T({ type: 3, isTyping: I });
2698
- }), Y = M((I, N, re) => (S.current = !1, I === V.Specific ? T({ type: 2, focus: V.Specific, idx: N, trigger: re }) : T({ type: 2, focus: I, trigger: re }))), ge = M((I, N) => (T({ type: 4, payload: { id: I, dataRef: N } }), () => {
2699
- x.isActive(N.current.value) && (S.current = !0), T({ type: 5, id: I });
2700
- })), R = M((I) => Re(x.mode, { 0() {
2701
- return O == null ? void 0 : O(I);
2702
- }, 1() {
2703
- let N = x.value.slice(), re = N.findIndex((qe) => A(qe, I));
2704
- return re === -1 ? N.push(I) : N.splice(re, 1), O == null ? void 0 : O(N);
2705
- } })), te = M((I) => {
2706
- T({ type: 6, trigger: I });
2707
- }), q = M((I) => {
2708
- T({ type: 8, element: I });
2709
- }), ne = M((I) => {
2710
- T({ type: 9, element: I });
2711
- }), W = M((I) => {
2712
- T({ type: 10, element: I });
2713
- }), Q = X(() => ({ onChange: R, registerOption: ge, goToOption: Y, setIsTyping: H, closeCombobox: $, openCombobox: P, setActivationTrigger: te, selectActiveOption: z, setInputElement: q, setButtonElement: ne, setOptionsElement: W }), []), [ve, In] = Wn(), Mn = t === null ? {} : { ref: t }, Pn = Ne(() => {
2714
- if (b !== void 0) return O == null ? void 0 : O(b);
2715
- }, [O, b]);
2716
- return j.createElement(In, { value: ve, props: { htmlFor: (o = x.inputElement) == null ? void 0 : o.id }, slot: { open: x.comboboxState === 0, disabled: d } }, j.createElement(Yi, null, j.createElement(Mt.Provider, { value: Q }, j.createElement(Ve.Provider, { value: x }, j.createElement(Qn, { value: Re(x.comboboxState, { 0: Je.Open, 1: Je.Closed }) }, u != null && j.createElement(jn, { disabled: d, data: E != null ? { [u]: E } : {}, form: a, onReset: Pn }), pe({ ourProps: Mn, theirProps: y, slot: _, defaultTag: xr, name: "Combobox" }))))));
2717
- }
2718
- let yr = "input";
2719
- function Er(e, t) {
2720
- var n, o, i, r, s;
2721
- let l = De("Combobox.Input"), a = Ye("Combobox.Input"), u = Be(), c = Un(), { id: d = c || `headlessui-combobox-input-${u}`, onChange: p, displayValue: f, disabled: m = l.disabled || !1, autoFocus: h = !1, type: g = "text", ...v } = e, y = J(null), b = Oe(y, t, Wi(), a.setInputElement), E = nt(l.inputElement), O = Zt(), C = M(() => {
2722
- a.onChange(null), l.optionsElement && (l.optionsElement.scrollTop = 0), a.goToOption(V.Nothing);
2723
- }), T = X(() => {
2724
- var R;
2725
- return typeof f == "function" && l.value !== void 0 ? (R = f(l.value)) != null ? R : "" : typeof l.value == "string" ? l.value : "";
2726
- }, [l.value, f]);
2727
- kt(([R, te], [q, ne]) => {
2728
- if (l.isTyping) return;
2729
- let W = y.current;
2730
- W && ((ne === 0 && te === 1 || R !== q) && (W.value = R), requestAnimationFrame(() => {
2731
- if (l.isTyping || !W || (E == null ? void 0 : E.activeElement) !== W) return;
2732
- let { selectionStart: Q, selectionEnd: ve } = W;
2733
- Math.abs((ve ?? 0) - (Q ?? 0)) === 0 && Q === 0 && W.setSelectionRange(W.value.length, W.value.length);
2734
- }));
2735
- }, [T, l.comboboxState, E, l.isTyping]), kt(([R], [te]) => {
2736
- if (R === 0 && te === 1) {
2737
- if (l.isTyping) return;
2738
- let q = y.current;
2739
- if (!q) return;
2740
- let ne = q.value, { selectionStart: W, selectionEnd: Q, selectionDirection: ve } = q;
2741
- q.value = "", q.value = ne, ve !== null ? q.setSelectionRange(W, Q, ve) : q.setSelectionRange(W, Q);
2742
- }
2743
- }, [l.comboboxState]);
2744
- let S = J(!1), L = M(() => {
2745
- S.current = !0;
2746
- }), A = M(() => {
2747
- O.nextFrame(() => {
2748
- S.current = !1;
2749
- });
2750
- }), D = M((R) => {
2751
- switch (a.setIsTyping(!0), R.key) {
2752
- case Z.Enter:
2753
- if (l.comboboxState !== 0 || S.current) return;
2754
- if (R.preventDefault(), R.stopPropagation(), l.activeOptionIndex === null) {
2755
- a.closeCombobox();
2756
- return;
2757
- }
2758
- a.selectActiveOption(), l.mode === 0 && a.closeCombobox();
2759
- break;
2760
- case Z.ArrowDown:
2761
- return R.preventDefault(), R.stopPropagation(), Re(l.comboboxState, { 0: () => a.goToOption(V.Next), 1: () => a.openCombobox() });
2762
- case Z.ArrowUp:
2763
- return R.preventDefault(), R.stopPropagation(), Re(l.comboboxState, { 0: () => a.goToOption(V.Previous), 1: () => {
2764
- xe(() => a.openCombobox()), l.value || a.goToOption(V.Last);
2765
- } });
2766
- case Z.Home:
2767
- if (R.shiftKey) break;
2768
- return R.preventDefault(), R.stopPropagation(), a.goToOption(V.First);
2769
- case Z.PageUp:
2770
- return R.preventDefault(), R.stopPropagation(), a.goToOption(V.First);
2771
- case Z.End:
2772
- if (R.shiftKey) break;
2773
- return R.preventDefault(), R.stopPropagation(), a.goToOption(V.Last);
2774
- case Z.PageDown:
2775
- return R.preventDefault(), R.stopPropagation(), a.goToOption(V.Last);
2776
- case Z.Escape:
2777
- return l.comboboxState !== 0 ? void 0 : (R.preventDefault(), l.optionsElement && !l.optionsPropsRef.current.static && R.stopPropagation(), l.mode === 0 && l.value === null && C(), a.closeCombobox());
2778
- case Z.Tab:
2779
- if (l.comboboxState !== 0) return;
2780
- l.mode === 0 && l.activationTrigger !== 1 && a.selectActiveOption(), a.closeCombobox();
2781
- break;
2782
- }
2783
- }), k = M((R) => {
2784
- p == null || p(R), l.mode === 0 && R.target.value === "" && C(), a.openCombobox();
2785
- }), F = M((R) => {
2786
- var te, q, ne;
2787
- let W = (te = R.relatedTarget) != null ? te : be.find((Q) => Q !== R.currentTarget);
2788
- if (!((q = l.optionsElement) != null && q.contains(W)) && !((ne = l.buttonElement) != null && ne.contains(W)) && l.comboboxState === 0) return R.preventDefault(), l.mode === 0 && l.value === null && C(), a.closeCombobox();
2789
- }), x = M((R) => {
2790
- var te, q, ne;
2791
- let W = (te = R.relatedTarget) != null ? te : be.find((Q) => Q !== R.currentTarget);
2792
- (q = l.buttonElement) != null && q.contains(W) || (ne = l.optionsElement) != null && ne.contains(W) || l.disabled || l.immediate && l.comboboxState !== 0 && O.microTask(() => {
2793
- xe(() => a.openCombobox()), a.setActivationTrigger(1);
2794
- });
2795
- }), B = Et(), _ = Yn(), { isFocused: z, focusProps: P } = en({ autoFocus: h }), { isHovered: $, hoverProps: H } = tn({ isDisabled: m }), Y = X(() => ({ open: l.comboboxState === 0, disabled: m, hover: $, focus: z, autofocus: h }), [l, $, z, h, m]), ge = yt({ ref: b, id: d, role: "combobox", type: g, "aria-controls": (n = l.optionsElement) == null ? void 0 : n.id, "aria-expanded": l.comboboxState === 0, "aria-activedescendant": l.activeOptionIndex === null ? void 0 : l.virtual ? (o = l.options.find((R) => !R.dataRef.current.disabled && l.compare(R.dataRef.current.value, l.virtual.options[l.activeOptionIndex]))) == null ? void 0 : o.id : (i = l.options[l.activeOptionIndex]) == null ? void 0 : i.id, "aria-labelledby": B, "aria-describedby": _, "aria-autocomplete": "list", defaultValue: (s = (r = e.defaultValue) != null ? r : l.defaultValue !== void 0 ? f == null ? void 0 : f(l.defaultValue) : null) != null ? s : l.defaultValue, disabled: m || void 0, autoFocus: h, onCompositionStart: L, onCompositionEnd: A, onKeyDown: D, onChange: k, onFocus: x, onBlur: F }, P, H);
2796
- return pe({ ourProps: ge, theirProps: v, slot: Y, defaultTag: yr, name: "Combobox.Input" });
2797
- }
2798
- let Or = "button";
2799
- function Sr(e, t) {
2800
- var n;
2801
- let o = De("Combobox.Button"), i = Ye("Combobox.Button"), r = Oe(t, i.setButtonElement), s = Dn(), l = Be(), { id: a = `headlessui-combobox-button-${l}`, disabled: u = o.disabled || !1, autoFocus: c = !1, ...d } = e, p = un(o.inputElement), f = M((S) => {
2802
- switch (S.key) {
2803
- case Z.Space:
2804
- case Z.Enter:
2805
- S.preventDefault(), S.stopPropagation(), o.comboboxState === 1 && xe(() => i.openCombobox()), p();
2806
- return;
2807
- case Z.ArrowDown:
2808
- S.preventDefault(), S.stopPropagation(), o.comboboxState === 1 && (xe(() => i.openCombobox()), o.value || i.goToOption(V.First)), p();
2809
- return;
2810
- case Z.ArrowUp:
2811
- S.preventDefault(), S.stopPropagation(), o.comboboxState === 1 && (xe(() => i.openCombobox()), o.value || i.goToOption(V.Last)), p();
2812
- return;
2813
- case Z.Escape:
2814
- if (o.comboboxState !== 0) return;
2815
- S.preventDefault(), o.optionsElement && !o.optionsPropsRef.current.static && S.stopPropagation(), xe(() => i.closeCombobox()), p();
2816
- return;
2817
- default:
2818
- return;
2819
- }
2820
- }), m = M((S) => {
2821
- S.preventDefault(), !no(S.currentTarget) && (S.button === It.Left && (o.comboboxState === 0 ? i.closeCombobox() : i.openCombobox()), p());
2822
- }), h = Et([a]), { isFocusVisible: g, focusProps: v } = en({ autoFocus: c }), { isHovered: y, hoverProps: b } = tn({ isDisabled: u }), { pressed: E, pressProps: O } = Nn({ disabled: u }), C = X(() => ({ open: o.comboboxState === 0, active: E || o.comboboxState === 0, disabled: u, value: o.value, hover: y, focus: g }), [o, y, g, E, u]), T = yt({ ref: r, id: a, type: Jn(e, o.buttonElement), tabIndex: -1, "aria-haspopup": "listbox", "aria-controls": (n = o.optionsElement) == null ? void 0 : n.id, "aria-expanded": o.comboboxState === 0, "aria-labelledby": h, disabled: u || void 0, autoFocus: c, onMouseDown: m, onKeyDown: f }, v, b, O);
2823
- return pe({ mergeRefs: s, ourProps: T, theirProps: d, slot: C, defaultTag: Or, name: "Combobox.Button" });
2824
- }
2825
- let Rr = "div", Cr = At.RenderStrategy | At.Static;
2826
- function Tr(e, t) {
2827
- var n, o, i;
2828
- let r = Be(), { id: s = `headlessui-combobox-options-${r}`, hold: l = !1, anchor: a, portal: u = !1, modal: c = !0, transition: d = !1, ...p } = e, f = De("Combobox.Options"), m = Ye("Combobox.Options"), h = Bi(a);
2829
- h && (u = !0);
2830
- let [g, v] = Ui(h), [y, b] = ce(null), E = ji(), O = Oe(t, h ? g : null, m.setOptionsElement, b), C = nt(f.optionsElement), T = Zn(), [S, L] = eo(d, y, T !== null ? (T & Je.Open) === Je.Open : f.comboboxState === 0);
2831
- Eo(S, f.inputElement, m.closeCombobox);
2832
- let A = f.__demoMode ? !1 : c && f.comboboxState === 0;
2833
- $o(A, C);
2834
- let D = f.__demoMode ? !1 : c && f.comboboxState === 0;
2835
- yo(D, { allowed: Ne(() => [f.inputElement, f.buttonElement, f.optionsElement], [f.inputElement, f.buttonElement, f.optionsElement]) }), U(() => {
2836
- var Y;
2837
- f.optionsPropsRef.current.static = (Y = e.static) != null ? Y : !1;
2838
- }, [f.optionsPropsRef, e.static]), U(() => {
2839
- f.optionsPropsRef.current.hold = l;
2840
- }, [f.optionsPropsRef, l]), Fo(f.comboboxState === 0, { container: f.optionsElement, accept(Y) {
2841
- return Y.getAttribute("role") === "option" ? NodeFilter.FILTER_REJECT : Y.hasAttribute("role") ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
2842
- }, walk(Y) {
2843
- Y.setAttribute("role", "none");
2844
- } });
2845
- let k = Et([(n = f.buttonElement) == null ? void 0 : n.id]), F = X(() => ({ open: f.comboboxState === 0, option: void 0 }), [f.comboboxState]), x = M(() => {
2846
- m.setActivationTrigger(0);
2847
- }), B = M((Y) => {
2848
- Y.preventDefault(), m.setActivationTrigger(0);
2849
- }), _ = yt(h ? E() : {}, { "aria-labelledby": k, role: "listbox", "aria-multiselectable": f.mode === 1 ? !0 : void 0, id: s, ref: O, style: { ...p.style, ...v, "--input-width": Dt(f.inputElement, !0).width, "--button-width": Dt(f.buttonElement, !0).width }, onWheel: f.activationTrigger === 0 ? void 0 : x, onMouseDown: B, ...to(L) }), z = S && f.comboboxState === 1, P = xt(z, (o = f.virtual) == null ? void 0 : o.options), $ = xt(z, f.value), H = M((Y) => f.compare($, Y));
2850
- if (f.virtual) {
2851
- if (P === void 0) throw new Error("Missing `options` in virtual mode");
2852
- Object.assign(p, { children: j.createElement(Ve.Provider, { value: P !== f.virtual.options ? { ...f, virtual: { ...f.virtual, options: P } } : f }, j.createElement(vr, { slot: F }, p.children)) });
2853
- }
2854
- return j.createElement(fr, { enabled: u ? e.static || S : !1 }, j.createElement(Ve.Provider, { value: f.mode === 1 ? f : { ...f, isSelected: H } }, pe({ ourProps: _, theirProps: { ...p, children: j.createElement(Gi, { freeze: z }, typeof p.children == "function" ? (i = p.children) == null ? void 0 : i.call(p, F) : p.children) }, slot: F, defaultTag: Rr, features: Cr, visible: S, name: "Combobox.Options" })));
2855
- }
2856
- let Ir = "div";
2857
- function Mr(e, t) {
2858
- var n, o, i, r;
2859
- let s = De("Combobox.Option"), l = Ye("Combobox.Option"), a = Be(), { id: u = `headlessui-combobox-option-${a}`, value: c, disabled: d = (i = (o = (n = s.virtual) == null ? void 0 : n.disabled) == null ? void 0 : o.call(n, c)) != null ? i : !1, order: p = null, ...f } = e, m = un(s.inputElement), h = s.virtual ? s.activeOptionIndex === s.calculateIndex(c) : s.activeOptionIndex === null ? !1 : ((r = s.options[s.activeOptionIndex]) == null ? void 0 : r.id) === u, g = s.isSelected(c), v = J(null), y = Pe({ disabled: d, value: c, domRef: v, order: p }), b = le(Tn), E = Oe(t, v, b ? b.measureElement : null), O = M(() => {
2860
- l.setIsTyping(!1), l.onChange(c);
2861
- });
2862
- U(() => l.registerOption(u, y), [y, u]);
2863
- let C = J(!(s.virtual || s.__demoMode));
2864
- U(() => {
2865
- if (!s.virtual && !s.__demoMode) return Te().requestAnimationFrame(() => {
2866
- C.current = !0;
2867
- });
2868
- }, [s.virtual, s.__demoMode]), U(() => {
2869
- if (C.current && s.comboboxState === 0 && h && s.activationTrigger !== 0) return Te().requestAnimationFrame(() => {
2870
- var x, B;
2871
- (B = (x = v.current) == null ? void 0 : x.scrollIntoView) == null || B.call(x, { block: "nearest" });
2872
- });
2873
- }, [v, h, s.comboboxState, s.activationTrigger, s.activeOptionIndex]);
2874
- let T = M((x) => {
2875
- x.preventDefault(), x.button === It.Left && (d || (O(), cn() || requestAnimationFrame(() => m()), s.mode === 0 && l.closeCombobox()));
2876
- }), S = M(() => {
2877
- if (d) return l.goToOption(V.Nothing);
2878
- let x = s.calculateIndex(c);
2879
- l.goToOption(V.Specific, x);
2880
- }), L = Do(), A = M((x) => L.update(x)), D = M((x) => {
2881
- if (!L.wasMoved(x) || d || h) return;
2882
- let B = s.calculateIndex(c);
2883
- l.goToOption(V.Specific, B, 0);
2884
- }), k = M((x) => {
2885
- L.wasMoved(x) && (d || h && (s.optionsPropsRef.current.hold || l.goToOption(V.Nothing)));
2886
- }), F = X(() => ({ active: h, focus: h, selected: g, disabled: d }), [h, g, d]);
2887
- return pe({ ourProps: { id: u, ref: E, role: "option", tabIndex: d === !0 ? void 0 : -1, "aria-disabled": d === !0 ? !0 : void 0, "aria-selected": g, disabled: void 0, onMouseDown: T, onFocus: S, onPointerEnter: A, onMouseEnter: A, onPointerMove: D, onMouseMove: D, onPointerLeave: k, onMouseLeave: k }, theirProps: f, slot: F, defaultTag: Ir, name: "Combobox.Option" });
2888
- }
2889
- let Pr = me(wr), Ar = me(Sr), $r = me(Er), Dr = zn, Fr = me(Tr), Lr = me(Mr), qr = Object.assign(Pr, { Input: $r, Button: Ar, Label: Dr, Options: Fr, Option: Lr });
2890
- export {
2891
- $r as G,
2892
- qr as H,
2893
- Fr as K,
2894
- Ar as U,
2895
- Lr as j
2896
- };