@arc-ui/components 11.0.0 → 11.2.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 (142) hide show
  1. package/dist/Align/Align.esm.js +4 -4
  2. package/dist/Badge/Badge.cjs.d.ts +26 -0
  3. package/dist/Badge/Badge.cjs.js +37 -0
  4. package/dist/Badge/Badge.esm.d.ts +26 -0
  5. package/dist/Badge/Badge.esm.js +29 -0
  6. package/dist/Badge/package.json +7 -0
  7. package/dist/Base/Base.cjs.d.ts +1 -16
  8. package/dist/Base/Base.cjs.js +4 -16
  9. package/dist/Base/Base.esm.d.ts +1 -16
  10. package/dist/Base/Base.esm.js +3 -15
  11. package/dist/BrandLogo/BrandLogo.esm.d.ts +1 -1
  12. package/dist/BrandLogo/BrandLogo.esm.js +2 -2
  13. package/dist/Breadcrumbs/Breadcrumbs.esm.js +27 -27
  14. package/dist/Button/Button.esm.d.ts +1 -1
  15. package/dist/Button/Button.esm.js +4 -4
  16. package/dist/Card/Card.esm.js +27 -27
  17. package/dist/Checkbox/Checkbox.cjs.js +4 -1
  18. package/dist/Checkbox/Checkbox.esm.js +18 -15
  19. package/dist/Clock/Clock.esm.js +3 -3
  20. package/dist/Columns/Columns.esm.js +5 -5
  21. package/dist/Curve/Curve.esm.d.ts +1 -1
  22. package/dist/Curve/Curve.esm.js +1 -1
  23. package/dist/Disclosure/Disclosure.esm.d.ts +1 -1
  24. package/dist/Disclosure/Disclosure.esm.js +10 -10
  25. package/dist/Elevation/Elevation.esm.js +2 -2
  26. package/dist/FormControl/FormControl.cjs.d.ts +1 -1
  27. package/dist/FormControl/FormControl.cjs.js +4 -1
  28. package/dist/FormControl/FormControl.esm.d.ts +1 -1
  29. package/dist/FormControl/FormControl.esm.js +5 -2
  30. package/dist/Group/Group.esm.js +6 -6
  31. package/dist/Heading/Heading.esm.d.ts +1 -1
  32. package/dist/Heading/Heading.esm.js +2 -2
  33. package/dist/Icon/Icon.esm.d.ts +1 -1
  34. package/dist/Icon/Icon.esm.js +2 -2
  35. package/dist/Image/Image.esm.d.ts +1 -1
  36. package/dist/Image/Image.esm.js +1 -1
  37. package/dist/Markup/Markup.esm.js +3 -3
  38. package/dist/Poster/Poster.esm.d.ts +1 -1
  39. package/dist/Poster/Poster.esm.js +9 -9
  40. package/dist/RadioGroup/RadioGroup.cjs.d.ts +1 -1
  41. package/dist/RadioGroup/RadioGroup.cjs.js +4 -1
  42. package/dist/RadioGroup/RadioGroup.esm.d.ts +1 -1
  43. package/dist/RadioGroup/RadioGroup.esm.js +15 -12
  44. package/dist/Rule/Rule.esm.js +3 -3
  45. package/dist/Section/Section.esm.d.ts +1 -1
  46. package/dist/Section/Section.esm.js +1 -1
  47. package/dist/Select/Select.cjs.d.ts +25 -0
  48. package/dist/Select/Select.cjs.js +2611 -0
  49. package/dist/Select/Select.esm.d.ts +25 -0
  50. package/dist/Select/Select.esm.js +2584 -0
  51. package/dist/Select/package.json +7 -0
  52. package/dist/SiteFooter/SiteFooter.esm.js +33 -33
  53. package/dist/SiteHeader/SiteHeader.esm.d.ts +1 -1
  54. package/dist/SiteHeader/SiteHeader.esm.js +98 -98
  55. package/dist/Surface/Surface.esm.d.ts +1 -1
  56. package/dist/Surface/Surface.esm.js +1 -1
  57. package/dist/Switch/Switch.cjs.d.ts +40 -0
  58. package/dist/Switch/Switch.cjs.js +210 -0
  59. package/dist/Switch/Switch.esm.d.ts +40 -0
  60. package/dist/Switch/Switch.esm.js +202 -0
  61. package/dist/Switch/package.json +7 -0
  62. package/dist/Text/Text.esm.d.ts +1 -1
  63. package/dist/Text/Text.esm.js +2 -2
  64. package/dist/TextInput/TextInput.cjs.d.ts +5 -1
  65. package/dist/TextInput/TextInput.cjs.js +25 -6
  66. package/dist/TextInput/TextInput.esm.d.ts +5 -1
  67. package/dist/TextInput/TextInput.esm.js +28 -9
  68. package/dist/Truncate/Truncate.cjs.d.ts +18 -0
  69. package/dist/Truncate/Truncate.cjs.js +17 -0
  70. package/dist/Truncate/Truncate.esm.d.ts +18 -0
  71. package/dist/Truncate/Truncate.esm.js +9 -0
  72. package/dist/Truncate/package.json +7 -0
  73. package/dist/UniversalHeader/UniversalHeader.esm.js +8 -8
  74. package/dist/VerticalSpace/VerticalSpace.cjs.d.ts +1 -18
  75. package/dist/VerticalSpace/VerticalSpace.cjs.js +5 -20
  76. package/dist/VerticalSpace/VerticalSpace.esm.d.ts +1 -18
  77. package/dist/VerticalSpace/VerticalSpace.esm.js +4 -19
  78. package/dist/VisuallyHidden/VisuallyHidden.cjs.d.ts +1 -12
  79. package/dist/VisuallyHidden/VisuallyHidden.cjs.js +3 -12
  80. package/dist/VisuallyHidden/VisuallyHidden.esm.d.ts +1 -12
  81. package/dist/VisuallyHidden/VisuallyHidden.esm.js +2 -11
  82. package/dist/_shared/cjs/Base-e2b846fe.d.ts +19 -0
  83. package/dist/_shared/cjs/Base-e2b846fe.js +22 -0
  84. package/dist/_shared/cjs/BtIconTickAlt2Px-b12ecc78.js +425 -0
  85. package/dist/_shared/cjs/{FormControl-a1b7421b.d.ts → FormControl-e6b7d7c5.d.ts} +51 -3
  86. package/dist/_shared/cjs/{FormControl-a1b7421b.js → FormControl-e6b7d7c5.js} +40 -8
  87. package/dist/_shared/cjs/VerticalSpace-65ad083c.d.ts +18 -0
  88. package/dist/_shared/cjs/VerticalSpace-65ad083c.js +25 -0
  89. package/dist/_shared/cjs/VisuallyHidden-e2c8b291.d.ts +12 -0
  90. package/dist/_shared/cjs/VisuallyHidden-e2c8b291.js +17 -0
  91. package/dist/_shared/cjs/index-c81c9401.d.ts +1 -1
  92. package/dist/_shared/esm/Base-c235dc45.d.ts +19 -0
  93. package/dist/_shared/esm/Base-c235dc45.js +15 -0
  94. package/dist/_shared/esm/{BrandLogo-ea3dd0e6.js → BrandLogo-4f13fe85.js} +4 -4
  95. package/dist/_shared/esm/{BtIconChevronDown2Px-4abd079b.js → BtIconChevronDown2Px-782876e2.js} +2 -2
  96. package/dist/_shared/esm/{BtIconChevronRight2Px-a5cc1d05.js → BtIconChevronRight2Px-b8e7b4ad.js} +3 -3
  97. package/dist/_shared/esm/{BtIconChevronRightMid-386cf272.js → BtIconChevronRightMid-d9b11761.js} +2 -2
  98. package/dist/_shared/esm/BtIconTickAlt2Px-2c4ec3be.js +408 -0
  99. package/dist/_shared/esm/{Button-5ff56a7b.js → Button-69439f8f.js} +15 -15
  100. package/dist/_shared/esm/{Curve-cfdca379.js → Curve-50697f7e.js} +2 -2
  101. package/dist/_shared/esm/{FormControl-feedc495.d.ts → FormControl-84c9ace6.d.ts} +51 -3
  102. package/dist/_shared/esm/FormControl-84c9ace6.js +138 -0
  103. package/dist/_shared/esm/{Heading-183be76c.js → Heading-eb1e42db.js} +4 -4
  104. package/dist/_shared/esm/{Icon-76d0d8c0.js → Icon-61f7237a.js} +5 -5
  105. package/dist/_shared/esm/{Image-7e4948f6.js → Image-c0f3d42f.js} +7 -7
  106. package/dist/_shared/esm/{Section-f1256c87.js → Section-7bc71e26.js} +2 -2
  107. package/dist/_shared/esm/{Surface-d515d212.js → Surface-bf201530.js} +3 -3
  108. package/dist/_shared/esm/{Text-d8988620.js → Text-6b958ad8.js} +3 -3
  109. package/dist/_shared/esm/VerticalSpace-6b4f5e50.d.ts +18 -0
  110. package/dist/_shared/esm/VerticalSpace-6b4f5e50.js +19 -0
  111. package/dist/_shared/esm/VisuallyHidden-b9eebf71.d.ts +12 -0
  112. package/dist/_shared/esm/VisuallyHidden-b9eebf71.js +11 -0
  113. package/dist/_shared/esm/index-c81c9401.d.ts +1 -1
  114. package/dist/index.es.js +34623 -529
  115. package/dist/index.es.js.map +1 -1
  116. package/dist/index.js +34527 -411
  117. package/dist/index.js.map +1 -1
  118. package/dist/styles.css +1 -1
  119. package/dist/types/components/Badge/Badge.d.ts +25 -0
  120. package/dist/types/components/Badge/index.d.ts +1 -0
  121. package/dist/types/components/FormControl/FormControl.d.ts +17 -0
  122. package/dist/types/components/FormControl/FormControlDisclosure/FormControlDisclosure.d.ts +28 -0
  123. package/dist/types/components/FormControl/FormControlDisclosure/index.d.ts +1 -0
  124. package/dist/types/components/Select/Select.d.ts +2 -1
  125. package/dist/types/components/Switch/Switch.d.ts +13 -8
  126. package/dist/types/components/TextInput/TextInput.d.ts +4 -0
  127. package/dist/types/components/Truncate/Truncate.d.ts +17 -0
  128. package/dist/types/components/Truncate/index.d.ts +1 -0
  129. package/dist/types/components/index.d.ts +4 -0
  130. package/dist/types/hooks/use-aria-describedby.d.ts +5 -1
  131. package/dist/types/styles.d.ts +4 -0
  132. package/package.json +4 -4
  133. package/dist/_shared/esm/FormControl-feedc495.js +0 -106
  134. /package/dist/_shared/esm/{BrandLogo-ea3dd0e6.d.ts → BrandLogo-4f13fe85.d.ts} +0 -0
  135. /package/dist/_shared/esm/{Button-5ff56a7b.d.ts → Button-69439f8f.d.ts} +0 -0
  136. /package/dist/_shared/esm/{Curve-cfdca379.d.ts → Curve-50697f7e.d.ts} +0 -0
  137. /package/dist/_shared/esm/{Heading-183be76c.d.ts → Heading-eb1e42db.d.ts} +0 -0
  138. /package/dist/_shared/esm/{Icon-76d0d8c0.d.ts → Icon-61f7237a.d.ts} +0 -0
  139. /package/dist/_shared/esm/{Image-7e4948f6.d.ts → Image-c0f3d42f.d.ts} +0 -0
  140. /package/dist/_shared/esm/{Section-f1256c87.d.ts → Section-7bc71e26.d.ts} +0 -0
  141. /package/dist/_shared/esm/{Surface-d515d212.d.ts → Surface-bf201530.d.ts} +0 -0
  142. /package/dist/_shared/esm/{Text-d8988620.d.ts → Text-6b958ad8.d.ts} +0 -0
@@ -0,0 +1,2611 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var index = require('../_shared/cjs/index-45bfb67b.js');
6
+ var React$1 = require('react');
7
+ var BtIconTickAlt2Px = require('../_shared/cjs/BtIconTickAlt2Px-b12ecc78.js');
8
+ var $7SXl2$reactdom = require('react-dom');
9
+ var BtIconChevronDown2Px = require('../_shared/cjs/BtIconChevronDown2Px-8fb4e2eb.js');
10
+ var Icon = require('../_shared/cjs/Icon-719d13d4.js');
11
+ var FormControl = require('../_shared/cjs/FormControl-e6b7d7c5.js');
12
+ var Surface = require('../_shared/cjs/Surface-d6b8010e.js');
13
+ var Base = require('../_shared/cjs/Base-e2b846fe.js');
14
+ require('../_shared/cjs/index-78b35bc1.js');
15
+ require('../_shared/cjs/suffix-modifier-edf7851e.js');
16
+ require('../_shared/cjs/Text-1d3844be.js');
17
+ require('../_shared/cjs/BtIconChevronRightMid-5a38d855.js');
18
+
19
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
+
21
+ function _interopNamespace(e) {
22
+ if (e && e.__esModule) return e;
23
+ var n = Object.create(null);
24
+ if (e) {
25
+ Object.keys(e).forEach(function (k) {
26
+ if (k !== 'default') {
27
+ var d = Object.getOwnPropertyDescriptor(e, k);
28
+ Object.defineProperty(n, k, d.get ? d : {
29
+ enumerable: true,
30
+ get: function () { return e[k]; }
31
+ });
32
+ }
33
+ });
34
+ }
35
+ n["default"] = e;
36
+ return Object.freeze(n);
37
+ }
38
+
39
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
40
+ var React__namespace = /*#__PURE__*/_interopNamespace(React$1);
41
+ var $7SXl2$reactdom__default = /*#__PURE__*/_interopDefaultLegacy($7SXl2$reactdom);
42
+
43
+ function $ae6933e535247d3d$export$7d15b64cf5a3a4c4(value, [min, max]) {
44
+ return Math.min(max, Math.max(min, value));
45
+ }
46
+
47
+ // We have resorted to returning slots directly rather than exposing primitives that can then
48
+ // be slotted like `<CollectionItem as={Slot}>…</CollectionItem>`.
49
+ // This is because we encountered issues with generic types that cannot be statically analysed
50
+ // due to creating them dynamically via createCollection.
51
+ function $e02a7d9cb1dc128c$export$c74125a8e3af6bb2(name) {
52
+ /* -----------------------------------------------------------------------------------------------
53
+ * CollectionProvider
54
+ * ---------------------------------------------------------------------------------------------*/ const PROVIDER_NAME = name + 'CollectionProvider';
55
+ const [createCollectionContext, createCollectionScope] = BtIconTickAlt2Px.$c512c27ab02ef895$export$50c7b4e9d9f19c1(PROVIDER_NAME);
56
+ const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
57
+ collectionRef: {
58
+ current: null
59
+ },
60
+ itemMap: new Map()
61
+ });
62
+ const CollectionProvider = (props)=>{
63
+ const { scope: scope , children: children } = props;
64
+ const ref = React__default["default"].useRef(null);
65
+ const itemMap = React__default["default"].useRef(new Map()).current;
66
+ return /*#__PURE__*/ React__default["default"].createElement(CollectionProviderImpl, {
67
+ scope: scope,
68
+ itemMap: itemMap,
69
+ collectionRef: ref
70
+ }, children);
71
+ };
72
+ /* -----------------------------------------------------------------------------------------------
73
+ * CollectionSlot
74
+ * ---------------------------------------------------------------------------------------------*/ const COLLECTION_SLOT_NAME = name + 'CollectionSlot';
75
+ const CollectionSlot = /*#__PURE__*/ React__default["default"].forwardRef((props, forwardedRef)=>{
76
+ const { scope: scope , children: children } = props;
77
+ const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
78
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.collectionRef);
79
+ return /*#__PURE__*/ React__default["default"].createElement(BtIconTickAlt2Px.$5e63c961fc1ce211$export$8c6ed5c666ac1360, {
80
+ ref: composedRefs
81
+ }, children);
82
+ });
83
+ /* -----------------------------------------------------------------------------------------------
84
+ * CollectionItem
85
+ * ---------------------------------------------------------------------------------------------*/ const ITEM_SLOT_NAME = name + 'CollectionItemSlot';
86
+ const ITEM_DATA_ATTR = 'data-radix-collection-item';
87
+ const CollectionItemSlot = /*#__PURE__*/ React__default["default"].forwardRef((props, forwardedRef)=>{
88
+ const { scope: scope , children: children , ...itemData } = props;
89
+ const ref = React__default["default"].useRef(null);
90
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
91
+ const context = useCollectionContext(ITEM_SLOT_NAME, scope);
92
+ React__default["default"].useEffect(()=>{
93
+ context.itemMap.set(ref, {
94
+ ref: ref,
95
+ ...itemData
96
+ });
97
+ return ()=>void context.itemMap.delete(ref)
98
+ ;
99
+ });
100
+ return /*#__PURE__*/ React__default["default"].createElement(BtIconTickAlt2Px.$5e63c961fc1ce211$export$8c6ed5c666ac1360, {
101
+ [ITEM_DATA_ATTR]: '',
102
+ ref: composedRefs
103
+ }, children);
104
+ });
105
+ /* -----------------------------------------------------------------------------------------------
106
+ * useCollection
107
+ * ---------------------------------------------------------------------------------------------*/ function useCollection(scope) {
108
+ const context = useCollectionContext(name + 'CollectionConsumer', scope);
109
+ const getItems = React__default["default"].useCallback(()=>{
110
+ const collectionNode = context.collectionRef.current;
111
+ if (!collectionNode) return [];
112
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
113
+ const items = Array.from(context.itemMap.values());
114
+ const orderedItems = items.sort((a, b)=>orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
115
+ );
116
+ return orderedItems;
117
+ }, [
118
+ context.collectionRef,
119
+ context.itemMap
120
+ ]);
121
+ return getItems;
122
+ }
123
+ return [
124
+ {
125
+ Provider: CollectionProvider,
126
+ Slot: CollectionSlot,
127
+ ItemSlot: CollectionItemSlot
128
+ },
129
+ useCollection,
130
+ createCollectionScope
131
+ ];
132
+ }
133
+
134
+ const $f631663db3294ace$var$DirectionContext = /*#__PURE__*/ React$1.createContext(undefined);
135
+ /* -----------------------------------------------------------------------------------------------*/ function $f631663db3294ace$export$b39126d51d94e6f3(localDir) {
136
+ const globalDir = React$1.useContext($f631663db3294ace$var$DirectionContext);
137
+ return localDir || globalDir || 'ltr';
138
+ }
139
+
140
+ /**
141
+ * Listens for when the escape key is down
142
+ */ function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
143
+ const onEscapeKeyDown = BtIconTickAlt2Px.$b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp);
144
+ React$1.useEffect(()=>{
145
+ const handleKeyDown = (event)=>{
146
+ if (event.key === 'Escape') onEscapeKeyDown(event);
147
+ };
148
+ ownerDocument.addEventListener('keydown', handleKeyDown);
149
+ return ()=>ownerDocument.removeEventListener('keydown', handleKeyDown)
150
+ ;
151
+ }, [
152
+ onEscapeKeyDown,
153
+ ownerDocument
154
+ ]);
155
+ }
156
+
157
+ const $5cb92bef7577960e$var$CONTEXT_UPDATE = 'dismissableLayer.update';
158
+ const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';
159
+ const $5cb92bef7577960e$var$FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';
160
+ let $5cb92bef7577960e$var$originalBodyPointerEvents;
161
+ const $5cb92bef7577960e$var$DismissableLayerContext = /*#__PURE__*/ React$1.createContext({
162
+ layers: new Set(),
163
+ layersWithOutsidePointerEventsDisabled: new Set(),
164
+ branches: new Set()
165
+ });
166
+ const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
167
+ var _node$ownerDocument;
168
+ const { disableOutsidePointerEvents: disableOutsidePointerEvents = false , onEscapeKeyDown: onEscapeKeyDown , onPointerDownOutside: onPointerDownOutside , onFocusOutside: onFocusOutside , onInteractOutside: onInteractOutside , onDismiss: onDismiss , ...layerProps } = props;
169
+ const context = React$1.useContext($5cb92bef7577960e$var$DismissableLayerContext);
170
+ const [node1, setNode] = React$1.useState(null);
171
+ const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
172
+ const [, force] = React$1.useState({});
173
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setNode(node)
174
+ );
175
+ const layers = Array.from(context.layers);
176
+ const [highestLayerWithOutsidePointerEventsDisabled] = [
177
+ ...context.layersWithOutsidePointerEventsDisabled
178
+ ].slice(-1); // prettier-ignore
179
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); // prettier-ignore
180
+ const index = node1 ? layers.indexOf(node1) : -1;
181
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
182
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
183
+ const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event)=>{
184
+ const target = event.target;
185
+ const isPointerDownOnBranch = [
186
+ ...context.branches
187
+ ].some((branch)=>branch.contains(target)
188
+ );
189
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
190
+ onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event);
191
+ onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
192
+ if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
193
+ }, ownerDocument);
194
+ const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event)=>{
195
+ const target = event.target;
196
+ const isFocusInBranch = [
197
+ ...context.branches
198
+ ].some((branch)=>branch.contains(target)
199
+ );
200
+ if (isFocusInBranch) return;
201
+ onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event);
202
+ onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
203
+ if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
204
+ }, ownerDocument);
205
+ $addc16e1bbe58fd0$export$3a72a57244d6e765((event)=>{
206
+ const isHighestLayer = index === context.layers.size - 1;
207
+ if (!isHighestLayer) return;
208
+ onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event);
209
+ if (!event.defaultPrevented && onDismiss) {
210
+ event.preventDefault();
211
+ onDismiss();
212
+ }
213
+ }, ownerDocument);
214
+ React$1.useEffect(()=>{
215
+ if (!node1) return;
216
+ if (disableOutsidePointerEvents) {
217
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
218
+ $5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
219
+ ownerDocument.body.style.pointerEvents = 'none';
220
+ }
221
+ context.layersWithOutsidePointerEventsDisabled.add(node1);
222
+ }
223
+ context.layers.add(node1);
224
+ $5cb92bef7577960e$var$dispatchUpdate();
225
+ return ()=>{
226
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents;
227
+ };
228
+ }, [
229
+ node1,
230
+ ownerDocument,
231
+ disableOutsidePointerEvents,
232
+ context
233
+ ]);
234
+ /**
235
+ * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect
236
+ * because a change to `disableOutsidePointerEvents` would remove this layer from the stack
237
+ * and add it to the end again so the layering order wouldn't be _creation order_.
238
+ * We only want them to be removed from context stacks when unmounted.
239
+ */ React$1.useEffect(()=>{
240
+ return ()=>{
241
+ if (!node1) return;
242
+ context.layers.delete(node1);
243
+ context.layersWithOutsidePointerEventsDisabled.delete(node1);
244
+ $5cb92bef7577960e$var$dispatchUpdate();
245
+ };
246
+ }, [
247
+ node1,
248
+ context
249
+ ]);
250
+ React$1.useEffect(()=>{
251
+ const handleUpdate = ()=>force({})
252
+ ;
253
+ document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
254
+ return ()=>document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate)
255
+ ;
256
+ }, []);
257
+ return /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, BtIconTickAlt2Px._extends({}, layerProps, {
258
+ ref: composedRefs,
259
+ style: {
260
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? 'auto' : 'none' : undefined,
261
+ ...props.style
262
+ },
263
+ onFocusCapture: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture),
264
+ onBlurCapture: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture),
265
+ onPointerDownCapture: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
266
+ }));
267
+ });
268
+ /* -----------------------------------------------------------------------------------------------*/ /**
269
+ * Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`
270
+ * to mimic layer dismissing behaviour present in OS.
271
+ * Returns props to pass to the node we want to check for outside events.
272
+ */ function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
273
+ const handlePointerDownOutside = BtIconTickAlt2Px.$b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside);
274
+ const isPointerInsideReactTreeRef = React$1.useRef(false);
275
+ const handleClickRef = React$1.useRef(()=>{});
276
+ React$1.useEffect(()=>{
277
+ const handlePointerDown = (event)=>{
278
+ if (event.target && !isPointerInsideReactTreeRef.current) {
279
+ const eventDetail = {
280
+ originalEvent: event
281
+ };
282
+ function handleAndDispatchPointerDownOutsideEvent() {
283
+ $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, {
284
+ discrete: true
285
+ });
286
+ }
287
+ /**
288
+ * On touch devices, we need to wait for a click event because browsers implement
289
+ * a ~350ms delay between the time the user stops touching the display and when the
290
+ * browser executres events. We need to ensure we don't reactivate pointer-events within
291
+ * this timeframe otherwise the browser may execute events that should have been prevented.
292
+ *
293
+ * Additionally, this also lets us deal automatically with cancellations when a click event
294
+ * isn't raised because the page was considered scrolled/drag-scrolled, long-pressed, etc.
295
+ *
296
+ * This is why we also continuously remove the previous listener, because we cannot be
297
+ * certain that it was raised, and therefore cleaned-up.
298
+ */ if (event.pointerType === 'touch') {
299
+ ownerDocument.removeEventListener('click', handleClickRef.current);
300
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;
301
+ ownerDocument.addEventListener('click', handleClickRef.current, {
302
+ once: true
303
+ });
304
+ } else handleAndDispatchPointerDownOutsideEvent();
305
+ }
306
+ isPointerInsideReactTreeRef.current = false;
307
+ };
308
+ /**
309
+ * if this hook executes in a component that mounts via a `pointerdown` event, the event
310
+ * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid
311
+ * this by delaying the event listener registration on the document.
312
+ * This is not React specific, but rather how the DOM works, ie:
313
+ * ```
314
+ * button.addEventListener('pointerdown', () => {
315
+ * console.log('I will log');
316
+ * document.addEventListener('pointerdown', () => {
317
+ * console.log('I will also log');
318
+ * })
319
+ * });
320
+ */ const timerId = window.setTimeout(()=>{
321
+ ownerDocument.addEventListener('pointerdown', handlePointerDown);
322
+ }, 0);
323
+ return ()=>{
324
+ window.clearTimeout(timerId);
325
+ ownerDocument.removeEventListener('pointerdown', handlePointerDown);
326
+ ownerDocument.removeEventListener('click', handleClickRef.current);
327
+ };
328
+ }, [
329
+ ownerDocument,
330
+ handlePointerDownOutside
331
+ ]);
332
+ return {
333
+ // ensures we check React component tree (not just DOM tree)
334
+ onPointerDownCapture: ()=>isPointerInsideReactTreeRef.current = true
335
+ };
336
+ }
337
+ /**
338
+ * Listens for when focus happens outside a react subtree.
339
+ * Returns props to pass to the root (node) of the subtree we want to check.
340
+ */ function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
341
+ const handleFocusOutside = BtIconTickAlt2Px.$b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside);
342
+ const isFocusInsideReactTreeRef = React$1.useRef(false);
343
+ React$1.useEffect(()=>{
344
+ const handleFocus = (event)=>{
345
+ if (event.target && !isFocusInsideReactTreeRef.current) {
346
+ const eventDetail = {
347
+ originalEvent: event
348
+ };
349
+ $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
350
+ discrete: false
351
+ });
352
+ }
353
+ };
354
+ ownerDocument.addEventListener('focusin', handleFocus);
355
+ return ()=>ownerDocument.removeEventListener('focusin', handleFocus)
356
+ ;
357
+ }, [
358
+ ownerDocument,
359
+ handleFocusOutside
360
+ ]);
361
+ return {
362
+ onFocusCapture: ()=>isFocusInsideReactTreeRef.current = true
363
+ ,
364
+ onBlurCapture: ()=>isFocusInsideReactTreeRef.current = false
365
+ };
366
+ }
367
+ function $5cb92bef7577960e$var$dispatchUpdate() {
368
+ const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE);
369
+ document.dispatchEvent(event);
370
+ }
371
+ function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name, handler, detail, { discrete: discrete }) {
372
+ const target = detail.originalEvent.target;
373
+ const event = new CustomEvent(name, {
374
+ bubbles: false,
375
+ cancelable: true,
376
+ detail: detail
377
+ });
378
+ if (handler) target.addEventListener(name, handler, {
379
+ once: true
380
+ });
381
+ if (discrete) BtIconTickAlt2Px.$8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event);
382
+ else target.dispatchEvent(event);
383
+ }
384
+
385
+ /** Number of components which have requested interest to have focus guards */ let $3db38b7d1fb3fe6a$var$count = 0;
386
+ /**
387
+ * Injects a pair of focus guards at the edges of the whole DOM tree
388
+ * to ensure `focusin` & `focusout` events can be caught consistently.
389
+ */ function $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c() {
390
+ React$1.useEffect(()=>{
391
+ var _edgeGuards$, _edgeGuards$2;
392
+ const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');
393
+ document.body.insertAdjacentElement('afterbegin', (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $3db38b7d1fb3fe6a$var$createFocusGuard());
394
+ document.body.insertAdjacentElement('beforeend', (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $3db38b7d1fb3fe6a$var$createFocusGuard());
395
+ $3db38b7d1fb3fe6a$var$count++;
396
+ return ()=>{
397
+ if ($3db38b7d1fb3fe6a$var$count === 1) document.querySelectorAll('[data-radix-focus-guard]').forEach((node)=>node.remove()
398
+ );
399
+ $3db38b7d1fb3fe6a$var$count--;
400
+ };
401
+ }, []);
402
+ }
403
+ function $3db38b7d1fb3fe6a$var$createFocusGuard() {
404
+ const element = document.createElement('span');
405
+ element.setAttribute('data-radix-focus-guard', '');
406
+ element.tabIndex = 0;
407
+ element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';
408
+ return element;
409
+ }
410
+
411
+ const $d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT = 'focusScope.autoFocusOnMount';
412
+ const $d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT = 'focusScope.autoFocusOnUnmount';
413
+ const $d3863c46a17e8a28$var$EVENT_OPTIONS = {
414
+ bubbles: false,
415
+ cancelable: true
416
+ };
417
+ const $d3863c46a17e8a28$export$20e40289641fbbb6 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
418
+ const { loop: loop = false , trapped: trapped = false , onMountAutoFocus: onMountAutoFocusProp , onUnmountAutoFocus: onUnmountAutoFocusProp , ...scopeProps } = props;
419
+ const [container1, setContainer] = React$1.useState(null);
420
+ const onMountAutoFocus = BtIconTickAlt2Px.$b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onMountAutoFocusProp);
421
+ const onUnmountAutoFocus = BtIconTickAlt2Px.$b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onUnmountAutoFocusProp);
422
+ const lastFocusedElementRef = React$1.useRef(null);
423
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContainer(node)
424
+ );
425
+ const focusScope = React$1.useRef({
426
+ paused: false,
427
+ pause () {
428
+ this.paused = true;
429
+ },
430
+ resume () {
431
+ this.paused = false;
432
+ }
433
+ }).current; // Takes care of trapping focus if focus is moved outside programmatically for example
434
+ React$1.useEffect(()=>{
435
+ if (trapped) {
436
+ function handleFocusIn(event) {
437
+ if (focusScope.paused || !container1) return;
438
+ const target = event.target;
439
+ if (container1.contains(target)) lastFocusedElementRef.current = target;
440
+ else $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
441
+ select: true
442
+ });
443
+ }
444
+ function handleFocusOut(event) {
445
+ if (focusScope.paused || !container1) return;
446
+ if (!container1.contains(event.relatedTarget)) $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
447
+ select: true
448
+ });
449
+ }
450
+ document.addEventListener('focusin', handleFocusIn);
451
+ document.addEventListener('focusout', handleFocusOut);
452
+ return ()=>{
453
+ document.removeEventListener('focusin', handleFocusIn);
454
+ document.removeEventListener('focusout', handleFocusOut);
455
+ };
456
+ }
457
+ }, [
458
+ trapped,
459
+ container1,
460
+ focusScope.paused
461
+ ]);
462
+ React$1.useEffect(()=>{
463
+ if (container1) {
464
+ $d3863c46a17e8a28$var$focusScopesStack.add(focusScope);
465
+ const previouslyFocusedElement = document.activeElement;
466
+ const hasFocusedCandidate = container1.contains(previouslyFocusedElement);
467
+ if (!hasFocusedCandidate) {
468
+ const mountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
469
+ container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
470
+ container1.dispatchEvent(mountEvent);
471
+ if (!mountEvent.defaultPrevented) {
472
+ $d3863c46a17e8a28$var$focusFirst($d3863c46a17e8a28$var$removeLinks($d3863c46a17e8a28$var$getTabbableCandidates(container1)), {
473
+ select: true
474
+ });
475
+ if (document.activeElement === previouslyFocusedElement) $d3863c46a17e8a28$var$focus(container1);
476
+ }
477
+ }
478
+ return ()=>{
479
+ container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); // We hit a react bug (fixed in v17) with focusing in unmount.
480
+ // We need to delay the focus a little to get around it for now.
481
+ // See: https://github.com/facebook/react/issues/17894
482
+ setTimeout(()=>{
483
+ const unmountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
484
+ container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
485
+ container1.dispatchEvent(unmountEvent);
486
+ if (!unmountEvent.defaultPrevented) $d3863c46a17e8a28$var$focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, {
487
+ select: true
488
+ });
489
+ // we need to remove the listener after we `dispatchEvent`
490
+ container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
491
+ $d3863c46a17e8a28$var$focusScopesStack.remove(focusScope);
492
+ }, 0);
493
+ };
494
+ }
495
+ }, [
496
+ container1,
497
+ onMountAutoFocus,
498
+ onUnmountAutoFocus,
499
+ focusScope
500
+ ]); // Takes care of looping focus (when tabbing whilst at the edges)
501
+ const handleKeyDown = React$1.useCallback((event)=>{
502
+ if (!loop && !trapped) return;
503
+ if (focusScope.paused) return;
504
+ const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;
505
+ const focusedElement = document.activeElement;
506
+ if (isTabKey && focusedElement) {
507
+ const container = event.currentTarget;
508
+ const [first, last] = $d3863c46a17e8a28$var$getTabbableEdges(container);
509
+ const hasTabbableElementsInside = first && last; // we can only wrap focus if we have tabbable edges
510
+ if (!hasTabbableElementsInside) {
511
+ if (focusedElement === container) event.preventDefault();
512
+ } else {
513
+ if (!event.shiftKey && focusedElement === last) {
514
+ event.preventDefault();
515
+ if (loop) $d3863c46a17e8a28$var$focus(first, {
516
+ select: true
517
+ });
518
+ } else if (event.shiftKey && focusedElement === first) {
519
+ event.preventDefault();
520
+ if (loop) $d3863c46a17e8a28$var$focus(last, {
521
+ select: true
522
+ });
523
+ }
524
+ }
525
+ }
526
+ }, [
527
+ loop,
528
+ trapped,
529
+ focusScope.paused
530
+ ]);
531
+ return /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, BtIconTickAlt2Px._extends({
532
+ tabIndex: -1
533
+ }, scopeProps, {
534
+ ref: composedRefs,
535
+ onKeyDown: handleKeyDown
536
+ }));
537
+ });
538
+ /* -------------------------------------------------------------------------------------------------
539
+ * Utils
540
+ * -----------------------------------------------------------------------------------------------*/ /**
541
+ * Attempts focusing the first element in a list of candidates.
542
+ * Stops when focus has actually moved.
543
+ */ function $d3863c46a17e8a28$var$focusFirst(candidates, { select: select = false } = {}) {
544
+ const previouslyFocusedElement = document.activeElement;
545
+ for (const candidate of candidates){
546
+ $d3863c46a17e8a28$var$focus(candidate, {
547
+ select: select
548
+ });
549
+ if (document.activeElement !== previouslyFocusedElement) return;
550
+ }
551
+ }
552
+ /**
553
+ * Returns the first and last tabbable elements inside a container.
554
+ */ function $d3863c46a17e8a28$var$getTabbableEdges(container) {
555
+ const candidates = $d3863c46a17e8a28$var$getTabbableCandidates(container);
556
+ const first = $d3863c46a17e8a28$var$findVisible(candidates, container);
557
+ const last = $d3863c46a17e8a28$var$findVisible(candidates.reverse(), container);
558
+ return [
559
+ first,
560
+ last
561
+ ];
562
+ }
563
+ /**
564
+ * Returns a list of potential tabbable candidates.
565
+ *
566
+ * NOTE: This is only a close approximation. For example it doesn't take into account cases like when
567
+ * elements are not visible. This cannot be worked out easily by just reading a property, but rather
568
+ * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.
569
+ *
570
+ * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
571
+ * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
572
+ */ function $d3863c46a17e8a28$var$getTabbableCandidates(container) {
573
+ const nodes = [];
574
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
575
+ acceptNode: (node)=>{
576
+ const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';
577
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP; // `.tabIndex` is not the same as the `tabindex` attribute. It works on the
578
+ // runtime's understanding of tabbability, so this automatically accounts
579
+ // for any kind of element that could be tabbed to.
580
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
581
+ }
582
+ });
583
+ while(walker.nextNode())nodes.push(walker.currentNode); // we do not take into account the order of nodes with positive `tabIndex` as it
584
+ // hinders accessibility to have tab order different from visual order.
585
+ return nodes;
586
+ }
587
+ /**
588
+ * Returns the first visible element in a list.
589
+ * NOTE: Only checks visibility up to the `container`.
590
+ */ function $d3863c46a17e8a28$var$findVisible(elements, container) {
591
+ for (const element of elements){
592
+ // we stop checking if it's hidden at the `container` level (excluding)
593
+ if (!$d3863c46a17e8a28$var$isHidden(element, {
594
+ upTo: container
595
+ })) return element;
596
+ }
597
+ }
598
+ function $d3863c46a17e8a28$var$isHidden(node, { upTo: upTo }) {
599
+ if (getComputedStyle(node).visibility === 'hidden') return true;
600
+ while(node){
601
+ // we stop at `upTo` (excluding it)
602
+ if (upTo !== undefined && node === upTo) return false;
603
+ if (getComputedStyle(node).display === 'none') return true;
604
+ node = node.parentElement;
605
+ }
606
+ return false;
607
+ }
608
+ function $d3863c46a17e8a28$var$isSelectableInput(element) {
609
+ return element instanceof HTMLInputElement && 'select' in element;
610
+ }
611
+ function $d3863c46a17e8a28$var$focus(element, { select: select = false } = {}) {
612
+ // only focus if that element is focusable
613
+ if (element && element.focus) {
614
+ const previouslyFocusedElement = document.activeElement; // NOTE: we prevent scrolling on focus, to minimize jarring transitions for users
615
+ element.focus({
616
+ preventScroll: true
617
+ }); // only select if its not the same element, it supports selection and we need to select
618
+ if (element !== previouslyFocusedElement && $d3863c46a17e8a28$var$isSelectableInput(element) && select) element.select();
619
+ }
620
+ }
621
+ /* -------------------------------------------------------------------------------------------------
622
+ * FocusScope stack
623
+ * -----------------------------------------------------------------------------------------------*/ const $d3863c46a17e8a28$var$focusScopesStack = $d3863c46a17e8a28$var$createFocusScopesStack();
624
+ function $d3863c46a17e8a28$var$createFocusScopesStack() {
625
+ /** A stack of focus scopes, with the active one at the top */ let stack = [];
626
+ return {
627
+ add (focusScope) {
628
+ // pause the currently active focus scope (at the top of the stack)
629
+ const activeFocusScope = stack[0];
630
+ if (focusScope !== activeFocusScope) activeFocusScope === null || activeFocusScope === void 0 || activeFocusScope.pause();
631
+ // remove in case it already exists (because we'll re-add it at the top of the stack)
632
+ stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);
633
+ stack.unshift(focusScope);
634
+ },
635
+ remove (focusScope) {
636
+ var _stack$;
637
+ stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);
638
+ (_stack$ = stack[0]) === null || _stack$ === void 0 || _stack$.resume();
639
+ }
640
+ };
641
+ }
642
+ function $d3863c46a17e8a28$var$arrayRemove(array, item) {
643
+ const updatedArray = [
644
+ ...array
645
+ ];
646
+ const index = updatedArray.indexOf(item);
647
+ if (index !== -1) updatedArray.splice(index, 1);
648
+ return updatedArray;
649
+ }
650
+ function $d3863c46a17e8a28$var$removeLinks(items) {
651
+ return items.filter((item)=>item.tagName !== 'A'
652
+ );
653
+ }
654
+
655
+ const $1746a345f3d73bb7$var$useReactId = React__namespace['useId'.toString()] || (()=>undefined
656
+ );
657
+ let $1746a345f3d73bb7$var$count = 0;
658
+ function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
659
+ const [id, setId] = React__namespace.useState($1746a345f3d73bb7$var$useReactId()); // React versions older than 18 will have client-side ids only.
660
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
661
+ if (!deterministicId) setId((reactId)=>reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++)
662
+ );
663
+ }, [
664
+ deterministicId
665
+ ]);
666
+ return deterministicId || (id ? `radix-${id}` : '');
667
+ }
668
+
669
+ const $f1701beae083dbae$export$602eac185826482c = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
670
+ var _globalThis$document;
671
+ 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;
672
+ return container ? /*#__PURE__*/ $7SXl2$reactdom__default["default"].createPortal(/*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, BtIconTickAlt2Px._extends({}, portalProps, {
673
+ ref: forwardedRef
674
+ })), container) : null;
675
+ });
676
+
677
+ const $ea1ef594cf570d83$export$439d29a4e110a164 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
678
+ return /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.span, BtIconTickAlt2Px._extends({}, props, {
679
+ ref: forwardedRef,
680
+ style: {
681
+ // See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
682
+ position: 'absolute',
683
+ border: 0,
684
+ width: 1,
685
+ height: 1,
686
+ padding: 0,
687
+ margin: -1,
688
+ overflow: 'hidden',
689
+ clip: 'rect(0, 0, 0, 0)',
690
+ whiteSpace: 'nowrap',
691
+ wordWrap: 'normal',
692
+ ...props.style
693
+ }
694
+ }));
695
+ });
696
+
697
+ var getDefaultParent = function (originalTarget) {
698
+ if (typeof document === 'undefined') {
699
+ return null;
700
+ }
701
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
702
+ return sampleTarget.ownerDocument.body;
703
+ };
704
+ var counterMap = new WeakMap();
705
+ var uncontrolledNodes = new WeakMap();
706
+ var markerMap = {};
707
+ var lockCount = 0;
708
+ var unwrapHost = function (node) {
709
+ return node && (node.host || unwrapHost(node.parentNode));
710
+ };
711
+ var correctTargets = function (parent, targets) {
712
+ return targets.map(function (target) {
713
+ if (parent.contains(target)) {
714
+ return target;
715
+ }
716
+ var correctedTarget = unwrapHost(target);
717
+ if (correctedTarget && parent.contains(correctedTarget)) {
718
+ return correctedTarget;
719
+ }
720
+ console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
721
+ return null;
722
+ }).filter(function (x) { return Boolean(x); });
723
+ };
724
+ /**
725
+ * Marks everything except given node(or nodes) as aria-hidden
726
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
727
+ * @param [parentNode] - top element, defaults to document.body
728
+ * @param {String} [markerName] - a special attribute to mark every node
729
+ * @param {String} [controlAttribute] - html Attribute to control
730
+ * @return {Undo} undo command
731
+ */
732
+ var applyAttributeToOthers = function (originalTarget, parentNode, markerName, controlAttribute) {
733
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
734
+ if (!markerMap[markerName]) {
735
+ markerMap[markerName] = new WeakMap();
736
+ }
737
+ var markerCounter = markerMap[markerName];
738
+ var hiddenNodes = [];
739
+ var elementsToKeep = new Set();
740
+ var elementsToStop = new Set(targets);
741
+ var keep = function (el) {
742
+ if (!el || elementsToKeep.has(el)) {
743
+ return;
744
+ }
745
+ elementsToKeep.add(el);
746
+ keep(el.parentNode);
747
+ };
748
+ targets.forEach(keep);
749
+ var deep = function (parent) {
750
+ if (!parent || elementsToStop.has(parent)) {
751
+ return;
752
+ }
753
+ Array.prototype.forEach.call(parent.children, function (node) {
754
+ if (elementsToKeep.has(node)) {
755
+ deep(node);
756
+ }
757
+ else {
758
+ var attr = node.getAttribute(controlAttribute);
759
+ var alreadyHidden = attr !== null && attr !== 'false';
760
+ var counterValue = (counterMap.get(node) || 0) + 1;
761
+ var markerValue = (markerCounter.get(node) || 0) + 1;
762
+ counterMap.set(node, counterValue);
763
+ markerCounter.set(node, markerValue);
764
+ hiddenNodes.push(node);
765
+ if (counterValue === 1 && alreadyHidden) {
766
+ uncontrolledNodes.set(node, true);
767
+ }
768
+ if (markerValue === 1) {
769
+ node.setAttribute(markerName, 'true');
770
+ }
771
+ if (!alreadyHidden) {
772
+ node.setAttribute(controlAttribute, 'true');
773
+ }
774
+ }
775
+ });
776
+ };
777
+ deep(parentNode);
778
+ elementsToKeep.clear();
779
+ lockCount++;
780
+ return function () {
781
+ hiddenNodes.forEach(function (node) {
782
+ var counterValue = counterMap.get(node) - 1;
783
+ var markerValue = markerCounter.get(node) - 1;
784
+ counterMap.set(node, counterValue);
785
+ markerCounter.set(node, markerValue);
786
+ if (!counterValue) {
787
+ if (!uncontrolledNodes.has(node)) {
788
+ node.removeAttribute(controlAttribute);
789
+ }
790
+ uncontrolledNodes.delete(node);
791
+ }
792
+ if (!markerValue) {
793
+ node.removeAttribute(markerName);
794
+ }
795
+ });
796
+ lockCount--;
797
+ if (!lockCount) {
798
+ // clear
799
+ counterMap = new WeakMap();
800
+ counterMap = new WeakMap();
801
+ uncontrolledNodes = new WeakMap();
802
+ markerMap = {};
803
+ }
804
+ };
805
+ };
806
+ /**
807
+ * Marks everything except given node(or nodes) as aria-hidden
808
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
809
+ * @param [parentNode] - top element, defaults to document.body
810
+ * @param {String} [markerName] - a special attribute to mark every node
811
+ * @return {Undo} undo command
812
+ */
813
+ var hideOthers = function (originalTarget, parentNode, markerName) {
814
+ if (markerName === void 0) { markerName = 'data-aria-hidden'; }
815
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
816
+ var activeParentNode = parentNode || getDefaultParent(originalTarget);
817
+ if (!activeParentNode) {
818
+ return function () { return null; };
819
+ }
820
+ // we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
821
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
822
+ return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
823
+ };
824
+
825
+ /******************************************************************************
826
+ Copyright (c) Microsoft Corporation.
827
+
828
+ Permission to use, copy, modify, and/or distribute this software for any
829
+ purpose with or without fee is hereby granted.
830
+
831
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
832
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
833
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
834
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
835
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
836
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
837
+ PERFORMANCE OF THIS SOFTWARE.
838
+ ***************************************************************************** */
839
+
840
+ var __assign$1 = function() {
841
+ __assign$1 = Object.assign || function __assign(t) {
842
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
843
+ s = arguments[i];
844
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
845
+ }
846
+ return t;
847
+ };
848
+ return __assign$1.apply(this, arguments);
849
+ };
850
+
851
+ function __rest$1(s, e) {
852
+ var t = {};
853
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
854
+ t[p] = s[p];
855
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
856
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
857
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
858
+ t[p[i]] = s[p[i]];
859
+ }
860
+ return t;
861
+ }
862
+
863
+ function __spreadArray(to, from, pack) {
864
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
865
+ if (ar || !(i in from)) {
866
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
867
+ ar[i] = from[i];
868
+ }
869
+ }
870
+ return to.concat(ar || Array.prototype.slice.call(from));
871
+ }
872
+
873
+ var zeroRightClassName = 'right-scroll-bar-position';
874
+ var fullWidthClassName = 'width-before-scroll-bar';
875
+ var noScrollbarsClassName = 'with-scroll-bars-hidden';
876
+ /**
877
+ * Name of a CSS variable containing the amount of "hidden" scrollbar
878
+ * ! might be undefined ! use will fallback!
879
+ */
880
+ var removedBarSizeVariable = '--removed-body-scroll-bar-size';
881
+
882
+ /**
883
+ * Assigns a value for a given ref, no matter of the ref format
884
+ * @param {RefObject} ref - a callback function or ref object
885
+ * @param value - a new value
886
+ *
887
+ * @see https://github.com/theKashey/use-callback-ref#assignref
888
+ * @example
889
+ * const refObject = useRef();
890
+ * const refFn = (ref) => {....}
891
+ *
892
+ * assignRef(refObject, "refValue");
893
+ * assignRef(refFn, "refValue");
894
+ */
895
+ function assignRef(ref, value) {
896
+ if (typeof ref === 'function') {
897
+ ref(value);
898
+ }
899
+ else if (ref) {
900
+ ref.current = value;
901
+ }
902
+ return ref;
903
+ }
904
+
905
+ /**
906
+ * creates a MutableRef with ref change callback
907
+ * @param initialValue - initial ref value
908
+ * @param {Function} callback - a callback to run when value changes
909
+ *
910
+ * @example
911
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
912
+ * ref.current = 1;
913
+ * // prints 0 -> 1
914
+ *
915
+ * @see https://reactjs.org/docs/hooks-reference.html#useref
916
+ * @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
917
+ * @returns {MutableRefObject}
918
+ */
919
+ function useCallbackRef(initialValue, callback) {
920
+ var ref = React$1.useState(function () { return ({
921
+ // value
922
+ value: initialValue,
923
+ // last callback
924
+ callback: callback,
925
+ // "memoized" public interface
926
+ facade: {
927
+ get current() {
928
+ return ref.value;
929
+ },
930
+ set current(value) {
931
+ var last = ref.value;
932
+ if (last !== value) {
933
+ ref.value = value;
934
+ ref.callback(value, last);
935
+ }
936
+ },
937
+ },
938
+ }); })[0];
939
+ // update callback
940
+ ref.callback = callback;
941
+ return ref.facade;
942
+ }
943
+
944
+ /**
945
+ * Merges two or more refs together providing a single interface to set their value
946
+ * @param {RefObject|Ref} refs
947
+ * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
948
+ *
949
+ * @see {@link mergeRefs} a version without buit-in memoization
950
+ * @see https://github.com/theKashey/use-callback-ref#usemergerefs
951
+ * @example
952
+ * const Component = React.forwardRef((props, ref) => {
953
+ * const ownRef = useRef();
954
+ * const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
955
+ * return <div ref={domRef}>...</div>
956
+ * }
957
+ */
958
+ function useMergeRefs(refs, defaultValue) {
959
+ return useCallbackRef(defaultValue || null, function (newValue) { return refs.forEach(function (ref) { return assignRef(ref, newValue); }); });
960
+ }
961
+
962
+ /*! *****************************************************************************
963
+ Copyright (c) Microsoft Corporation.
964
+
965
+ Permission to use, copy, modify, and/or distribute this software for any
966
+ purpose with or without fee is hereby granted.
967
+
968
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
969
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
970
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
971
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
972
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
973
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
974
+ PERFORMANCE OF THIS SOFTWARE.
975
+ ***************************************************************************** */
976
+
977
+ var __assign = function() {
978
+ __assign = Object.assign || function __assign(t) {
979
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
980
+ s = arguments[i];
981
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
982
+ }
983
+ return t;
984
+ };
985
+ return __assign.apply(this, arguments);
986
+ };
987
+
988
+ function __rest(s, e) {
989
+ var t = {};
990
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
991
+ t[p] = s[p];
992
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
993
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
994
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
995
+ t[p[i]] = s[p[i]];
996
+ }
997
+ return t;
998
+ }
999
+
1000
+ function ItoI(a) {
1001
+ return a;
1002
+ }
1003
+ function innerCreateMedium(defaults, middleware) {
1004
+ if (middleware === void 0) { middleware = ItoI; }
1005
+ var buffer = [];
1006
+ var assigned = false;
1007
+ var medium = {
1008
+ read: function () {
1009
+ if (assigned) {
1010
+ throw new Error('Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.');
1011
+ }
1012
+ if (buffer.length) {
1013
+ return buffer[buffer.length - 1];
1014
+ }
1015
+ return defaults;
1016
+ },
1017
+ useMedium: function (data) {
1018
+ var item = middleware(data, assigned);
1019
+ buffer.push(item);
1020
+ return function () {
1021
+ buffer = buffer.filter(function (x) { return x !== item; });
1022
+ };
1023
+ },
1024
+ assignSyncMedium: function (cb) {
1025
+ assigned = true;
1026
+ while (buffer.length) {
1027
+ var cbs = buffer;
1028
+ buffer = [];
1029
+ cbs.forEach(cb);
1030
+ }
1031
+ buffer = {
1032
+ push: function (x) { return cb(x); },
1033
+ filter: function () { return buffer; },
1034
+ };
1035
+ },
1036
+ assignMedium: function (cb) {
1037
+ assigned = true;
1038
+ var pendingQueue = [];
1039
+ if (buffer.length) {
1040
+ var cbs = buffer;
1041
+ buffer = [];
1042
+ cbs.forEach(cb);
1043
+ pendingQueue = buffer;
1044
+ }
1045
+ var executeQueue = function () {
1046
+ var cbs = pendingQueue;
1047
+ pendingQueue = [];
1048
+ cbs.forEach(cb);
1049
+ };
1050
+ var cycle = function () { return Promise.resolve().then(executeQueue); };
1051
+ cycle();
1052
+ buffer = {
1053
+ push: function (x) {
1054
+ pendingQueue.push(x);
1055
+ cycle();
1056
+ },
1057
+ filter: function (filter) {
1058
+ pendingQueue = pendingQueue.filter(filter);
1059
+ return buffer;
1060
+ },
1061
+ };
1062
+ },
1063
+ };
1064
+ return medium;
1065
+ }
1066
+ // eslint-disable-next-line @typescript-eslint/ban-types
1067
+ function createSidecarMedium(options) {
1068
+ if (options === void 0) { options = {}; }
1069
+ var medium = innerCreateMedium(null);
1070
+ medium.options = __assign({ async: true, ssr: false }, options);
1071
+ return medium;
1072
+ }
1073
+
1074
+ var SideCar$1 = function (_a) {
1075
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
1076
+ if (!sideCar) {
1077
+ throw new Error('Sidecar: please provide `sideCar` property to import the right car');
1078
+ }
1079
+ var Target = sideCar.read();
1080
+ if (!Target) {
1081
+ throw new Error('Sidecar medium not found');
1082
+ }
1083
+ return React__namespace.createElement(Target, __assign({}, rest));
1084
+ };
1085
+ SideCar$1.isSideCarExport = true;
1086
+ function exportSidecar(medium, exported) {
1087
+ medium.useMedium(exported);
1088
+ return SideCar$1;
1089
+ }
1090
+
1091
+ var effectCar = createSidecarMedium();
1092
+
1093
+ var nothing = function () {
1094
+ return;
1095
+ };
1096
+ /**
1097
+ * Removes scrollbar from the page and contain the scroll within the Lock
1098
+ */
1099
+ var RemoveScroll = React__namespace.forwardRef(function (props, parentRef) {
1100
+ var ref = React__namespace.useRef(null);
1101
+ var _a = React__namespace.useState({
1102
+ onScrollCapture: nothing,
1103
+ onWheelCapture: nothing,
1104
+ onTouchMoveCapture: nothing,
1105
+ }), callbacks = _a[0], setCallbacks = _a[1];
1106
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, rest = __rest$1(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as"]);
1107
+ var SideCar = sideCar;
1108
+ var containerRef = useMergeRefs([ref, parentRef]);
1109
+ var containerProps = __assign$1(__assign$1({}, rest), callbacks);
1110
+ return (React__namespace.createElement(React__namespace.Fragment, null,
1111
+ enabled && (React__namespace.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref })),
1112
+ forwardProps ? (React__namespace.cloneElement(React__namespace.Children.only(children), __assign$1(__assign$1({}, containerProps), { ref: containerRef }))) : (React__namespace.createElement(Container, __assign$1({}, containerProps, { className: className, ref: containerRef }), children))));
1113
+ });
1114
+ RemoveScroll.defaultProps = {
1115
+ enabled: true,
1116
+ removeScrollBar: true,
1117
+ inert: false,
1118
+ };
1119
+ RemoveScroll.classNames = {
1120
+ fullWidth: fullWidthClassName,
1121
+ zeroRight: zeroRightClassName,
1122
+ };
1123
+
1124
+ var getNonce = function () {
1125
+ if (typeof __webpack_nonce__ !== 'undefined') {
1126
+ return __webpack_nonce__;
1127
+ }
1128
+ return undefined;
1129
+ };
1130
+
1131
+ function makeStyleTag() {
1132
+ if (!document)
1133
+ return null;
1134
+ var tag = document.createElement('style');
1135
+ tag.type = 'text/css';
1136
+ var nonce = getNonce();
1137
+ if (nonce) {
1138
+ tag.setAttribute('nonce', nonce);
1139
+ }
1140
+ return tag;
1141
+ }
1142
+ function injectStyles(tag, css) {
1143
+ // @ts-ignore
1144
+ if (tag.styleSheet) {
1145
+ // @ts-ignore
1146
+ tag.styleSheet.cssText = css;
1147
+ }
1148
+ else {
1149
+ tag.appendChild(document.createTextNode(css));
1150
+ }
1151
+ }
1152
+ function insertStyleTag(tag) {
1153
+ var head = document.head || document.getElementsByTagName('head')[0];
1154
+ head.appendChild(tag);
1155
+ }
1156
+ var stylesheetSingleton = function () {
1157
+ var counter = 0;
1158
+ var stylesheet = null;
1159
+ return {
1160
+ add: function (style) {
1161
+ if (counter == 0) {
1162
+ if ((stylesheet = makeStyleTag())) {
1163
+ injectStyles(stylesheet, style);
1164
+ insertStyleTag(stylesheet);
1165
+ }
1166
+ }
1167
+ counter++;
1168
+ },
1169
+ remove: function () {
1170
+ counter--;
1171
+ if (!counter && stylesheet) {
1172
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
1173
+ stylesheet = null;
1174
+ }
1175
+ },
1176
+ };
1177
+ };
1178
+
1179
+ /**
1180
+ * creates a hook to control style singleton
1181
+ * @see {@link styleSingleton} for a safer component version
1182
+ * @example
1183
+ * ```tsx
1184
+ * const useStyle = styleHookSingleton();
1185
+ * ///
1186
+ * useStyle('body { overflow: hidden}');
1187
+ */
1188
+ var styleHookSingleton = function () {
1189
+ var sheet = stylesheetSingleton();
1190
+ return function (styles, isDynamic) {
1191
+ React__namespace.useEffect(function () {
1192
+ sheet.add(styles);
1193
+ return function () {
1194
+ sheet.remove();
1195
+ };
1196
+ }, [styles && isDynamic]);
1197
+ };
1198
+ };
1199
+
1200
+ /**
1201
+ * create a Component to add styles on demand
1202
+ * - styles are added when first instance is mounted
1203
+ * - styles are removed when the last instance is unmounted
1204
+ * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
1205
+ */
1206
+ var styleSingleton = function () {
1207
+ var useStyle = styleHookSingleton();
1208
+ var Sheet = function (_a) {
1209
+ var styles = _a.styles, dynamic = _a.dynamic;
1210
+ useStyle(styles, dynamic);
1211
+ return null;
1212
+ };
1213
+ return Sheet;
1214
+ };
1215
+
1216
+ var zeroGap = {
1217
+ left: 0,
1218
+ top: 0,
1219
+ right: 0,
1220
+ gap: 0,
1221
+ };
1222
+ var parse = function (x) { return parseInt(x || '', 10) || 0; };
1223
+ var getOffset = function (gapMode) {
1224
+ var cs = window.getComputedStyle(document.body);
1225
+ var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
1226
+ var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
1227
+ var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
1228
+ return [parse(left), parse(top), parse(right)];
1229
+ };
1230
+ var getGapWidth = function (gapMode) {
1231
+ if (gapMode === void 0) { gapMode = 'margin'; }
1232
+ if (typeof window === 'undefined') {
1233
+ return zeroGap;
1234
+ }
1235
+ var offsets = getOffset(gapMode);
1236
+ var documentWidth = document.documentElement.clientWidth;
1237
+ var windowWidth = window.innerWidth;
1238
+ return {
1239
+ left: offsets[0],
1240
+ top: offsets[1],
1241
+ right: offsets[2],
1242
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
1243
+ };
1244
+ };
1245
+
1246
+ var Style = styleSingleton();
1247
+ // important tip - once we measure scrollBar width and remove them
1248
+ // we could not repeat this operation
1249
+ // thus we are using style-singleton - only the first "yet correct" style will be applied.
1250
+ var getStyles = function (_a, allowRelative, gapMode, important) {
1251
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
1252
+ if (gapMode === void 0) { gapMode = 'margin'; }
1253
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
1254
+ allowRelative && "position: relative ".concat(important, ";"),
1255
+ gapMode === 'margin' &&
1256
+ "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
1257
+ gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
1258
+ ]
1259
+ .filter(Boolean)
1260
+ .join(''), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
1261
+ };
1262
+ /**
1263
+ * Removes page scrollbar and blocks page scroll when mounted
1264
+ */
1265
+ var RemoveScrollBar = function (props) {
1266
+ var noRelative = props.noRelative, noImportant = props.noImportant, _a = props.gapMode, gapMode = _a === void 0 ? 'margin' : _a;
1267
+ /*
1268
+ gap will be measured on every component mount
1269
+ however it will be used only by the "first" invocation
1270
+ due to singleton nature of <Style
1271
+ */
1272
+ var gap = React__namespace.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
1273
+ return React__namespace.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
1274
+ };
1275
+
1276
+ var passiveSupported = false;
1277
+ if (typeof window !== 'undefined') {
1278
+ try {
1279
+ var options = Object.defineProperty({}, 'passive', {
1280
+ get: function () {
1281
+ passiveSupported = true;
1282
+ return true;
1283
+ },
1284
+ });
1285
+ // @ts-ignore
1286
+ window.addEventListener('test', options, options);
1287
+ // @ts-ignore
1288
+ window.removeEventListener('test', options, options);
1289
+ }
1290
+ catch (err) {
1291
+ passiveSupported = false;
1292
+ }
1293
+ }
1294
+ var nonPassive = passiveSupported ? { passive: false } : false;
1295
+
1296
+ var alwaysContainsScroll = function (node) {
1297
+ // textarea will always _contain_ scroll inside self. It only can be hidden
1298
+ return node.tagName === 'TEXTAREA';
1299
+ };
1300
+ var elementCanBeScrolled = function (node, overflow) {
1301
+ var styles = window.getComputedStyle(node);
1302
+ return (
1303
+ // not-not-scrollable
1304
+ styles[overflow] !== 'hidden' &&
1305
+ // contains scroll inside self
1306
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
1307
+ };
1308
+ var elementCouldBeVScrolled = function (node) { return elementCanBeScrolled(node, 'overflowY'); };
1309
+ var elementCouldBeHScrolled = function (node) { return elementCanBeScrolled(node, 'overflowX'); };
1310
+ var locationCouldBeScrolled = function (axis, node) {
1311
+ var current = node;
1312
+ do {
1313
+ // Skip over shadow root
1314
+ if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
1315
+ current = current.host;
1316
+ }
1317
+ var isScrollable = elementCouldBeScrolled(axis, current);
1318
+ if (isScrollable) {
1319
+ var _a = getScrollVariables(axis, current), s = _a[1], d = _a[2];
1320
+ if (s > d) {
1321
+ return true;
1322
+ }
1323
+ }
1324
+ current = current.parentNode;
1325
+ } while (current && current !== document.body);
1326
+ return false;
1327
+ };
1328
+ var getVScrollVariables = function (_a) {
1329
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
1330
+ return [
1331
+ scrollTop,
1332
+ scrollHeight,
1333
+ clientHeight,
1334
+ ];
1335
+ };
1336
+ var getHScrollVariables = function (_a) {
1337
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
1338
+ return [
1339
+ scrollLeft,
1340
+ scrollWidth,
1341
+ clientWidth,
1342
+ ];
1343
+ };
1344
+ var elementCouldBeScrolled = function (axis, node) {
1345
+ return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
1346
+ };
1347
+ var getScrollVariables = function (axis, node) {
1348
+ return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
1349
+ };
1350
+ var getDirectionFactor = function (axis, direction) {
1351
+ /**
1352
+ * If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
1353
+ * and then increasingly negative as you scroll towards the end of the content.
1354
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
1355
+ */
1356
+ return axis === 'h' && direction === 'rtl' ? -1 : 1;
1357
+ };
1358
+ var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) {
1359
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
1360
+ var delta = directionFactor * sourceDelta;
1361
+ // find scrollable target
1362
+ var target = event.target;
1363
+ var targetInLock = endTarget.contains(target);
1364
+ var shouldCancelScroll = false;
1365
+ var isDeltaPositive = delta > 0;
1366
+ var availableScroll = 0;
1367
+ var availableScrollTop = 0;
1368
+ do {
1369
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
1370
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
1371
+ if (position || elementScroll) {
1372
+ if (elementCouldBeScrolled(axis, target)) {
1373
+ availableScroll += elementScroll;
1374
+ availableScrollTop += position;
1375
+ }
1376
+ }
1377
+ target = target.parentNode;
1378
+ } while (
1379
+ // portaled content
1380
+ (!targetInLock && target !== document.body) ||
1381
+ // self content
1382
+ (targetInLock && (endTarget.contains(target) || endTarget === target)));
1383
+ if (isDeltaPositive && ((noOverscroll && availableScroll === 0) || (!noOverscroll && delta > availableScroll))) {
1384
+ shouldCancelScroll = true;
1385
+ }
1386
+ else if (!isDeltaPositive &&
1387
+ ((noOverscroll && availableScrollTop === 0) || (!noOverscroll && -delta > availableScrollTop))) {
1388
+ shouldCancelScroll = true;
1389
+ }
1390
+ return shouldCancelScroll;
1391
+ };
1392
+
1393
+ var getTouchXY = function (event) {
1394
+ return 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
1395
+ };
1396
+ var getDeltaXY = function (event) { return [event.deltaX, event.deltaY]; };
1397
+ var extractRef = function (ref) {
1398
+ return ref && 'current' in ref ? ref.current : ref;
1399
+ };
1400
+ var deltaCompare = function (x, y) { return x[0] === y[0] && x[1] === y[1]; };
1401
+ var generateStyle = function (id) { return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); };
1402
+ var idCounter = 0;
1403
+ var lockStack = [];
1404
+ function RemoveScrollSideCar(props) {
1405
+ var shouldPreventQueue = React__namespace.useRef([]);
1406
+ var touchStartRef = React__namespace.useRef([0, 0]);
1407
+ var activeAxis = React__namespace.useRef();
1408
+ var id = React__namespace.useState(idCounter++)[0];
1409
+ var Style = React__namespace.useState(function () { return styleSingleton(); })[0];
1410
+ var lastProps = React__namespace.useRef(props);
1411
+ React__namespace.useEffect(function () {
1412
+ lastProps.current = props;
1413
+ }, [props]);
1414
+ React__namespace.useEffect(function () {
1415
+ if (props.inert) {
1416
+ document.body.classList.add("block-interactivity-".concat(id));
1417
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
1418
+ allow_1.forEach(function (el) { return el.classList.add("allow-interactivity-".concat(id)); });
1419
+ return function () {
1420
+ document.body.classList.remove("block-interactivity-".concat(id));
1421
+ allow_1.forEach(function (el) { return el.classList.remove("allow-interactivity-".concat(id)); });
1422
+ };
1423
+ }
1424
+ return;
1425
+ }, [props.inert, props.lockRef.current, props.shards]);
1426
+ var shouldCancelEvent = React__namespace.useCallback(function (event, parent) {
1427
+ if ('touches' in event && event.touches.length === 2) {
1428
+ return !lastProps.current.allowPinchZoom;
1429
+ }
1430
+ var touch = getTouchXY(event);
1431
+ var touchStart = touchStartRef.current;
1432
+ var deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
1433
+ var deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
1434
+ var currentAxis;
1435
+ var target = event.target;
1436
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
1437
+ // allow horizontal touch move on Range inputs. They will not cause any scroll
1438
+ if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
1439
+ return false;
1440
+ }
1441
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
1442
+ if (!canBeScrolledInMainDirection) {
1443
+ return true;
1444
+ }
1445
+ if (canBeScrolledInMainDirection) {
1446
+ currentAxis = moveDirection;
1447
+ }
1448
+ else {
1449
+ currentAxis = moveDirection === 'v' ? 'h' : 'v';
1450
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
1451
+ // other axis might be not scrollable
1452
+ }
1453
+ if (!canBeScrolledInMainDirection) {
1454
+ return false;
1455
+ }
1456
+ if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
1457
+ activeAxis.current = currentAxis;
1458
+ }
1459
+ if (!currentAxis) {
1460
+ return true;
1461
+ }
1462
+ var cancelingAxis = activeAxis.current || currentAxis;
1463
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY, true);
1464
+ }, []);
1465
+ var shouldPrevent = React__namespace.useCallback(function (_event) {
1466
+ var event = _event;
1467
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
1468
+ // not the last active
1469
+ return;
1470
+ }
1471
+ var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
1472
+ var sourceEvent = shouldPreventQueue.current.filter(function (e) { return e.name === event.type && e.target === event.target && deltaCompare(e.delta, delta); })[0];
1473
+ // self event, and should be canceled
1474
+ if (sourceEvent && sourceEvent.should) {
1475
+ if (event.cancelable) {
1476
+ event.preventDefault();
1477
+ }
1478
+ return;
1479
+ }
1480
+ // outside or shard event
1481
+ if (!sourceEvent) {
1482
+ var shardNodes = (lastProps.current.shards || [])
1483
+ .map(extractRef)
1484
+ .filter(Boolean)
1485
+ .filter(function (node) { return node.contains(event.target); });
1486
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
1487
+ if (shouldStop) {
1488
+ if (event.cancelable) {
1489
+ event.preventDefault();
1490
+ }
1491
+ }
1492
+ }
1493
+ }, []);
1494
+ var shouldCancel = React__namespace.useCallback(function (name, delta, target, should) {
1495
+ var event = { name: name, delta: delta, target: target, should: should };
1496
+ shouldPreventQueue.current.push(event);
1497
+ setTimeout(function () {
1498
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function (e) { return e !== event; });
1499
+ }, 1);
1500
+ }, []);
1501
+ var scrollTouchStart = React__namespace.useCallback(function (event) {
1502
+ touchStartRef.current = getTouchXY(event);
1503
+ activeAxis.current = undefined;
1504
+ }, []);
1505
+ var scrollWheel = React__namespace.useCallback(function (event) {
1506
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
1507
+ }, []);
1508
+ var scrollTouchMove = React__namespace.useCallback(function (event) {
1509
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
1510
+ }, []);
1511
+ React__namespace.useEffect(function () {
1512
+ lockStack.push(Style);
1513
+ props.setCallbacks({
1514
+ onScrollCapture: scrollWheel,
1515
+ onWheelCapture: scrollWheel,
1516
+ onTouchMoveCapture: scrollTouchMove,
1517
+ });
1518
+ document.addEventListener('wheel', shouldPrevent, nonPassive);
1519
+ document.addEventListener('touchmove', shouldPrevent, nonPassive);
1520
+ document.addEventListener('touchstart', scrollTouchStart, nonPassive);
1521
+ return function () {
1522
+ lockStack = lockStack.filter(function (inst) { return inst !== Style; });
1523
+ document.removeEventListener('wheel', shouldPrevent, nonPassive);
1524
+ document.removeEventListener('touchmove', shouldPrevent, nonPassive);
1525
+ document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
1526
+ };
1527
+ }, []);
1528
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
1529
+ return (React__namespace.createElement(React__namespace.Fragment, null,
1530
+ inert ? React__namespace.createElement(Style, { styles: generateStyle(id) }) : null,
1531
+ removeScrollBar ? React__namespace.createElement(RemoveScrollBar, { gapMode: "margin" }) : null));
1532
+ }
1533
+
1534
+ var SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
1535
+
1536
+ var ReactRemoveScroll = React__namespace.forwardRef(function (props, ref) { return (React__namespace.createElement(RemoveScroll, __assign$1({}, props, { ref: ref, sideCar: SideCar }))); });
1537
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
1538
+ var $01b9c$RemoveScroll = ReactRemoveScroll;
1539
+
1540
+ const $cc7e05a45900e73f$var$OPEN_KEYS = [
1541
+ ' ',
1542
+ 'Enter',
1543
+ 'ArrowUp',
1544
+ 'ArrowDown'
1545
+ ];
1546
+ const $cc7e05a45900e73f$var$SELECTION_KEYS = [
1547
+ ' ',
1548
+ 'Enter'
1549
+ ];
1550
+ /* -------------------------------------------------------------------------------------------------
1551
+ * Select
1552
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SELECT_NAME = 'Select';
1553
+ const [$cc7e05a45900e73f$var$Collection, $cc7e05a45900e73f$var$useCollection, $cc7e05a45900e73f$var$createCollectionScope] = $e02a7d9cb1dc128c$export$c74125a8e3af6bb2($cc7e05a45900e73f$var$SELECT_NAME);
1554
+ const [$cc7e05a45900e73f$var$createSelectContext, $cc7e05a45900e73f$export$286727a75dc039bd] = BtIconTickAlt2Px.$c512c27ab02ef895$export$50c7b4e9d9f19c1($cc7e05a45900e73f$var$SELECT_NAME, [
1555
+ $cc7e05a45900e73f$var$createCollectionScope
1556
+ ]);
1557
+ const [$cc7e05a45900e73f$var$SelectProvider, $cc7e05a45900e73f$var$useSelectContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
1558
+ const [$cc7e05a45900e73f$var$SelectNativeOptionsProvider, $cc7e05a45900e73f$var$useSelectNativeOptionsContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
1559
+ const $cc7e05a45900e73f$export$ef9b1a59e592288f = (props)=>{
1560
+ 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;
1561
+ const [trigger, setTrigger] = React$1.useState(null);
1562
+ const [valueNode, setValueNode] = React$1.useState(null);
1563
+ const [valueNodeHasChildren, setValueNodeHasChildren] = React$1.useState(false);
1564
+ const direction = $f631663db3294ace$export$b39126d51d94e6f3(dir);
1565
+ const [open = false, setOpen] = BtIconTickAlt2Px.$71cd76cc60e0454e$export$6f32135080cb4c3({
1566
+ prop: openProp,
1567
+ defaultProp: defaultOpen,
1568
+ onChange: onOpenChange
1569
+ });
1570
+ const [value, setValue] = BtIconTickAlt2Px.$71cd76cc60e0454e$export$6f32135080cb4c3({
1571
+ prop: valueProp,
1572
+ defaultProp: defaultValue,
1573
+ onChange: onValueChange
1574
+ });
1575
+ const triggerPointerDownPosRef = React$1.useRef(null); // We set this to true by default so that events bubble to forms without JS (SSR)
1576
+ const isFormControl = trigger ? Boolean(trigger.closest('form')) : true;
1577
+ const [nativeOptionsSet, setNativeOptionsSet] = React$1.useState(new Set()); // The native `select` only associates the correct default value if the corresponding
1578
+ // `option` is rendered as a child **at the same time** as itself.
1579
+ // Because it might take a few renders for our items to gather the information to build
1580
+ // the native `option`(s), we generate a key on the `select` to make sure React re-builds it
1581
+ // each time the options change.
1582
+ const nativeSelectKey = Array.from(nativeOptionsSet).map((option)=>option.props.value
1583
+ ).join(';');
1584
+ return /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$SelectProvider, {
1585
+ required: required,
1586
+ scope: __scopeSelect,
1587
+ trigger: trigger,
1588
+ onTriggerChange: setTrigger,
1589
+ valueNode: valueNode,
1590
+ onValueNodeChange: setValueNode,
1591
+ valueNodeHasChildren: valueNodeHasChildren,
1592
+ onValueNodeHasChildrenChange: setValueNodeHasChildren,
1593
+ contentId: $1746a345f3d73bb7$export$f680877a34711e37(),
1594
+ value: value,
1595
+ onValueChange: setValue,
1596
+ open: open,
1597
+ onOpenChange: setOpen,
1598
+ dir: direction,
1599
+ triggerPointerDownPosRef: triggerPointerDownPosRef,
1600
+ disabled: disabled
1601
+ }, /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$Collection.Provider, {
1602
+ scope: __scopeSelect
1603
+ }, /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$SelectNativeOptionsProvider, {
1604
+ scope: props.__scopeSelect,
1605
+ onNativeOptionAdd: React$1.useCallback((option)=>{
1606
+ setNativeOptionsSet((prev)=>new Set(prev).add(option)
1607
+ );
1608
+ }, []),
1609
+ onNativeOptionRemove: React$1.useCallback((option)=>{
1610
+ setNativeOptionsSet((prev)=>{
1611
+ const optionsSet = new Set(prev);
1612
+ optionsSet.delete(option);
1613
+ return optionsSet;
1614
+ });
1615
+ }, [])
1616
+ }, children)), isFormControl ? /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$BubbleSelect, {
1617
+ key: nativeSelectKey,
1618
+ "aria-hidden": true,
1619
+ required: required,
1620
+ tabIndex: -1,
1621
+ name: name,
1622
+ autoComplete: autoComplete,
1623
+ value: value // enable form autofill
1624
+ ,
1625
+ onChange: (event)=>setValue(event.target.value)
1626
+ ,
1627
+ disabled: disabled
1628
+ }, value === undefined ? /*#__PURE__*/ React$1.createElement("option", {
1629
+ value: ""
1630
+ }) : null, Array.from(nativeOptionsSet)) : null);
1631
+ };
1632
+ /* -------------------------------------------------------------------------------------------------
1633
+ * SelectTrigger
1634
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$TRIGGER_NAME = 'SelectTrigger';
1635
+ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
1636
+ const { __scopeSelect: __scopeSelect , disabled: disabled = false , ...triggerProps } = props;
1637
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$TRIGGER_NAME, __scopeSelect);
1638
+ const isDisabled = context.disabled || disabled;
1639
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.onTriggerChange);
1640
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
1641
+ const [searchRef, handleTypeaheadSearch, resetTypeahead] = $cc7e05a45900e73f$var$useTypeaheadSearch((search)=>{
1642
+ const enabledItems = getItems().filter((item)=>!item.disabled
1643
+ );
1644
+ const currentItem = enabledItems.find((item)=>item.value === context.value
1645
+ );
1646
+ const nextItem = $cc7e05a45900e73f$var$findNextItem(enabledItems, search, currentItem);
1647
+ if (nextItem !== undefined) context.onValueChange(nextItem.value);
1648
+ });
1649
+ const handleOpen = ()=>{
1650
+ if (!isDisabled) {
1651
+ context.onOpenChange(true); // reset typeahead when we open
1652
+ resetTypeahead();
1653
+ }
1654
+ };
1655
+ return /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.button, BtIconTickAlt2Px._extends({
1656
+ type: "button",
1657
+ role: "combobox",
1658
+ "aria-controls": context.contentId,
1659
+ "aria-expanded": context.open,
1660
+ "aria-required": context.required,
1661
+ "aria-autocomplete": "none",
1662
+ dir: context.dir,
1663
+ "data-state": context.open ? 'open' : 'closed',
1664
+ disabled: isDisabled,
1665
+ "data-disabled": isDisabled ? '' : undefined,
1666
+ "data-placeholder": context.value === undefined ? '' : undefined
1667
+ }, triggerProps, {
1668
+ ref: composedRefs // Enable compatibility with native label or custom `Label` "click" for Safari:
1669
+ ,
1670
+ onClick: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onClick, (event)=>{
1671
+ // Whilst browsers generally have no issue focusing the trigger when clicking
1672
+ // on a label, Safari seems to struggle with the fact that there's no `onClick`.
1673
+ // We force `focus` in this case. Note: this doesn't create any other side-effect
1674
+ // because we are preventing default in `onPointerDown` so effectively
1675
+ // this only runs for a label "click"
1676
+ event.currentTarget.focus();
1677
+ }),
1678
+ onPointerDown: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onPointerDown, (event)=>{
1679
+ // prevent implicit pointer capture
1680
+ // https://www.w3.org/TR/pointerevents3/#implicit-pointer-capture
1681
+ const target = event.target;
1682
+ if (target.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);
1683
+ // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
1684
+ // but not when the control key is pressed (avoiding MacOS right click)
1685
+ if (event.button === 0 && event.ctrlKey === false) {
1686
+ handleOpen();
1687
+ context.triggerPointerDownPosRef.current = {
1688
+ x: Math.round(event.pageX),
1689
+ y: Math.round(event.pageY)
1690
+ }; // prevent trigger from stealing focus from the active item after opening.
1691
+ event.preventDefault();
1692
+ }
1693
+ }),
1694
+ onKeyDown: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onKeyDown, (event)=>{
1695
+ const isTypingAhead = searchRef.current !== '';
1696
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
1697
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
1698
+ if (isTypingAhead && event.key === ' ') return;
1699
+ if ($cc7e05a45900e73f$var$OPEN_KEYS.includes(event.key)) {
1700
+ handleOpen();
1701
+ event.preventDefault();
1702
+ }
1703
+ })
1704
+ }));
1705
+ });
1706
+ /* -------------------------------------------------------------------------------------------------
1707
+ * SelectValue
1708
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VALUE_NAME = 'SelectValue';
1709
+ const $cc7e05a45900e73f$export$e288731fd71264f0 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
1710
+ // We ignore `className` and `style` as this part shouldn't be styled.
1711
+ const { __scopeSelect: __scopeSelect , className: className , style: style , children: children , placeholder: placeholder , ...valueProps } = props;
1712
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$VALUE_NAME, __scopeSelect);
1713
+ const { onValueNodeHasChildrenChange: onValueNodeHasChildrenChange } = context;
1714
+ const hasChildren = children !== undefined;
1715
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.onValueNodeChange);
1716
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
1717
+ onValueNodeHasChildrenChange(hasChildren);
1718
+ }, [
1719
+ onValueNodeHasChildrenChange,
1720
+ hasChildren
1721
+ ]);
1722
+ return /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.span, BtIconTickAlt2Px._extends({}, valueProps, {
1723
+ ref: composedRefs // we don't want events from the portalled `SelectValue` children to bubble
1724
+ ,
1725
+ style: {
1726
+ pointerEvents: 'none'
1727
+ }
1728
+ }), context.value === undefined && placeholder !== undefined ? placeholder : children);
1729
+ });
1730
+ const $cc7e05a45900e73f$export$99b400cabb58c515 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
1731
+ const { __scopeSelect: __scopeSelect , children: children , ...iconProps } = props;
1732
+ return /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.span, BtIconTickAlt2Px._extends({
1733
+ "aria-hidden": true
1734
+ }, iconProps, {
1735
+ ref: forwardedRef
1736
+ }), children || '▼');
1737
+ });
1738
+ const $cc7e05a45900e73f$export$b2af6c9944296213 = (props)=>{
1739
+ return /*#__PURE__*/ React$1.createElement($f1701beae083dbae$export$602eac185826482c, BtIconTickAlt2Px._extends({
1740
+ asChild: true
1741
+ }, props));
1742
+ };
1743
+ /* -------------------------------------------------------------------------------------------------
1744
+ * SelectContent
1745
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$CONTENT_NAME = 'SelectContent';
1746
+ const $cc7e05a45900e73f$export$c973a4b3cb86a03d = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
1747
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, props.__scopeSelect);
1748
+ const [fragment, setFragment] = React$1.useState(); // setting the fragment in `useLayoutEffect` as `DocumentFragment` doesn't exist on the server
1749
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
1750
+ setFragment(new DocumentFragment());
1751
+ }, []);
1752
+ return /*#__PURE__*/ React$1.createElement(React$1.Fragment, null, context.open ? /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$SelectContentImpl, BtIconTickAlt2Px._extends({}, props, {
1753
+ ref: forwardedRef
1754
+ })) : fragment ? /*#__PURE__*/ $7SXl2$reactdom.createPortal(/*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$SelectContentProvider, {
1755
+ scope: props.__scopeSelect
1756
+ }, /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$Collection.Slot, {
1757
+ scope: props.__scopeSelect
1758
+ }, /*#__PURE__*/ React$1.createElement("div", null, props.children))), fragment) : null);
1759
+ });
1760
+ const $cc7e05a45900e73f$var$CONTENT_MARGIN = 10;
1761
+ const [$cc7e05a45900e73f$var$SelectContentProvider, $cc7e05a45900e73f$var$useSelectContentContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$CONTENT_NAME);
1762
+ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
1763
+ const { __scopeSelect: __scopeSelect , onCloseAutoFocus: onCloseAutoFocus , ...contentProps } = props;
1764
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
1765
+ const [contentWrapper, setContentWrapper] = React$1.useState(null);
1766
+ const [content, setContent] = React$1.useState(null);
1767
+ const [viewport, setViewport] = React$1.useState(null);
1768
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
1769
+ );
1770
+ const [selectedItem, setSelectedItem] = React$1.useState(null);
1771
+ const [selectedItemText, setSelectedItemText] = React$1.useState(null);
1772
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
1773
+ const [isPositioned, setIsPositioned] = React$1.useState(false);
1774
+ const shouldRepositionRef = React$1.useRef(true);
1775
+ const shouldExpandOnScrollRef = React$1.useRef(false);
1776
+ const firstValidItemFoundRef = React$1.useRef(false); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
1777
+ React$1.useEffect(()=>{
1778
+ if (content) return hideOthers(content);
1779
+ }, [
1780
+ content
1781
+ ]); // Make sure the whole tree has focus guards as our `Select` may be
1782
+ // the last element in the DOM (because of the `Portal`)
1783
+ $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
1784
+ const [contentZIndex, setContentZIndex] = React$1.useState();
1785
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
1786
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
1787
+ }, [
1788
+ content
1789
+ ]);
1790
+ const focusFirst = React$1.useCallback((candidates)=>{
1791
+ const [firstItem, ...restItems] = getItems().map((item)=>item.ref.current
1792
+ );
1793
+ const [lastItem] = restItems.slice(-1);
1794
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
1795
+ for (const candidate of candidates){
1796
+ // if focus is already where we want to go, we don't want to keep going through the candidates
1797
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
1798
+ candidate === null || candidate === void 0 || candidate.scrollIntoView({
1799
+ block: 'nearest'
1800
+ }); // viewport might have padding so scroll to its edges when focusing first/last items.
1801
+ if (candidate === firstItem && viewport) viewport.scrollTop = 0;
1802
+ if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
1803
+ candidate === null || candidate === void 0 || candidate.focus();
1804
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
1805
+ }
1806
+ }, [
1807
+ getItems,
1808
+ viewport
1809
+ ]);
1810
+ const position = React$1.useCallback(()=>{
1811
+ if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
1812
+ const triggerRect = context.trigger.getBoundingClientRect(); // -----------------------------------------------------------------------------------------
1813
+ // Horizontal positioning
1814
+ // -----------------------------------------------------------------------------------------
1815
+ const contentRect = content.getBoundingClientRect();
1816
+ const valueNodeRect = context.valueNode.getBoundingClientRect();
1817
+ const itemTextRect = selectedItemText.getBoundingClientRect();
1818
+ if (context.dir !== 'rtl') {
1819
+ const itemTextOffset = itemTextRect.left - contentRect.left;
1820
+ const left = valueNodeRect.left - itemTextOffset;
1821
+ const leftDelta = triggerRect.left - left;
1822
+ const minContentWidth = triggerRect.width + leftDelta;
1823
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
1824
+ const rightEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
1825
+ const clampedLeft = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(left, [
1826
+ $cc7e05a45900e73f$var$CONTENT_MARGIN,
1827
+ rightEdge - contentWidth
1828
+ ]);
1829
+ contentWrapper.style.minWidth = minContentWidth + 'px';
1830
+ contentWrapper.style.left = clampedLeft + 'px';
1831
+ } else {
1832
+ const itemTextOffset = contentRect.right - itemTextRect.right;
1833
+ const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
1834
+ const rightDelta = window.innerWidth - triggerRect.right - right;
1835
+ const minContentWidth = triggerRect.width + rightDelta;
1836
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
1837
+ const leftEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
1838
+ const clampedRight = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(right, [
1839
+ $cc7e05a45900e73f$var$CONTENT_MARGIN,
1840
+ leftEdge - contentWidth
1841
+ ]);
1842
+ contentWrapper.style.minWidth = minContentWidth + 'px';
1843
+ contentWrapper.style.right = clampedRight + 'px';
1844
+ } // -----------------------------------------------------------------------------------------
1845
+ // Vertical positioning
1846
+ // -----------------------------------------------------------------------------------------
1847
+ const items = getItems();
1848
+ const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
1849
+ const itemsHeight = viewport.scrollHeight;
1850
+ const contentStyles = window.getComputedStyle(content);
1851
+ const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
1852
+ const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
1853
+ const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
1854
+ const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
1855
+ const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth; // prettier-ignore
1856
+ const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
1857
+ const viewportStyles = window.getComputedStyle(viewport);
1858
+ const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
1859
+ const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
1860
+ const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - $cc7e05a45900e73f$var$CONTENT_MARGIN;
1861
+ const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
1862
+ const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
1863
+ const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
1864
+ const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
1865
+ const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
1866
+ const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
1867
+ if (willAlignWithoutTopOverflow) {
1868
+ const isLastItem = selectedItem === items[items.length - 1].ref.current;
1869
+ contentWrapper.style.bottom = "0px";
1870
+ const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
1871
+ const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
1872
+ const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
1873
+ contentWrapper.style.height = height + 'px';
1874
+ } else {
1875
+ const isFirstItem = selectedItem === items[0].ref.current;
1876
+ contentWrapper.style.top = "0px";
1877
+ const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
1878
+ const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
1879
+ contentWrapper.style.height = height + 'px';
1880
+ viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
1881
+ }
1882
+ contentWrapper.style.margin = `${$cc7e05a45900e73f$var$CONTENT_MARGIN}px 0`;
1883
+ contentWrapper.style.minHeight = minContentHeight + 'px';
1884
+ contentWrapper.style.maxHeight = availableHeight + 'px'; // -----------------------------------------------------------------------------------------
1885
+ setIsPositioned(true); // we don't want the initial scroll position adjustment to trigger "expand on scroll"
1886
+ // so we explicitly turn it on only after they've registered.
1887
+ requestAnimationFrame(()=>shouldExpandOnScrollRef.current = true
1888
+ );
1889
+ }
1890
+ }, [
1891
+ getItems,
1892
+ context.trigger,
1893
+ context.valueNode,
1894
+ contentWrapper,
1895
+ content,
1896
+ viewport,
1897
+ selectedItem,
1898
+ selectedItemText,
1899
+ context.dir
1900
+ ]);
1901
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>position()
1902
+ , [
1903
+ position
1904
+ ]);
1905
+ const focusSelectedItem = React$1.useCallback(()=>focusFirst([
1906
+ selectedItem,
1907
+ content
1908
+ ])
1909
+ , [
1910
+ focusFirst,
1911
+ selectedItem,
1912
+ content
1913
+ ]); // Since this is not dependent on layout, we want to ensure this runs at the same time as
1914
+ // other effects across components. Hence why we don't call `focusSelectedItem` inside `position`.
1915
+ React$1.useEffect(()=>{
1916
+ if (isPositioned) focusSelectedItem();
1917
+ }, [
1918
+ isPositioned,
1919
+ focusSelectedItem
1920
+ ]); // When the viewport becomes scrollable at the top, the scroll up button will mount.
1921
+ // Because it is part of the normal flow, it will push down the viewport, thus throwing our
1922
+ // trigger => selectedItem alignment off by the amount the viewport was pushed down.
1923
+ // We wait for this to happen and then re-run the positining logic one more time to account for it.
1924
+ const handleScrollButtonChange = React$1.useCallback((node)=>{
1925
+ if (node && shouldRepositionRef.current === true) {
1926
+ position();
1927
+ focusSelectedItem();
1928
+ shouldRepositionRef.current = false;
1929
+ }
1930
+ }, [
1931
+ position,
1932
+ focusSelectedItem
1933
+ ]); // prevent selecting items on `pointerup` in some cases after opening from `pointerdown`
1934
+ // and close on `pointerup` outside.
1935
+ const { onOpenChange: onOpenChange , triggerPointerDownPosRef: triggerPointerDownPosRef } = context;
1936
+ React$1.useEffect(()=>{
1937
+ if (content) {
1938
+ let pointerMoveDelta = {
1939
+ x: 0,
1940
+ y: 0
1941
+ };
1942
+ const handlePointerMove = (event)=>{
1943
+ var _triggerPointerDownPo, _triggerPointerDownPo2, _triggerPointerDownPo3, _triggerPointerDownPo4;
1944
+ pointerMoveDelta = {
1945
+ x: Math.abs(Math.round(event.pageX) - ((_triggerPointerDownPo = (_triggerPointerDownPo2 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo2 === void 0 ? void 0 : _triggerPointerDownPo2.x) !== null && _triggerPointerDownPo !== void 0 ? _triggerPointerDownPo : 0)),
1946
+ y: Math.abs(Math.round(event.pageY) - ((_triggerPointerDownPo3 = (_triggerPointerDownPo4 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo4 === void 0 ? void 0 : _triggerPointerDownPo4.y) !== null && _triggerPointerDownPo3 !== void 0 ? _triggerPointerDownPo3 : 0))
1947
+ };
1948
+ };
1949
+ const handlePointerUp = (event)=>{
1950
+ // If the pointer hasn't moved by a certain threshold then we prevent selecting item on `pointerup`.
1951
+ if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) event.preventDefault();
1952
+ else // otherwise, if the event was outside the content, close.
1953
+ if (!content.contains(event.target)) onOpenChange(false);
1954
+ document.removeEventListener('pointermove', handlePointerMove);
1955
+ triggerPointerDownPosRef.current = null;
1956
+ };
1957
+ if (triggerPointerDownPosRef.current !== null) {
1958
+ document.addEventListener('pointermove', handlePointerMove);
1959
+ document.addEventListener('pointerup', handlePointerUp, {
1960
+ capture: true,
1961
+ once: true
1962
+ });
1963
+ }
1964
+ return ()=>{
1965
+ document.removeEventListener('pointermove', handlePointerMove);
1966
+ document.removeEventListener('pointerup', handlePointerUp, {
1967
+ capture: true
1968
+ });
1969
+ };
1970
+ }
1971
+ }, [
1972
+ content,
1973
+ onOpenChange,
1974
+ triggerPointerDownPosRef
1975
+ ]);
1976
+ React$1.useEffect(()=>{
1977
+ const close = ()=>onOpenChange(false)
1978
+ ;
1979
+ window.addEventListener('blur', close);
1980
+ window.addEventListener('resize', close);
1981
+ return ()=>{
1982
+ window.removeEventListener('blur', close);
1983
+ window.removeEventListener('resize', close);
1984
+ };
1985
+ }, [
1986
+ onOpenChange
1987
+ ]);
1988
+ const [searchRef, handleTypeaheadSearch] = $cc7e05a45900e73f$var$useTypeaheadSearch((search)=>{
1989
+ const enabledItems = getItems().filter((item)=>!item.disabled
1990
+ );
1991
+ const currentItem = enabledItems.find((item)=>item.ref.current === document.activeElement
1992
+ );
1993
+ const nextItem = $cc7e05a45900e73f$var$findNextItem(enabledItems, search, currentItem);
1994
+ if (nextItem) /**
1995
+ * Imperative focus during keydown is risky so we prevent React's batching updates
1996
+ * to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
1997
+ */ setTimeout(()=>nextItem.ref.current.focus()
1998
+ );
1999
+ });
2000
+ const itemRefCallback = React$1.useCallback((node, value, disabled)=>{
2001
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
2002
+ const isSelectedItem = context.value !== undefined && context.value === value;
2003
+ if (isSelectedItem || isFirstValidItem) {
2004
+ setSelectedItem(node);
2005
+ if (isFirstValidItem) firstValidItemFoundRef.current = true;
2006
+ }
2007
+ }, [
2008
+ context.value
2009
+ ]);
2010
+ const handleItemLeave = React$1.useCallback(()=>content === null || content === void 0 ? void 0 : content.focus()
2011
+ , [
2012
+ content
2013
+ ]);
2014
+ const itemTextRefCallback = React$1.useCallback((node, value, disabled)=>{
2015
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
2016
+ const isSelectedItem = context.value !== undefined && context.value === value;
2017
+ if (isSelectedItem || isFirstValidItem) setSelectedItemText(node);
2018
+ }, [
2019
+ context.value
2020
+ ]);
2021
+ return /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$SelectContentProvider, {
2022
+ scope: __scopeSelect,
2023
+ contentWrapper: contentWrapper,
2024
+ content: content,
2025
+ viewport: viewport,
2026
+ onViewportChange: setViewport,
2027
+ itemRefCallback: itemRefCallback,
2028
+ selectedItem: selectedItem,
2029
+ onItemLeave: handleItemLeave,
2030
+ itemTextRefCallback: itemTextRefCallback,
2031
+ selectedItemText: selectedItemText,
2032
+ onScrollButtonChange: handleScrollButtonChange,
2033
+ isPositioned: isPositioned,
2034
+ shouldExpandOnScrollRef: shouldExpandOnScrollRef,
2035
+ searchRef: searchRef
2036
+ }, /*#__PURE__*/ React$1.createElement($01b9c$RemoveScroll, {
2037
+ as: BtIconTickAlt2Px.$5e63c961fc1ce211$export$8c6ed5c666ac1360,
2038
+ allowPinchZoom: true
2039
+ }, /*#__PURE__*/ React$1.createElement("div", {
2040
+ ref: setContentWrapper,
2041
+ style: {
2042
+ display: 'flex',
2043
+ flexDirection: 'column',
2044
+ position: 'fixed',
2045
+ zIndex: contentZIndex
2046
+ }
2047
+ }, /*#__PURE__*/ React$1.createElement($d3863c46a17e8a28$export$20e40289641fbbb6, {
2048
+ asChild: true // we make sure we're not trapping once it's been closed
2049
+ ,
2050
+ trapped: context.open,
2051
+ onMountAutoFocus: (event)=>{
2052
+ // we prevent open autofocus because we manually focus the selected item
2053
+ event.preventDefault();
2054
+ },
2055
+ onUnmountAutoFocus: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(onCloseAutoFocus, (event)=>{
2056
+ var _context$trigger;
2057
+ (_context$trigger = context.trigger) === null || _context$trigger === void 0 || _context$trigger.focus({
2058
+ preventScroll: true
2059
+ });
2060
+ event.preventDefault();
2061
+ })
2062
+ }, /*#__PURE__*/ React$1.createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, BtIconTickAlt2Px._extends({
2063
+ role: "listbox",
2064
+ id: context.contentId,
2065
+ "data-state": context.open ? 'open' : 'closed',
2066
+ dir: context.dir,
2067
+ onContextMenu: (event)=>event.preventDefault()
2068
+ }, contentProps, {
2069
+ ref: composedRefs,
2070
+ style: {
2071
+ display: 'flex',
2072
+ flexDirection: 'column',
2073
+ // When we get the height of the content, it includes borders. If we were to set
2074
+ // the height without having `boxSizing: 'border-box'` it would be too big.
2075
+ boxSizing: 'border-box',
2076
+ maxHeight: '100%',
2077
+ outline: 'none',
2078
+ ...contentProps.style
2079
+ },
2080
+ disableOutsidePointerEvents: true // When focus is trapped, a focusout event may still happen.
2081
+ ,
2082
+ onFocusOutside: (event)=>event.preventDefault()
2083
+ ,
2084
+ onDismiss: ()=>context.onOpenChange(false)
2085
+ ,
2086
+ onKeyDown: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(contentProps.onKeyDown, (event)=>{
2087
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey; // select should not be navigated using tab key so we prevent it
2088
+ if (event.key === 'Tab') event.preventDefault();
2089
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
2090
+ if ([
2091
+ 'ArrowUp',
2092
+ 'ArrowDown',
2093
+ 'Home',
2094
+ 'End'
2095
+ ].includes(event.key)) {
2096
+ const items = getItems().filter((item)=>!item.disabled
2097
+ );
2098
+ let candidateNodes = items.map((item)=>item.ref.current
2099
+ );
2100
+ if ([
2101
+ 'ArrowUp',
2102
+ 'End'
2103
+ ].includes(event.key)) candidateNodes = candidateNodes.slice().reverse();
2104
+ if ([
2105
+ 'ArrowUp',
2106
+ 'ArrowDown'
2107
+ ].includes(event.key)) {
2108
+ const currentElement = event.target;
2109
+ const currentIndex = candidateNodes.indexOf(currentElement);
2110
+ candidateNodes = candidateNodes.slice(currentIndex + 1);
2111
+ }
2112
+ /**
2113
+ * Imperative focus during keydown is risky so we prevent React's batching updates
2114
+ * to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
2115
+ */ setTimeout(()=>focusFirst(candidateNodes)
2116
+ );
2117
+ event.preventDefault();
2118
+ }
2119
+ })
2120
+ }))))));
2121
+ });
2122
+ /* -------------------------------------------------------------------------------------------------
2123
+ * SelectViewport
2124
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VIEWPORT_NAME = 'SelectViewport';
2125
+ const $cc7e05a45900e73f$export$9ed6e7b40248d36d = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
2126
+ const { __scopeSelect: __scopeSelect , ...viewportProps } = props;
2127
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$VIEWPORT_NAME, __scopeSelect);
2128
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onViewportChange);
2129
+ const prevScrollTopRef = React$1.useRef(0);
2130
+ return /*#__PURE__*/ React$1.createElement(React$1.Fragment, null, /*#__PURE__*/ React$1.createElement("style", {
2131
+ dangerouslySetInnerHTML: {
2132
+ __html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
2133
+ }
2134
+ }), /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$Collection.Slot, {
2135
+ scope: __scopeSelect
2136
+ }, /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, BtIconTickAlt2Px._extends({
2137
+ "data-radix-select-viewport": "",
2138
+ role: "presentation"
2139
+ }, viewportProps, {
2140
+ ref: composedRefs,
2141
+ style: {
2142
+ // we use position: 'relative' here on the `viewport` so that when we call
2143
+ // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
2144
+ // (independent of the scrollUpButton).
2145
+ position: 'relative',
2146
+ flex: 1,
2147
+ overflow: 'auto',
2148
+ ...viewportProps.style
2149
+ },
2150
+ onScroll: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(viewportProps.onScroll, (event)=>{
2151
+ const viewport = event.currentTarget;
2152
+ const { contentWrapper: contentWrapper , shouldExpandOnScrollRef: shouldExpandOnScrollRef } = contentContext;
2153
+ if (shouldExpandOnScrollRef !== null && shouldExpandOnScrollRef !== void 0 && shouldExpandOnScrollRef.current && contentWrapper) {
2154
+ const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
2155
+ if (scrolledBy > 0) {
2156
+ const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
2157
+ const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
2158
+ const cssHeight = parseFloat(contentWrapper.style.height);
2159
+ const prevHeight = Math.max(cssMinHeight, cssHeight);
2160
+ if (prevHeight < availableHeight) {
2161
+ const nextHeight = prevHeight + scrolledBy;
2162
+ const clampedNextHeight = Math.min(availableHeight, nextHeight);
2163
+ const heightDiff = nextHeight - clampedNextHeight;
2164
+ contentWrapper.style.height = clampedNextHeight + 'px';
2165
+ if (contentWrapper.style.bottom === '0px') {
2166
+ viewport.scrollTop = heightDiff > 0 ? heightDiff : 0; // ensure the content stays pinned to the bottom
2167
+ contentWrapper.style.justifyContent = 'flex-end';
2168
+ }
2169
+ }
2170
+ }
2171
+ }
2172
+ prevScrollTopRef.current = viewport.scrollTop;
2173
+ })
2174
+ }))));
2175
+ });
2176
+ /* -------------------------------------------------------------------------------------------------
2177
+ * SelectGroup
2178
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$GROUP_NAME = 'SelectGroup';
2179
+ $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$GROUP_NAME);
2180
+ /* -------------------------------------------------------------------------------------------------
2181
+ * SelectItem
2182
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_NAME = 'SelectItem';
2183
+ const [$cc7e05a45900e73f$var$SelectItemContextProvider, $cc7e05a45900e73f$var$useSelectItemContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$ITEM_NAME);
2184
+ const $cc7e05a45900e73f$export$13ef48a934230896 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
2185
+ const { __scopeSelect: __scopeSelect , value: value , disabled: disabled = false , textValue: textValueProp , ...itemProps } = props;
2186
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
2187
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
2188
+ const isSelected = context.value === value;
2189
+ const [textValue, setTextValue] = React$1.useState(textValueProp !== null && textValueProp !== void 0 ? textValueProp : '');
2190
+ const [isFocused, setIsFocused] = React$1.useState(false);
2191
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>{
2192
+ var _contentContext$itemR;
2193
+ return (_contentContext$itemR = contentContext.itemRefCallback) === null || _contentContext$itemR === void 0 ? void 0 : _contentContext$itemR.call(contentContext, node, value, disabled);
2194
+ });
2195
+ const textId = $1746a345f3d73bb7$export$f680877a34711e37();
2196
+ const handleSelect = ()=>{
2197
+ if (!disabled) {
2198
+ context.onValueChange(value);
2199
+ context.onOpenChange(false);
2200
+ }
2201
+ };
2202
+ return /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$SelectItemContextProvider, {
2203
+ scope: __scopeSelect,
2204
+ value: value,
2205
+ disabled: disabled,
2206
+ textId: textId,
2207
+ isSelected: isSelected,
2208
+ onItemTextChange: React$1.useCallback((node)=>{
2209
+ setTextValue((prevTextValue)=>{
2210
+ var _node$textContent;
2211
+ return prevTextValue || ((_node$textContent = node === null || node === void 0 ? void 0 : node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : '').trim();
2212
+ });
2213
+ }, [])
2214
+ }, /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$Collection.ItemSlot, {
2215
+ scope: __scopeSelect,
2216
+ value: value,
2217
+ disabled: disabled,
2218
+ textValue: textValue
2219
+ }, /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, BtIconTickAlt2Px._extends({
2220
+ role: "option",
2221
+ "aria-labelledby": textId,
2222
+ "data-highlighted": isFocused ? '' : undefined // `isFocused` caveat fixes stuttering in VoiceOver
2223
+ ,
2224
+ "aria-selected": isSelected && isFocused,
2225
+ "data-state": isSelected ? 'checked' : 'unchecked',
2226
+ "aria-disabled": disabled || undefined,
2227
+ "data-disabled": disabled ? '' : undefined,
2228
+ tabIndex: disabled ? undefined : -1
2229
+ }, itemProps, {
2230
+ ref: composedRefs,
2231
+ onFocus: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onFocus, ()=>setIsFocused(true)
2232
+ ),
2233
+ onBlur: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onBlur, ()=>setIsFocused(false)
2234
+ ),
2235
+ onPointerUp: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerUp, handleSelect),
2236
+ onPointerMove: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerMove, (event)=>{
2237
+ if (disabled) {
2238
+ var _contentContext$onIte;
2239
+ (_contentContext$onIte = contentContext.onItemLeave) === null || _contentContext$onIte === void 0 || _contentContext$onIte.call(contentContext);
2240
+ } else // even though safari doesn't support this option, it's acceptable
2241
+ // as it only means it might scroll a few pixels when using the pointer.
2242
+ event.currentTarget.focus({
2243
+ preventScroll: true
2244
+ });
2245
+ }),
2246
+ onPointerLeave: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerLeave, (event)=>{
2247
+ if (event.currentTarget === document.activeElement) {
2248
+ var _contentContext$onIte2;
2249
+ (_contentContext$onIte2 = contentContext.onItemLeave) === null || _contentContext$onIte2 === void 0 || _contentContext$onIte2.call(contentContext);
2250
+ }
2251
+ }),
2252
+ onKeyDown: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onKeyDown, (event)=>{
2253
+ var _contentContext$searc;
2254
+ const isTypingAhead = ((_contentContext$searc = contentContext.searchRef) === null || _contentContext$searc === void 0 ? void 0 : _contentContext$searc.current) !== '';
2255
+ if (isTypingAhead && event.key === ' ') return;
2256
+ if ($cc7e05a45900e73f$var$SELECTION_KEYS.includes(event.key)) handleSelect(); // prevent page scroll if using the space key to select an item
2257
+ if (event.key === ' ') event.preventDefault();
2258
+ })
2259
+ }))));
2260
+ });
2261
+ /* -------------------------------------------------------------------------------------------------
2262
+ * SelectItemText
2263
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_TEXT_NAME = 'SelectItemText';
2264
+ const $cc7e05a45900e73f$export$3572fb0fb821ff49 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
2265
+ // We ignore `className` and `style` as this part shouldn't be styled.
2266
+ const { __scopeSelect: __scopeSelect , className: className , style: style , ...itemTextProps } = props;
2267
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2268
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2269
+ const itemContext = $cc7e05a45900e73f$var$useSelectItemContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2270
+ const nativeOptionsContext = $cc7e05a45900e73f$var$useSelectNativeOptionsContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2271
+ const [itemTextNode, setItemTextNode] = React$1.useState(null);
2272
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setItemTextNode(node)
2273
+ , itemContext.onItemTextChange, (node)=>{
2274
+ var _contentContext$itemT;
2275
+ return (_contentContext$itemT = contentContext.itemTextRefCallback) === null || _contentContext$itemT === void 0 ? void 0 : _contentContext$itemT.call(contentContext, node, itemContext.value, itemContext.disabled);
2276
+ });
2277
+ const textContent = itemTextNode === null || itemTextNode === void 0 ? void 0 : itemTextNode.textContent;
2278
+ const nativeOption = React$1.useMemo(()=>/*#__PURE__*/ React$1.createElement("option", {
2279
+ key: itemContext.value,
2280
+ value: itemContext.value,
2281
+ disabled: itemContext.disabled
2282
+ }, textContent)
2283
+ , [
2284
+ itemContext.disabled,
2285
+ itemContext.value,
2286
+ textContent
2287
+ ]);
2288
+ const { onNativeOptionAdd: onNativeOptionAdd , onNativeOptionRemove: onNativeOptionRemove } = nativeOptionsContext;
2289
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2290
+ onNativeOptionAdd(nativeOption);
2291
+ return ()=>onNativeOptionRemove(nativeOption)
2292
+ ;
2293
+ }, [
2294
+ onNativeOptionAdd,
2295
+ onNativeOptionRemove,
2296
+ nativeOption
2297
+ ]);
2298
+ return /*#__PURE__*/ React$1.createElement(React$1.Fragment, null, /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.span, BtIconTickAlt2Px._extends({
2299
+ id: itemContext.textId
2300
+ }, itemTextProps, {
2301
+ ref: composedRefs
2302
+ })), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? /*#__PURE__*/ $7SXl2$reactdom.createPortal(itemTextProps.children, context.valueNode) : null);
2303
+ });
2304
+ /* -------------------------------------------------------------------------------------------------
2305
+ * SelectItemIndicator
2306
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_INDICATOR_NAME = 'SelectItemIndicator';
2307
+ const $cc7e05a45900e73f$export$6b9198de19accfe6 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
2308
+ const { __scopeSelect: __scopeSelect , ...itemIndicatorProps } = props;
2309
+ const itemContext = $cc7e05a45900e73f$var$useSelectItemContext($cc7e05a45900e73f$var$ITEM_INDICATOR_NAME, __scopeSelect);
2310
+ return itemContext.isSelected ? /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.span, BtIconTickAlt2Px._extends({
2311
+ "aria-hidden": true
2312
+ }, itemIndicatorProps, {
2313
+ ref: forwardedRef
2314
+ })) : null;
2315
+ });
2316
+ /* -------------------------------------------------------------------------------------------------
2317
+ * SelectScrollUpButton
2318
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton';
2319
+ const $cc7e05a45900e73f$export$d8117927658af6d7 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
2320
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
2321
+ const [canScrollUp1, setCanScrollUp] = React$1.useState(false);
2322
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onScrollButtonChange);
2323
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2324
+ if (contentContext.viewport && contentContext.isPositioned) {
2325
+ const viewport = contentContext.viewport;
2326
+ function handleScroll() {
2327
+ const canScrollUp = viewport.scrollTop > 0;
2328
+ setCanScrollUp(canScrollUp);
2329
+ }
2330
+ handleScroll();
2331
+ viewport.addEventListener('scroll', handleScroll);
2332
+ return ()=>viewport.removeEventListener('scroll', handleScroll)
2333
+ ;
2334
+ }
2335
+ }, [
2336
+ contentContext.viewport,
2337
+ contentContext.isPositioned
2338
+ ]);
2339
+ return canScrollUp1 ? /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$SelectScrollButtonImpl, BtIconTickAlt2Px._extends({}, props, {
2340
+ ref: composedRefs,
2341
+ onAutoScroll: ()=>{
2342
+ const { viewport: viewport , selectedItem: selectedItem } = contentContext;
2343
+ if (viewport && selectedItem) viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
2344
+ }
2345
+ })) : null;
2346
+ });
2347
+ /* -------------------------------------------------------------------------------------------------
2348
+ * SelectScrollDownButton
2349
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton';
2350
+ const $cc7e05a45900e73f$export$ff951e476c12189 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
2351
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
2352
+ const [canScrollDown1, setCanScrollDown] = React$1.useState(false);
2353
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onScrollButtonChange);
2354
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2355
+ if (contentContext.viewport && contentContext.isPositioned) {
2356
+ const viewport = contentContext.viewport;
2357
+ function handleScroll() {
2358
+ const maxScroll = viewport.scrollHeight - viewport.clientHeight; // we use Math.ceil here because if the UI is zoomed-in
2359
+ // `scrollTop` is not always reported as an integer
2360
+ const canScrollDown = Math.ceil(viewport.scrollTop) < maxScroll;
2361
+ setCanScrollDown(canScrollDown);
2362
+ }
2363
+ handleScroll();
2364
+ viewport.addEventListener('scroll', handleScroll);
2365
+ return ()=>viewport.removeEventListener('scroll', handleScroll)
2366
+ ;
2367
+ }
2368
+ }, [
2369
+ contentContext.viewport,
2370
+ contentContext.isPositioned
2371
+ ]);
2372
+ return canScrollDown1 ? /*#__PURE__*/ React$1.createElement($cc7e05a45900e73f$var$SelectScrollButtonImpl, BtIconTickAlt2Px._extends({}, props, {
2373
+ ref: composedRefs,
2374
+ onAutoScroll: ()=>{
2375
+ const { viewport: viewport , selectedItem: selectedItem } = contentContext;
2376
+ if (viewport && selectedItem) viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
2377
+ }
2378
+ })) : null;
2379
+ });
2380
+ const $cc7e05a45900e73f$var$SelectScrollButtonImpl = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
2381
+ const { __scopeSelect: __scopeSelect , onAutoScroll: onAutoScroll , ...scrollIndicatorProps } = props;
2382
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext('SelectScrollButton', __scopeSelect);
2383
+ const autoScrollTimerRef = React$1.useRef(null);
2384
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
2385
+ const clearAutoScrollTimer = React$1.useCallback(()=>{
2386
+ if (autoScrollTimerRef.current !== null) {
2387
+ window.clearInterval(autoScrollTimerRef.current);
2388
+ autoScrollTimerRef.current = null;
2389
+ }
2390
+ }, []);
2391
+ React$1.useEffect(()=>{
2392
+ return ()=>clearAutoScrollTimer()
2393
+ ;
2394
+ }, [
2395
+ clearAutoScrollTimer
2396
+ ]); // When the viewport becomes scrollable on either side, the relevant scroll button will mount.
2397
+ // Because it is part of the normal flow, it will push down (top button) or shrink (bottom button)
2398
+ // the viewport, potentially causing the active item to now be partially out of view.
2399
+ // We re-run the `scrollIntoView` logic to make sure it stays within the viewport.
2400
+ BtIconTickAlt2Px.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2401
+ var _activeItem$ref$curre;
2402
+ const activeItem = getItems().find((item)=>item.ref.current === document.activeElement
2403
+ );
2404
+ activeItem === null || activeItem === void 0 || (_activeItem$ref$curre = activeItem.ref.current) === null || _activeItem$ref$curre === void 0 || _activeItem$ref$curre.scrollIntoView({
2405
+ block: 'nearest'
2406
+ });
2407
+ }, [
2408
+ getItems
2409
+ ]);
2410
+ return /*#__PURE__*/ React$1.createElement(BtIconTickAlt2Px.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, BtIconTickAlt2Px._extends({
2411
+ "aria-hidden": true
2412
+ }, scrollIndicatorProps, {
2413
+ ref: forwardedRef,
2414
+ style: {
2415
+ flexShrink: 0,
2416
+ ...scrollIndicatorProps.style
2417
+ },
2418
+ onPointerMove: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerMove, ()=>{
2419
+ var _contentContext$onIte3;
2420
+ (_contentContext$onIte3 = contentContext.onItemLeave) === null || _contentContext$onIte3 === void 0 || _contentContext$onIte3.call(contentContext);
2421
+ if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
2422
+ }),
2423
+ onPointerLeave: BtIconTickAlt2Px.$e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerLeave, ()=>{
2424
+ clearAutoScrollTimer();
2425
+ })
2426
+ }));
2427
+ });
2428
+ /* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$BubbleSelect = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
2429
+ const { value: value , ...selectProps } = props;
2430
+ const ref = React$1.useRef(null);
2431
+ const composedRefs = BtIconTickAlt2Px.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
2432
+ const prevValue = BtIconTickAlt2Px.$010c2913dbd2fe3d$export$5cae361ad82dce8b(value); // Bubble value change to parents (e.g form change event)
2433
+ React$1.useEffect(()=>{
2434
+ const select = ref.current;
2435
+ const selectProto = window.HTMLSelectElement.prototype;
2436
+ const descriptor = Object.getOwnPropertyDescriptor(selectProto, 'value');
2437
+ const setValue = descriptor.set;
2438
+ if (prevValue !== value && setValue) {
2439
+ const event = new Event('change', {
2440
+ bubbles: true
2441
+ });
2442
+ setValue.call(select, value);
2443
+ select.dispatchEvent(event);
2444
+ }
2445
+ }, [
2446
+ prevValue,
2447
+ value
2448
+ ]);
2449
+ /**
2450
+ * We purposefully use a `select` here to support form autofill as much
2451
+ * as possible.
2452
+ *
2453
+ * We purposefully do not add the `value` attribute here to allow the value
2454
+ * to be set programatically and bubble to any parent form `onChange` event.
2455
+ * Adding the `value` will cause React to consider the programatic
2456
+ * dispatch a duplicate and it will get swallowed.
2457
+ *
2458
+ * We use `VisuallyHidden` rather than `display: "none"` because Safari autofill
2459
+ * won't work otherwise.
2460
+ */ return /*#__PURE__*/ React$1.createElement($ea1ef594cf570d83$export$439d29a4e110a164, {
2461
+ asChild: true
2462
+ }, /*#__PURE__*/ React$1.createElement("select", BtIconTickAlt2Px._extends({}, selectProps, {
2463
+ ref: composedRefs,
2464
+ defaultValue: value
2465
+ })));
2466
+ });
2467
+ $cc7e05a45900e73f$var$BubbleSelect.displayName = 'BubbleSelect';
2468
+ function $cc7e05a45900e73f$var$useTypeaheadSearch(onSearchChange) {
2469
+ const handleSearchChange = BtIconTickAlt2Px.$b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onSearchChange);
2470
+ const searchRef = React$1.useRef('');
2471
+ const timerRef = React$1.useRef(0);
2472
+ const handleTypeaheadSearch = React$1.useCallback((key)=>{
2473
+ const search = searchRef.current + key;
2474
+ handleSearchChange(search);
2475
+ (function updateSearch(value) {
2476
+ searchRef.current = value;
2477
+ window.clearTimeout(timerRef.current); // Reset `searchRef` 1 second after it was last updated
2478
+ if (value !== '') timerRef.current = window.setTimeout(()=>updateSearch('')
2479
+ , 1000);
2480
+ })(search);
2481
+ }, [
2482
+ handleSearchChange
2483
+ ]);
2484
+ const resetTypeahead = React$1.useCallback(()=>{
2485
+ searchRef.current = '';
2486
+ window.clearTimeout(timerRef.current);
2487
+ }, []);
2488
+ React$1.useEffect(()=>{
2489
+ return ()=>window.clearTimeout(timerRef.current)
2490
+ ;
2491
+ }, []);
2492
+ return [
2493
+ searchRef,
2494
+ handleTypeaheadSearch,
2495
+ resetTypeahead
2496
+ ];
2497
+ }
2498
+ /**
2499
+ * This is the "meat" of the typeahead matching logic. It takes in a list of items,
2500
+ * the search and the current item, and returns the next item (or `undefined`).
2501
+ *
2502
+ * We normalize the search because if a user has repeatedly pressed a character,
2503
+ * we want the exact same behavior as if we only had that one character
2504
+ * (ie. cycle through items starting with that character)
2505
+ *
2506
+ * We also reorder the items by wrapping the array around the current item.
2507
+ * This is so we always look forward from the current item, and picking the first
2508
+ * item will always be the correct one.
2509
+ *
2510
+ * Finally, if the normalized search is exactly one character, we exclude the
2511
+ * current item from the values because otherwise it would be the first to match always
2512
+ * and focus would never move. This is as opposed to the regular case, where we
2513
+ * don't want focus to move if the current item still matches.
2514
+ */ function $cc7e05a45900e73f$var$findNextItem(items, search, currentItem) {
2515
+ const isRepeated = search.length > 1 && Array.from(search).every((char)=>char === search[0]
2516
+ );
2517
+ const normalizedSearch = isRepeated ? search[0] : search;
2518
+ const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
2519
+ let wrappedItems = $cc7e05a45900e73f$var$wrapArray(items, Math.max(currentItemIndex, 0));
2520
+ const excludeCurrentItem = normalizedSearch.length === 1;
2521
+ if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v)=>v !== currentItem
2522
+ );
2523
+ const nextItem = wrappedItems.find((item)=>item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
2524
+ );
2525
+ return nextItem !== currentItem ? nextItem : undefined;
2526
+ }
2527
+ /**
2528
+ * Wraps an array around itself at a given start index
2529
+ * Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
2530
+ */ function $cc7e05a45900e73f$var$wrapArray(array, startIndex) {
2531
+ return array.map((_, index)=>array[(startIndex + index) % array.length]
2532
+ );
2533
+ }
2534
+ const $cc7e05a45900e73f$export$be92b6f5f03c0fe9 = $cc7e05a45900e73f$export$ef9b1a59e592288f;
2535
+ const $cc7e05a45900e73f$export$41fb9f06171c75f4 = $cc7e05a45900e73f$export$3ac1e88a1c0b9f1;
2536
+ const $cc7e05a45900e73f$export$4c8d1a57a761ef94 = $cc7e05a45900e73f$export$e288731fd71264f0;
2537
+ const $cc7e05a45900e73f$export$f04a61298a47a40f = $cc7e05a45900e73f$export$99b400cabb58c515;
2538
+ const $cc7e05a45900e73f$export$602eac185826482c = $cc7e05a45900e73f$export$b2af6c9944296213;
2539
+ const $cc7e05a45900e73f$export$7c6e2c02157bb7d2 = $cc7e05a45900e73f$export$c973a4b3cb86a03d;
2540
+ const $cc7e05a45900e73f$export$d5c6c08dc2d3ca7 = $cc7e05a45900e73f$export$9ed6e7b40248d36d;
2541
+ const $cc7e05a45900e73f$export$6d08773d2e66f8f2 = $cc7e05a45900e73f$export$13ef48a934230896;
2542
+ const $cc7e05a45900e73f$export$d6e5bf9c43ea9319 = $cc7e05a45900e73f$export$3572fb0fb821ff49;
2543
+ const $cc7e05a45900e73f$export$c3468e2714d175fa = $cc7e05a45900e73f$export$6b9198de19accfe6;
2544
+ const $cc7e05a45900e73f$export$2f60d3ec9ad468f2 = $cc7e05a45900e73f$export$d8117927658af6d7;
2545
+ const $cc7e05a45900e73f$export$bf1aedc3039c8d63 = $cc7e05a45900e73f$export$ff951e476c12189;
2546
+
2547
+ const React = React__default["default"];
2548
+ const BtIconChevronUp2Px = props =>
2549
+ /*#__PURE__*/ React.createElement(
2550
+ "svg",
2551
+ Object.assign(
2552
+ {
2553
+ xmlns: "http://www.w3.org/2000/svg",
2554
+ viewBox: "0 0 32 32"
2555
+ },
2556
+ props
2557
+ ),
2558
+ /*#__PURE__*/ React.createElement("defs", null),
2559
+ /*#__PURE__*/ React.createElement("path", {
2560
+ d:
2561
+ "M28.999,23.5a.99676.99676,0,0,1-.707-.293l-12.28515-12.293L3.708,23.207A.99989.99989,0,0,1,2.294,21.793l13.71289-13.707L29.70605,21.793a.99976.99976,0,0,1-.707,1.707Z",
2562
+ fill: "currentColor"
2563
+ })
2564
+ );
2565
+ var BtIconChevronUp2Px_2 = BtIconChevronUp2Px;
2566
+
2567
+ /** Use `Select` to choose from a dropdown list of options. */
2568
+ var Select = function (_a) {
2569
+ var isRequired = _a.isRequired, isDisabled = _a.isDisabled, placeholder = _a.placeholder, label = _a.label, 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;
2570
+ var id = React$1.useId();
2571
+ var arcRootElement = React$1.useContext(Base.ArcRootElementContext);
2572
+ var surface = React$1.useContext(Surface.Context).surface;
2573
+ var _b = React$1.useState(defaultValue), selectedValue = _b[0], setSelectedValue = _b[1];
2574
+ var onValueChange = function (value) {
2575
+ onChange && onChange(value);
2576
+ setSelectedValue(value);
2577
+ };
2578
+ var getSelectedValueName = function (value) {
2579
+ var _a;
2580
+ return (_a = options.find(function (option) { return option.value === value; })) === null || _a === void 0 ? void 0 : _a.name;
2581
+ };
2582
+ return (React__default["default"].createElement(FormControl.FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, label: label, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", isDisabled: isDisabled, disclosureText: disclosureText, disclosureTitle: disclosureTitle, onClickDisclosure: onClickDisclosure },
2583
+ React__default["default"].createElement($cc7e05a45900e73f$export$be92b6f5f03c0fe9, { name: name, required: isRequired, disabled: isDisabled, defaultOpen: isDefaultOpen, value: selectedValue, onOpenChange: onOpenChange, onValueChange: function (value) { return onValueChange(value); } },
2584
+ React__default["default"].createElement($cc7e05a45900e73f$export$41fb9f06171c75f4, { id: id, name: name, onBlur: onBlur, className: index.classNames("arc-Select-trigger", {
2585
+ "arc-Select-trigger--constrained": !isFluid,
2586
+ "arc-Select-trigger--onDarkSurface": surface === "dark",
2587
+ "arc-Select-trigger--invalid": errorMessage
2588
+ }) },
2589
+ React__default["default"].createElement($cc7e05a45900e73f$export$4c8d1a57a761ef94, { asChild: true, "aria-label": getSelectedValueName(selectedValue) }, !selectedValue ? (React__default["default"].createElement("span", { "aria-hidden": true, className: "arc-Select-placeHolder" }, placeholder)) : (React__default["default"].createElement("span", { className: "arc-Select-valueItem" }, getSelectedValueName(selectedValue)))),
2590
+ React__default["default"].createElement($cc7e05a45900e73f$export$f04a61298a47a40f, { className: "arc-Select-triggerIcon" },
2591
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronDown2Px.BtIconChevronDown2Px_2, size: 20 }))),
2592
+ React__default["default"].createElement($cc7e05a45900e73f$export$602eac185826482c, { container: arcRootElement },
2593
+ React__default["default"].createElement($cc7e05a45900e73f$export$7c6e2c02157bb7d2, { className: index.classNames("arc-Select-content", {
2594
+ "arc-Select-content--onDarkSurface": surface === "dark"
2595
+ }) },
2596
+ React__default["default"].createElement($cc7e05a45900e73f$export$2f60d3ec9ad468f2, { className: "arc-Select-scrollButton" },
2597
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronUp2Px_2, size: 16 })),
2598
+ React__default["default"].createElement($cc7e05a45900e73f$export$d5c6c08dc2d3ca7, null, options.map(function (_a, i) {
2599
+ var name = _a.name, value = _a.value;
2600
+ return (React__default["default"].createElement($cc7e05a45900e73f$export$6d08773d2e66f8f2, { className: "arc-Select-item", key: "select-item-".concat(i), value: value },
2601
+ React__default["default"].createElement("div", { className: "arc-Select-itemTextWrapper" },
2602
+ React__default["default"].createElement($cc7e05a45900e73f$export$d6e5bf9c43ea9319, { asChild: true },
2603
+ React__default["default"].createElement("span", { className: "arc-Select-itemText" }, name))),
2604
+ React__default["default"].createElement($cc7e05a45900e73f$export$c3468e2714d175fa, null,
2605
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconTickAlt2Px.BtIconTickAlt2Px_2, size: 20 }))));
2606
+ })),
2607
+ React__default["default"].createElement($cc7e05a45900e73f$export$bf1aedc3039c8d63, { className: "arc-Select-scrollButton" },
2608
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronDown2Px.BtIconChevronDown2Px_2, size: 16 })))))));
2609
+ };
2610
+
2611
+ exports.Select = Select;