@arc-ui/components 11.14.0 → 11.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/Breadcrumbs/Breadcrumbs.cjs.js +1 -1
  2. package/dist/Breadcrumbs/Breadcrumbs.esm.js +1 -1
  3. package/dist/Checkbox/Checkbox.cjs.js +2 -2
  4. package/dist/Checkbox/Checkbox.esm.js +2 -2
  5. package/dist/FormControl/FormControl.cjs.js +1 -1
  6. package/dist/FormControl/FormControl.esm.js +1 -1
  7. package/dist/InformationCard/InformationCard.cjs.js +25 -43
  8. package/dist/InformationCard/InformationCard.esm.js +24 -42
  9. package/dist/Modal/Modal.cjs.js +16 -40
  10. package/dist/Modal/Modal.esm.js +6 -30
  11. package/dist/PaginationSimple/PaginationSimple.cjs.js +19 -16
  12. package/dist/PaginationSimple/PaginationSimple.esm.js +19 -16
  13. package/dist/RadioGroup/RadioGroup.cjs.js +2 -2
  14. package/dist/RadioGroup/RadioGroup.esm.js +2 -2
  15. package/dist/Select/Select.cjs.js +2736 -619
  16. package/dist/Select/Select.esm.js +2535 -418
  17. package/dist/Switch/Switch.cjs.js +335 -11
  18. package/dist/Switch/Switch.esm.js +328 -4
  19. package/dist/Tabs/Tabs.cjs.js +7 -4
  20. package/dist/Tabs/Tabs.esm.js +7 -4
  21. package/dist/TextArea/TextArea.cjs.js +17 -12
  22. package/dist/TextArea/TextArea.esm.js +17 -12
  23. package/dist/TextInput/TextInput.cjs.js +2 -2
  24. package/dist/TextInput/TextInput.esm.js +2 -2
  25. package/dist/Toast/Toast.cjs.js +7 -4
  26. package/dist/Toast/Toast.esm.js +7 -4
  27. package/dist/TypographyCard/TypographyCard.cjs.js +93 -0
  28. package/dist/TypographyCard/TypographyCard.esm.js +85 -0
  29. package/dist/TypographyCard/package.json +7 -0
  30. package/dist/UniversalHeader/UniversalHeader.cjs.js +1 -1
  31. package/dist/UniversalHeader/UniversalHeader.esm.js +1 -1
  32. package/dist/_shared/cjs/{Breadcrumbs-ed70e75a.js → Breadcrumbs-ef659d2b.js} +5 -5
  33. package/dist/_shared/cjs/BtIconArrowRight.esm-8e8ac316.js +30 -0
  34. package/dist/_shared/cjs/BtIconArrowRightFill.esm-435cf4bd.js +26 -0
  35. package/dist/_shared/cjs/{Checkbox-b126194e.js → Checkbox-904ad028.js} +1 -1
  36. package/dist/_shared/cjs/{FormControl-7daf8110.js → FormControl-166e0957.js} +5 -1
  37. package/dist/_shared/cjs/{RadioGroup-56e3b0e5.js → RadioGroup-1eddf86f.js} +1 -1
  38. package/dist/_shared/cjs/{Tabs-2d2a517d.js → Tabs-cc77dabb.js} +17 -37
  39. package/dist/_shared/cjs/{TextInput-bf1fe052.js → TextInput-fd9c756f.js} +10 -4
  40. package/dist/_shared/cjs/{Toast-69108261.js → Toast-91e96744.js} +36 -54
  41. package/dist/_shared/cjs/{UniversalHeader-5e43d320.js → UniversalHeader-b8389447.js} +4 -2
  42. package/dist/_shared/cjs/index-1641d0b4.js +27 -0
  43. package/dist/_shared/cjs/{index-43458549.js → index-3d69ea00.js} +28 -1
  44. package/dist/_shared/cjs/index-49c72a87.js +131 -0
  45. package/dist/_shared/cjs/{index-6b2a9ac3.js → index-4ecad2dd.js} +6 -22
  46. package/dist/_shared/cjs/{index.module-dd1d7d0b.js → index-56a040f4.js} +87 -104
  47. package/dist/_shared/cjs/index-6542b467.js +23 -0
  48. package/dist/_shared/cjs/{index-adbb63da.js → index-84e6a68f.js} +1 -1
  49. package/dist/_shared/cjs/{index-b2fd6338.js → index-d31f2b65.js} +1 -1
  50. package/dist/_shared/cjs/index-dcfdd5da.js +11 -0
  51. package/dist/_shared/esm/{Breadcrumbs-87e2bd46.js → Breadcrumbs-36edfb3d.js} +5 -5
  52. package/dist/_shared/esm/BtIconArrowRight.esm-267916a4.js +24 -0
  53. package/dist/_shared/esm/BtIconArrowRightFill.esm-99019d1a.js +20 -0
  54. package/dist/_shared/esm/{Checkbox-d6ec5024.js → Checkbox-8a5bb9a1.js} +1 -1
  55. package/dist/_shared/esm/{FormControl-351e5f1b.js → FormControl-9d4ddfec.js} +5 -1
  56. package/dist/_shared/esm/{RadioGroup-c838764c.js → RadioGroup-238db88d.js} +1 -1
  57. package/dist/_shared/esm/{Tabs-f903187a.js → Tabs-8719d952.js} +7 -27
  58. package/dist/_shared/esm/{TextInput-991804b6.js → TextInput-c1e2a1dd.js} +10 -4
  59. package/dist/_shared/esm/{Toast-37549e68.js → Toast-7cb1e544.js} +6 -24
  60. package/dist/_shared/esm/{UniversalHeader-b4c1577c.js → UniversalHeader-80c7313f.js} +4 -2
  61. package/dist/_shared/esm/{index.module-44714d3f.js → index-12f3a407.js} +89 -105
  62. package/dist/_shared/esm/index-246b4f18.js +21 -0
  63. package/dist/_shared/esm/{index-a1d2d9b3.js → index-39019a9b.js} +1 -1
  64. package/dist/_shared/esm/{index-41d7af2b.js → index-3e2bc99d.js} +29 -3
  65. package/dist/_shared/esm/index-6b7b075c.js +25 -0
  66. package/dist/_shared/esm/{index-efd9ef1c.js → index-936b5179.js} +1 -1
  67. package/dist/_shared/esm/index-a624de47.js +9 -0
  68. package/dist/_shared/esm/{index-3797d77e.js → index-d0307140.js} +5 -21
  69. package/dist/_shared/esm/index-db47e95a.js +129 -0
  70. package/dist/index.es.js +3062 -865
  71. package/dist/index.es.js.map +1 -1
  72. package/dist/index.js +3062 -864
  73. package/dist/index.js.map +1 -1
  74. package/dist/styles.css +5 -5
  75. package/dist/types/components/MediaCard/MediaCard.d.ts +24 -30
  76. package/dist/types/components/Select/Select.d.ts +49 -0
  77. package/dist/types/components/TextInput/TextInput.d.ts +12 -1
  78. package/dist/types/components/TypographyCard/TypographyCard.d.ts +48 -0
  79. package/dist/types/components/TypographyCard/index.d.ts +1 -0
  80. package/dist/types/components/UniversalHeader/UniversalHeader.d.ts +4 -0
  81. package/dist/types/components/index.d.ts +1 -0
  82. package/dist/types/internal-components/ConditionalWrapper/ConditionalWrapper.d.ts +6 -0
  83. package/dist/types/internal-components/ConditionalWrapper/index.d.ts +1 -0
  84. package/dist/types/internal-components/index.d.ts +1 -0
  85. package/dist/types/styles.d.ts +2 -1
  86. package/package.json +2 -2
  87. package/dist/_shared/cjs/index-c575a255.js +0 -490
  88. package/dist/_shared/esm/index-13d575cc.js +0 -479
  89. package/dist/types/components/MediaCard/MediaCard.stories-wip.d.ts +0 -15
@@ -1,15 +1,21 @@
1
1
  import { _ as __rest, a as __assign, f as filterDataAttrs } from '../_shared/esm/filter-data-attrs-ea8f4ed4.js';
2
2
  import { c as classNames } from '../_shared/esm/index-2e73c2e9.js';
3
3
  import * as React from 'react';
4
- import React__default, { useContext, createContext, useEffect, forwardRef, useState, createElement, useRef, useCallback, Fragment, useMemo, useId } from 'react';
4
+ import React__default, { forwardRef, useContext, useState, useEffect, createElement, useRef, createContext, useCallback, useLayoutEffect, useMemo, Fragment, useId } from 'react';
5
5
  import { _ as _extends } from '../_shared/esm/extends-8cc61aad.js';
6
- import $7SXl2$reactdom, { createPortal } from 'react-dom';
7
- import { $ as $c512c27ab02ef895$export$50c7b4e9d9f19c1, a as $6ed0406888f73fc4$export$c7b2cbe3552a0d05, b as $5e63c961fc1ce211$export$8c6ed5c666ac1360, c as $b1b2314f5f9a1d84$export$25bec8c6f54ee79a, d as $8927f6f2acc4f386$export$250ffa63cdc0d034, e as $e42e1063c40fb3ef$export$b9ecd428b558ff10, f as $8927f6f2acc4f386$export$6d1a0317bde7de7f, g as $9f79659886946c16$export$e5c5a5f917a5871c, h as $71cd76cc60e0454e$export$6f32135080cb4c3, i as $010c2913dbd2fe3d$export$5cae361ad82dce8b } from '../_shared/esm/index.module-44714d3f.js';
8
- import { h as hideOthers, $ as $01b9c$RemoveScroll } from '../_shared/esm/index-41d7af2b.js';
6
+ import * as $7SXl2$reactdom from 'react-dom';
7
+ import $7SXl2$reactdom__default, { createPortal } from 'react-dom';
8
+ import { a as $6ed0406888f73fc4$export$c7b2cbe3552a0d05, b as $8927f6f2acc4f386$export$250ffa63cdc0d034, f as $e42e1063c40fb3ef$export$b9ecd428b558ff10, $ as $b1b2314f5f9a1d84$export$25bec8c6f54ee79a, h as $8927f6f2acc4f386$export$6d1a0317bde7de7f, g as $9f79659886946c16$export$e5c5a5f917a5871c, c as $c512c27ab02ef895$export$50c7b4e9d9f19c1, d as $71cd76cc60e0454e$export$6f32135080cb4c3, e as $5e63c961fc1ce211$export$8c6ed5c666ac1360 } from '../_shared/esm/index-12f3a407.js';
9
+ import { $ as $e02a7d9cb1dc128c$export$c74125a8e3af6bb2 } from '../_shared/esm/index-39019a9b.js';
10
+ import { $ as $f631663db3294ace$export$b39126d51d94e6f3 } from '../_shared/esm/index-a624de47.js';
11
+ import { $ as $addc16e1bbe58fd0$export$3a72a57244d6e765 } from '../_shared/esm/index-246b4f18.js';
12
+ import { h as hideOthers, a as $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c, $ as $01b9c$RemoveScroll } from '../_shared/esm/index-3e2bc99d.js';
13
+ import { $ as $1746a345f3d73bb7$export$f680877a34711e37 } from '../_shared/esm/index-936b5179.js';
14
+ import { $ as $ea1ef594cf570d83$export$439d29a4e110a164 } from '../_shared/esm/index-6b7b075c.js';
9
15
  import { B as BtIconChevronDown2Px } from '../_shared/esm/BtIconChevronDown2Px.esm-217276c2.js';
10
16
  import { B as BtIconTickAlt2Px } from '../_shared/esm/BtIconTickAlt2Px.esm-0bc2ded0.js';
11
17
  import { I as Icon } from '../_shared/esm/Icon-abd0d990.js';
12
- import { F as FormControl } from '../_shared/esm/FormControl-351e5f1b.js';
18
+ import { F as FormControl } from '../_shared/esm/FormControl-9d4ddfec.js';
13
19
  import { C as Context } from '../_shared/esm/Surface-0ca6817d.js';
14
20
  import { A as ArcRootElementContext } from '../_shared/esm/Base-f200653c.js';
15
21
  import '../_shared/esm/suffix-modifier-3d548e45.js';
@@ -21,116 +27,6 @@ function $ae6933e535247d3d$export$7d15b64cf5a3a4c4(value, [min, max]) {
21
27
  return Math.min(max, Math.max(min, value));
22
28
  }
23
29
 
24
- // We have resorted to returning slots directly rather than exposing primitives that can then
25
- // be slotted like `<CollectionItem as={Slot}>…</CollectionItem>`.
26
- // This is because we encountered issues with generic types that cannot be statically analysed
27
- // due to creating them dynamically via createCollection.
28
- function $e02a7d9cb1dc128c$export$c74125a8e3af6bb2(name) {
29
- /* -----------------------------------------------------------------------------------------------
30
- * CollectionProvider
31
- * ---------------------------------------------------------------------------------------------*/ const PROVIDER_NAME = name + 'CollectionProvider';
32
- const [createCollectionContext, createCollectionScope] = $c512c27ab02ef895$export$50c7b4e9d9f19c1(PROVIDER_NAME);
33
- const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
34
- collectionRef: {
35
- current: null
36
- },
37
- itemMap: new Map()
38
- });
39
- const CollectionProvider = (props)=>{
40
- const { scope: scope , children: children } = props;
41
- const ref = React__default.useRef(null);
42
- const itemMap = React__default.useRef(new Map()).current;
43
- return /*#__PURE__*/ React__default.createElement(CollectionProviderImpl, {
44
- scope: scope,
45
- itemMap: itemMap,
46
- collectionRef: ref
47
- }, children);
48
- };
49
- /* -----------------------------------------------------------------------------------------------
50
- * CollectionSlot
51
- * ---------------------------------------------------------------------------------------------*/ const COLLECTION_SLOT_NAME = name + 'CollectionSlot';
52
- const CollectionSlot = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
53
- const { scope: scope , children: children } = props;
54
- const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
55
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.collectionRef);
56
- return /*#__PURE__*/ React__default.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, {
57
- ref: composedRefs
58
- }, children);
59
- });
60
- /* -----------------------------------------------------------------------------------------------
61
- * CollectionItem
62
- * ---------------------------------------------------------------------------------------------*/ const ITEM_SLOT_NAME = name + 'CollectionItemSlot';
63
- const ITEM_DATA_ATTR = 'data-radix-collection-item';
64
- const CollectionItemSlot = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
65
- const { scope: scope , children: children , ...itemData } = props;
66
- const ref = React__default.useRef(null);
67
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
68
- const context = useCollectionContext(ITEM_SLOT_NAME, scope);
69
- React__default.useEffect(()=>{
70
- context.itemMap.set(ref, {
71
- ref: ref,
72
- ...itemData
73
- });
74
- return ()=>void context.itemMap.delete(ref)
75
- ;
76
- });
77
- return /*#__PURE__*/ React__default.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, {
78
- [ITEM_DATA_ATTR]: '',
79
- ref: composedRefs
80
- }, children);
81
- });
82
- /* -----------------------------------------------------------------------------------------------
83
- * useCollection
84
- * ---------------------------------------------------------------------------------------------*/ function useCollection(scope) {
85
- const context = useCollectionContext(name + 'CollectionConsumer', scope);
86
- const getItems = React__default.useCallback(()=>{
87
- const collectionNode = context.collectionRef.current;
88
- if (!collectionNode) return [];
89
- const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
90
- const items = Array.from(context.itemMap.values());
91
- const orderedItems = items.sort((a, b)=>orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
92
- );
93
- return orderedItems;
94
- }, [
95
- context.collectionRef,
96
- context.itemMap
97
- ]);
98
- return getItems;
99
- }
100
- return [
101
- {
102
- Provider: CollectionProvider,
103
- Slot: CollectionSlot,
104
- ItemSlot: CollectionItemSlot
105
- },
106
- useCollection,
107
- createCollectionScope
108
- ];
109
- }
110
-
111
- const $f631663db3294ace$var$DirectionContext = /*#__PURE__*/ createContext(undefined);
112
- /* -----------------------------------------------------------------------------------------------*/ function $f631663db3294ace$export$b39126d51d94e6f3(localDir) {
113
- const globalDir = useContext($f631663db3294ace$var$DirectionContext);
114
- return localDir || globalDir || 'ltr';
115
- }
116
-
117
- /**
118
- * Listens for when the escape key is down
119
- */ function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
120
- const onEscapeKeyDown = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp);
121
- useEffect(()=>{
122
- const handleKeyDown = (event)=>{
123
- if (event.key === 'Escape') onEscapeKeyDown(event);
124
- };
125
- ownerDocument.addEventListener('keydown', handleKeyDown);
126
- return ()=>ownerDocument.removeEventListener('keydown', handleKeyDown)
127
- ;
128
- }, [
129
- onEscapeKeyDown,
130
- ownerDocument
131
- ]);
132
- }
133
-
134
30
  const $5cb92bef7577960e$var$CONTEXT_UPDATE = 'dismissableLayer.update';
135
31
  const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';
136
32
  const $5cb92bef7577960e$var$FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';
@@ -279,7 +175,9 @@ const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /*#__PURE__*/ forwardRef((prop
279
175
  once: true
280
176
  });
281
177
  } else handleAndDispatchPointerDownOutsideEvent();
282
- }
178
+ } else // We need to remove the event listener in case the outside click has been canceled.
179
+ // See: https://github.com/radix-ui/primitives/issues/2171
180
+ ownerDocument.removeEventListener('click', handleClickRef.current);
283
181
  isPointerInsideReactTreeRef.current = false;
284
182
  };
285
183
  /**
@@ -359,32 +257,6 @@ function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name, handler, detai
359
257
  else target.dispatchEvent(event);
360
258
  }
361
259
 
362
- /** Number of components which have requested interest to have focus guards */ let $3db38b7d1fb3fe6a$var$count = 0;
363
- /**
364
- * Injects a pair of focus guards at the edges of the whole DOM tree
365
- * to ensure `focusin` & `focusout` events can be caught consistently.
366
- */ function $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c() {
367
- useEffect(()=>{
368
- var _edgeGuards$, _edgeGuards$2;
369
- const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');
370
- document.body.insertAdjacentElement('afterbegin', (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $3db38b7d1fb3fe6a$var$createFocusGuard());
371
- document.body.insertAdjacentElement('beforeend', (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $3db38b7d1fb3fe6a$var$createFocusGuard());
372
- $3db38b7d1fb3fe6a$var$count++;
373
- return ()=>{
374
- if ($3db38b7d1fb3fe6a$var$count === 1) document.querySelectorAll('[data-radix-focus-guard]').forEach((node)=>node.remove()
375
- );
376
- $3db38b7d1fb3fe6a$var$count--;
377
- };
378
- }, []);
379
- }
380
- function $3db38b7d1fb3fe6a$var$createFocusGuard() {
381
- const element = document.createElement('span');
382
- element.setAttribute('data-radix-focus-guard', '');
383
- element.tabIndex = 0;
384
- element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';
385
- return element;
386
- }
387
-
388
260
  const $d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT = 'focusScope.autoFocusOnMount';
389
261
  const $d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT = 'focusScope.autoFocusOnUnmount';
390
262
  const $d3863c46a17e8a28$var$EVENT_OPTIONS = {
@@ -420,15 +292,40 @@ const $d3863c46a17e8a28$export$20e40289641fbbb6 = /*#__PURE__*/ forwardRef((prop
420
292
  }
421
293
  function handleFocusOut(event) {
422
294
  if (focusScope.paused || !container1) return;
423
- if (!container1.contains(event.relatedTarget)) $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
295
+ const relatedTarget = event.relatedTarget; // A `focusout` event with a `null` `relatedTarget` will happen in at least two cases:
296
+ //
297
+ // 1. When the user switches app/tabs/windows/the browser itself loses focus.
298
+ // 2. In Google Chrome, when the focused element is removed from the DOM.
299
+ //
300
+ // We let the browser do its thing here because:
301
+ //
302
+ // 1. The browser already keeps a memory of what's focused for when the page gets refocused.
303
+ // 2. In Google Chrome, if we try to focus the deleted focused element (as per below), it
304
+ // throws the CPU to 100%, so we avoid doing anything for this reason here too.
305
+ if (relatedTarget === null) return; // If the focus has moved to an actual legitimate element (`relatedTarget !== null`)
306
+ // that is outside the container, we move focus to the last valid focused element inside.
307
+ if (!container1.contains(relatedTarget)) $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
424
308
  select: true
425
309
  });
310
+ } // When the focused element gets removed from the DOM, browsers move focus
311
+ // back to the document.body. In this case, we move focus to the container
312
+ // to keep focus trapped correctly.
313
+ function handleMutations(mutations) {
314
+ const focusedElement = document.activeElement;
315
+ if (focusedElement !== document.body) return;
316
+ for (const mutation of mutations)if (mutation.removedNodes.length > 0) $d3863c46a17e8a28$var$focus(container1);
426
317
  }
427
318
  document.addEventListener('focusin', handleFocusIn);
428
319
  document.addEventListener('focusout', handleFocusOut);
320
+ const mutationObserver = new MutationObserver(handleMutations);
321
+ if (container1) mutationObserver.observe(container1, {
322
+ childList: true,
323
+ subtree: true
324
+ });
429
325
  return ()=>{
430
326
  document.removeEventListener('focusin', handleFocusIn);
431
327
  document.removeEventListener('focusout', handleFocusOut);
328
+ mutationObserver.disconnect();
432
329
  };
433
330
  }
434
331
  }, [
@@ -629,47 +526,2179 @@ function $d3863c46a17e8a28$var$removeLinks(items) {
629
526
  );
630
527
  }
631
528
 
632
- const $1746a345f3d73bb7$var$useReactId = React['useId'.toString()] || (()=>undefined
633
- );
634
- let $1746a345f3d73bb7$var$count = 0;
635
- function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
636
- const [id, setId] = React.useState($1746a345f3d73bb7$var$useReactId()); // React versions older than 18 will have client-side ids only.
529
+ const sides = ['top', 'right', 'bottom', 'left'];
530
+ const min = Math.min;
531
+ const max = Math.max;
532
+ const round = Math.round;
533
+ const floor = Math.floor;
534
+ const createCoords = v => ({
535
+ x: v,
536
+ y: v
537
+ });
538
+ const oppositeSideMap = {
539
+ left: 'right',
540
+ right: 'left',
541
+ bottom: 'top',
542
+ top: 'bottom'
543
+ };
544
+ const oppositeAlignmentMap = {
545
+ start: 'end',
546
+ end: 'start'
547
+ };
548
+ function clamp(start, value, end) {
549
+ return max(start, min(value, end));
550
+ }
551
+ function evaluate(value, param) {
552
+ return typeof value === 'function' ? value(param) : value;
553
+ }
554
+ function getSide(placement) {
555
+ return placement.split('-')[0];
556
+ }
557
+ function getAlignment(placement) {
558
+ return placement.split('-')[1];
559
+ }
560
+ function getOppositeAxis(axis) {
561
+ return axis === 'x' ? 'y' : 'x';
562
+ }
563
+ function getAxisLength(axis) {
564
+ return axis === 'y' ? 'height' : 'width';
565
+ }
566
+ function getSideAxis(placement) {
567
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
568
+ }
569
+ function getAlignmentAxis(placement) {
570
+ return getOppositeAxis(getSideAxis(placement));
571
+ }
572
+ function getAlignmentSides(placement, rects, rtl) {
573
+ if (rtl === void 0) {
574
+ rtl = false;
575
+ }
576
+ const alignment = getAlignment(placement);
577
+ const alignmentAxis = getAlignmentAxis(placement);
578
+ const length = getAxisLength(alignmentAxis);
579
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
580
+ if (rects.reference[length] > rects.floating[length]) {
581
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
582
+ }
583
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
584
+ }
585
+ function getExpandedPlacements(placement) {
586
+ const oppositePlacement = getOppositePlacement(placement);
587
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
588
+ }
589
+ function getOppositeAlignmentPlacement(placement) {
590
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
591
+ }
592
+ function getSideList(side, isStart, rtl) {
593
+ const lr = ['left', 'right'];
594
+ const rl = ['right', 'left'];
595
+ const tb = ['top', 'bottom'];
596
+ const bt = ['bottom', 'top'];
597
+ switch (side) {
598
+ case 'top':
599
+ case 'bottom':
600
+ if (rtl) return isStart ? rl : lr;
601
+ return isStart ? lr : rl;
602
+ case 'left':
603
+ case 'right':
604
+ return isStart ? tb : bt;
605
+ default:
606
+ return [];
607
+ }
608
+ }
609
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
610
+ const alignment = getAlignment(placement);
611
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
612
+ if (alignment) {
613
+ list = list.map(side => side + "-" + alignment);
614
+ if (flipAlignment) {
615
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
616
+ }
617
+ }
618
+ return list;
619
+ }
620
+ function getOppositePlacement(placement) {
621
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
622
+ }
623
+ function expandPaddingObject(padding) {
624
+ return {
625
+ top: 0,
626
+ right: 0,
627
+ bottom: 0,
628
+ left: 0,
629
+ ...padding
630
+ };
631
+ }
632
+ function getPaddingObject(padding) {
633
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
634
+ top: padding,
635
+ right: padding,
636
+ bottom: padding,
637
+ left: padding
638
+ };
639
+ }
640
+ function rectToClientRect(rect) {
641
+ return {
642
+ ...rect,
643
+ top: rect.y,
644
+ left: rect.x,
645
+ right: rect.x + rect.width,
646
+ bottom: rect.y + rect.height
647
+ };
648
+ }
649
+
650
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
651
+ let {
652
+ reference,
653
+ floating
654
+ } = _ref;
655
+ const sideAxis = getSideAxis(placement);
656
+ const alignmentAxis = getAlignmentAxis(placement);
657
+ const alignLength = getAxisLength(alignmentAxis);
658
+ const side = getSide(placement);
659
+ const isVertical = sideAxis === 'y';
660
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
661
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
662
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
663
+ let coords;
664
+ switch (side) {
665
+ case 'top':
666
+ coords = {
667
+ x: commonX,
668
+ y: reference.y - floating.height
669
+ };
670
+ break;
671
+ case 'bottom':
672
+ coords = {
673
+ x: commonX,
674
+ y: reference.y + reference.height
675
+ };
676
+ break;
677
+ case 'right':
678
+ coords = {
679
+ x: reference.x + reference.width,
680
+ y: commonY
681
+ };
682
+ break;
683
+ case 'left':
684
+ coords = {
685
+ x: reference.x - floating.width,
686
+ y: commonY
687
+ };
688
+ break;
689
+ default:
690
+ coords = {
691
+ x: reference.x,
692
+ y: reference.y
693
+ };
694
+ }
695
+ switch (getAlignment(placement)) {
696
+ case 'start':
697
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
698
+ break;
699
+ case 'end':
700
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
701
+ break;
702
+ }
703
+ return coords;
704
+ }
705
+
706
+ /**
707
+ * Computes the `x` and `y` coordinates that will place the floating element
708
+ * next to a reference element when it is given a certain positioning strategy.
709
+ *
710
+ * This export does not have any `platform` interface logic. You will need to
711
+ * write one for the platform you are using Floating UI with.
712
+ */
713
+ const computePosition$1 = async (reference, floating, config) => {
714
+ const {
715
+ placement = 'bottom',
716
+ strategy = 'absolute',
717
+ middleware = [],
718
+ platform
719
+ } = config;
720
+ const validMiddleware = middleware.filter(Boolean);
721
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
722
+ let rects = await platform.getElementRects({
723
+ reference,
724
+ floating,
725
+ strategy
726
+ });
727
+ let {
728
+ x,
729
+ y
730
+ } = computeCoordsFromPlacement(rects, placement, rtl);
731
+ let statefulPlacement = placement;
732
+ let middlewareData = {};
733
+ let resetCount = 0;
734
+ for (let i = 0; i < validMiddleware.length; i++) {
735
+ const {
736
+ name,
737
+ fn
738
+ } = validMiddleware[i];
739
+ const {
740
+ x: nextX,
741
+ y: nextY,
742
+ data,
743
+ reset
744
+ } = await fn({
745
+ x,
746
+ y,
747
+ initialPlacement: placement,
748
+ placement: statefulPlacement,
749
+ strategy,
750
+ middlewareData,
751
+ rects,
752
+ platform,
753
+ elements: {
754
+ reference,
755
+ floating
756
+ }
757
+ });
758
+ x = nextX != null ? nextX : x;
759
+ y = nextY != null ? nextY : y;
760
+ middlewareData = {
761
+ ...middlewareData,
762
+ [name]: {
763
+ ...middlewareData[name],
764
+ ...data
765
+ }
766
+ };
767
+ if (reset && resetCount <= 50) {
768
+ resetCount++;
769
+ if (typeof reset === 'object') {
770
+ if (reset.placement) {
771
+ statefulPlacement = reset.placement;
772
+ }
773
+ if (reset.rects) {
774
+ rects = reset.rects === true ? await platform.getElementRects({
775
+ reference,
776
+ floating,
777
+ strategy
778
+ }) : reset.rects;
779
+ }
780
+ ({
781
+ x,
782
+ y
783
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
784
+ }
785
+ i = -1;
786
+ continue;
787
+ }
788
+ }
789
+ return {
790
+ x,
791
+ y,
792
+ placement: statefulPlacement,
793
+ strategy,
794
+ middlewareData
795
+ };
796
+ };
797
+
798
+ /**
799
+ * Resolves with an object of overflow side offsets that determine how much the
800
+ * element is overflowing a given clipping boundary on each side.
801
+ * - positive = overflowing the boundary by that number of pixels
802
+ * - negative = how many pixels left before it will overflow
803
+ * - 0 = lies flush with the boundary
804
+ * @see https://floating-ui.com/docs/detectOverflow
805
+ */
806
+ async function detectOverflow(state, options) {
807
+ var _await$platform$isEle;
808
+ if (options === void 0) {
809
+ options = {};
810
+ }
811
+ const {
812
+ x,
813
+ y,
814
+ platform,
815
+ rects,
816
+ elements,
817
+ strategy
818
+ } = state;
819
+ const {
820
+ boundary = 'clippingAncestors',
821
+ rootBoundary = 'viewport',
822
+ elementContext = 'floating',
823
+ altBoundary = false,
824
+ padding = 0
825
+ } = evaluate(options, state);
826
+ const paddingObject = getPaddingObject(padding);
827
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
828
+ const element = elements[altBoundary ? altContext : elementContext];
829
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
830
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
831
+ boundary,
832
+ rootBoundary,
833
+ strategy
834
+ }));
835
+ const rect = elementContext === 'floating' ? {
836
+ ...rects.floating,
837
+ x,
838
+ y
839
+ } : rects.reference;
840
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
841
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
842
+ x: 1,
843
+ y: 1
844
+ } : {
845
+ x: 1,
846
+ y: 1
847
+ };
848
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
849
+ rect,
850
+ offsetParent,
851
+ strategy
852
+ }) : rect);
853
+ return {
854
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
855
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
856
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
857
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
858
+ };
859
+ }
860
+
861
+ /**
862
+ * Provides data to position an inner element of the floating element so that it
863
+ * appears centered to the reference element.
864
+ * @see https://floating-ui.com/docs/arrow
865
+ */
866
+ const arrow$1 = options => ({
867
+ name: 'arrow',
868
+ options,
869
+ async fn(state) {
870
+ const {
871
+ x,
872
+ y,
873
+ placement,
874
+ rects,
875
+ platform,
876
+ elements,
877
+ middlewareData
878
+ } = state;
879
+ // Since `element` is required, we don't Partial<> the type.
880
+ const {
881
+ element,
882
+ padding = 0
883
+ } = evaluate(options, state) || {};
884
+ if (element == null) {
885
+ return {};
886
+ }
887
+ const paddingObject = getPaddingObject(padding);
888
+ const coords = {
889
+ x,
890
+ y
891
+ };
892
+ const axis = getAlignmentAxis(placement);
893
+ const length = getAxisLength(axis);
894
+ const arrowDimensions = await platform.getDimensions(element);
895
+ const isYAxis = axis === 'y';
896
+ const minProp = isYAxis ? 'top' : 'left';
897
+ const maxProp = isYAxis ? 'bottom' : 'right';
898
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
899
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
900
+ const startDiff = coords[axis] - rects.reference[axis];
901
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
902
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
903
+
904
+ // DOM platform can return `window` as the `offsetParent`.
905
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
906
+ clientSize = elements.floating[clientProp] || rects.floating[length];
907
+ }
908
+ const centerToReference = endDiff / 2 - startDiff / 2;
909
+
910
+ // If the padding is large enough that it causes the arrow to no longer be
911
+ // centered, modify the padding so that it is centered.
912
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
913
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
914
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
915
+
916
+ // Make sure the arrow doesn't overflow the floating element if the center
917
+ // point is outside the floating element's bounds.
918
+ const min$1 = minPadding;
919
+ const max = clientSize - arrowDimensions[length] - maxPadding;
920
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
921
+ const offset = clamp(min$1, center, max);
922
+
923
+ // If the reference is small enough that the arrow's padding causes it to
924
+ // to point to nothing for an aligned placement, adjust the offset of the
925
+ // floating element itself. To ensure `shift()` continues to take action,
926
+ // a single reset is performed when this is true.
927
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
928
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
929
+ return {
930
+ [axis]: coords[axis] + alignmentOffset,
931
+ data: {
932
+ [axis]: offset,
933
+ centerOffset: center - offset - alignmentOffset,
934
+ ...(shouldAddOffset && {
935
+ alignmentOffset
936
+ })
937
+ },
938
+ reset: shouldAddOffset
939
+ };
940
+ }
941
+ });
942
+
943
+ /**
944
+ * Optimizes the visibility of the floating element by flipping the `placement`
945
+ * in order to keep it in view when the preferred placement(s) will overflow the
946
+ * clipping boundary. Alternative to `autoPlacement`.
947
+ * @see https://floating-ui.com/docs/flip
948
+ */
949
+ const flip = function (options) {
950
+ if (options === void 0) {
951
+ options = {};
952
+ }
953
+ return {
954
+ name: 'flip',
955
+ options,
956
+ async fn(state) {
957
+ var _middlewareData$arrow, _middlewareData$flip;
958
+ const {
959
+ placement,
960
+ middlewareData,
961
+ rects,
962
+ initialPlacement,
963
+ platform,
964
+ elements
965
+ } = state;
966
+ const {
967
+ mainAxis: checkMainAxis = true,
968
+ crossAxis: checkCrossAxis = true,
969
+ fallbackPlacements: specifiedFallbackPlacements,
970
+ fallbackStrategy = 'bestFit',
971
+ fallbackAxisSideDirection = 'none',
972
+ flipAlignment = true,
973
+ ...detectOverflowOptions
974
+ } = evaluate(options, state);
975
+
976
+ // If a reset by the arrow was caused due to an alignment offset being
977
+ // added, we should skip any logic now since `flip()` has already done its
978
+ // work.
979
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
980
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
981
+ return {};
982
+ }
983
+ const side = getSide(placement);
984
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
985
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
986
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
987
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
988
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
989
+ }
990
+ const placements = [initialPlacement, ...fallbackPlacements];
991
+ const overflow = await detectOverflow(state, detectOverflowOptions);
992
+ const overflows = [];
993
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
994
+ if (checkMainAxis) {
995
+ overflows.push(overflow[side]);
996
+ }
997
+ if (checkCrossAxis) {
998
+ const sides = getAlignmentSides(placement, rects, rtl);
999
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
1000
+ }
1001
+ overflowsData = [...overflowsData, {
1002
+ placement,
1003
+ overflows
1004
+ }];
1005
+
1006
+ // One or more sides is overflowing.
1007
+ if (!overflows.every(side => side <= 0)) {
1008
+ var _middlewareData$flip2, _overflowsData$filter;
1009
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1010
+ const nextPlacement = placements[nextIndex];
1011
+ if (nextPlacement) {
1012
+ // Try next placement and re-run the lifecycle.
1013
+ return {
1014
+ data: {
1015
+ index: nextIndex,
1016
+ overflows: overflowsData
1017
+ },
1018
+ reset: {
1019
+ placement: nextPlacement
1020
+ }
1021
+ };
1022
+ }
1023
+
1024
+ // First, find the candidates that fit on the mainAxis side of overflow,
1025
+ // then find the placement that fits the best on the main crossAxis side.
1026
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1027
+
1028
+ // Otherwise fallback.
1029
+ if (!resetPlacement) {
1030
+ switch (fallbackStrategy) {
1031
+ case 'bestFit':
1032
+ {
1033
+ var _overflowsData$map$so;
1034
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
1035
+ if (placement) {
1036
+ resetPlacement = placement;
1037
+ }
1038
+ break;
1039
+ }
1040
+ case 'initialPlacement':
1041
+ resetPlacement = initialPlacement;
1042
+ break;
1043
+ }
1044
+ }
1045
+ if (placement !== resetPlacement) {
1046
+ return {
1047
+ reset: {
1048
+ placement: resetPlacement
1049
+ }
1050
+ };
1051
+ }
1052
+ }
1053
+ return {};
1054
+ }
1055
+ };
1056
+ };
1057
+
1058
+ function getSideOffsets(overflow, rect) {
1059
+ return {
1060
+ top: overflow.top - rect.height,
1061
+ right: overflow.right - rect.width,
1062
+ bottom: overflow.bottom - rect.height,
1063
+ left: overflow.left - rect.width
1064
+ };
1065
+ }
1066
+ function isAnySideFullyClipped(overflow) {
1067
+ return sides.some(side => overflow[side] >= 0);
1068
+ }
1069
+ /**
1070
+ * Provides data to hide the floating element in applicable situations, such as
1071
+ * when it is not in the same clipping context as the reference element.
1072
+ * @see https://floating-ui.com/docs/hide
1073
+ */
1074
+ const hide = function (options) {
1075
+ if (options === void 0) {
1076
+ options = {};
1077
+ }
1078
+ return {
1079
+ name: 'hide',
1080
+ options,
1081
+ async fn(state) {
1082
+ const {
1083
+ rects
1084
+ } = state;
1085
+ const {
1086
+ strategy = 'referenceHidden',
1087
+ ...detectOverflowOptions
1088
+ } = evaluate(options, state);
1089
+ switch (strategy) {
1090
+ case 'referenceHidden':
1091
+ {
1092
+ const overflow = await detectOverflow(state, {
1093
+ ...detectOverflowOptions,
1094
+ elementContext: 'reference'
1095
+ });
1096
+ const offsets = getSideOffsets(overflow, rects.reference);
1097
+ return {
1098
+ data: {
1099
+ referenceHiddenOffsets: offsets,
1100
+ referenceHidden: isAnySideFullyClipped(offsets)
1101
+ }
1102
+ };
1103
+ }
1104
+ case 'escaped':
1105
+ {
1106
+ const overflow = await detectOverflow(state, {
1107
+ ...detectOverflowOptions,
1108
+ altBoundary: true
1109
+ });
1110
+ const offsets = getSideOffsets(overflow, rects.floating);
1111
+ return {
1112
+ data: {
1113
+ escapedOffsets: offsets,
1114
+ escaped: isAnySideFullyClipped(offsets)
1115
+ }
1116
+ };
1117
+ }
1118
+ default:
1119
+ {
1120
+ return {};
1121
+ }
1122
+ }
1123
+ }
1124
+ };
1125
+ };
1126
+
1127
+ // For type backwards-compatibility, the `OffsetOptions` type was also
1128
+ // Derivable.
1129
+ async function convertValueToCoords(state, options) {
1130
+ const {
1131
+ placement,
1132
+ platform,
1133
+ elements
1134
+ } = state;
1135
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1136
+ const side = getSide(placement);
1137
+ const alignment = getAlignment(placement);
1138
+ const isVertical = getSideAxis(placement) === 'y';
1139
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1140
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1141
+ const rawValue = evaluate(options, state);
1142
+
1143
+ // eslint-disable-next-line prefer-const
1144
+ let {
1145
+ mainAxis,
1146
+ crossAxis,
1147
+ alignmentAxis
1148
+ } = typeof rawValue === 'number' ? {
1149
+ mainAxis: rawValue,
1150
+ crossAxis: 0,
1151
+ alignmentAxis: null
1152
+ } : {
1153
+ mainAxis: 0,
1154
+ crossAxis: 0,
1155
+ alignmentAxis: null,
1156
+ ...rawValue
1157
+ };
1158
+ if (alignment && typeof alignmentAxis === 'number') {
1159
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1160
+ }
1161
+ return isVertical ? {
1162
+ x: crossAxis * crossAxisMulti,
1163
+ y: mainAxis * mainAxisMulti
1164
+ } : {
1165
+ x: mainAxis * mainAxisMulti,
1166
+ y: crossAxis * crossAxisMulti
1167
+ };
1168
+ }
1169
+
1170
+ /**
1171
+ * Modifies the placement by translating the floating element along the
1172
+ * specified axes.
1173
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1174
+ * object may be passed.
1175
+ * @see https://floating-ui.com/docs/offset
1176
+ */
1177
+ const offset = function (options) {
1178
+ if (options === void 0) {
1179
+ options = 0;
1180
+ }
1181
+ return {
1182
+ name: 'offset',
1183
+ options,
1184
+ async fn(state) {
1185
+ const {
1186
+ x,
1187
+ y
1188
+ } = state;
1189
+ const diffCoords = await convertValueToCoords(state, options);
1190
+ return {
1191
+ x: x + diffCoords.x,
1192
+ y: y + diffCoords.y,
1193
+ data: diffCoords
1194
+ };
1195
+ }
1196
+ };
1197
+ };
1198
+
1199
+ /**
1200
+ * Optimizes the visibility of the floating element by shifting it in order to
1201
+ * keep it in view when it will overflow the clipping boundary.
1202
+ * @see https://floating-ui.com/docs/shift
1203
+ */
1204
+ const shift = function (options) {
1205
+ if (options === void 0) {
1206
+ options = {};
1207
+ }
1208
+ return {
1209
+ name: 'shift',
1210
+ options,
1211
+ async fn(state) {
1212
+ const {
1213
+ x,
1214
+ y,
1215
+ placement
1216
+ } = state;
1217
+ const {
1218
+ mainAxis: checkMainAxis = true,
1219
+ crossAxis: checkCrossAxis = false,
1220
+ limiter = {
1221
+ fn: _ref => {
1222
+ let {
1223
+ x,
1224
+ y
1225
+ } = _ref;
1226
+ return {
1227
+ x,
1228
+ y
1229
+ };
1230
+ }
1231
+ },
1232
+ ...detectOverflowOptions
1233
+ } = evaluate(options, state);
1234
+ const coords = {
1235
+ x,
1236
+ y
1237
+ };
1238
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1239
+ const crossAxis = getSideAxis(getSide(placement));
1240
+ const mainAxis = getOppositeAxis(crossAxis);
1241
+ let mainAxisCoord = coords[mainAxis];
1242
+ let crossAxisCoord = coords[crossAxis];
1243
+ if (checkMainAxis) {
1244
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
1245
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
1246
+ const min = mainAxisCoord + overflow[minSide];
1247
+ const max = mainAxisCoord - overflow[maxSide];
1248
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
1249
+ }
1250
+ if (checkCrossAxis) {
1251
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
1252
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1253
+ const min = crossAxisCoord + overflow[minSide];
1254
+ const max = crossAxisCoord - overflow[maxSide];
1255
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
1256
+ }
1257
+ const limitedCoords = limiter.fn({
1258
+ ...state,
1259
+ [mainAxis]: mainAxisCoord,
1260
+ [crossAxis]: crossAxisCoord
1261
+ });
1262
+ return {
1263
+ ...limitedCoords,
1264
+ data: {
1265
+ x: limitedCoords.x - x,
1266
+ y: limitedCoords.y - y
1267
+ }
1268
+ };
1269
+ }
1270
+ };
1271
+ };
1272
+ /**
1273
+ * Built-in `limiter` that will stop `shift()` at a certain point.
1274
+ */
1275
+ const limitShift = function (options) {
1276
+ if (options === void 0) {
1277
+ options = {};
1278
+ }
1279
+ return {
1280
+ options,
1281
+ fn(state) {
1282
+ const {
1283
+ x,
1284
+ y,
1285
+ placement,
1286
+ rects,
1287
+ middlewareData
1288
+ } = state;
1289
+ const {
1290
+ offset = 0,
1291
+ mainAxis: checkMainAxis = true,
1292
+ crossAxis: checkCrossAxis = true
1293
+ } = evaluate(options, state);
1294
+ const coords = {
1295
+ x,
1296
+ y
1297
+ };
1298
+ const crossAxis = getSideAxis(placement);
1299
+ const mainAxis = getOppositeAxis(crossAxis);
1300
+ let mainAxisCoord = coords[mainAxis];
1301
+ let crossAxisCoord = coords[crossAxis];
1302
+ const rawOffset = evaluate(offset, state);
1303
+ const computedOffset = typeof rawOffset === 'number' ? {
1304
+ mainAxis: rawOffset,
1305
+ crossAxis: 0
1306
+ } : {
1307
+ mainAxis: 0,
1308
+ crossAxis: 0,
1309
+ ...rawOffset
1310
+ };
1311
+ if (checkMainAxis) {
1312
+ const len = mainAxis === 'y' ? 'height' : 'width';
1313
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
1314
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
1315
+ if (mainAxisCoord < limitMin) {
1316
+ mainAxisCoord = limitMin;
1317
+ } else if (mainAxisCoord > limitMax) {
1318
+ mainAxisCoord = limitMax;
1319
+ }
1320
+ }
1321
+ if (checkCrossAxis) {
1322
+ var _middlewareData$offse, _middlewareData$offse2;
1323
+ const len = mainAxis === 'y' ? 'width' : 'height';
1324
+ const isOriginSide = ['top', 'left'].includes(getSide(placement));
1325
+ const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
1326
+ const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
1327
+ if (crossAxisCoord < limitMin) {
1328
+ crossAxisCoord = limitMin;
1329
+ } else if (crossAxisCoord > limitMax) {
1330
+ crossAxisCoord = limitMax;
1331
+ }
1332
+ }
1333
+ return {
1334
+ [mainAxis]: mainAxisCoord,
1335
+ [crossAxis]: crossAxisCoord
1336
+ };
1337
+ }
1338
+ };
1339
+ };
1340
+
1341
+ /**
1342
+ * Provides data that allows you to change the size of the floating element —
1343
+ * for instance, prevent it from overflowing the clipping boundary or match the
1344
+ * width of the reference element.
1345
+ * @see https://floating-ui.com/docs/size
1346
+ */
1347
+ const size = function (options) {
1348
+ if (options === void 0) {
1349
+ options = {};
1350
+ }
1351
+ return {
1352
+ name: 'size',
1353
+ options,
1354
+ async fn(state) {
1355
+ const {
1356
+ placement,
1357
+ rects,
1358
+ platform,
1359
+ elements
1360
+ } = state;
1361
+ const {
1362
+ apply = () => {},
1363
+ ...detectOverflowOptions
1364
+ } = evaluate(options, state);
1365
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1366
+ const side = getSide(placement);
1367
+ const alignment = getAlignment(placement);
1368
+ const isYAxis = getSideAxis(placement) === 'y';
1369
+ const {
1370
+ width,
1371
+ height
1372
+ } = rects.floating;
1373
+ let heightSide;
1374
+ let widthSide;
1375
+ if (side === 'top' || side === 'bottom') {
1376
+ heightSide = side;
1377
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
1378
+ } else {
1379
+ widthSide = side;
1380
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
1381
+ }
1382
+ const overflowAvailableHeight = height - overflow[heightSide];
1383
+ const overflowAvailableWidth = width - overflow[widthSide];
1384
+ const noShift = !state.middlewareData.shift;
1385
+ let availableHeight = overflowAvailableHeight;
1386
+ let availableWidth = overflowAvailableWidth;
1387
+ if (isYAxis) {
1388
+ const maximumClippingWidth = width - overflow.left - overflow.right;
1389
+ availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
1390
+ } else {
1391
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
1392
+ availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
1393
+ }
1394
+ if (noShift && !alignment) {
1395
+ const xMin = max(overflow.left, 0);
1396
+ const xMax = max(overflow.right, 0);
1397
+ const yMin = max(overflow.top, 0);
1398
+ const yMax = max(overflow.bottom, 0);
1399
+ if (isYAxis) {
1400
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1401
+ } else {
1402
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1403
+ }
1404
+ }
1405
+ await apply({
1406
+ ...state,
1407
+ availableWidth,
1408
+ availableHeight
1409
+ });
1410
+ const nextDimensions = await platform.getDimensions(elements.floating);
1411
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1412
+ return {
1413
+ reset: {
1414
+ rects: true
1415
+ }
1416
+ };
1417
+ }
1418
+ return {};
1419
+ }
1420
+ };
1421
+ };
1422
+
1423
+ function getNodeName(node) {
1424
+ if (isNode(node)) {
1425
+ return (node.nodeName || '').toLowerCase();
1426
+ }
1427
+ // Mocked nodes in testing environments may not be instances of Node. By
1428
+ // returning `#document` an infinite loop won't occur.
1429
+ // https://github.com/floating-ui/floating-ui/issues/2317
1430
+ return '#document';
1431
+ }
1432
+ function getWindow(node) {
1433
+ var _node$ownerDocument;
1434
+ return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1435
+ }
1436
+ function getDocumentElement(node) {
1437
+ var _ref;
1438
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1439
+ }
1440
+ function isNode(value) {
1441
+ return value instanceof Node || value instanceof getWindow(value).Node;
1442
+ }
1443
+ function isElement(value) {
1444
+ return value instanceof Element || value instanceof getWindow(value).Element;
1445
+ }
1446
+ function isHTMLElement(value) {
1447
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1448
+ }
1449
+ function isShadowRoot(value) {
1450
+ // Browsers without `ShadowRoot` support.
1451
+ if (typeof ShadowRoot === 'undefined') {
1452
+ return false;
1453
+ }
1454
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1455
+ }
1456
+ function isOverflowElement(element) {
1457
+ const {
1458
+ overflow,
1459
+ overflowX,
1460
+ overflowY,
1461
+ display
1462
+ } = getComputedStyle$1(element);
1463
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
1464
+ }
1465
+ function isTableElement(element) {
1466
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1467
+ }
1468
+ function isContainingBlock(element) {
1469
+ const webkit = isWebKit();
1470
+ const css = getComputedStyle$1(element);
1471
+
1472
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1473
+ return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
1474
+ }
1475
+ function getContainingBlock(element) {
1476
+ let currentNode = getParentNode(element);
1477
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1478
+ if (isContainingBlock(currentNode)) {
1479
+ return currentNode;
1480
+ } else {
1481
+ currentNode = getParentNode(currentNode);
1482
+ }
1483
+ }
1484
+ return null;
1485
+ }
1486
+ function isWebKit() {
1487
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
1488
+ return CSS.supports('-webkit-backdrop-filter', 'none');
1489
+ }
1490
+ function isLastTraversableNode(node) {
1491
+ return ['html', 'body', '#document'].includes(getNodeName(node));
1492
+ }
1493
+ function getComputedStyle$1(element) {
1494
+ return getWindow(element).getComputedStyle(element);
1495
+ }
1496
+ function getNodeScroll(element) {
1497
+ if (isElement(element)) {
1498
+ return {
1499
+ scrollLeft: element.scrollLeft,
1500
+ scrollTop: element.scrollTop
1501
+ };
1502
+ }
1503
+ return {
1504
+ scrollLeft: element.pageXOffset,
1505
+ scrollTop: element.pageYOffset
1506
+ };
1507
+ }
1508
+ function getParentNode(node) {
1509
+ if (getNodeName(node) === 'html') {
1510
+ return node;
1511
+ }
1512
+ const result =
1513
+ // Step into the shadow DOM of the parent of a slotted node.
1514
+ node.assignedSlot ||
1515
+ // DOM Element detected.
1516
+ node.parentNode ||
1517
+ // ShadowRoot detected.
1518
+ isShadowRoot(node) && node.host ||
1519
+ // Fallback.
1520
+ getDocumentElement(node);
1521
+ return isShadowRoot(result) ? result.host : result;
1522
+ }
1523
+ function getNearestOverflowAncestor(node) {
1524
+ const parentNode = getParentNode(node);
1525
+ if (isLastTraversableNode(parentNode)) {
1526
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1527
+ }
1528
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1529
+ return parentNode;
1530
+ }
1531
+ return getNearestOverflowAncestor(parentNode);
1532
+ }
1533
+ function getOverflowAncestors(node, list, traverseIframes) {
1534
+ var _node$ownerDocument2;
1535
+ if (list === void 0) {
1536
+ list = [];
1537
+ }
1538
+ if (traverseIframes === void 0) {
1539
+ traverseIframes = true;
1540
+ }
1541
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1542
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1543
+ const win = getWindow(scrollableAncestor);
1544
+ if (isBody) {
1545
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
1546
+ }
1547
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1548
+ }
1549
+
1550
+ function getCssDimensions(element) {
1551
+ const css = getComputedStyle$1(element);
1552
+ // In testing environments, the `width` and `height` properties are empty
1553
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1554
+ let width = parseFloat(css.width) || 0;
1555
+ let height = parseFloat(css.height) || 0;
1556
+ const hasOffset = isHTMLElement(element);
1557
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1558
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1559
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1560
+ if (shouldFallback) {
1561
+ width = offsetWidth;
1562
+ height = offsetHeight;
1563
+ }
1564
+ return {
1565
+ width,
1566
+ height,
1567
+ $: shouldFallback
1568
+ };
1569
+ }
1570
+
1571
+ function unwrapElement(element) {
1572
+ return !isElement(element) ? element.contextElement : element;
1573
+ }
1574
+
1575
+ function getScale(element) {
1576
+ const domElement = unwrapElement(element);
1577
+ if (!isHTMLElement(domElement)) {
1578
+ return createCoords(1);
1579
+ }
1580
+ const rect = domElement.getBoundingClientRect();
1581
+ const {
1582
+ width,
1583
+ height,
1584
+ $
1585
+ } = getCssDimensions(domElement);
1586
+ let x = ($ ? round(rect.width) : rect.width) / width;
1587
+ let y = ($ ? round(rect.height) : rect.height) / height;
1588
+
1589
+ // 0, NaN, or Infinity should always fallback to 1.
1590
+
1591
+ if (!x || !Number.isFinite(x)) {
1592
+ x = 1;
1593
+ }
1594
+ if (!y || !Number.isFinite(y)) {
1595
+ y = 1;
1596
+ }
1597
+ return {
1598
+ x,
1599
+ y
1600
+ };
1601
+ }
1602
+
1603
+ const noOffsets = /*#__PURE__*/createCoords(0);
1604
+ function getVisualOffsets(element) {
1605
+ const win = getWindow(element);
1606
+ if (!isWebKit() || !win.visualViewport) {
1607
+ return noOffsets;
1608
+ }
1609
+ return {
1610
+ x: win.visualViewport.offsetLeft,
1611
+ y: win.visualViewport.offsetTop
1612
+ };
1613
+ }
1614
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1615
+ if (isFixed === void 0) {
1616
+ isFixed = false;
1617
+ }
1618
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1619
+ return false;
1620
+ }
1621
+ return isFixed;
1622
+ }
1623
+
1624
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1625
+ if (includeScale === void 0) {
1626
+ includeScale = false;
1627
+ }
1628
+ if (isFixedStrategy === void 0) {
1629
+ isFixedStrategy = false;
1630
+ }
1631
+ const clientRect = element.getBoundingClientRect();
1632
+ const domElement = unwrapElement(element);
1633
+ let scale = createCoords(1);
1634
+ if (includeScale) {
1635
+ if (offsetParent) {
1636
+ if (isElement(offsetParent)) {
1637
+ scale = getScale(offsetParent);
1638
+ }
1639
+ } else {
1640
+ scale = getScale(element);
1641
+ }
1642
+ }
1643
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1644
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1645
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1646
+ let width = clientRect.width / scale.x;
1647
+ let height = clientRect.height / scale.y;
1648
+ if (domElement) {
1649
+ const win = getWindow(domElement);
1650
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1651
+ let currentIFrame = win.frameElement;
1652
+ while (currentIFrame && offsetParent && offsetWin !== win) {
1653
+ const iframeScale = getScale(currentIFrame);
1654
+ const iframeRect = currentIFrame.getBoundingClientRect();
1655
+ const css = getComputedStyle$1(currentIFrame);
1656
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1657
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1658
+ x *= iframeScale.x;
1659
+ y *= iframeScale.y;
1660
+ width *= iframeScale.x;
1661
+ height *= iframeScale.y;
1662
+ x += left;
1663
+ y += top;
1664
+ currentIFrame = getWindow(currentIFrame).frameElement;
1665
+ }
1666
+ }
1667
+ return rectToClientRect({
1668
+ width,
1669
+ height,
1670
+ x,
1671
+ y
1672
+ });
1673
+ }
1674
+
1675
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1676
+ let {
1677
+ rect,
1678
+ offsetParent,
1679
+ strategy
1680
+ } = _ref;
1681
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1682
+ const documentElement = getDocumentElement(offsetParent);
1683
+ if (offsetParent === documentElement) {
1684
+ return rect;
1685
+ }
1686
+ let scroll = {
1687
+ scrollLeft: 0,
1688
+ scrollTop: 0
1689
+ };
1690
+ let scale = createCoords(1);
1691
+ const offsets = createCoords(0);
1692
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1693
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1694
+ scroll = getNodeScroll(offsetParent);
1695
+ }
1696
+ if (isHTMLElement(offsetParent)) {
1697
+ const offsetRect = getBoundingClientRect(offsetParent);
1698
+ scale = getScale(offsetParent);
1699
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1700
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1701
+ }
1702
+ }
1703
+ return {
1704
+ width: rect.width * scale.x,
1705
+ height: rect.height * scale.y,
1706
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
1707
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
1708
+ };
1709
+ }
1710
+
1711
+ function getClientRects(element) {
1712
+ return Array.from(element.getClientRects());
1713
+ }
1714
+
1715
+ function getWindowScrollBarX(element) {
1716
+ // If <html> has a CSS width greater than the viewport, then this will be
1717
+ // incorrect for RTL.
1718
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1719
+ }
1720
+
1721
+ // Gets the entire size of the scrollable document area, even extending outside
1722
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1723
+ function getDocumentRect(element) {
1724
+ const html = getDocumentElement(element);
1725
+ const scroll = getNodeScroll(element);
1726
+ const body = element.ownerDocument.body;
1727
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1728
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1729
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1730
+ const y = -scroll.scrollTop;
1731
+ if (getComputedStyle$1(body).direction === 'rtl') {
1732
+ x += max(html.clientWidth, body.clientWidth) - width;
1733
+ }
1734
+ return {
1735
+ width,
1736
+ height,
1737
+ x,
1738
+ y
1739
+ };
1740
+ }
1741
+
1742
+ function getViewportRect(element, strategy) {
1743
+ const win = getWindow(element);
1744
+ const html = getDocumentElement(element);
1745
+ const visualViewport = win.visualViewport;
1746
+ let width = html.clientWidth;
1747
+ let height = html.clientHeight;
1748
+ let x = 0;
1749
+ let y = 0;
1750
+ if (visualViewport) {
1751
+ width = visualViewport.width;
1752
+ height = visualViewport.height;
1753
+ const visualViewportBased = isWebKit();
1754
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1755
+ x = visualViewport.offsetLeft;
1756
+ y = visualViewport.offsetTop;
1757
+ }
1758
+ }
1759
+ return {
1760
+ width,
1761
+ height,
1762
+ x,
1763
+ y
1764
+ };
1765
+ }
1766
+
1767
+ // Returns the inner client rect, subtracting scrollbars if present.
1768
+ function getInnerBoundingClientRect(element, strategy) {
1769
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1770
+ const top = clientRect.top + element.clientTop;
1771
+ const left = clientRect.left + element.clientLeft;
1772
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1773
+ const width = element.clientWidth * scale.x;
1774
+ const height = element.clientHeight * scale.y;
1775
+ const x = left * scale.x;
1776
+ const y = top * scale.y;
1777
+ return {
1778
+ width,
1779
+ height,
1780
+ x,
1781
+ y
1782
+ };
1783
+ }
1784
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1785
+ let rect;
1786
+ if (clippingAncestor === 'viewport') {
1787
+ rect = getViewportRect(element, strategy);
1788
+ } else if (clippingAncestor === 'document') {
1789
+ rect = getDocumentRect(getDocumentElement(element));
1790
+ } else if (isElement(clippingAncestor)) {
1791
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1792
+ } else {
1793
+ const visualOffsets = getVisualOffsets(element);
1794
+ rect = {
1795
+ ...clippingAncestor,
1796
+ x: clippingAncestor.x - visualOffsets.x,
1797
+ y: clippingAncestor.y - visualOffsets.y
1798
+ };
1799
+ }
1800
+ return rectToClientRect(rect);
1801
+ }
1802
+ function hasFixedPositionAncestor(element, stopNode) {
1803
+ const parentNode = getParentNode(element);
1804
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1805
+ return false;
1806
+ }
1807
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1808
+ }
1809
+
1810
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1811
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1812
+ // of the given element up the tree.
1813
+ function getClippingElementAncestors(element, cache) {
1814
+ const cachedResult = cache.get(element);
1815
+ if (cachedResult) {
1816
+ return cachedResult;
1817
+ }
1818
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1819
+ let currentContainingBlockComputedStyle = null;
1820
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1821
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1822
+
1823
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1824
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1825
+ const computedStyle = getComputedStyle$1(currentNode);
1826
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1827
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1828
+ currentContainingBlockComputedStyle = null;
1829
+ }
1830
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1831
+ if (shouldDropCurrentNode) {
1832
+ // Drop non-containing blocks.
1833
+ result = result.filter(ancestor => ancestor !== currentNode);
1834
+ } else {
1835
+ // Record last containing block for next iteration.
1836
+ currentContainingBlockComputedStyle = computedStyle;
1837
+ }
1838
+ currentNode = getParentNode(currentNode);
1839
+ }
1840
+ cache.set(element, result);
1841
+ return result;
1842
+ }
1843
+
1844
+ // Gets the maximum area that the element is visible in due to any number of
1845
+ // clipping ancestors.
1846
+ function getClippingRect(_ref) {
1847
+ let {
1848
+ element,
1849
+ boundary,
1850
+ rootBoundary,
1851
+ strategy
1852
+ } = _ref;
1853
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1854
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1855
+ const firstClippingAncestor = clippingAncestors[0];
1856
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1857
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1858
+ accRect.top = max(rect.top, accRect.top);
1859
+ accRect.right = min(rect.right, accRect.right);
1860
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1861
+ accRect.left = max(rect.left, accRect.left);
1862
+ return accRect;
1863
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1864
+ return {
1865
+ width: clippingRect.right - clippingRect.left,
1866
+ height: clippingRect.bottom - clippingRect.top,
1867
+ x: clippingRect.left,
1868
+ y: clippingRect.top
1869
+ };
1870
+ }
1871
+
1872
+ function getDimensions(element) {
1873
+ return getCssDimensions(element);
1874
+ }
1875
+
1876
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1877
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1878
+ const documentElement = getDocumentElement(offsetParent);
1879
+ const isFixed = strategy === 'fixed';
1880
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1881
+ let scroll = {
1882
+ scrollLeft: 0,
1883
+ scrollTop: 0
1884
+ };
1885
+ const offsets = createCoords(0);
1886
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1887
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1888
+ scroll = getNodeScroll(offsetParent);
1889
+ }
1890
+ if (isOffsetParentAnElement) {
1891
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1892
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1893
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1894
+ } else if (documentElement) {
1895
+ offsets.x = getWindowScrollBarX(documentElement);
1896
+ }
1897
+ }
1898
+ return {
1899
+ x: rect.left + scroll.scrollLeft - offsets.x,
1900
+ y: rect.top + scroll.scrollTop - offsets.y,
1901
+ width: rect.width,
1902
+ height: rect.height
1903
+ };
1904
+ }
1905
+
1906
+ function getTrueOffsetParent(element, polyfill) {
1907
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1908
+ return null;
1909
+ }
1910
+ if (polyfill) {
1911
+ return polyfill(element);
1912
+ }
1913
+ return element.offsetParent;
1914
+ }
1915
+
1916
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1917
+ // such as table ancestors and cross browser bugs.
1918
+ function getOffsetParent(element, polyfill) {
1919
+ const window = getWindow(element);
1920
+ if (!isHTMLElement(element)) {
1921
+ return window;
1922
+ }
1923
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1924
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
1925
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1926
+ }
1927
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1928
+ return window;
1929
+ }
1930
+ return offsetParent || getContainingBlock(element) || window;
1931
+ }
1932
+
1933
+ const getElementRects = async function (_ref) {
1934
+ let {
1935
+ reference,
1936
+ floating,
1937
+ strategy
1938
+ } = _ref;
1939
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1940
+ const getDimensionsFn = this.getDimensions;
1941
+ return {
1942
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
1943
+ floating: {
1944
+ x: 0,
1945
+ y: 0,
1946
+ ...(await getDimensionsFn(floating))
1947
+ }
1948
+ };
1949
+ };
1950
+
1951
+ function isRTL(element) {
1952
+ return getComputedStyle$1(element).direction === 'rtl';
1953
+ }
1954
+
1955
+ const platform = {
1956
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1957
+ getDocumentElement,
1958
+ getClippingRect,
1959
+ getOffsetParent,
1960
+ getElementRects,
1961
+ getClientRects,
1962
+ getDimensions,
1963
+ getScale,
1964
+ isElement,
1965
+ isRTL
1966
+ };
1967
+
1968
+ // https://samthor.au/2021/observing-dom/
1969
+ function observeMove(element, onMove) {
1970
+ let io = null;
1971
+ let timeoutId;
1972
+ const root = getDocumentElement(element);
1973
+ function cleanup() {
1974
+ clearTimeout(timeoutId);
1975
+ io && io.disconnect();
1976
+ io = null;
1977
+ }
1978
+ function refresh(skip, threshold) {
1979
+ if (skip === void 0) {
1980
+ skip = false;
1981
+ }
1982
+ if (threshold === void 0) {
1983
+ threshold = 1;
1984
+ }
1985
+ cleanup();
1986
+ const {
1987
+ left,
1988
+ top,
1989
+ width,
1990
+ height
1991
+ } = element.getBoundingClientRect();
1992
+ if (!skip) {
1993
+ onMove();
1994
+ }
1995
+ if (!width || !height) {
1996
+ return;
1997
+ }
1998
+ const insetTop = floor(top);
1999
+ const insetRight = floor(root.clientWidth - (left + width));
2000
+ const insetBottom = floor(root.clientHeight - (top + height));
2001
+ const insetLeft = floor(left);
2002
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2003
+ const options = {
2004
+ rootMargin,
2005
+ threshold: max(0, min(1, threshold)) || 1
2006
+ };
2007
+ let isFirstUpdate = true;
2008
+ function handleObserve(entries) {
2009
+ const ratio = entries[0].intersectionRatio;
2010
+ if (ratio !== threshold) {
2011
+ if (!isFirstUpdate) {
2012
+ return refresh();
2013
+ }
2014
+ if (!ratio) {
2015
+ timeoutId = setTimeout(() => {
2016
+ refresh(false, 1e-7);
2017
+ }, 100);
2018
+ } else {
2019
+ refresh(false, ratio);
2020
+ }
2021
+ }
2022
+ isFirstUpdate = false;
2023
+ }
2024
+
2025
+ // Older browsers don't support a `document` as the root and will throw an
2026
+ // error.
2027
+ try {
2028
+ io = new IntersectionObserver(handleObserve, {
2029
+ ...options,
2030
+ // Handle <iframe>s
2031
+ root: root.ownerDocument
2032
+ });
2033
+ } catch (e) {
2034
+ io = new IntersectionObserver(handleObserve, options);
2035
+ }
2036
+ io.observe(element);
2037
+ }
2038
+ refresh(true);
2039
+ return cleanup;
2040
+ }
2041
+
2042
+ /**
2043
+ * Automatically updates the position of the floating element when necessary.
2044
+ * Should only be called when the floating element is mounted on the DOM or
2045
+ * visible on the screen.
2046
+ * @returns cleanup function that should be invoked when the floating element is
2047
+ * removed from the DOM or hidden from the screen.
2048
+ * @see https://floating-ui.com/docs/autoUpdate
2049
+ */
2050
+ function autoUpdate(reference, floating, update, options) {
2051
+ if (options === void 0) {
2052
+ options = {};
2053
+ }
2054
+ const {
2055
+ ancestorScroll = true,
2056
+ ancestorResize = true,
2057
+ elementResize = typeof ResizeObserver === 'function',
2058
+ layoutShift = typeof IntersectionObserver === 'function',
2059
+ animationFrame = false
2060
+ } = options;
2061
+ const referenceEl = unwrapElement(reference);
2062
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
2063
+ ancestors.forEach(ancestor => {
2064
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
2065
+ passive: true
2066
+ });
2067
+ ancestorResize && ancestor.addEventListener('resize', update);
2068
+ });
2069
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2070
+ let reobserveFrame = -1;
2071
+ let resizeObserver = null;
2072
+ if (elementResize) {
2073
+ resizeObserver = new ResizeObserver(_ref => {
2074
+ let [firstEntry] = _ref;
2075
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2076
+ // Prevent update loops when using the `size` middleware.
2077
+ // https://github.com/floating-ui/floating-ui/issues/1740
2078
+ resizeObserver.unobserve(floating);
2079
+ cancelAnimationFrame(reobserveFrame);
2080
+ reobserveFrame = requestAnimationFrame(() => {
2081
+ resizeObserver && resizeObserver.observe(floating);
2082
+ });
2083
+ }
2084
+ update();
2085
+ });
2086
+ if (referenceEl && !animationFrame) {
2087
+ resizeObserver.observe(referenceEl);
2088
+ }
2089
+ resizeObserver.observe(floating);
2090
+ }
2091
+ let frameId;
2092
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2093
+ if (animationFrame) {
2094
+ frameLoop();
2095
+ }
2096
+ function frameLoop() {
2097
+ const nextRefRect = getBoundingClientRect(reference);
2098
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2099
+ update();
2100
+ }
2101
+ prevRefRect = nextRefRect;
2102
+ frameId = requestAnimationFrame(frameLoop);
2103
+ }
2104
+ update();
2105
+ return () => {
2106
+ ancestors.forEach(ancestor => {
2107
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
2108
+ ancestorResize && ancestor.removeEventListener('resize', update);
2109
+ });
2110
+ cleanupIo && cleanupIo();
2111
+ resizeObserver && resizeObserver.disconnect();
2112
+ resizeObserver = null;
2113
+ if (animationFrame) {
2114
+ cancelAnimationFrame(frameId);
2115
+ }
2116
+ };
2117
+ }
2118
+
2119
+ /**
2120
+ * Computes the `x` and `y` coordinates that will place the floating element
2121
+ * next to a reference element when it is given a certain CSS positioning
2122
+ * strategy.
2123
+ */
2124
+ const computePosition = (reference, floating, options) => {
2125
+ // This caches the expensive `getClippingElementAncestors` function so that
2126
+ // multiple lifecycle resets re-use the same result. It only lives for a
2127
+ // single call. If other functions become expensive, we can add them as well.
2128
+ const cache = new Map();
2129
+ const mergedOptions = {
2130
+ platform,
2131
+ ...options
2132
+ };
2133
+ const platformWithCache = {
2134
+ ...mergedOptions.platform,
2135
+ _c: cache
2136
+ };
2137
+ return computePosition$1(reference, floating, {
2138
+ ...mergedOptions,
2139
+ platform: platformWithCache
2140
+ });
2141
+ };
2142
+
2143
+ /**
2144
+ * Provides data to position an inner element of the floating element so that it
2145
+ * appears centered to the reference element.
2146
+ * This wraps the core `arrow` middleware to allow React refs as the element.
2147
+ * @see https://floating-ui.com/docs/arrow
2148
+ */
2149
+ const arrow = options => {
2150
+ function isRef(value) {
2151
+ return {}.hasOwnProperty.call(value, 'current');
2152
+ }
2153
+ return {
2154
+ name: 'arrow',
2155
+ options,
2156
+ fn(state) {
2157
+ const {
2158
+ element,
2159
+ padding
2160
+ } = typeof options === 'function' ? options(state) : options;
2161
+ if (element && isRef(element)) {
2162
+ if (element.current != null) {
2163
+ return arrow$1({
2164
+ element: element.current,
2165
+ padding
2166
+ }).fn(state);
2167
+ }
2168
+ return {};
2169
+ } else if (element) {
2170
+ return arrow$1({
2171
+ element,
2172
+ padding
2173
+ }).fn(state);
2174
+ }
2175
+ return {};
2176
+ }
2177
+ };
2178
+ };
2179
+
2180
+ var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
2181
+
2182
+ // Fork of `fast-deep-equal` that only does the comparisons we need and compares
2183
+ // functions
2184
+ function deepEqual(a, b) {
2185
+ if (a === b) {
2186
+ return true;
2187
+ }
2188
+ if (typeof a !== typeof b) {
2189
+ return false;
2190
+ }
2191
+ if (typeof a === 'function' && a.toString() === b.toString()) {
2192
+ return true;
2193
+ }
2194
+ let length, i, keys;
2195
+ if (a && b && typeof a == 'object') {
2196
+ if (Array.isArray(a)) {
2197
+ length = a.length;
2198
+ if (length != b.length) return false;
2199
+ for (i = length; i-- !== 0;) {
2200
+ if (!deepEqual(a[i], b[i])) {
2201
+ return false;
2202
+ }
2203
+ }
2204
+ return true;
2205
+ }
2206
+ keys = Object.keys(a);
2207
+ length = keys.length;
2208
+ if (length !== Object.keys(b).length) {
2209
+ return false;
2210
+ }
2211
+ for (i = length; i-- !== 0;) {
2212
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
2213
+ return false;
2214
+ }
2215
+ }
2216
+ for (i = length; i-- !== 0;) {
2217
+ const key = keys[i];
2218
+ if (key === '_owner' && a.$$typeof) {
2219
+ continue;
2220
+ }
2221
+ if (!deepEqual(a[key], b[key])) {
2222
+ return false;
2223
+ }
2224
+ }
2225
+ return true;
2226
+ }
2227
+ return a !== a && b !== b;
2228
+ }
2229
+
2230
+ function getDPR(element) {
2231
+ if (typeof window === 'undefined') {
2232
+ return 1;
2233
+ }
2234
+ const win = element.ownerDocument.defaultView || window;
2235
+ return win.devicePixelRatio || 1;
2236
+ }
2237
+
2238
+ function roundByDPR(element, value) {
2239
+ const dpr = getDPR(element);
2240
+ return Math.round(value * dpr) / dpr;
2241
+ }
2242
+
2243
+ function useLatestRef(value) {
2244
+ const ref = React.useRef(value);
2245
+ index(() => {
2246
+ ref.current = value;
2247
+ });
2248
+ return ref;
2249
+ }
2250
+
2251
+ /**
2252
+ * Provides data to position a floating element.
2253
+ * @see https://floating-ui.com/docs/react
2254
+ */
2255
+ function useFloating(options) {
2256
+ if (options === void 0) {
2257
+ options = {};
2258
+ }
2259
+ const {
2260
+ placement = 'bottom',
2261
+ strategy = 'absolute',
2262
+ middleware = [],
2263
+ platform,
2264
+ elements: {
2265
+ reference: externalReference,
2266
+ floating: externalFloating
2267
+ } = {},
2268
+ transform = true,
2269
+ whileElementsMounted,
2270
+ open
2271
+ } = options;
2272
+ const [data, setData] = React.useState({
2273
+ x: 0,
2274
+ y: 0,
2275
+ strategy,
2276
+ placement,
2277
+ middlewareData: {},
2278
+ isPositioned: false
2279
+ });
2280
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
2281
+ if (!deepEqual(latestMiddleware, middleware)) {
2282
+ setLatestMiddleware(middleware);
2283
+ }
2284
+ const [_reference, _setReference] = React.useState(null);
2285
+ const [_floating, _setFloating] = React.useState(null);
2286
+ const setReference = React.useCallback(node => {
2287
+ if (node != referenceRef.current) {
2288
+ referenceRef.current = node;
2289
+ _setReference(node);
2290
+ }
2291
+ }, [_setReference]);
2292
+ const setFloating = React.useCallback(node => {
2293
+ if (node !== floatingRef.current) {
2294
+ floatingRef.current = node;
2295
+ _setFloating(node);
2296
+ }
2297
+ }, [_setFloating]);
2298
+ const referenceEl = externalReference || _reference;
2299
+ const floatingEl = externalFloating || _floating;
2300
+ const referenceRef = React.useRef(null);
2301
+ const floatingRef = React.useRef(null);
2302
+ const dataRef = React.useRef(data);
2303
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2304
+ const platformRef = useLatestRef(platform);
2305
+ const update = React.useCallback(() => {
2306
+ if (!referenceRef.current || !floatingRef.current) {
2307
+ return;
2308
+ }
2309
+ const config = {
2310
+ placement,
2311
+ strategy,
2312
+ middleware: latestMiddleware
2313
+ };
2314
+ if (platformRef.current) {
2315
+ config.platform = platformRef.current;
2316
+ }
2317
+ computePosition(referenceRef.current, floatingRef.current, config).then(data => {
2318
+ const fullData = {
2319
+ ...data,
2320
+ isPositioned: true
2321
+ };
2322
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2323
+ dataRef.current = fullData;
2324
+ $7SXl2$reactdom.flushSync(() => {
2325
+ setData(fullData);
2326
+ });
2327
+ }
2328
+ });
2329
+ }, [latestMiddleware, placement, strategy, platformRef]);
2330
+ index(() => {
2331
+ if (open === false && dataRef.current.isPositioned) {
2332
+ dataRef.current.isPositioned = false;
2333
+ setData(data => ({
2334
+ ...data,
2335
+ isPositioned: false
2336
+ }));
2337
+ }
2338
+ }, [open]);
2339
+ const isMountedRef = React.useRef(false);
2340
+ index(() => {
2341
+ isMountedRef.current = true;
2342
+ return () => {
2343
+ isMountedRef.current = false;
2344
+ };
2345
+ }, []);
2346
+ index(() => {
2347
+ if (referenceEl) referenceRef.current = referenceEl;
2348
+ if (floatingEl) floatingRef.current = floatingEl;
2349
+ if (referenceEl && floatingEl) {
2350
+ if (whileElementsMountedRef.current) {
2351
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2352
+ } else {
2353
+ update();
2354
+ }
2355
+ }
2356
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef]);
2357
+ const refs = React.useMemo(() => ({
2358
+ reference: referenceRef,
2359
+ floating: floatingRef,
2360
+ setReference,
2361
+ setFloating
2362
+ }), [setReference, setFloating]);
2363
+ const elements = React.useMemo(() => ({
2364
+ reference: referenceEl,
2365
+ floating: floatingEl
2366
+ }), [referenceEl, floatingEl]);
2367
+ const floatingStyles = React.useMemo(() => {
2368
+ const initialStyles = {
2369
+ position: strategy,
2370
+ left: 0,
2371
+ top: 0
2372
+ };
2373
+ if (!elements.floating) {
2374
+ return initialStyles;
2375
+ }
2376
+ const x = roundByDPR(elements.floating, data.x);
2377
+ const y = roundByDPR(elements.floating, data.y);
2378
+ if (transform) {
2379
+ return {
2380
+ ...initialStyles,
2381
+ transform: "translate(" + x + "px, " + y + "px)",
2382
+ ...(getDPR(elements.floating) >= 1.5 && {
2383
+ willChange: 'transform'
2384
+ })
2385
+ };
2386
+ }
2387
+ return {
2388
+ position: strategy,
2389
+ left: x,
2390
+ top: y
2391
+ };
2392
+ }, [strategy, transform, elements.floating, data.x, data.y]);
2393
+ return React.useMemo(() => ({
2394
+ ...data,
2395
+ update,
2396
+ refs,
2397
+ elements,
2398
+ floatingStyles
2399
+ }), [data, update, refs, elements, floatingStyles]);
2400
+ }
2401
+
2402
+ function $db6c3485150b8e66$export$1ab7ae714698c4b8(element) {
2403
+ const [size, setSize] = useState(undefined);
637
2404
  $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
638
- if (!deterministicId) setId((reactId)=>reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++)
639
- );
2405
+ if (element) {
2406
+ // provide size as early as possible
2407
+ setSize({
2408
+ width: element.offsetWidth,
2409
+ height: element.offsetHeight
2410
+ });
2411
+ const resizeObserver = new ResizeObserver((entries)=>{
2412
+ if (!Array.isArray(entries)) return;
2413
+ // Since we only observe the one element, we don't need to loop over the
2414
+ // array
2415
+ if (!entries.length) return;
2416
+ const entry = entries[0];
2417
+ let width;
2418
+ let height;
2419
+ if ('borderBoxSize' in entry) {
2420
+ const borderSizeEntry = entry['borderBoxSize']; // iron out differences between browsers
2421
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
2422
+ width = borderSize['inlineSize'];
2423
+ height = borderSize['blockSize'];
2424
+ } else {
2425
+ // for browsers that don't support `borderBoxSize`
2426
+ // we calculate it ourselves to get the correct border box.
2427
+ width = element.offsetWidth;
2428
+ height = element.offsetHeight;
2429
+ }
2430
+ setSize({
2431
+ width: width,
2432
+ height: height
2433
+ });
2434
+ });
2435
+ resizeObserver.observe(element, {
2436
+ box: 'border-box'
2437
+ });
2438
+ return ()=>resizeObserver.unobserve(element)
2439
+ ;
2440
+ } else // We only want to reset to `undefined` when the element becomes `null`,
2441
+ // not if it changes to another element.
2442
+ setSize(undefined);
2443
+ }, [
2444
+ element
2445
+ ]);
2446
+ return size;
2447
+ }
2448
+
2449
+ /* -------------------------------------------------------------------------------------------------
2450
+ * Popper
2451
+ * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$POPPER_NAME = 'Popper';
2452
+ const [$cf1ac5d9fe0e8206$var$createPopperContext, $cf1ac5d9fe0e8206$export$722aac194ae923] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cf1ac5d9fe0e8206$var$POPPER_NAME);
2453
+ const [$cf1ac5d9fe0e8206$var$PopperProvider, $cf1ac5d9fe0e8206$var$usePopperContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$POPPER_NAME);
2454
+ const $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9 = (props)=>{
2455
+ const { __scopePopper: __scopePopper , children: children } = props;
2456
+ const [anchor, setAnchor] = useState(null);
2457
+ return /*#__PURE__*/ createElement($cf1ac5d9fe0e8206$var$PopperProvider, {
2458
+ scope: __scopePopper,
2459
+ anchor: anchor,
2460
+ onAnchorChange: setAnchor
2461
+ }, children);
2462
+ };
2463
+ /* -------------------------------------------------------------------------------------------------
2464
+ * PopperAnchor
2465
+ * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$ANCHOR_NAME = 'PopperAnchor';
2466
+ const $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2467
+ const { __scopePopper: __scopePopper , virtualRef: virtualRef , ...anchorProps } = props;
2468
+ const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$ANCHOR_NAME, __scopePopper);
2469
+ const ref = useRef(null);
2470
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
2471
+ useEffect(()=>{
2472
+ // Consumer can anchor the popper to something that isn't
2473
+ // a DOM node e.g. pointer position, so we override the
2474
+ // `anchorRef` with their virtual ref in this case.
2475
+ context.onAnchorChange((virtualRef === null || virtualRef === void 0 ? void 0 : virtualRef.current) || ref.current);
2476
+ });
2477
+ return virtualRef ? null : /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, anchorProps, {
2478
+ ref: composedRefs
2479
+ }));
2480
+ });
2481
+ /* -------------------------------------------------------------------------------------------------
2482
+ * PopperContent
2483
+ * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$CONTENT_NAME = 'PopperContent';
2484
+ const [$cf1ac5d9fe0e8206$var$PopperContentProvider, $cf1ac5d9fe0e8206$var$useContentContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME);
2485
+ const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2486
+ var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide;
2487
+ const { __scopePopper: __scopePopper , side: side = 'bottom' , sideOffset: sideOffset = 0 , align: align = 'center' , alignOffset: alignOffset = 0 , arrowPadding: arrowPadding = 0 , avoidCollisions: avoidCollisions = true , collisionBoundary: collisionBoundary = [] , collisionPadding: collisionPaddingProp = 0 , sticky: sticky = 'partial' , hideWhenDetached: hideWhenDetached = false , updatePositionStrategy: updatePositionStrategy = 'optimized' , onPlaced: onPlaced , ...contentProps } = props;
2488
+ const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME, __scopePopper);
2489
+ const [content, setContent] = useState(null);
2490
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
2491
+ );
2492
+ const [arrow$1, setArrow] = useState(null);
2493
+ const arrowSize = $db6c3485150b8e66$export$1ab7ae714698c4b8(arrow$1);
2494
+ const arrowWidth = (_arrowSize$width = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.width) !== null && _arrowSize$width !== void 0 ? _arrowSize$width : 0;
2495
+ const arrowHeight = (_arrowSize$height = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.height) !== null && _arrowSize$height !== void 0 ? _arrowSize$height : 0;
2496
+ const desiredPlacement = side + (align !== 'center' ? '-' + align : '');
2497
+ const collisionPadding = typeof collisionPaddingProp === 'number' ? collisionPaddingProp : {
2498
+ top: 0,
2499
+ right: 0,
2500
+ bottom: 0,
2501
+ left: 0,
2502
+ ...collisionPaddingProp
2503
+ };
2504
+ const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [
2505
+ collisionBoundary
2506
+ ];
2507
+ const hasExplicitBoundaries = boundary.length > 0;
2508
+ const detectOverflowOptions = {
2509
+ padding: collisionPadding,
2510
+ boundary: boundary.filter($cf1ac5d9fe0e8206$var$isNotNull),
2511
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
2512
+ altBoundary: hasExplicitBoundaries
2513
+ };
2514
+ const { refs: refs , floatingStyles: floatingStyles , placement: placement , isPositioned: isPositioned , middlewareData: middlewareData } = useFloating({
2515
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
2516
+ strategy: 'fixed',
2517
+ placement: desiredPlacement,
2518
+ whileElementsMounted: (...args)=>{
2519
+ const cleanup = autoUpdate(...args, {
2520
+ animationFrame: updatePositionStrategy === 'always'
2521
+ });
2522
+ return cleanup;
2523
+ },
2524
+ elements: {
2525
+ reference: context.anchor
2526
+ },
2527
+ middleware: [
2528
+ offset({
2529
+ mainAxis: sideOffset + arrowHeight,
2530
+ alignmentAxis: alignOffset
2531
+ }),
2532
+ avoidCollisions && shift({
2533
+ mainAxis: true,
2534
+ crossAxis: false,
2535
+ limiter: sticky === 'partial' ? limitShift() : undefined,
2536
+ ...detectOverflowOptions
2537
+ }),
2538
+ avoidCollisions && flip({
2539
+ ...detectOverflowOptions
2540
+ }),
2541
+ size({
2542
+ ...detectOverflowOptions,
2543
+ apply: ({ elements: elements , rects: rects , availableWidth: availableWidth , availableHeight: availableHeight })=>{
2544
+ const { width: anchorWidth , height: anchorHeight } = rects.reference;
2545
+ const contentStyle = elements.floating.style;
2546
+ contentStyle.setProperty('--radix-popper-available-width', `${availableWidth}px`);
2547
+ contentStyle.setProperty('--radix-popper-available-height', `${availableHeight}px`);
2548
+ contentStyle.setProperty('--radix-popper-anchor-width', `${anchorWidth}px`);
2549
+ contentStyle.setProperty('--radix-popper-anchor-height', `${anchorHeight}px`);
2550
+ }
2551
+ }),
2552
+ arrow$1 && arrow({
2553
+ element: arrow$1,
2554
+ padding: arrowPadding
2555
+ }),
2556
+ $cf1ac5d9fe0e8206$var$transformOrigin({
2557
+ arrowWidth: arrowWidth,
2558
+ arrowHeight: arrowHeight
2559
+ }),
2560
+ hideWhenDetached && hide({
2561
+ strategy: 'referenceHidden',
2562
+ ...detectOverflowOptions
2563
+ })
2564
+ ]
2565
+ });
2566
+ const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
2567
+ const handlePlaced = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPlaced);
2568
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2569
+ if (isPositioned) handlePlaced === null || handlePlaced === void 0 || handlePlaced();
2570
+ }, [
2571
+ isPositioned,
2572
+ handlePlaced
2573
+ ]);
2574
+ const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
2575
+ const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
2576
+ const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
2577
+ const [contentZIndex, setContentZIndex] = useState();
2578
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2579
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
640
2580
  }, [
641
- deterministicId
2581
+ content
642
2582
  ]);
643
- return deterministicId || (id ? `radix-${id}` : '');
2583
+ return /*#__PURE__*/ createElement("div", {
2584
+ ref: refs.setFloating,
2585
+ "data-radix-popper-content-wrapper": "",
2586
+ style: {
2587
+ ...floatingStyles,
2588
+ transform: isPositioned ? floatingStyles.transform : 'translate(0, -200%)',
2589
+ // keep off the page when measuring
2590
+ minWidth: 'max-content',
2591
+ zIndex: contentZIndex,
2592
+ ['--radix-popper-transform-origin']: [
2593
+ (_middlewareData$trans = middlewareData.transformOrigin) === null || _middlewareData$trans === void 0 ? void 0 : _middlewareData$trans.x,
2594
+ (_middlewareData$trans2 = middlewareData.transformOrigin) === null || _middlewareData$trans2 === void 0 ? void 0 : _middlewareData$trans2.y
2595
+ ].join(' ')
2596
+ } // Floating UI interally calculates logical alignment based the `dir` attribute on
2597
+ ,
2598
+ dir: props.dir
2599
+ }, /*#__PURE__*/ createElement($cf1ac5d9fe0e8206$var$PopperContentProvider, {
2600
+ scope: __scopePopper,
2601
+ placedSide: placedSide,
2602
+ onArrowChange: setArrow,
2603
+ arrowX: arrowX,
2604
+ arrowY: arrowY,
2605
+ shouldHideArrow: cannotCenterArrow
2606
+ }, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2607
+ "data-side": placedSide,
2608
+ "data-align": placedAlign
2609
+ }, contentProps, {
2610
+ ref: composedRefs,
2611
+ style: {
2612
+ ...contentProps.style,
2613
+ // if the PopperContent hasn't been placed yet (not all measurements done)
2614
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
2615
+ animation: !isPositioned ? 'none' : undefined,
2616
+ // hide the content if using the hide middleware and should be hidden
2617
+ opacity: (_middlewareData$hide = middlewareData.hide) !== null && _middlewareData$hide !== void 0 && _middlewareData$hide.referenceHidden ? 0 : undefined
2618
+ }
2619
+ }))));
2620
+ });
2621
+ /* -----------------------------------------------------------------------------------------------*/ function $cf1ac5d9fe0e8206$var$isNotNull(value) {
2622
+ return value !== null;
2623
+ }
2624
+ const $cf1ac5d9fe0e8206$var$transformOrigin = (options)=>({
2625
+ name: 'transformOrigin',
2626
+ options: options,
2627
+ fn (data) {
2628
+ var _middlewareData$arrow4, _middlewareData$arrow5, _middlewareData$arrow6, _middlewareData$arrow7, _middlewareData$arrow8;
2629
+ const { placement: placement , rects: rects , middlewareData: middlewareData } = data;
2630
+ const cannotCenterArrow = ((_middlewareData$arrow4 = middlewareData.arrow) === null || _middlewareData$arrow4 === void 0 ? void 0 : _middlewareData$arrow4.centerOffset) !== 0;
2631
+ const isArrowHidden = cannotCenterArrow;
2632
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
2633
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
2634
+ const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
2635
+ const noArrowAlign = {
2636
+ start: '0%',
2637
+ center: '50%',
2638
+ end: '100%'
2639
+ }[placedAlign];
2640
+ const arrowXCenter = ((_middlewareData$arrow5 = (_middlewareData$arrow6 = middlewareData.arrow) === null || _middlewareData$arrow6 === void 0 ? void 0 : _middlewareData$arrow6.x) !== null && _middlewareData$arrow5 !== void 0 ? _middlewareData$arrow5 : 0) + arrowWidth / 2;
2641
+ const arrowYCenter = ((_middlewareData$arrow7 = (_middlewareData$arrow8 = middlewareData.arrow) === null || _middlewareData$arrow8 === void 0 ? void 0 : _middlewareData$arrow8.y) !== null && _middlewareData$arrow7 !== void 0 ? _middlewareData$arrow7 : 0) + arrowHeight / 2;
2642
+ let x = '';
2643
+ let y = '';
2644
+ if (placedSide === 'bottom') {
2645
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2646
+ y = `${-arrowHeight}px`;
2647
+ } else if (placedSide === 'top') {
2648
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2649
+ y = `${rects.floating.height + arrowHeight}px`;
2650
+ } else if (placedSide === 'right') {
2651
+ x = `${-arrowHeight}px`;
2652
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2653
+ } else if (placedSide === 'left') {
2654
+ x = `${rects.floating.width + arrowHeight}px`;
2655
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2656
+ }
2657
+ return {
2658
+ data: {
2659
+ x: x,
2660
+ y: y
2661
+ }
2662
+ };
2663
+ }
2664
+ })
2665
+ ;
2666
+ function $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement) {
2667
+ const [side, align = 'center'] = placement.split('-');
2668
+ return [
2669
+ side,
2670
+ align
2671
+ ];
644
2672
  }
2673
+ const $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9 = $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9;
2674
+ const $cf1ac5d9fe0e8206$export$b688253958b8dfe7 = $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d;
2675
+ const $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2 = $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc;
645
2676
 
646
2677
  const $f1701beae083dbae$export$602eac185826482c = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
647
2678
  var _globalThis$document;
648
2679
  const { container: container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body , ...portalProps } = props;
649
- return container ? /*#__PURE__*/ $7SXl2$reactdom.createPortal(/*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, portalProps, {
2680
+ return container ? /*#__PURE__*/ $7SXl2$reactdom__default.createPortal(/*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, portalProps, {
650
2681
  ref: forwardedRef
651
2682
  })), container) : null;
652
2683
  });
653
2684
 
654
- const $ea1ef594cf570d83$export$439d29a4e110a164 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
655
- return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, props, {
656
- ref: forwardedRef,
657
- style: {
658
- // See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
659
- position: 'absolute',
660
- border: 0,
661
- width: 1,
662
- height: 1,
663
- padding: 0,
664
- margin: -1,
665
- overflow: 'hidden',
666
- clip: 'rect(0, 0, 0, 0)',
667
- whiteSpace: 'nowrap',
668
- wordWrap: 'normal',
669
- ...props.style
2685
+ function $010c2913dbd2fe3d$export$5cae361ad82dce8b(value) {
2686
+ const ref = useRef({
2687
+ value: value,
2688
+ previous: value
2689
+ }); // We compare values before making an update to ensure that
2690
+ // a change has been made. This ensures the previous value is
2691
+ // persisted correctly between renders.
2692
+ return useMemo(()=>{
2693
+ if (ref.current.value !== value) {
2694
+ ref.current.previous = ref.current.value;
2695
+ ref.current.value = value;
670
2696
  }
671
- }));
672
- });
2697
+ return ref.current.previous;
2698
+ }, [
2699
+ value
2700
+ ]);
2701
+ }
673
2702
 
674
2703
  const $cc7e05a45900e73f$var$OPEN_KEYS = [
675
2704
  ' ',
@@ -686,12 +2715,15 @@ const $cc7e05a45900e73f$var$SELECTION_KEYS = [
686
2715
  * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SELECT_NAME = 'Select';
687
2716
  const [$cc7e05a45900e73f$var$Collection, $cc7e05a45900e73f$var$useCollection, $cc7e05a45900e73f$var$createCollectionScope] = $e02a7d9cb1dc128c$export$c74125a8e3af6bb2($cc7e05a45900e73f$var$SELECT_NAME);
688
2717
  const [$cc7e05a45900e73f$var$createSelectContext, $cc7e05a45900e73f$export$286727a75dc039bd] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cc7e05a45900e73f$var$SELECT_NAME, [
689
- $cc7e05a45900e73f$var$createCollectionScope
2718
+ $cc7e05a45900e73f$var$createCollectionScope,
2719
+ $cf1ac5d9fe0e8206$export$722aac194ae923
690
2720
  ]);
2721
+ const $cc7e05a45900e73f$var$usePopperScope = $cf1ac5d9fe0e8206$export$722aac194ae923();
691
2722
  const [$cc7e05a45900e73f$var$SelectProvider, $cc7e05a45900e73f$var$useSelectContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
692
2723
  const [$cc7e05a45900e73f$var$SelectNativeOptionsProvider, $cc7e05a45900e73f$var$useSelectNativeOptionsContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
693
2724
  const $cc7e05a45900e73f$export$ef9b1a59e592288f = (props)=>{
694
2725
  const { __scopeSelect: __scopeSelect , children: children , open: openProp , defaultOpen: defaultOpen , onOpenChange: onOpenChange , value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange , dir: dir , name: name , autoComplete: autoComplete , disabled: disabled , required: required } = props;
2726
+ const popperScope = $cc7e05a45900e73f$var$usePopperScope(__scopeSelect);
695
2727
  const [trigger, setTrigger] = useState(null);
696
2728
  const [valueNode, setValueNode] = useState(null);
697
2729
  const [valueNodeHasChildren, setValueNodeHasChildren] = useState(false);
@@ -715,7 +2747,7 @@ const $cc7e05a45900e73f$export$ef9b1a59e592288f = (props)=>{
715
2747
  // each time the options change.
716
2748
  const nativeSelectKey = Array.from(nativeOptionsSet).map((option)=>option.props.value
717
2749
  ).join(';');
718
- return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectProvider, {
2750
+ return /*#__PURE__*/ createElement($cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9, popperScope, /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectProvider, {
719
2751
  required: required,
720
2752
  scope: __scopeSelect,
721
2753
  trigger: trigger,
@@ -761,13 +2793,14 @@ const $cc7e05a45900e73f$export$ef9b1a59e592288f = (props)=>{
761
2793
  disabled: disabled
762
2794
  }, value === undefined ? /*#__PURE__*/ createElement("option", {
763
2795
  value: ""
764
- }) : null, Array.from(nativeOptionsSet)) : null);
2796
+ }) : null, Array.from(nativeOptionsSet)) : null));
765
2797
  };
766
2798
  /* -------------------------------------------------------------------------------------------------
767
2799
  * SelectTrigger
768
2800
  * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$TRIGGER_NAME = 'SelectTrigger';
769
2801
  const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
770
2802
  const { __scopeSelect: __scopeSelect , disabled: disabled = false , ...triggerProps } = props;
2803
+ const popperScope = $cc7e05a45900e73f$var$usePopperScope(__scopeSelect);
771
2804
  const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$TRIGGER_NAME, __scopeSelect);
772
2805
  const isDisabled = context.disabled || disabled;
773
2806
  const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.onTriggerChange);
@@ -786,7 +2819,9 @@ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ forwardRef((props
786
2819
  resetTypeahead();
787
2820
  }
788
2821
  };
789
- return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
2822
+ return /*#__PURE__*/ createElement($cf1ac5d9fe0e8206$export$b688253958b8dfe7, _extends({
2823
+ asChild: true
2824
+ }, popperScope), /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
790
2825
  type: "button",
791
2826
  role: "combobox",
792
2827
  "aria-controls": context.contentId,
@@ -797,7 +2832,7 @@ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ forwardRef((props
797
2832
  "data-state": context.open ? 'open' : 'closed',
798
2833
  disabled: isDisabled,
799
2834
  "data-disabled": isDisabled ? '' : undefined,
800
- "data-placeholder": context.value === undefined ? '' : undefined
2835
+ "data-placeholder": $cc7e05a45900e73f$var$shouldShowPlaceholder(context.value) ? '' : undefined
801
2836
  }, triggerProps, {
802
2837
  ref: composedRefs // Enable compatibility with native label or custom `Label` "click" for Safari:
803
2838
  ,
@@ -835,14 +2870,14 @@ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ forwardRef((props
835
2870
  event.preventDefault();
836
2871
  }
837
2872
  })
838
- }));
2873
+ })));
839
2874
  });
840
2875
  /* -------------------------------------------------------------------------------------------------
841
2876
  * SelectValue
842
2877
  * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VALUE_NAME = 'SelectValue';
843
2878
  const $cc7e05a45900e73f$export$e288731fd71264f0 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
844
2879
  // We ignore `className` and `style` as this part shouldn't be styled.
845
- const { __scopeSelect: __scopeSelect , className: className , style: style , children: children , placeholder: placeholder , ...valueProps } = props;
2880
+ const { __scopeSelect: __scopeSelect , className: className , style: style , children: children , placeholder: placeholder = '' , ...valueProps } = props;
846
2881
  const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$VALUE_NAME, __scopeSelect);
847
2882
  const { onValueNodeHasChildrenChange: onValueNodeHasChildrenChange } = context;
848
2883
  const hasChildren = children !== undefined;
@@ -859,182 +2894,87 @@ const $cc7e05a45900e73f$export$e288731fd71264f0 = /*#__PURE__*/ forwardRef((prop
859
2894
  style: {
860
2895
  pointerEvents: 'none'
861
2896
  }
862
- }), context.value === undefined && placeholder !== undefined ? placeholder : children);
2897
+ }), $cc7e05a45900e73f$var$shouldShowPlaceholder(context.value) ? /*#__PURE__*/ createElement(Fragment, null, placeholder) : children);
863
2898
  });
864
2899
  const $cc7e05a45900e73f$export$99b400cabb58c515 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
865
- const { __scopeSelect: __scopeSelect , children: children , ...iconProps } = props;
866
- return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
867
- "aria-hidden": true
868
- }, iconProps, {
869
- ref: forwardedRef
870
- }), children || '▼');
871
- });
872
- const $cc7e05a45900e73f$export$b2af6c9944296213 = (props)=>{
873
- return /*#__PURE__*/ createElement($f1701beae083dbae$export$602eac185826482c, _extends({
874
- asChild: true
875
- }, props));
876
- };
877
- /* -------------------------------------------------------------------------------------------------
878
- * SelectContent
879
- * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$CONTENT_NAME = 'SelectContent';
880
- const $cc7e05a45900e73f$export$c973a4b3cb86a03d = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
881
- const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, props.__scopeSelect);
882
- const [fragment, setFragment] = useState(); // setting the fragment in `useLayoutEffect` as `DocumentFragment` doesn't exist on the server
883
- $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
884
- setFragment(new DocumentFragment());
885
- }, []);
886
- return /*#__PURE__*/ createElement(Fragment, null, context.open ? /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectContentImpl, _extends({}, props, {
887
- ref: forwardedRef
888
- })) : fragment ? /*#__PURE__*/ createPortal(/*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectContentProvider, {
889
- scope: props.__scopeSelect
890
- }, /*#__PURE__*/ createElement($cc7e05a45900e73f$var$Collection.Slot, {
891
- scope: props.__scopeSelect
892
- }, /*#__PURE__*/ createElement("div", null, props.children))), fragment) : null);
893
- });
894
- const $cc7e05a45900e73f$var$CONTENT_MARGIN = 10;
895
- const [$cc7e05a45900e73f$var$SelectContentProvider, $cc7e05a45900e73f$var$useSelectContentContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$CONTENT_NAME);
896
- const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
897
- const { __scopeSelect: __scopeSelect , onCloseAutoFocus: onCloseAutoFocus , ...contentProps } = props;
898
- const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
899
- const [contentWrapper, setContentWrapper] = useState(null);
900
- const [content, setContent] = useState(null);
901
- const [viewport, setViewport] = useState(null);
902
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
903
- );
904
- const [selectedItem, setSelectedItem] = useState(null);
905
- const [selectedItemText, setSelectedItemText] = useState(null);
906
- const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
907
- const [isPositioned, setIsPositioned] = useState(false);
908
- const shouldRepositionRef = useRef(true);
909
- const shouldExpandOnScrollRef = useRef(false);
910
- const firstValidItemFoundRef = useRef(false); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
911
- useEffect(()=>{
912
- if (content) return hideOthers(content);
913
- }, [
914
- content
915
- ]); // Make sure the whole tree has focus guards as our `Select` may be
916
- // the last element in the DOM (because of the `Portal`)
917
- $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
918
- const [contentZIndex, setContentZIndex] = useState();
919
- $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
920
- if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
921
- }, [
922
- content
923
- ]);
924
- const focusFirst = useCallback((candidates)=>{
925
- const [firstItem, ...restItems] = getItems().map((item)=>item.ref.current
926
- );
927
- const [lastItem] = restItems.slice(-1);
928
- const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
929
- for (const candidate of candidates){
930
- // if focus is already where we want to go, we don't want to keep going through the candidates
931
- if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
932
- candidate === null || candidate === void 0 || candidate.scrollIntoView({
933
- block: 'nearest'
934
- }); // viewport might have padding so scroll to its edges when focusing first/last items.
935
- if (candidate === firstItem && viewport) viewport.scrollTop = 0;
936
- if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
937
- candidate === null || candidate === void 0 || candidate.focus();
938
- if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
939
- }
940
- }, [
941
- getItems,
942
- viewport
943
- ]);
944
- const position = useCallback(()=>{
945
- if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
946
- const triggerRect = context.trigger.getBoundingClientRect(); // -----------------------------------------------------------------------------------------
947
- // Horizontal positioning
948
- // -----------------------------------------------------------------------------------------
949
- const contentRect = content.getBoundingClientRect();
950
- const valueNodeRect = context.valueNode.getBoundingClientRect();
951
- const itemTextRect = selectedItemText.getBoundingClientRect();
952
- if (context.dir !== 'rtl') {
953
- const itemTextOffset = itemTextRect.left - contentRect.left;
954
- const left = valueNodeRect.left - itemTextOffset;
955
- const leftDelta = triggerRect.left - left;
956
- const minContentWidth = triggerRect.width + leftDelta;
957
- const contentWidth = Math.max(minContentWidth, contentRect.width);
958
- const rightEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
959
- const clampedLeft = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(left, [
960
- $cc7e05a45900e73f$var$CONTENT_MARGIN,
961
- rightEdge - contentWidth
962
- ]);
963
- contentWrapper.style.minWidth = minContentWidth + 'px';
964
- contentWrapper.style.left = clampedLeft + 'px';
965
- } else {
966
- const itemTextOffset = contentRect.right - itemTextRect.right;
967
- const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
968
- const rightDelta = window.innerWidth - triggerRect.right - right;
969
- const minContentWidth = triggerRect.width + rightDelta;
970
- const contentWidth = Math.max(minContentWidth, contentRect.width);
971
- const leftEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
972
- const clampedRight = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(right, [
973
- $cc7e05a45900e73f$var$CONTENT_MARGIN,
974
- leftEdge - contentWidth
975
- ]);
976
- contentWrapper.style.minWidth = minContentWidth + 'px';
977
- contentWrapper.style.right = clampedRight + 'px';
978
- } // -----------------------------------------------------------------------------------------
979
- // Vertical positioning
980
- // -----------------------------------------------------------------------------------------
981
- const items = getItems();
982
- const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
983
- const itemsHeight = viewport.scrollHeight;
984
- const contentStyles = window.getComputedStyle(content);
985
- const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
986
- const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
987
- const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
988
- const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
989
- const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth; // prettier-ignore
990
- const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
991
- const viewportStyles = window.getComputedStyle(viewport);
992
- const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
993
- const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
994
- const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - $cc7e05a45900e73f$var$CONTENT_MARGIN;
995
- const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
996
- const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
997
- const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
998
- const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
999
- const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
1000
- const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
1001
- if (willAlignWithoutTopOverflow) {
1002
- const isLastItem = selectedItem === items[items.length - 1].ref.current;
1003
- contentWrapper.style.bottom = "0px";
1004
- const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
1005
- const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
1006
- const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
1007
- contentWrapper.style.height = height + 'px';
1008
- } else {
1009
- const isFirstItem = selectedItem === items[0].ref.current;
1010
- contentWrapper.style.top = "0px";
1011
- const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
1012
- const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
1013
- contentWrapper.style.height = height + 'px';
1014
- viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
1015
- }
1016
- contentWrapper.style.margin = `${$cc7e05a45900e73f$var$CONTENT_MARGIN}px 0`;
1017
- contentWrapper.style.minHeight = minContentHeight + 'px';
1018
- contentWrapper.style.maxHeight = availableHeight + 'px'; // -----------------------------------------------------------------------------------------
1019
- setIsPositioned(true); // we don't want the initial scroll position adjustment to trigger "expand on scroll"
1020
- // so we explicitly turn it on only after they've registered.
1021
- requestAnimationFrame(()=>shouldExpandOnScrollRef.current = true
1022
- );
2900
+ const { __scopeSelect: __scopeSelect , children: children , ...iconProps } = props;
2901
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
2902
+ "aria-hidden": true
2903
+ }, iconProps, {
2904
+ ref: forwardedRef
2905
+ }), children || '▼');
2906
+ });
2907
+ const $cc7e05a45900e73f$export$b2af6c9944296213 = (props)=>{
2908
+ return /*#__PURE__*/ createElement($f1701beae083dbae$export$602eac185826482c, _extends({
2909
+ asChild: true
2910
+ }, props));
2911
+ };
2912
+ /* -------------------------------------------------------------------------------------------------
2913
+ * SelectContent
2914
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$CONTENT_NAME = 'SelectContent';
2915
+ const $cc7e05a45900e73f$export$c973a4b3cb86a03d = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2916
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, props.__scopeSelect);
2917
+ const [fragment, setFragment] = useState(); // setting the fragment in `useLayoutEffect` as `DocumentFragment` doesn't exist on the server
2918
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2919
+ setFragment(new DocumentFragment());
2920
+ }, []);
2921
+ if (!context.open) {
2922
+ const frag = fragment;
2923
+ return frag ? /*#__PURE__*/ createPortal(/*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectContentProvider, {
2924
+ scope: props.__scopeSelect
2925
+ }, /*#__PURE__*/ createElement($cc7e05a45900e73f$var$Collection.Slot, {
2926
+ scope: props.__scopeSelect
2927
+ }, /*#__PURE__*/ createElement("div", null, props.children))), frag) : null;
2928
+ }
2929
+ return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectContentImpl, _extends({}, props, {
2930
+ ref: forwardedRef
2931
+ }));
2932
+ });
2933
+ /* -------------------------------------------------------------------------------------------------
2934
+ * SelectContentImpl
2935
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$CONTENT_MARGIN = 10;
2936
+ const [$cc7e05a45900e73f$var$SelectContentProvider, $cc7e05a45900e73f$var$useSelectContentContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$CONTENT_NAME);
2937
+ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2938
+ const { __scopeSelect: __scopeSelect , position: position = 'item-aligned' , onCloseAutoFocus: onCloseAutoFocus , onEscapeKeyDown: onEscapeKeyDown , onPointerDownOutside: onPointerDownOutside , side: //
2939
+ // PopperContent props
2940
+ side , sideOffset: sideOffset , align: align , alignOffset: alignOffset , arrowPadding: arrowPadding , collisionBoundary: collisionBoundary , collisionPadding: collisionPadding , sticky: sticky , hideWhenDetached: hideWhenDetached , avoidCollisions: avoidCollisions , //
2941
+ ...contentProps } = props;
2942
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
2943
+ const [content, setContent] = useState(null);
2944
+ const [viewport, setViewport] = useState(null);
2945
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
2946
+ );
2947
+ const [selectedItem, setSelectedItem] = useState(null);
2948
+ const [selectedItemText, setSelectedItemText] = useState(null);
2949
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
2950
+ const [isPositioned, setIsPositioned] = useState(false);
2951
+ const firstValidItemFoundRef = useRef(false); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
2952
+ useEffect(()=>{
2953
+ if (content) return hideOthers(content);
2954
+ }, [
2955
+ content
2956
+ ]); // Make sure the whole tree has focus guards as our `Select` may be
2957
+ // the last element in the DOM (because of the `Portal`)
2958
+ $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
2959
+ const focusFirst = useCallback((candidates)=>{
2960
+ const [firstItem, ...restItems] = getItems().map((item)=>item.ref.current
2961
+ );
2962
+ const [lastItem] = restItems.slice(-1);
2963
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
2964
+ for (const candidate of candidates){
2965
+ // if focus is already where we want to go, we don't want to keep going through the candidates
2966
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
2967
+ candidate === null || candidate === void 0 || candidate.scrollIntoView({
2968
+ block: 'nearest'
2969
+ }); // viewport might have padding so scroll to its edges when focusing first/last items.
2970
+ if (candidate === firstItem && viewport) viewport.scrollTop = 0;
2971
+ if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
2972
+ candidate === null || candidate === void 0 || candidate.focus();
2973
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
1023
2974
  }
1024
2975
  }, [
1025
2976
  getItems,
1026
- context.trigger,
1027
- context.valueNode,
1028
- contentWrapper,
1029
- content,
1030
- viewport,
1031
- selectedItem,
1032
- selectedItemText,
1033
- context.dir
1034
- ]);
1035
- $9f79659886946c16$export$e5c5a5f917a5871c(()=>position()
1036
- , [
1037
- position
2977
+ viewport
1038
2978
  ]);
1039
2979
  const focusSelectedItem = useCallback(()=>focusFirst([
1040
2980
  selectedItem,
@@ -1051,19 +2991,6 @@ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ forwardRef((props,
1051
2991
  }, [
1052
2992
  isPositioned,
1053
2993
  focusSelectedItem
1054
- ]); // When the viewport becomes scrollable at the top, the scroll up button will mount.
1055
- // Because it is part of the normal flow, it will push down the viewport, thus throwing our
1056
- // trigger => selectedItem alignment off by the amount the viewport was pushed down.
1057
- // We wait for this to happen and then re-run the positining logic one more time to account for it.
1058
- const handleScrollButtonChange = useCallback((node)=>{
1059
- if (node && shouldRepositionRef.current === true) {
1060
- position();
1061
- focusSelectedItem();
1062
- shouldRepositionRef.current = false;
1063
- }
1064
- }, [
1065
- position,
1066
- focusSelectedItem
1067
2994
  ]); // prevent selecting items on `pointerup` in some cases after opening from `pointerdown`
1068
2995
  // and close on `pointerup` outside.
1069
2996
  const { onOpenChange: onOpenChange , triggerPointerDownPosRef: triggerPointerDownPosRef } = context;
@@ -1152,9 +3079,21 @@ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ forwardRef((props,
1152
3079
  }, [
1153
3080
  context.value
1154
3081
  ]);
3082
+ const SelectPosition = position === 'popper' ? $cc7e05a45900e73f$var$SelectPopperPosition : $cc7e05a45900e73f$var$SelectItemAlignedPosition; // Silently ignore props that are not supported by `SelectItemAlignedPosition`
3083
+ const popperContentProps = SelectPosition === $cc7e05a45900e73f$var$SelectPopperPosition ? {
3084
+ side: side,
3085
+ sideOffset: sideOffset,
3086
+ align: align,
3087
+ alignOffset: alignOffset,
3088
+ arrowPadding: arrowPadding,
3089
+ collisionBoundary: collisionBoundary,
3090
+ collisionPadding: collisionPadding,
3091
+ sticky: sticky,
3092
+ hideWhenDetached: hideWhenDetached,
3093
+ avoidCollisions: avoidCollisions
3094
+ } : {};
1155
3095
  return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectContentProvider, {
1156
3096
  scope: __scopeSelect,
1157
- contentWrapper: contentWrapper,
1158
3097
  content: content,
1159
3098
  viewport: viewport,
1160
3099
  onViewportChange: setViewport,
@@ -1162,22 +3101,14 @@ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ forwardRef((props,
1162
3101
  selectedItem: selectedItem,
1163
3102
  onItemLeave: handleItemLeave,
1164
3103
  itemTextRefCallback: itemTextRefCallback,
3104
+ focusSelectedItem: focusSelectedItem,
1165
3105
  selectedItemText: selectedItemText,
1166
- onScrollButtonChange: handleScrollButtonChange,
3106
+ position: position,
1167
3107
  isPositioned: isPositioned,
1168
- shouldExpandOnScrollRef: shouldExpandOnScrollRef,
1169
3108
  searchRef: searchRef
1170
3109
  }, /*#__PURE__*/ createElement($01b9c$RemoveScroll, {
1171
3110
  as: $5e63c961fc1ce211$export$8c6ed5c666ac1360,
1172
3111
  allowPinchZoom: true
1173
- }, /*#__PURE__*/ createElement("div", {
1174
- ref: setContentWrapper,
1175
- style: {
1176
- display: 'flex',
1177
- flexDirection: 'column',
1178
- position: 'fixed',
1179
- zIndex: contentZIndex
1180
- }
1181
3112
  }, /*#__PURE__*/ createElement($d3863c46a17e8a28$export$20e40289641fbbb6, {
1182
3113
  asChild: true // we make sure we're not trapping once it's been closed
1183
3114
  ,
@@ -1193,30 +3124,33 @@ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ forwardRef((props,
1193
3124
  });
1194
3125
  event.preventDefault();
1195
3126
  })
1196
- }, /*#__PURE__*/ createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, _extends({
3127
+ }, /*#__PURE__*/ createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, {
3128
+ asChild: true,
3129
+ disableOutsidePointerEvents: true,
3130
+ onEscapeKeyDown: onEscapeKeyDown,
3131
+ onPointerDownOutside: onPointerDownOutside // When focus is trapped, a focusout event may still happen.
3132
+ ,
3133
+ onFocusOutside: (event)=>event.preventDefault()
3134
+ ,
3135
+ onDismiss: ()=>context.onOpenChange(false)
3136
+ }, /*#__PURE__*/ createElement(SelectPosition, _extends({
1197
3137
  role: "listbox",
1198
3138
  id: context.contentId,
1199
3139
  "data-state": context.open ? 'open' : 'closed',
1200
3140
  dir: context.dir,
1201
3141
  onContextMenu: (event)=>event.preventDefault()
1202
- }, contentProps, {
3142
+ }, contentProps, popperContentProps, {
3143
+ onPlaced: ()=>setIsPositioned(true)
3144
+ ,
1203
3145
  ref: composedRefs,
1204
3146
  style: {
3147
+ // flex layout so we can place the scroll buttons properly
1205
3148
  display: 'flex',
1206
3149
  flexDirection: 'column',
1207
- // When we get the height of the content, it includes borders. If we were to set
1208
- // the height without having `boxSizing: 'border-box'` it would be too big.
1209
- boxSizing: 'border-box',
1210
- maxHeight: '100%',
3150
+ // reset the outline by default as the content MAY get focused
1211
3151
  outline: 'none',
1212
3152
  ...contentProps.style
1213
3153
  },
1214
- disableOutsidePointerEvents: true // When focus is trapped, a focusout event may still happen.
1215
- ,
1216
- onFocusOutside: (event)=>event.preventDefault()
1217
- ,
1218
- onDismiss: ()=>context.onOpenChange(false)
1219
- ,
1220
3154
  onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(contentProps.onKeyDown, (event)=>{
1221
3155
  const isModifierKey = event.ctrlKey || event.altKey || event.metaKey; // select should not be navigated using tab key so we prevent it
1222
3156
  if (event.key === 'Tab') event.preventDefault();
@@ -1253,12 +3187,185 @@ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ forwardRef((props,
1253
3187
  })
1254
3188
  }))))));
1255
3189
  });
3190
+ const $cc7e05a45900e73f$var$SelectItemAlignedPosition = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
3191
+ const { __scopeSelect: __scopeSelect , onPlaced: onPlaced , ...popperProps } = props;
3192
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
3193
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
3194
+ const [contentWrapper, setContentWrapper] = useState(null);
3195
+ const [content, setContent] = useState(null);
3196
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
3197
+ );
3198
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
3199
+ const shouldExpandOnScrollRef = useRef(false);
3200
+ const shouldRepositionRef = useRef(true);
3201
+ const { viewport: viewport , selectedItem: selectedItem , selectedItemText: selectedItemText , focusSelectedItem: focusSelectedItem } = contentContext;
3202
+ const position = useCallback(()=>{
3203
+ if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
3204
+ const triggerRect = context.trigger.getBoundingClientRect(); // -----------------------------------------------------------------------------------------
3205
+ // Horizontal positioning
3206
+ // -----------------------------------------------------------------------------------------
3207
+ const contentRect = content.getBoundingClientRect();
3208
+ const valueNodeRect = context.valueNode.getBoundingClientRect();
3209
+ const itemTextRect = selectedItemText.getBoundingClientRect();
3210
+ if (context.dir !== 'rtl') {
3211
+ const itemTextOffset = itemTextRect.left - contentRect.left;
3212
+ const left = valueNodeRect.left - itemTextOffset;
3213
+ const leftDelta = triggerRect.left - left;
3214
+ const minContentWidth = triggerRect.width + leftDelta;
3215
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
3216
+ const rightEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
3217
+ const clampedLeft = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(left, [
3218
+ $cc7e05a45900e73f$var$CONTENT_MARGIN,
3219
+ rightEdge - contentWidth
3220
+ ]);
3221
+ contentWrapper.style.minWidth = minContentWidth + 'px';
3222
+ contentWrapper.style.left = clampedLeft + 'px';
3223
+ } else {
3224
+ const itemTextOffset = contentRect.right - itemTextRect.right;
3225
+ const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
3226
+ const rightDelta = window.innerWidth - triggerRect.right - right;
3227
+ const minContentWidth = triggerRect.width + rightDelta;
3228
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
3229
+ const leftEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
3230
+ const clampedRight = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(right, [
3231
+ $cc7e05a45900e73f$var$CONTENT_MARGIN,
3232
+ leftEdge - contentWidth
3233
+ ]);
3234
+ contentWrapper.style.minWidth = minContentWidth + 'px';
3235
+ contentWrapper.style.right = clampedRight + 'px';
3236
+ } // -----------------------------------------------------------------------------------------
3237
+ // Vertical positioning
3238
+ // -----------------------------------------------------------------------------------------
3239
+ const items = getItems();
3240
+ const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
3241
+ const itemsHeight = viewport.scrollHeight;
3242
+ const contentStyles = window.getComputedStyle(content);
3243
+ const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
3244
+ const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
3245
+ const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
3246
+ const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
3247
+ const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth; // prettier-ignore
3248
+ const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
3249
+ const viewportStyles = window.getComputedStyle(viewport);
3250
+ const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
3251
+ const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
3252
+ const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - $cc7e05a45900e73f$var$CONTENT_MARGIN;
3253
+ const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
3254
+ const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
3255
+ const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
3256
+ const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
3257
+ const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
3258
+ const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
3259
+ if (willAlignWithoutTopOverflow) {
3260
+ const isLastItem = selectedItem === items[items.length - 1].ref.current;
3261
+ contentWrapper.style.bottom = "0px";
3262
+ const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
3263
+ const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
3264
+ const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
3265
+ contentWrapper.style.height = height + 'px';
3266
+ } else {
3267
+ const isFirstItem = selectedItem === items[0].ref.current;
3268
+ contentWrapper.style.top = "0px";
3269
+ const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
3270
+ const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
3271
+ contentWrapper.style.height = height + 'px';
3272
+ viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
3273
+ }
3274
+ contentWrapper.style.margin = `${$cc7e05a45900e73f$var$CONTENT_MARGIN}px 0`;
3275
+ contentWrapper.style.minHeight = minContentHeight + 'px';
3276
+ contentWrapper.style.maxHeight = availableHeight + 'px'; // -----------------------------------------------------------------------------------------
3277
+ onPlaced === null || onPlaced === void 0 || onPlaced(); // we don't want the initial scroll position adjustment to trigger "expand on scroll"
3278
+ // so we explicitly turn it on only after they've registered.
3279
+ requestAnimationFrame(()=>shouldExpandOnScrollRef.current = true
3280
+ );
3281
+ }
3282
+ }, [
3283
+ getItems,
3284
+ context.trigger,
3285
+ context.valueNode,
3286
+ contentWrapper,
3287
+ content,
3288
+ viewport,
3289
+ selectedItem,
3290
+ selectedItemText,
3291
+ context.dir,
3292
+ onPlaced
3293
+ ]);
3294
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>position()
3295
+ , [
3296
+ position
3297
+ ]); // copy z-index from content to wrapper
3298
+ const [contentZIndex, setContentZIndex] = useState();
3299
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
3300
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
3301
+ }, [
3302
+ content
3303
+ ]); // When the viewport becomes scrollable at the top, the scroll up button will mount.
3304
+ // Because it is part of the normal flow, it will push down the viewport, thus throwing our
3305
+ // trigger => selectedItem alignment off by the amount the viewport was pushed down.
3306
+ // We wait for this to happen and then re-run the positining logic one more time to account for it.
3307
+ const handleScrollButtonChange = useCallback((node)=>{
3308
+ if (node && shouldRepositionRef.current === true) {
3309
+ position();
3310
+ focusSelectedItem === null || focusSelectedItem === void 0 || focusSelectedItem();
3311
+ shouldRepositionRef.current = false;
3312
+ }
3313
+ }, [
3314
+ position,
3315
+ focusSelectedItem
3316
+ ]);
3317
+ return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectViewportProvider, {
3318
+ scope: __scopeSelect,
3319
+ contentWrapper: contentWrapper,
3320
+ shouldExpandOnScrollRef: shouldExpandOnScrollRef,
3321
+ onScrollButtonChange: handleScrollButtonChange
3322
+ }, /*#__PURE__*/ createElement("div", {
3323
+ ref: setContentWrapper,
3324
+ style: {
3325
+ display: 'flex',
3326
+ flexDirection: 'column',
3327
+ position: 'fixed',
3328
+ zIndex: contentZIndex
3329
+ }
3330
+ }, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, popperProps, {
3331
+ ref: composedRefs,
3332
+ style: {
3333
+ // When we get the height of the content, it includes borders. If we were to set
3334
+ // the height without having `boxSizing: 'border-box'` it would be too big.
3335
+ boxSizing: 'border-box',
3336
+ // We need to ensure the content doesn't get taller than the wrapper
3337
+ maxHeight: '100%',
3338
+ ...popperProps.style
3339
+ }
3340
+ }))));
3341
+ });
3342
+ const $cc7e05a45900e73f$var$SelectPopperPosition = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
3343
+ const { __scopeSelect: __scopeSelect , align: align = 'start' , collisionPadding: collisionPadding = $cc7e05a45900e73f$var$CONTENT_MARGIN , ...popperProps } = props;
3344
+ const popperScope = $cc7e05a45900e73f$var$usePopperScope(__scopeSelect);
3345
+ return /*#__PURE__*/ createElement($cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2, _extends({}, popperScope, popperProps, {
3346
+ ref: forwardedRef,
3347
+ align: align,
3348
+ collisionPadding: collisionPadding,
3349
+ style: {
3350
+ // Ensure border-box for floating-ui calculations
3351
+ boxSizing: 'border-box',
3352
+ ...popperProps.style,
3353
+ '--radix-select-content-transform-origin': 'var(--radix-popper-transform-origin)',
3354
+ '--radix-select-content-available-width': 'var(--radix-popper-available-width)',
3355
+ '--radix-select-content-available-height': 'var(--radix-popper-available-height)',
3356
+ '--radix-select-trigger-width': 'var(--radix-popper-anchor-width)',
3357
+ '--radix-select-trigger-height': 'var(--radix-popper-anchor-height)'
3358
+ }
3359
+ }));
3360
+ });
1256
3361
  /* -------------------------------------------------------------------------------------------------
1257
3362
  * SelectViewport
1258
- * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VIEWPORT_NAME = 'SelectViewport';
3363
+ * -----------------------------------------------------------------------------------------------*/ const [$cc7e05a45900e73f$var$SelectViewportProvider, $cc7e05a45900e73f$var$useSelectViewportContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, {});
3364
+ const $cc7e05a45900e73f$var$VIEWPORT_NAME = 'SelectViewport';
1259
3365
  const $cc7e05a45900e73f$export$9ed6e7b40248d36d = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1260
3366
  const { __scopeSelect: __scopeSelect , ...viewportProps } = props;
1261
3367
  const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$VIEWPORT_NAME, __scopeSelect);
3368
+ const viewportContext = $cc7e05a45900e73f$var$useSelectViewportContext($cc7e05a45900e73f$var$VIEWPORT_NAME, __scopeSelect);
1262
3369
  const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onViewportChange);
1263
3370
  const prevScrollTopRef = useRef(0);
1264
3371
  return /*#__PURE__*/ createElement(Fragment, null, /*#__PURE__*/ createElement("style", {
@@ -1283,7 +3390,7 @@ const $cc7e05a45900e73f$export$9ed6e7b40248d36d = /*#__PURE__*/ forwardRef((prop
1283
3390
  },
1284
3391
  onScroll: $e42e1063c40fb3ef$export$b9ecd428b558ff10(viewportProps.onScroll, (event)=>{
1285
3392
  const viewport = event.currentTarget;
1286
- const { contentWrapper: contentWrapper , shouldExpandOnScrollRef: shouldExpandOnScrollRef } = contentContext;
3393
+ const { contentWrapper: contentWrapper , shouldExpandOnScrollRef: shouldExpandOnScrollRef } = viewportContext;
1287
3394
  if (shouldExpandOnScrollRef !== null && shouldExpandOnScrollRef !== void 0 && shouldExpandOnScrollRef.current && contentWrapper) {
1288
3395
  const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
1289
3396
  if (scrolledBy > 0) {
@@ -1333,6 +3440,7 @@ const $cc7e05a45900e73f$export$13ef48a934230896 = /*#__PURE__*/ forwardRef((prop
1333
3440
  context.onOpenChange(false);
1334
3441
  }
1335
3442
  };
3443
+ if (value === '') throw new Error('A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.');
1336
3444
  return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectItemContextProvider, {
1337
3445
  scope: __scopeSelect,
1338
3446
  value: value,
@@ -1452,8 +3560,9 @@ const $cc7e05a45900e73f$export$6b9198de19accfe6 = /*#__PURE__*/ forwardRef((prop
1452
3560
  * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton';
1453
3561
  const $cc7e05a45900e73f$export$d8117927658af6d7 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1454
3562
  const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
3563
+ const viewportContext = $cc7e05a45900e73f$var$useSelectViewportContext($cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
1455
3564
  const [canScrollUp1, setCanScrollUp] = useState(false);
1456
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onScrollButtonChange);
3565
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, viewportContext.onScrollButtonChange);
1457
3566
  $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
1458
3567
  if (contentContext.viewport && contentContext.isPositioned) {
1459
3568
  const viewport = contentContext.viewport;
@@ -1483,8 +3592,9 @@ const $cc7e05a45900e73f$export$d8117927658af6d7 = /*#__PURE__*/ forwardRef((prop
1483
3592
  * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton';
1484
3593
  const $cc7e05a45900e73f$export$ff951e476c12189 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1485
3594
  const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
3595
+ const viewportContext = $cc7e05a45900e73f$var$useSelectViewportContext($cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
1486
3596
  const [canScrollDown1, setCanScrollDown] = useState(false);
1487
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onScrollButtonChange);
3597
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, viewportContext.onScrollButtonChange);
1488
3598
  $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
1489
3599
  if (contentContext.viewport && contentContext.isPositioned) {
1490
3600
  const viewport = contentContext.viewport;
@@ -1549,6 +3659,9 @@ const $cc7e05a45900e73f$var$SelectScrollButtonImpl = /*#__PURE__*/ forwardRef((p
1549
3659
  flexShrink: 0,
1550
3660
  ...scrollIndicatorProps.style
1551
3661
  },
3662
+ onPointerDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerDown, ()=>{
3663
+ if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
3664
+ }),
1552
3665
  onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerMove, ()=>{
1553
3666
  var _contentContext$onIte3;
1554
3667
  (_contentContext$onIte3 = contentContext.onItemLeave) === null || _contentContext$onIte3 === void 0 || _contentContext$onIte3.call(contentContext);
@@ -1559,7 +3672,10 @@ const $cc7e05a45900e73f$var$SelectScrollButtonImpl = /*#__PURE__*/ forwardRef((p
1559
3672
  })
1560
3673
  }));
1561
3674
  });
1562
- /* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$BubbleSelect = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
3675
+ /* -----------------------------------------------------------------------------------------------*/ function $cc7e05a45900e73f$var$shouldShowPlaceholder(value) {
3676
+ return value === '' || value === undefined;
3677
+ }
3678
+ const $cc7e05a45900e73f$var$BubbleSelect = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1563
3679
  const { value: value , ...selectProps } = props;
1564
3680
  const ref = useRef(null);
1565
3681
  const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
@@ -1698,7 +3814,7 @@ const BtIconChevronUp2Px = (props) =>
1698
3814
  /** Use `Select` to choose from a dropdown list of options. */
1699
3815
  var Select = function (_a) {
1700
3816
  var _b;
1701
- var isRequired = _a.isRequired, isDisabled = _a.isDisabled, placeholder = _a.placeholder, label = _a.label, _c = _a.ariaLabel, ariaLabel = _c === void 0 ? label : _c, options = _a.options, onOpenChange = _a.onOpenChange, isDefaultOpen = _a.isDefaultOpen, defaultValue = _a.defaultValue, errorMessage = _a.errorMessage, labelSize = _a.labelSize, helper = _a.helper, name = _a.name, isFluid = _a.isFluid, onBlur = _a.onBlur, onChange = _a.onChange, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure, _d = _a.selectSize, selectSize = _d === void 0 ? "m" : _d, props = __rest(_a, ["isRequired", "isDisabled", "placeholder", "label", "ariaLabel", "options", "onOpenChange", "isDefaultOpen", "defaultValue", "errorMessage", "labelSize", "helper", "name", "isFluid", "onBlur", "onChange", "disclosureTitle", "disclosureText", "onClickDisclosure", "selectSize"]);
3817
+ var isRequired = _a.isRequired, isDisabled = _a.isDisabled, placeholder = _a.placeholder, label = _a.label, _c = _a.ariaLabel, ariaLabel = _c === void 0 ? label : _c, options = _a.options, onOpenChange = _a.onOpenChange, isDefaultOpen = _a.isDefaultOpen, defaultValue = _a.defaultValue, errorMessage = _a.errorMessage, labelSize = _a.labelSize, helper = _a.helper, name = _a.name, width = _a.width, isFluid = _a.isFluid, onBlur = _a.onBlur, onChange = _a.onChange, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure, _d = _a.selectSize, selectSize = _d === void 0 ? "m" : _d, props = __rest(_a, ["isRequired", "isDisabled", "placeholder", "label", "ariaLabel", "options", "onOpenChange", "isDefaultOpen", "defaultValue", "errorMessage", "labelSize", "helper", "name", "width", "isFluid", "onBlur", "onChange", "disclosureTitle", "disclosureText", "onClickDisclosure", "selectSize"]);
1702
3818
  var id = useId();
1703
3819
  var arcRootElement = useContext(ArcRootElementContext);
1704
3820
  var surface = useContext(Context).surface;
@@ -1723,33 +3839,34 @@ var Select = function (_a) {
1723
3839
  };
1724
3840
  return (React__default.createElement(FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, label: label, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", isDisabled: isDisabled, disclosureText: disclosureText, disclosureTitle: disclosureTitle, onClickDisclosure: onClickDisclosure },
1725
3841
  React__default.createElement($cc7e05a45900e73f$export$be92b6f5f03c0fe9, { name: name, required: isRequired, disabled: isDisabled, defaultOpen: isDefaultOpen, value: selectedValue, onOpenChange: onOpenChange, onValueChange: function (value) { return onValueChange(value); } },
1726
- React__default.createElement($cc7e05a45900e73f$export$41fb9f06171c75f4, __assign({ id: id, name: name, onBlur: onBlur, "aria-label": ariaLabel, className: classNames("arc-Select-trigger", (_b = {
1727
- "arc-Select-trigger--constrained": !isFluid,
1728
- "arc-Select-trigger--onDarkSurface": surface === "dark",
1729
- "arc-Select-trigger--invalid": errorMessage
1730
- },
1731
- _b["arc-Select-trigger--size".concat(selectSize && selectSize.toUpperCase())] = selectSize && selectSize !== "m",
1732
- _b)) }, filterDataAttrs(props)),
1733
- React__default.createElement($cc7e05a45900e73f$export$4c8d1a57a761ef94, { asChild: true, "aria-label": getSelectedValueName(selectedValue) }, !selectedValue ? (React__default.createElement("span", { "aria-hidden": true, className: "arc-Select-placeHolder" }, placeholder)) : (React__default.createElement("span", { className: "arc-Select-valueItem" }, getSelectedValueName(selectedValue)))),
1734
- React__default.createElement($cc7e05a45900e73f$export$f04a61298a47a40f, { className: "arc-Select-triggerIcon" },
1735
- React__default.createElement(Icon, { icon: BtIconChevronDown2Px, size: getIconSize(selectSize) }))),
1736
- React__default.createElement($cc7e05a45900e73f$export$602eac185826482c, { container: arcRootElement || undefined },
1737
- React__default.createElement($cc7e05a45900e73f$export$7c6e2c02157bb7d2, { className: classNames("arc-Select-content", {
1738
- "arc-Select-content--onDarkSurface": surface === "dark"
1739
- }) },
1740
- React__default.createElement($cc7e05a45900e73f$export$2f60d3ec9ad468f2, { className: "arc-Select-scrollButton" },
1741
- React__default.createElement(Icon, { icon: BtIconChevronUp2Px, size: 16 })),
1742
- React__default.createElement($cc7e05a45900e73f$export$d5c6c08dc2d3ca7, null, options.map(function (_a, i) {
1743
- var name = _a.name, value = _a.value;
1744
- return (React__default.createElement($cc7e05a45900e73f$export$6d08773d2e66f8f2, { className: "arc-Select-item", key: "select-item-".concat(i), value: value },
1745
- React__default.createElement("div", { className: "arc-Select-itemTextWrapper" },
1746
- React__default.createElement($cc7e05a45900e73f$export$d6e5bf9c43ea9319, { asChild: true },
1747
- React__default.createElement("span", { className: "arc-Select-itemText" }, name))),
1748
- React__default.createElement($cc7e05a45900e73f$export$c3468e2714d175fa, null,
1749
- React__default.createElement(Icon, { icon: BtIconTickAlt2Px, size: 20 }))));
1750
- })),
1751
- React__default.createElement($cc7e05a45900e73f$export$bf1aedc3039c8d63, { className: "arc-Select-scrollButton" },
1752
- React__default.createElement(Icon, { icon: BtIconChevronDown2Px, size: 16 })))))));
3842
+ React__default.createElement("div", { className: "arc-Select-wrapper" },
3843
+ React__default.createElement($cc7e05a45900e73f$export$41fb9f06171c75f4, __assign({ id: id, name: name, onBlur: onBlur, "aria-label": ariaLabel, style: { width: width }, className: classNames("arc-Select-trigger", (_b = {
3844
+ "arc-Select-trigger--constrained": !isFluid,
3845
+ "arc-Select-trigger--onDarkSurface": surface === "dark",
3846
+ "arc-Select-trigger--invalid": errorMessage
3847
+ },
3848
+ _b["arc-Select-trigger--size".concat(selectSize && selectSize.toUpperCase())] = selectSize && selectSize !== "m",
3849
+ _b)) }, filterDataAttrs(props)),
3850
+ React__default.createElement($cc7e05a45900e73f$export$4c8d1a57a761ef94, { className: "arc-Select-triggerText", placeholder: placeholder, "aria-label": getSelectedValueName(selectedValue) }),
3851
+ React__default.createElement($cc7e05a45900e73f$export$f04a61298a47a40f, { className: "arc-Select-triggerIcon" },
3852
+ React__default.createElement(Icon, { icon: BtIconChevronDown2Px, size: getIconSize(selectSize) }))),
3853
+ React__default.createElement($cc7e05a45900e73f$export$602eac185826482c, { container: arcRootElement || undefined },
3854
+ React__default.createElement($cc7e05a45900e73f$export$7c6e2c02157bb7d2, { sideOffset: 5, position: "popper", className: classNames("arc-Select-content", {
3855
+ "arc-Select-content--onDarkSurface": surface === "dark"
3856
+ }) },
3857
+ React__default.createElement($cc7e05a45900e73f$export$2f60d3ec9ad468f2, { className: "arc-Select-scrollButton" },
3858
+ React__default.createElement(Icon, { icon: BtIconChevronUp2Px, size: 16 })),
3859
+ React__default.createElement($cc7e05a45900e73f$export$d5c6c08dc2d3ca7, null, options.map(function (_a, i) {
3860
+ var name = _a.name, value = _a.value;
3861
+ return (React__default.createElement($cc7e05a45900e73f$export$6d08773d2e66f8f2, { className: "arc-Select-item", key: "select-item-".concat(i), value: value },
3862
+ React__default.createElement("div", { className: "arc-Select-itemTextWrapper" },
3863
+ React__default.createElement($cc7e05a45900e73f$export$d6e5bf9c43ea9319, { asChild: true },
3864
+ React__default.createElement("span", { className: "arc-Select-itemText" }, name))),
3865
+ React__default.createElement($cc7e05a45900e73f$export$c3468e2714d175fa, null,
3866
+ React__default.createElement(Icon, { icon: BtIconTickAlt2Px, size: 20 }))));
3867
+ })),
3868
+ React__default.createElement($cc7e05a45900e73f$export$bf1aedc3039c8d63, { className: "arc-Select-scrollButton" },
3869
+ React__default.createElement(Icon, { icon: BtIconChevronDown2Px, size: 16 }))))))));
1753
3870
  };
1754
3871
 
1755
3872
  export { Select };