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