@sanity/ui 4.0.0-static.13 → 4.0.0-static.15

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.
package/dist/index.cjs DELETED
@@ -1,4514 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), react = require("react"), compilerRuntime = require("react/compiler-runtime"), css = require("@sanity/ui/css"), reactIs = require("react-is"), reactDom$1 = require("@floating-ui/react-dom"), framerMotion = require("framer-motion"), reactDom = require("react-dom"), dynamic = require("@vanilla-extract/dynamic"), useEffectEvent = require("use-effect-event"), resizeObserver = require("@juggle/resize-observer");
4
- const EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_PROPS = {
5
- card: {
6
- initial: {
7
- scale: 0.97,
8
- willChange: "transform"
9
- },
10
- hidden: {
11
- opacity: 0
12
- },
13
- visible: {
14
- opacity: 1,
15
- transition: {
16
- when: "beforeChildren",
17
- duration: 0.1
18
- }
19
- },
20
- scaleIn: {
21
- scale: 1
22
- },
23
- scaleOut: {
24
- scale: 0.97
25
- }
26
- },
27
- transition: {
28
- type: "spring",
29
- visualDuration: 0.2,
30
- bounce: 0.25
31
- }
32
- }, Z_OFFSETS = {
33
- dialog: 600,
34
- popover: 400,
35
- tooltip: 200
36
- };
37
- function _raf(fn) {
38
- const frameId = requestAnimationFrame(fn);
39
- return () => {
40
- cancelAnimationFrame(frameId);
41
- };
42
- }
43
- function _raf2(fn) {
44
- let innerDispose = null;
45
- const outerDispose = _raf(() => {
46
- innerDispose = _raf(fn);
47
- });
48
- return () => {
49
- innerDispose && innerDispose(), outerDispose();
50
- };
51
- }
52
- function _isEnterToClickElement(element) {
53
- return isHTMLAnchorElement(element) || isHTMLButtonElement(element);
54
- }
55
- function isHTMLElement(node) {
56
- return node instanceof Node && node.nodeType === Node.ELEMENT_NODE;
57
- }
58
- function isHTMLAnchorElement(element) {
59
- return isHTMLElement(element) && element.nodeName === "A";
60
- }
61
- function isHTMLInputElement(element) {
62
- return isHTMLElement(element) && element.nodeName === "INPUT";
63
- }
64
- function isHTMLButtonElement(element) {
65
- return isHTMLElement(element) && element.nodeName === "BUTTON";
66
- }
67
- function isHTMLSelectElement(element) {
68
- return isHTMLElement(element) && element.nodeName === "SELECT";
69
- }
70
- function isHTMLTextAreaElement(element) {
71
- return isHTMLElement(element) && element.nodeName === "TEXTAREA";
72
- }
73
- function containsOrEqualsElement(element, node) {
74
- return element.contains(node) || element === node;
75
- }
76
- function _hasFocus(element) {
77
- return !!document.activeElement && element.contains(document.activeElement);
78
- }
79
- function isFocusable(element) {
80
- return element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute("tabIndex") !== null ? !0 : isHTMLAnchorElement(element) ? !!element.href && element.rel !== "ignore" : isHTMLInputElement(element) ? element.type !== "hidden" && element.type !== "file" && !element.disabled : isHTMLButtonElement(element) || isHTMLSelectElement(element) || isHTMLTextAreaElement(element) ? !element.disabled : !1;
81
- }
82
- function attemptFocus(element) {
83
- if (!isFocusable(element))
84
- return !1;
85
- try {
86
- element.focus();
87
- } catch {
88
- }
89
- return document.activeElement === element;
90
- }
91
- function focusFirstDescendant(element) {
92
- for (let i = 0; i < element.childNodes.length; i++) {
93
- const child = element.childNodes[i];
94
- if (isHTMLElement(child) && (attemptFocus(child) || focusFirstDescendant(child)))
95
- return !0;
96
- }
97
- return !1;
98
- }
99
- function focusLastDescendant(element) {
100
- for (let i = element.childNodes.length - 1; i >= 0; i--) {
101
- const child = element.childNodes[i];
102
- if (isHTMLElement(child) && (attemptFocus(child) || focusLastDescendant(child)))
103
- return !0;
104
- }
105
- return !1;
106
- }
107
- function isArray(val) {
108
- return Array.isArray(val);
109
- }
110
- function isRecord(value) {
111
- return !!(value && typeof value == "object" && !Array.isArray(value));
112
- }
113
- function _getArrayProp(val, defaultVal) {
114
- return val === void 0 ? defaultVal || EMPTY_ARRAY : Array.isArray(val) ? val : [val];
115
- }
116
- function _getResponsiveProp(val, defaultVal) {
117
- return val === void 0 ? defaultVal || EMPTY_ARRAY : isArray(val) || isRecord(val) ? val : [val];
118
- }
119
- function useResponsiveProp(val, defaultVal) {
120
- const $ = compilerRuntime.c(3);
121
- let t0;
122
- $[0] !== defaultVal || $[1] !== val ? (t0 = () => [_getResponsiveProp(val, defaultVal), JSON.stringify(val ?? defaultVal)], $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2];
123
- const [t1, setCache] = react.useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
124
- return hash !== cachedHash && setCache([_getResponsiveProp(val, defaultVal), hash]), cachedVal;
125
- }
126
- const DEFAULT_BOX_ELEMENT = "div";
127
- function Box(props) {
128
- const $ = compilerRuntime.c(132), t0 = props;
129
- let alignItems, borderBottom, borderLeft, borderRight, borderTop, children, className, flex, flexDirection, flexWrap, gap, gapX, gapY, gridAutoColumns, gridAutoFlow, gridAutoRows, gridColumn, gridColumnEnd, gridColumnStart, gridRow, gridRowEnd, gridRowStart, gridTemplateColumns, gridTemplateRows, height, inset, insetBottom, insetLeft, insetRight, insetTop, justifyContent, marginBottom, marginLeft, marginRight, marginTop, marginX, marginY, maxWidth, muted, outline, overflow, overflowX, overflowY, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, pointerEvents, position, radius, rest, shadow, t1, t2, t3, t4, t5, t6, t7, t8, textAlign, width;
130
- $[0] !== t0 ? ({
131
- alignItems,
132
- as: t1,
133
- border: t2,
134
- borderTop,
135
- borderRight,
136
- borderBottom,
137
- borderLeft,
138
- className,
139
- children,
140
- display: t3,
141
- flex,
142
- flexDirection,
143
- flexWrap,
144
- gap,
145
- gapX,
146
- gapY,
147
- gridAutoColumns,
148
- gridAutoFlow,
149
- gridAutoRows,
150
- gridColumn,
151
- gridColumnEnd,
152
- gridColumnStart,
153
- gridRow,
154
- gridRowEnd,
155
- gridRowStart,
156
- gridTemplateColumns,
157
- gridTemplateRows,
158
- height,
159
- inset,
160
- insetBottom,
161
- insetLeft,
162
- insetRight,
163
- insetTop,
164
- justifyContent,
165
- margin: t4,
166
- marginX,
167
- marginY,
168
- marginTop,
169
- marginRight,
170
- marginBottom,
171
- marginLeft,
172
- maxWidth,
173
- minHeight: t5,
174
- minWidth: t6,
175
- muted,
176
- outline,
177
- overflow,
178
- overflowX,
179
- overflowY,
180
- padding: t7,
181
- paddingX,
182
- paddingY,
183
- paddingTop,
184
- paddingRight,
185
- paddingBottom,
186
- paddingLeft,
187
- pointerEvents,
188
- position,
189
- radius,
190
- shadow,
191
- sizing: t8,
192
- textAlign,
193
- width,
194
- ...rest
195
- } = t0, $[0] = t0, $[1] = alignItems, $[2] = borderBottom, $[3] = borderLeft, $[4] = borderRight, $[5] = borderTop, $[6] = children, $[7] = className, $[8] = flex, $[9] = flexDirection, $[10] = flexWrap, $[11] = gap, $[12] = gapX, $[13] = gapY, $[14] = gridAutoColumns, $[15] = gridAutoFlow, $[16] = gridAutoRows, $[17] = gridColumn, $[18] = gridColumnEnd, $[19] = gridColumnStart, $[20] = gridRow, $[21] = gridRowEnd, $[22] = gridRowStart, $[23] = gridTemplateColumns, $[24] = gridTemplateRows, $[25] = height, $[26] = inset, $[27] = insetBottom, $[28] = insetLeft, $[29] = insetRight, $[30] = insetTop, $[31] = justifyContent, $[32] = marginBottom, $[33] = marginLeft, $[34] = marginRight, $[35] = marginTop, $[36] = marginX, $[37] = marginY, $[38] = maxWidth, $[39] = muted, $[40] = outline, $[41] = overflow, $[42] = overflowX, $[43] = overflowY, $[44] = paddingBottom, $[45] = paddingLeft, $[46] = paddingRight, $[47] = paddingTop, $[48] = paddingX, $[49] = paddingY, $[50] = pointerEvents, $[51] = position, $[52] = radius, $[53] = rest, $[54] = shadow, $[55] = t1, $[56] = t2, $[57] = t3, $[58] = t4, $[59] = t5, $[60] = t6, $[61] = t7, $[62] = t8, $[63] = textAlign, $[64] = width) : (alignItems = $[1], borderBottom = $[2], borderLeft = $[3], borderRight = $[4], borderTop = $[5], children = $[6], className = $[7], flex = $[8], flexDirection = $[9], flexWrap = $[10], gap = $[11], gapX = $[12], gapY = $[13], gridAutoColumns = $[14], gridAutoFlow = $[15], gridAutoRows = $[16], gridColumn = $[17], gridColumnEnd = $[18], gridColumnStart = $[19], gridRow = $[20], gridRowEnd = $[21], gridRowStart = $[22], gridTemplateColumns = $[23], gridTemplateRows = $[24], height = $[25], inset = $[26], insetBottom = $[27], insetLeft = $[28], insetRight = $[29], insetTop = $[30], justifyContent = $[31], marginBottom = $[32], marginLeft = $[33], marginRight = $[34], marginTop = $[35], marginX = $[36], marginY = $[37], maxWidth = $[38], muted = $[39], outline = $[40], overflow = $[41], overflowX = $[42], overflowY = $[43], paddingBottom = $[44], paddingLeft = $[45], paddingRight = $[46], paddingTop = $[47], paddingX = $[48], paddingY = $[49], pointerEvents = $[50], position = $[51], radius = $[52], rest = $[53], shadow = $[54], t1 = $[55], t2 = $[56], t3 = $[57], t4 = $[58], t5 = $[59], t6 = $[60], t7 = $[61], t8 = $[62], textAlign = $[63], width = $[64]);
196
- const Element2 = t1 === void 0 ? DEFAULT_BOX_ELEMENT : t1, border = t2 === void 0 ? !1 : t2, display = t3 === void 0 ? "block" : t3, margin = t4 === void 0 ? 0 : t4, minHeight = t5 === void 0 ? 0 : t5, minWidth = t6 === void 0 ? 0 : t6, padding = t7 === void 0 ? 0 : t7, sizing = t8 === void 0 ? "border" : t8;
197
- let t9;
198
- $[65] !== alignItems || $[66] !== border || $[67] !== borderBottom || $[68] !== borderLeft || $[69] !== borderRight || $[70] !== borderTop || $[71] !== className || $[72] !== display || $[73] !== flex || $[74] !== flexDirection || $[75] !== flexWrap || $[76] !== gap || $[77] !== gapX || $[78] !== gapY || $[79] !== gridAutoColumns || $[80] !== gridAutoFlow || $[81] !== gridAutoRows || $[82] !== gridColumn || $[83] !== gridColumnEnd || $[84] !== gridColumnStart || $[85] !== gridRow || $[86] !== gridRowEnd || $[87] !== gridRowStart || $[88] !== gridTemplateColumns || $[89] !== gridTemplateRows || $[90] !== height || $[91] !== inset || $[92] !== insetBottom || $[93] !== insetLeft || $[94] !== insetRight || $[95] !== insetTop || $[96] !== justifyContent || $[97] !== margin || $[98] !== marginBottom || $[99] !== marginLeft || $[100] !== marginRight || $[101] !== marginTop || $[102] !== marginX || $[103] !== marginY || $[104] !== maxWidth || $[105] !== minHeight || $[106] !== minWidth || $[107] !== muted || $[108] !== outline || $[109] !== overflow || $[110] !== overflowX || $[111] !== overflowY || $[112] !== padding || $[113] !== paddingBottom || $[114] !== paddingLeft || $[115] !== paddingRight || $[116] !== paddingTop || $[117] !== paddingX || $[118] !== paddingY || $[119] !== pointerEvents || $[120] !== position || $[121] !== radius || $[122] !== shadow || $[123] !== sizing || $[124] !== textAlign || $[125] !== width ? (t9 = css.box({
199
- className,
200
- alignItems,
201
- border,
202
- borderTop,
203
- borderRight,
204
- borderBottom,
205
- borderLeft,
206
- display,
207
- flex,
208
- flexDirection,
209
- flexWrap,
210
- gap,
211
- gapX,
212
- gapY,
213
- gridAutoColumns,
214
- gridAutoFlow,
215
- gridAutoRows,
216
- gridColumn,
217
- gridColumnEnd,
218
- gridColumnStart,
219
- gridRow,
220
- gridRowEnd,
221
- gridRowStart,
222
- gridTemplateColumns,
223
- gridTemplateRows,
224
- height,
225
- inset,
226
- insetBottom,
227
- insetLeft,
228
- insetRight,
229
- insetTop,
230
- justifyContent,
231
- margin,
232
- marginX,
233
- marginY,
234
- marginTop,
235
- marginRight,
236
- marginBottom,
237
- marginLeft,
238
- maxWidth,
239
- minHeight,
240
- minWidth,
241
- muted,
242
- outline,
243
- overflow,
244
- overflowX,
245
- overflowY,
246
- padding,
247
- paddingX,
248
- paddingY,
249
- paddingTop,
250
- paddingRight,
251
- paddingBottom,
252
- paddingLeft,
253
- pointerEvents,
254
- position,
255
- radius,
256
- shadow,
257
- sizing,
258
- textAlign,
259
- width
260
- }), $[65] = alignItems, $[66] = border, $[67] = borderBottom, $[68] = borderLeft, $[69] = borderRight, $[70] = borderTop, $[71] = className, $[72] = display, $[73] = flex, $[74] = flexDirection, $[75] = flexWrap, $[76] = gap, $[77] = gapX, $[78] = gapY, $[79] = gridAutoColumns, $[80] = gridAutoFlow, $[81] = gridAutoRows, $[82] = gridColumn, $[83] = gridColumnEnd, $[84] = gridColumnStart, $[85] = gridRow, $[86] = gridRowEnd, $[87] = gridRowStart, $[88] = gridTemplateColumns, $[89] = gridTemplateRows, $[90] = height, $[91] = inset, $[92] = insetBottom, $[93] = insetLeft, $[94] = insetRight, $[95] = insetTop, $[96] = justifyContent, $[97] = margin, $[98] = marginBottom, $[99] = marginLeft, $[100] = marginRight, $[101] = marginTop, $[102] = marginX, $[103] = marginY, $[104] = maxWidth, $[105] = minHeight, $[106] = minWidth, $[107] = muted, $[108] = outline, $[109] = overflow, $[110] = overflowX, $[111] = overflowY, $[112] = padding, $[113] = paddingBottom, $[114] = paddingLeft, $[115] = paddingRight, $[116] = paddingTop, $[117] = paddingX, $[118] = paddingY, $[119] = pointerEvents, $[120] = position, $[121] = radius, $[122] = shadow, $[123] = sizing, $[124] = textAlign, $[125] = width, $[126] = t9) : t9 = $[126];
261
- let t10;
262
- return $[127] !== Element2 || $[128] !== children || $[129] !== rest || $[130] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { "data-ui": "Box", ...rest, className: t9, children }), $[127] = Element2, $[128] = children, $[129] = rest, $[130] = t9, $[131] = t10) : t10 = $[131], t10;
263
- }
264
- const DEFAULT_TEXT_ELEMENT = "div";
265
- function Text(props) {
266
- const $ = compilerRuntime.c(30), t0 = props;
267
- let align, children, className, flex, muted, rest, t1, t2, t3, t4, textOverflowProp;
268
- $[0] !== t0 ? ({
269
- align,
270
- as: t1,
271
- children,
272
- className,
273
- flex,
274
- maxWidth: t2,
275
- muted,
276
- size: t3,
277
- textOverflow: textOverflowProp,
278
- weight: t4,
279
- ...rest
280
- } = t0, $[0] = t0, $[1] = align, $[2] = children, $[3] = className, $[4] = flex, $[5] = muted, $[6] = rest, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = t4, $[11] = textOverflowProp) : (align = $[1], children = $[2], className = $[3], flex = $[4], muted = $[5], rest = $[6], t1 = $[7], t2 = $[8], t3 = $[9], t4 = $[10], textOverflowProp = $[11]);
281
- const Element2 = t1 === void 0 ? DEFAULT_TEXT_ELEMENT : t1, maxWidth = t2 === void 0 ? "fill" : t2, size2 = t3 === void 0 ? 2 : t3, weight = t4 === void 0 ? "regular" : t4;
282
- let t5;
283
- $[12] !== align || $[13] !== className || $[14] !== flex || $[15] !== maxWidth || $[16] !== muted || $[17] !== size2 || $[18] !== weight ? (t5 = css.text({
284
- className,
285
- align,
286
- flex,
287
- maxWidth,
288
- muted,
289
- size: size2,
290
- weight
291
- }), $[12] = align, $[13] = className, $[14] = flex, $[15] = maxWidth, $[16] = muted, $[17] = size2, $[18] = weight, $[19] = t5) : t5 = $[19];
292
- let t6;
293
- $[20] !== textOverflowProp ? (t6 = css.textOverflow({
294
- textOverflow: textOverflowProp
295
- }), $[20] = textOverflowProp, $[21] = t6) : t6 = $[21];
296
- let t7;
297
- $[22] !== children || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t6, children }), $[22] = children, $[23] = t6, $[24] = t7) : t7 = $[24];
298
- let t8;
299
- return $[25] !== Element2 || $[26] !== rest || $[27] !== t5 || $[28] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { "data-ui": "Text", ...rest, className: t5, children: t7 }), $[25] = Element2, $[26] = rest, $[27] = t5, $[28] = t7, $[29] = t8) : t8 = $[29], t8;
300
- }
301
- function AnimatedSpinnerIcon(props) {
302
- const $ = compilerRuntime.c(5);
303
- let rest;
304
- $[0] !== props ? ({
305
- ...rest
306
- } = props, $[0] = props, $[1] = rest) : rest = $[1];
307
- let t0;
308
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t0 = css.animatedSpinnerIcon(), $[2] = t0) : t0 = $[2];
309
- let t1;
310
- return $[3] !== rest ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(icons.SpinnerIcon, { "data-sanity-icon": "animated-spinner", ...rest, className: t0 }), $[3] = rest, $[4] = t1) : t1 = $[4], t1;
311
- }
312
- const DEFAULT_SPINNER_ELEMENT = "div";
313
- function Spinner(props) {
314
- const $ = compilerRuntime.c(11), t0 = props;
315
- let className, rest, t1;
316
- $[0] !== t0 ? ({
317
- as: t1,
318
- className,
319
- ...rest
320
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
321
- const as = t1 === void 0 ? DEFAULT_SPINNER_ELEMENT : t1;
322
- let t2;
323
- $[4] !== className ? (t2 = css.spinner({
324
- className
325
- }), $[4] = className, $[5] = t2) : t2 = $[5];
326
- let t3;
327
- $[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(AnimatedSpinnerIcon, {}), $[6] = t3) : t3 = $[6];
328
- let t4;
329
- return $[7] !== as || $[8] !== rest || $[9] !== t2 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(Text, { as, "data-ui": "Spinner", ...rest, className: t2, children: t3 }), $[7] = as, $[8] = rest, $[9] = t2, $[10] = t4) : t4 = $[10], t4;
330
- }
331
- const DEFAULT_BUTTON_ELEMENT = "button";
332
- function Button(props) {
333
- const {
334
- align = "center",
335
- as: Element2 = DEFAULT_BUTTON_ELEMENT,
336
- children,
337
- className,
338
- disabled,
339
- flex,
340
- fontSize = 1,
341
- gap = props.padding ?? 3,
342
- gapX,
343
- gapY,
344
- icon: IconComponent,
345
- iconRight: IconRightComponent,
346
- justify = "center",
347
- loading,
348
- mode = "default",
349
- padding = 3,
350
- paddingX,
351
- paddingY,
352
- paddingTop,
353
- paddingBottom,
354
- paddingLeft,
355
- paddingRight,
356
- radius = 2,
357
- selected,
358
- text,
359
- textAlign,
360
- textOverflow = "ellipsis",
361
- textWeight = "medium",
362
- tone = "default",
363
- type = "button",
364
- muted = !1,
365
- width,
366
- ...rest
367
- } = props;
368
- let href;
369
- return "href" in rest && (href = typeof rest.href == "string" ? rest.href : href, delete rest.href), /* @__PURE__ */ jsxRuntime.jsxs(
370
- Element2,
371
- {
372
- "data-ui": "Button",
373
- ...rest,
374
- className: css.button({
375
- className,
376
- flex,
377
- mode,
378
- radius,
379
- tone,
380
- width
381
- }),
382
- "data-disabled": loading || disabled ? "" : void 0,
383
- "data-selected": selected ? "" : void 0,
384
- disabled: !!(loading || disabled),
385
- href: disabled ? void 0 : href,
386
- type,
387
- children: [
388
- !!loading && /* @__PURE__ */ jsxRuntime.jsx(Box, { alignItems: "center", as: "span", className: css.buttonLoadingBox(), display: "flex", flex: 1, justifyContent: "center", width: "fill", children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: fontSize }) }),
389
- (IconComponent || text || IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsxs(Box, { alignItems: align, as: "span", display: "flex", flex: 1, gap, gapX, gapY, justifyContent: justify, padding, paddingX, paddingY, paddingTop, paddingBottom, paddingLeft, paddingRight, children: [
390
- IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { as: "span", flex: "none", muted: !0, size: fontSize, children: [
391
- react.isValidElement(IconComponent) && IconComponent,
392
- reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
393
- ] }),
394
- text && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", maxWidth: "auto", children: /* @__PURE__ */ jsxRuntime.jsx(Text, { align: textAlign, as: "span", muted, size: fontSize, textOverflow, weight: textWeight, children: text }) }),
395
- IconRightComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { as: "span", flex: "none", muted: !0, size: fontSize, children: [
396
- react.isValidElement(IconRightComponent) && IconRightComponent,
397
- reactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
398
- ] })
399
- ] }),
400
- children && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", flex: 1, padding, paddingX, paddingY, paddingTop, paddingBottom, paddingLeft, paddingRight, children })
401
- ]
402
- }
403
- );
404
- }
405
- function useMatchMedia(mediaQueryString, getServerSnapshot2) {
406
- const $ = compilerRuntime.c(4);
407
- react.useDebugValue(mediaQueryString);
408
- let t0;
409
- $[0] !== mediaQueryString ? (t0 = (onStoreChange) => {
410
- const media2 = window.matchMedia(mediaQueryString);
411
- return media2.addEventListener("change", onStoreChange), () => media2.removeEventListener("change", onStoreChange);
412
- }, $[0] = mediaQueryString, $[1] = t0) : t0 = $[1];
413
- let t1;
414
- return $[2] !== mediaQueryString ? (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1) : t1 = $[3], react.useSyncExternalStore(t0, t1, getServerSnapshot2);
415
- }
416
- function usePrefersReducedMotion(t0) {
417
- return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$a : t0);
418
- }
419
- function _temp$a() {
420
- return !1;
421
- }
422
- const origin = {
423
- name: "@sanity/ui/origin",
424
- fn({
425
- middlewareData,
426
- placement,
427
- rects
428
- }) {
429
- const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
430
- if (floatingWidth <= 0 || floatingHeight <= 0)
431
- return {};
432
- const isVerticalPlacement = ["bottom", "top"].includes(side), {
433
- originX,
434
- originY
435
- } = isVerticalPlacement ? {
436
- originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
437
- originY: side === "bottom" ? 0 : 1
438
- } : {
439
- originX: side === "left" ? 1 : 0,
440
- originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
441
- };
442
- return {
443
- data: {
444
- originX,
445
- originY
446
- }
447
- };
448
- }
449
- };
450
- function clamp(num, min, max) {
451
- return Math.min(Math.max(num, min), max);
452
- }
453
- function getGlobalScope() {
454
- if (typeof globalThis < "u") return globalThis;
455
- if (typeof window < "u") return window;
456
- if (typeof self < "u") return self;
457
- if (typeof global < "u") return global;
458
- throw new Error("@sanity/ui: could not locate global scope");
459
- }
460
- const globalScope = getGlobalScope();
461
- function createGlobalScopedContext(key2, defaultValue) {
462
- const symbol = Symbol.for(key2);
463
- if (typeof document > "u")
464
- return react.createContext(defaultValue);
465
- const symbolMap = globalScope;
466
- return symbolMap[symbol] = symbolMap[symbol] || react.createContext(defaultValue), symbolMap[symbol];
467
- }
468
- const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/v3/boundaryElement", null), DEFAULT_VALUE = {
469
- version: 0,
470
- element: null
471
- };
472
- function useBoundaryElement() {
473
- const value = react.useContext(BoundaryElementContext);
474
- if (value && (!isRecord(value) || value.version !== 0))
475
- throw new Error("useBoundaryElement(): the context value is not compatible");
476
- return value || DEFAULT_VALUE;
477
- }
478
- function getElementRef(element) {
479
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
480
- return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
481
- }
482
- const CardContext = createGlobalScopedContext("@sanity/ui/v3/card", null);
483
- function CardProvider(props) {
484
- const $ = compilerRuntime.c(7), {
485
- children,
486
- tone,
487
- scheme,
488
- unstable_CompatProvider
489
- } = props;
490
- let t0, t1;
491
- $[0] !== scheme || $[1] !== tone || $[2] !== unstable_CompatProvider ? (t1 = {
492
- tone,
493
- scheme,
494
- unstable_CompatProvider
495
- }, $[0] = scheme, $[1] = tone, $[2] = unstable_CompatProvider, $[3] = t1) : t1 = $[3], t0 = t1;
496
- let t2;
497
- return $[4] !== children || $[5] !== t0 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(CardContext.Provider, { value: t0, children }), $[4] = children, $[5] = t0, $[6] = t2) : t2 = $[6], t2;
498
- }
499
- function useCard() {
500
- const card = react.useContext(CardContext);
501
- if (!card)
502
- throw new Error("useCard(): missing context value");
503
- return card;
504
- }
505
- const key = "@sanity/ui/v3/portal", elementKey = Symbol.for(`${key}/element`), elementMap = globalScope;
506
- elementMap[elementKey] = null;
507
- const defaultContextValue = {
508
- version: 0,
509
- boundaryElement: null,
510
- get element() {
511
- return typeof document > "u" ? null : (elementMap[elementKey] || (elementMap[elementKey] = document.createElement("div"), elementMap[elementKey].setAttribute("data-portal", ""), document.body.appendChild(elementMap[elementKey])), elementMap[elementKey]);
512
- }
513
- }, PortalContext = createGlobalScopedContext(key, defaultContextValue);
514
- function usePortal() {
515
- const value = react.useContext(PortalContext);
516
- if (!value)
517
- throw new Error("usePortal(): missing context value");
518
- if (!isRecord(value) || value.version !== 0)
519
- throw new Error("usePortal(): the context value is not compatible");
520
- return value;
521
- }
522
- function Portal(props) {
523
- const $ = compilerRuntime.c(6), {
524
- children,
525
- __unstable_name: name
526
- } = props, card = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
527
- if (!portalElement)
528
- return null;
529
- let t0;
530
- $[0] !== card.scheme || $[1] !== children ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: "transparent", scheme: card.scheme, children }), $[0] = card.scheme, $[1] = children, $[2] = t0) : t0 = $[2];
531
- let t1;
532
- return $[3] !== portalElement || $[4] !== t0 ? (t1 = reactDom.createPortal(t0, portalElement), $[3] = portalElement, $[4] = t0, $[5] = t1) : t1 = $[5], t1;
533
- }
534
- function getLayerContext(contextValue) {
535
- if (!isRecord(contextValue) || contextValue.version !== 0)
536
- throw new Error("the context value is not compatible");
537
- if (!contextValue)
538
- throw new Error("components using `useLayer()` should be wrapped in a <LayerProvider>.");
539
- if (contextValue.version === 0)
540
- return contextValue;
541
- throw new Error("could not get layer context");
542
- }
543
- const LayerContext = createGlobalScopedContext("@sanity/ui/v3/layer", null);
544
- function useLayer() {
545
- const $ = compilerRuntime.c(2), value = react.useContext(LayerContext);
546
- if (!value)
547
- throw new Error("useLayer(): missing context value");
548
- try {
549
- let t1;
550
- return $[0] !== value ? (t1 = getLayerContext(value), $[0] = value, $[1] = t1) : t1 = $[1], t1;
551
- } catch (t0) {
552
- const err = t0;
553
- throw err instanceof Error ? new Error(`useLayer(): ${err.message}`) : new Error(`useLayer(): ${err}`);
554
- }
555
- }
556
- const DEFAULT_POPOVER_DISTANCE = 4, DEFAULT_POPOVER_PADDING = 4, DEFAULT_POPOVER_ARROW_WIDTH = 19, DEFAULT_POPOVER_ARROW_HEIGHT = 8, DEFAULT_POPOVER_ARROW_RADIUS = 2, DEFAULT_POPOVER_MARGINS = [0, 0, 0, 0], DEFAULT_FALLBACK_PLACEMENTS$1 = {
557
- top: ["bottom", "left", "right"],
558
- "top-start": ["bottom-start", "left-start", "right-start"],
559
- "top-end": ["bottom-end", "left-end", "right-end"],
560
- bottom: ["top", "left", "right"],
561
- "bottom-start": ["top-start", "left-start", "right-start"],
562
- "bottom-end": ["top-end", "left-end", "right-end"],
563
- left: ["right", "top", "bottom"],
564
- "left-start": ["right-start", "top-start", "bottom-start"],
565
- "left-end": ["right-end", "top-end", "bottom-end"],
566
- right: ["left", "top", "bottom"],
567
- "right-start": ["left-start", "top-start", "bottom-start"],
568
- "right-end": ["left-end", "top-end", "bottom-end"]
569
- };
570
- function size(options) {
571
- const {
572
- apply,
573
- margins,
574
- padding = 0
575
- } = options;
576
- return {
577
- name: "@sanity/ui/size",
578
- async fn(args) {
579
- const {
580
- elements,
581
- placement,
582
- platform,
583
- rects
584
- } = args, {
585
- floating,
586
- reference
587
- } = rects, overflow = await reactDom$1.detectOverflow(args, {
588
- altBoundary: !0,
589
- boundary: options.boundaryElement || void 0,
590
- elementContext: "floating",
591
- padding,
592
- rootBoundary: "viewport"
593
- });
594
- let maxWidth = 1 / 0, maxHeight = 1 / 0;
595
- const floatingW = floating.width, floatingH = floating.height;
596
- placement.includes("top") && (maxWidth = floatingW - (overflow.left + overflow.right), maxHeight = floatingH - overflow.top), placement.includes("right") && (maxWidth = floatingW - overflow.right, maxHeight = floatingH - (overflow.top + overflow.bottom)), placement.includes("bottom") && (maxWidth = floatingW - (overflow.left + overflow.right), maxHeight = floatingH - overflow.bottom), placement.includes("left") && (maxWidth = floatingW - overflow.left, maxHeight = floatingH - (overflow.top + overflow.bottom)), apply({
597
- availableWidth: maxWidth - margins[1] - margins[3],
598
- availableHeight: maxHeight - margins[0] - margins[2],
599
- elements,
600
- referenceWidth: reference.width - margins[1] - margins[3]
601
- });
602
- const nextDimensions = await platform.getDimensions(elements.floating), targetH = nextDimensions.height, targetW = nextDimensions.width;
603
- return floatingW !== targetW || floatingH !== targetH ? {
604
- reset: {
605
- rects: !0
606
- }
607
- } : {};
608
- }
609
- };
610
- }
611
- function moveTowardsLength(movingPoint, targetPoint, amount) {
612
- const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
613
- return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
614
- }
615
- function moveTowardsFractional(movingPoint, targetPoint, fraction) {
616
- return {
617
- x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
618
- y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
619
- };
620
- }
621
- function getRoundedCommands(points) {
622
- const len = points.length, cmds = [];
623
- for (let i = 0; i < len; i += 1) {
624
- const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
625
- if (prevPoint && point.radius) {
626
- const curveStart = moveTowardsLength(point, prevPoint, point.radius), curveEnd = moveTowardsLength(point, nextPoint, point.radius), startControl = moveTowardsFractional(curveStart, point, 0.5), endControl = moveTowardsFractional(point, curveEnd, 0.5);
627
- cmds.push({
628
- type: "point",
629
- ...curveStart
630
- }), cmds.push({
631
- type: "curve",
632
- curveEnd,
633
- startControl,
634
- endControl
635
- });
636
- } else
637
- cmds.push({
638
- type: "point",
639
- ...point
640
- });
641
- }
642
- return cmds;
643
- }
644
- function compileCommands(cmds) {
645
- return cmds.map((n, idx) => n.type === "point" ? `${idx === 0 ? "M" : "L"} ${n.x} ${n.y}` : n.type === "curve" ? `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}` : "").join(" ");
646
- }
647
- const DEFAULT_ARROW_ELEMENT = "div";
648
- function Arrow(props) {
649
- const $ = compilerRuntime.c(34), t0 = props;
650
- let h, rest, style, t1, t2, w;
651
- $[0] !== t0 ? ({
652
- as: t1,
653
- width: w,
654
- height: h,
655
- radius: t2,
656
- style,
657
- ...rest
658
- } = t0, $[0] = t0, $[1] = h, $[2] = rest, $[3] = style, $[4] = t1, $[5] = t2, $[6] = w) : (h = $[1], rest = $[2], style = $[3], t1 = $[4], t2 = $[5], w = $[6]);
659
- const Element2 = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
660
- let t3;
661
- const points = [{
662
- x: 0,
663
- y: 0
664
- }, {
665
- x: radius,
666
- y: 0,
667
- radius
668
- }, {
669
- x: center,
670
- y: h - 1,
671
- radius
672
- }, {
673
- x: w - radius,
674
- y: 0,
675
- radius
676
- }, {
677
- x: w,
678
- y: 0
679
- }], cmds = getRoundedCommands(points);
680
- t3 = compileCommands(cmds);
681
- const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
682
- let t4;
683
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = css._arrow(), $[7] = t4) : t4 = $[7];
684
- const t5 = `${w}px`;
685
- let t6;
686
- $[8] !== t5 ? (t6 = dynamic.assignInlineVars({
687
- [css.vars.arrow.size]: t5
688
- }), $[8] = t5, $[9] = t6) : t6 = $[9];
689
- let t7;
690
- $[10] !== style || $[11] !== t6 ? (t7 = {
691
- ...style,
692
- ...t6
693
- }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
694
- let t8;
695
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = css._arrowSvg(), $[13] = t8) : t8 = $[13];
696
- const t9 = `0 0 ${w} ${w}`;
697
- let t10;
698
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = css._arrowStrokeMask(), $[14] = t10) : t10 = $[14];
699
- let t11;
700
- $[15] !== w ? (t11 = /* @__PURE__ */ jsxRuntime.jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { className: t10, x: 0, width: w, height: w, fill: "white" }) }), $[15] = w, $[16] = t11) : t11 = $[16];
701
- let t12;
702
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = css._arrowStroke(), $[17] = t12) : t12 = $[17];
703
- let t13;
704
- $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsxRuntime.jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
705
- let t14;
706
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = css._arrowShape(), $[20] = t14) : t14 = $[20];
707
- let t15;
708
- $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsxRuntime.jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
709
- let t16;
710
- $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
711
- t11,
712
- t13,
713
- t15
714
- ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
715
- let t17;
716
- return $[29] !== Element2 || $[30] !== rest || $[31] !== t16 || $[32] !== t7 ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { ...rest, className: t4, style: t7, children: t16 }), $[29] = Element2, $[30] = rest, $[31] = t16, $[32] = t7, $[33] = t17) : t17 = $[33], t17;
717
- }
718
- const DEFAULT_FLEX_ELEMENT = "div";
719
- function Flex(props) {
720
- const $ = compilerRuntime.c(14), t0 = props;
721
- let align, justify, rest, t1, t2, wrap;
722
- $[0] !== t0 ? ({
723
- align,
724
- as: t1,
725
- direction: t2,
726
- justify,
727
- wrap,
728
- ...rest
729
- } = t0, $[0] = t0, $[1] = align, $[2] = justify, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = wrap) : (align = $[1], justify = $[2], rest = $[3], t1 = $[4], t2 = $[5], wrap = $[6]);
730
- const as = t1 === void 0 ? DEFAULT_FLEX_ELEMENT : t1, direction = t2 === void 0 ? "row" : t2;
731
- let t3;
732
- return $[7] !== align || $[8] !== as || $[9] !== direction || $[10] !== justify || $[11] !== rest || $[12] !== wrap ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Flex", ...rest, alignItems: align, as, display: "flex", flexDirection: direction, flexWrap: wrap, justifyContent: justify }), $[7] = align, $[8] = as, $[9] = direction, $[10] = justify, $[11] = rest, $[12] = wrap, $[13] = t3) : t3 = $[13], t3;
733
- }
734
- const DEFAULT_CARD_ELEMENT = "div";
735
- function Card(props) {
736
- const $ = compilerRuntime.c(38), t0 = props;
737
- let className, disabled, pressed, rest, schemeProp, selected, style, t1, t2, t3, t4, t5;
738
- $[0] !== t0 ? ({
739
- __unstable_checkered: t1,
740
- __unstable_focusRing: t2,
741
- as: t3,
742
- className,
743
- disabled,
744
- pressed,
745
- radius: t4,
746
- scheme: schemeProp,
747
- selected,
748
- style,
749
- tone: t5,
750
- ...rest
751
- } = t0, $[0] = t0, $[1] = className, $[2] = disabled, $[3] = pressed, $[4] = rest, $[5] = schemeProp, $[6] = selected, $[7] = style, $[8] = t1, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = t5) : (className = $[1], disabled = $[2], pressed = $[3], rest = $[4], schemeProp = $[5], selected = $[6], style = $[7], t1 = $[8], t2 = $[9], t3 = $[10], t4 = $[11], t5 = $[12]);
752
- const checkered = t1 === void 0 ? !1 : t1, focusRing = t2 === void 0 ? !1 : t2, as = t3 === void 0 ? DEFAULT_CARD_ELEMENT : t3, radius = t4 === void 0 ? 0 : t4, toneProp = t5 === void 0 ? "default" : t5, parent = react.useContext(CardContext), tone = toneProp === "inherit" ? parent?.tone : toneProp, scheme = schemeProp === void 0 ? parent?.scheme : schemeProp, t6 = scheme === parent?.scheme ? void 0 : scheme;
753
- let t7;
754
- $[13] !== className || $[14] !== t6 || $[15] !== tone ? (t7 = css.card({
755
- className,
756
- scheme: t6,
757
- tone
758
- }), $[13] = className, $[14] = t6, $[15] = tone, $[16] = t7) : t7 = $[16];
759
- const t8 = checkered ? "" : void 0, t9 = disabled ? "" : void 0, t10 = focusRing ? "" : void 0, t11 = pressed ? "" : void 0, t12 = selected ? "" : void 0;
760
- let t13;
761
- $[17] !== as || $[18] !== radius || $[19] !== rest || $[20] !== style || $[21] !== t10 || $[22] !== t11 || $[23] !== t12 || $[24] !== t7 || $[25] !== t8 || $[26] !== t9 ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Card", ...rest, as, className: t7, "data-checkered": t8, "data-disabled": t9, "data-focus-ring": t10, "data-pressed": t11, "data-selected": t12, radius, style }), $[17] = as, $[18] = radius, $[19] = rest, $[20] = style, $[21] = t10, $[22] = t11, $[23] = t12, $[24] = t7, $[25] = t8, $[26] = t9, $[27] = t13) : t13 = $[27];
762
- let node = t13;
763
- if (scheme === parent?.scheme && tone === parent?.tone)
764
- return node;
765
- const t14 = scheme ?? "light", t15 = tone ?? "default", t16 = parent?.unstable_CompatProvider;
766
- let t17;
767
- if ($[28] !== node || $[29] !== t14 || $[30] !== t15 || $[31] !== t16 ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { scheme: t14, tone: t15, unstable_CompatProvider: t16, children: node }), $[28] = node, $[29] = t14, $[30] = t15, $[31] = t16, $[32] = t17) : t17 = $[32], node = t17, parent?.unstable_CompatProvider) {
768
- const CompatProvider = parent.unstable_CompatProvider, t18 = scheme ?? "light", t19 = tone ?? parent.tone;
769
- let t20;
770
- return $[33] !== CompatProvider || $[34] !== node || $[35] !== t18 || $[36] !== t19 ? (t20 = /* @__PURE__ */ jsxRuntime.jsx(CompatProvider, { scheme: t18, tone: t19, children: node }), $[33] = CompatProvider, $[34] = node, $[35] = t18, $[36] = t19, $[37] = t20) : t20 = $[37], t20;
771
- }
772
- return node;
773
- }
774
- const DEFAULT_LAYER_CARD_ELEMENT = "div";
775
- function LayerCard(props) {
776
- const $ = compilerRuntime.c(27), t0 = props;
777
- let children, forwardedRef, onActivate, onFocus, rest, t1, t2, t3;
778
- $[0] !== t0 ? ({
779
- as: t1,
780
- children,
781
- onActivate,
782
- onFocus,
783
- position: t2,
784
- ref: forwardedRef,
785
- style: t3,
786
- ...rest
787
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = onActivate, $[4] = onFocus, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3) : (children = $[1], forwardedRef = $[2], onActivate = $[3], onFocus = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8]);
788
- const as = t1 === void 0 ? DEFAULT_LAYER_CARD_ELEMENT : t1, position = t2 === void 0 ? "relative" : t2, style = t3 === void 0 ? EMPTY_RECORD : t3, {
789
- zIndex,
790
- isTopLayer
791
- } = useLayer(), lastFocusedRef = react.useRef(null), ref = react.useRef(null), isTopLayerRef = react.useRef(isTopLayer);
792
- let t4;
793
- $[9] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[9] = t4) : t4 = $[9], react.useImperativeHandle(forwardedRef, t4);
794
- let t5, t6;
795
- $[10] !== isTopLayer || $[11] !== onActivate ? (t5 = () => {
796
- isTopLayerRef.current !== isTopLayer && isTopLayer && onActivate?.({
797
- activeElement: lastFocusedRef.current
798
- }), isTopLayerRef.current = isTopLayer;
799
- }, t6 = [isTopLayer, onActivate], $[10] = isTopLayer, $[11] = onActivate, $[12] = t5, $[13] = t6) : (t5 = $[12], t6 = $[13]), react.useEffect(t5, t6);
800
- let t7;
801
- $[14] !== isTopLayer || $[15] !== onFocus ? (t7 = (event) => {
802
- onFocus?.(event);
803
- const rootElement = ref.current, target = document.activeElement;
804
- !isTopLayer || !rootElement || !target || isHTMLElement(target) && containsOrEqualsElement(rootElement, target) && (lastFocusedRef.current = target);
805
- }, $[14] = isTopLayer, $[15] = onFocus, $[16] = t7) : t7 = $[16];
806
- const handleFocus = t7, t8 = as;
807
- let t9;
808
- $[17] !== style || $[18] !== zIndex ? (t9 = {
809
- ...style,
810
- zIndex
811
- }, $[17] = style, $[18] = zIndex, $[19] = t9) : t9 = $[19];
812
- let t10;
813
- return $[20] !== children || $[21] !== handleFocus || $[22] !== position || $[23] !== rest || $[24] !== t8 || $[25] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(Card, { "data-ui": "Layer", ...rest, as: t8, onFocus: handleFocus, position, ref, style: t9, children }), $[20] = children, $[21] = handleFocus, $[22] = position, $[23] = rest, $[24] = t8, $[25] = t9, $[26] = t10) : t10 = $[26], t10;
814
- }
815
- const media = Object.values(css.BREAKPOINTS);
816
- function _getMediaQuery(media2, index) {
817
- return index === 0 ? `screen and (max-width: ${media2[index + 1] - 1}px)` : index === media2.length - 1 ? `screen and (min-width: ${media2[index]}px)` : `screen and (min-width: ${media2[index]}px) and (max-width: ${media2[index + 1] - 1}px)`;
818
- }
819
- function _createMediaStore() {
820
- const mediaLen = media.length;
821
- let sizes;
822
- const getSizes = () => {
823
- if (typeof window > "u")
824
- return sizes;
825
- if (!sizes) {
826
- sizes = [];
827
- for (let index = mediaLen; index > -1; index -= 1) {
828
- const mediaQuery = _getMediaQuery(media, index);
829
- sizes.push({
830
- index,
831
- mq: window.matchMedia(mediaQuery)
832
- });
833
- }
834
- }
835
- return sizes;
836
- };
837
- return {
838
- getSnapshot: () => {
839
- for (const {
840
- index,
841
- mq
842
- } of getSizes() ?? [])
843
- if (mq.matches) return index;
844
- return 0;
845
- },
846
- subscribe: (onStoreChange) => {
847
- const disposeFns = [];
848
- for (const {
849
- mq
850
- } of getSizes() ?? []) {
851
- const handleChange = () => {
852
- mq.matches && onStoreChange();
853
- };
854
- mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
855
- }
856
- return () => {
857
- for (const disposeFn of disposeFns)
858
- disposeFn();
859
- };
860
- }
861
- };
862
- }
863
- function getServerSnapshot() {
864
- return 0;
865
- }
866
- function useMediaIndex() {
867
- const $ = compilerRuntime.c(1);
868
- let t0, t1;
869
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = _createMediaStore(), $[0] = t1) : t1 = $[0], t0 = t1;
870
- const store = t0;
871
- return react.useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
872
- }
873
- function LayerProvider(props) {
874
- const $ = compilerRuntime.c(19), {
875
- children,
876
- zOffset: t0
877
- } = props, zOffsetProp = t0 === void 0 ? 0 : t0, parentContextValue = react.useContext(LayerContext);
878
- let t1;
879
- $[0] !== parentContextValue ? (t1 = parentContextValue && getLayerContext(parentContextValue), $[0] = parentContextValue, $[1] = t1) : t1 = $[1];
880
- const parent = t1, parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, zOffset = useResponsiveProp(zOffsetProp), maxMediaIndex = Object.values(zOffset).length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + (zOffset[mediaIndex] ?? 0) : zOffset[mediaIndex] ?? 0;
881
- let t2;
882
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[2] = t2) : t2 = $[2];
883
- const [, setChildLayers] = react.useState(t2), [size2, setSize] = react.useState(0), isTopLayer = size2 === 0;
884
- let t3;
885
- $[3] !== parentRegisterChild || $[4] !== setChildLayers ? (t3 = (childLevel) => {
886
- const parentDispose = parentRegisterChild?.(childLevel);
887
- return childLevel !== void 0 ? setChildLayers((state) => {
888
- const prevLen = state[childLevel] ?? 0, nextState = {
889
- ...state,
890
- [childLevel]: prevLen + 1
891
- };
892
- return setSize(Object.keys(nextState).length), nextState;
893
- }) : setSize(_temp$9), () => {
894
- childLevel !== void 0 ? setChildLayers((state_0) => {
895
- const nextState_0 = {
896
- ...state_0
897
- };
898
- return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] = nextState_0[childLevel] - 1, nextState_0;
899
- }) : setSize(_temp2$2), parentDispose?.();
900
- };
901
- }, $[3] = parentRegisterChild, $[4] = setChildLayers, $[5] = t3) : t3 = $[5];
902
- const registerChild = t3;
903
- let t4, t5;
904
- $[6] !== level || $[7] !== parentRegisterChild ? (t4 = () => parentRegisterChild?.(level), t5 = [level, parentRegisterChild], $[6] = level, $[7] = parentRegisterChild, $[8] = t4, $[9] = t5) : (t4 = $[8], t5 = $[9]), react.useEffect(t4, t5);
905
- let t6, t7;
906
- $[10] !== isTopLayer || $[11] !== level || $[12] !== registerChild || $[13] !== size2 || $[14] !== zIndex ? (t7 = {
907
- version: 0,
908
- isTopLayer,
909
- level,
910
- registerChild,
911
- size: size2,
912
- zIndex
913
- }, $[10] = isTopLayer, $[11] = level, $[12] = registerChild, $[13] = size2, $[14] = zIndex, $[15] = t7) : t7 = $[15], t6 = t7;
914
- const value = t6;
915
- let t8;
916
- return $[16] !== children || $[17] !== value ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(LayerContext.Provider, { value, children }), $[16] = children, $[17] = value, $[18] = t8) : t8 = $[18], t8;
917
- }
918
- function _temp2$2(v_0) {
919
- return v_0 - 1;
920
- }
921
- function _temp$9(v) {
922
- return v + 1;
923
- }
924
- const DEFAULT_LAYER_ELEMENT = "div";
925
- function Layer(props) {
926
- const $ = compilerRuntime.c(12), t0 = props;
927
- let children, rest, t1, t2;
928
- $[0] !== t0 ? ({
929
- as: t1,
930
- children,
931
- zOffset: t2,
932
- ...rest
933
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1, $[4] = t2) : (children = $[1], rest = $[2], t1 = $[3], t2 = $[4]);
934
- const as = t1 === void 0 ? DEFAULT_LAYER_ELEMENT : t1, zOffset = t2 === void 0 ? 1 : t2;
935
- let t3;
936
- $[5] !== as || $[6] !== children || $[7] !== rest ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(LayerCard, { ...rest, as, children }), $[5] = as, $[6] = children, $[7] = rest, $[8] = t3) : t3 = $[8];
937
- let t4;
938
- return $[9] !== t3 || $[10] !== zOffset ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(LayerProvider, { zOffset, children: t3 }), $[9] = t3, $[10] = zOffset, $[11] = t4) : t4 = $[11], t4;
939
- }
940
- function PopoverLayer(props) {
941
- const $ = compilerRuntime.c(65);
942
- let animate, arrow, arrowRef, arrowX, arrowY, children, marginsProp, maxWidth, originX, originY, overflow, padding, placement, radius, referenceWidth, rest, shadow, strategy, style, t0, xProp, yProp;
943
- $[0] !== props ? ({
944
- __unstable_margins: marginsProp,
945
- animate,
946
- arrow,
947
- arrowRef,
948
- arrowX,
949
- arrowY,
950
- children,
951
- maxWidth,
952
- padding,
953
- placement,
954
- originX,
955
- originY,
956
- overflow,
957
- radius,
958
- referenceWidth,
959
- shadow,
960
- strategy,
961
- style,
962
- tone: t0,
963
- x: xProp,
964
- y: yProp,
965
- ...rest
966
- } = props, $[0] = props, $[1] = animate, $[2] = arrow, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = marginsProp, $[8] = maxWidth, $[9] = originX, $[10] = originY, $[11] = overflow, $[12] = padding, $[13] = placement, $[14] = radius, $[15] = referenceWidth, $[16] = rest, $[17] = shadow, $[18] = strategy, $[19] = style, $[20] = t0, $[21] = xProp, $[22] = yProp) : (animate = $[1], arrow = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], marginsProp = $[7], maxWidth = $[8], originX = $[9], originY = $[10], overflow = $[11], padding = $[12], placement = $[13], radius = $[14], referenceWidth = $[15], rest = $[16], shadow = $[17], strategy = $[18], style = $[19], t0 = $[20], xProp = $[21], yProp = $[22]);
967
- const tone = t0 === void 0 ? "inherit" : t0;
968
- let t1;
969
- t1 = marginsProp || DEFAULT_POPOVER_MARGINS;
970
- const margins = t1, x = (xProp ?? 0) + margins[3], y = (yProp ?? 0) + margins[0];
971
- let t2;
972
- const t3 = animate ? "transform" : void 0;
973
- let t4;
974
- $[23] !== originX || $[24] !== originY || $[25] !== referenceWidth || $[26] !== style || $[27] !== t3 || $[28] !== x || $[29] !== y ? (t4 = {
975
- left: x,
976
- originX,
977
- originY,
978
- top: y,
979
- width: referenceWidth,
980
- willChange: t3,
981
- ...style
982
- }, $[23] = originX, $[24] = originY, $[25] = referenceWidth, $[26] = style, $[27] = t3, $[28] = x, $[29] = y, $[30] = t4) : t4 = $[30], t2 = t4;
983
- const rootStyle = t2;
984
- let t5;
985
- const t6 = arrowX !== null ? arrowX : void 0, t7 = arrowY !== null ? arrowY : void 0;
986
- let t8;
987
- $[31] !== t6 || $[32] !== t7 ? (t8 = {
988
- left: t6,
989
- top: t7,
990
- right: void 0,
991
- bottom: void 0
992
- }, $[31] = t6, $[32] = t7, $[33] = t8) : t8 = $[33], t5 = t8;
993
- const arrowStyle = t5;
994
- let t9;
995
- $[34] === Symbol.for("react.memo_cache_sentinel") ? (t9 = css.popoverCard(), $[34] = t9) : t9 = $[34];
996
- let t10;
997
- $[35] !== animate ? (t10 = animate ? ["hidden", "initial"] : void 0, $[35] = animate, $[36] = t10) : t10 = $[36];
998
- let t11;
999
- $[37] !== animate ? (t11 = animate ? ["visible", "scaleIn"] : void 0, $[37] = animate, $[38] = t11) : t11 = $[38];
1000
- let t12;
1001
- $[39] !== animate ? (t12 = animate ? ["hidden", "scaleOut"] : void 0, $[39] = animate, $[40] = t12) : t12 = $[40];
1002
- let t13;
1003
- $[41] !== children || $[42] !== padding ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(Flex, { direction: "column", flex: 1, padding, children }), $[41] = children, $[42] = padding, $[43] = t13) : t13 = $[43];
1004
- let t14;
1005
- $[44] !== maxWidth || $[45] !== overflow || $[46] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(Flex, { "data-ui": "Popover__wrapper", direction: "column", flex: 1, maxWidth, overflow, children: t13 }), $[44] = maxWidth, $[45] = overflow, $[46] = t13, $[47] = t14) : t14 = $[47];
1006
- let t15;
1007
- $[48] !== arrow || $[49] !== arrowRef || $[50] !== arrowStyle ? (t15 = arrow && /* @__PURE__ */ jsxRuntime.jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_POPOVER_ARROW_WIDTH, height: DEFAULT_POPOVER_ARROW_HEIGHT, radius: DEFAULT_POPOVER_ARROW_RADIUS }), $[48] = arrow, $[49] = arrowRef, $[50] = arrowStyle, $[51] = t15) : t15 = $[51];
1008
- let t16;
1009
- return $[52] !== placement || $[53] !== radius || $[54] !== rest || $[55] !== rootStyle || $[56] !== shadow || $[57] !== strategy || $[58] !== t10 || $[59] !== t11 || $[60] !== t12 || $[61] !== t14 || $[62] !== t15 || $[63] !== tone ? (t16 = /* @__PURE__ */ jsxRuntime.jsxs(Layer, { className: t9, "data-ui": "Popover", ...rest, as: framerMotion.motion.div, "data-context-tone": tone, "data-placement": placement, flexDirection: "column", display: "flex", position: strategy, radius, shadow, sizing: "border", style: rootStyle, tone, variants: POPOVER_MOTION_PROPS.card, transition: POPOVER_MOTION_PROPS.transition, initial: t10, animate: t11, exit: t12, children: [
1010
- t14,
1011
- t15
1012
- ] }), $[52] = placement, $[53] = radius, $[54] = rest, $[55] = rootStyle, $[56] = shadow, $[57] = strategy, $[58] = t10, $[59] = t11, $[60] = t12, $[61] = t14, $[62] = t15, $[63] = tone, $[64] = t16) : t16 = $[64], t16;
1013
- }
1014
- const DEFAULT_POPOVER_ELEMENT = "div";
1015
- function ViewportOverlay() {
1016
- const $ = compilerRuntime.c(2), {
1017
- zIndex
1018
- } = useLayer();
1019
- let t0;
1020
- return $[0] !== zIndex ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1021
- position: "fixed",
1022
- inset: 0,
1023
- width: "100vw",
1024
- height: "100vh",
1025
- zIndex
1026
- } }), $[0] = zIndex, $[1] = t0) : t0 = $[1], t0;
1027
- }
1028
- function Popover(props) {
1029
- const boundaryElementContext = useBoundaryElement(), {
1030
- __unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
1031
- animate: _animate = !1,
1032
- arrow: arrowProp = !1,
1033
- as = DEFAULT_POPOVER_ELEMENT,
1034
- children: childProp,
1035
- className,
1036
- constrainSize = !1,
1037
- content: content2,
1038
- disabled,
1039
- fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS$1[props.placement ?? "bottom"],
1040
- matchReferenceWidth,
1041
- floatingBoundary = boundaryElementContext.element,
1042
- modal,
1043
- onActivate,
1044
- open,
1045
- overflow = "hidden",
1046
- padding,
1047
- placement: placementProp = "bottom",
1048
- placementStrategy = "flip",
1049
- portal,
1050
- preventOverflow = !0,
1051
- radius = 3,
1052
- ref: forwardedRef,
1053
- referenceBoundary = boundaryElementContext.element,
1054
- referenceElement,
1055
- scheme,
1056
- shadow = 3,
1057
- tone = "inherit",
1058
- width: widthProp = "auto",
1059
- zOffset: zOffsetProp = Z_OFFSETS.popover,
1060
- updateRef,
1061
- ...rest
1062
- } = props, card = useCard(), animate = usePrefersReducedMotion() ? !1 : _animate, zOffset = useResponsiveProp(zOffsetProp), ref = react.useRef(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
1063
- react.useImperativeHandle(forwardedRef, () => ref.current);
1064
- const referenceWidthRef = react.useRef(void 0), middleware = react.useMemo(() => {
1065
- const ret = [];
1066
- return (constrainSize || preventOverflow) && (placementStrategy === "autoPlacement" ? ret.push(reactDom$1.autoPlacement({
1067
- allowedPlacements: [placementProp].concat(fallbackPlacements)
1068
- })) : ret.push(reactDom$1.flip({
1069
- boundary: floatingBoundary || void 0,
1070
- fallbackPlacements,
1071
- padding: DEFAULT_POPOVER_PADDING,
1072
- rootBoundary
1073
- }))), ret.push(reactDom$1.offset({
1074
- mainAxis: DEFAULT_POPOVER_DISTANCE
1075
- })), (constrainSize || matchReferenceWidth) && ret.push(size({
1076
- apply({
1077
- availableWidth,
1078
- availableHeight,
1079
- elements,
1080
- referenceWidth
1081
- }) {
1082
- referenceWidthRef.current = referenceWidth, matchReferenceWidth && (elements.floating.style.width = `${referenceWidth}px`), constrainSize && (elements.floating.style.maxWidth = `${availableWidth}px`, elements.floating.style.maxHeight = `${availableHeight}px`);
1083
- },
1084
- boundaryElement: floatingBoundary || void 0,
1085
- margins,
1086
- padding: DEFAULT_POPOVER_PADDING
1087
- })), preventOverflow && ret.push(reactDom$1.shift({
1088
- boundary: floatingBoundary || void 0,
1089
- rootBoundary,
1090
- padding: DEFAULT_POPOVER_PADDING
1091
- })), arrowProp && ret.push(reactDom$1.arrow({
1092
- element: arrowRef,
1093
- padding: DEFAULT_POPOVER_PADDING
1094
- })), animate && ret.push(origin), ret.push(reactDom$1.hide({
1095
- boundary: referenceBoundary || void 0,
1096
- padding: DEFAULT_POPOVER_PADDING,
1097
- strategy: "referenceHidden"
1098
- })), ret;
1099
- }, [animate, arrowProp, constrainSize, fallbackPlacements, floatingBoundary, placementProp, placementStrategy, margins, matchReferenceWidth, preventOverflow, referenceBoundary]), {
1100
- x,
1101
- y,
1102
- middlewareData,
1103
- placement,
1104
- refs,
1105
- strategy,
1106
- update
1107
- } = reactDom$1.useFloating({
1108
- middleware,
1109
- placement: placementProp,
1110
- whileElementsMounted: reactDom$1.autoUpdate,
1111
- elements: referenceElement ? {
1112
- reference: referenceElement
1113
- } : void 0
1114
- }), referenceHidden = middlewareData.hide?.referenceHidden, arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, setArrow = react.useCallback((arrowEl) => {
1115
- arrowRef.current = arrowEl;
1116
- }, []), setFloating = react.useCallback((node) => {
1117
- ref.current = node, refs.setFloating(node);
1118
- }, [refs]), setReference = react.useCallback((node_0) => {
1119
- if (refs.setReference(node_0), !childProp) return;
1120
- const childRef = getElementRef(childProp);
1121
- typeof childRef == "function" ? childRef(node_0) : childRef && (childRef.current = node_0);
1122
- }, [childProp, refs]), child = react.useMemo(() => referenceElement ? childProp : childProp ? react.cloneElement(childProp, {
1123
- ref: setReference
1124
- }) : null, [childProp, referenceElement, setReference]);
1125
- if (react.useEffect(() => {
1126
- updateRef && (typeof updateRef == "function" ? updateRef(update) : updateRef && (updateRef.current = update));
1127
- }, [update, updateRef]), disabled)
1128
- return childProp || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
1129
- const node_1 = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1130
- modal && /* @__PURE__ */ jsxRuntime.jsx(ViewportOverlay, {}),
1131
- /* @__PURE__ */ jsxRuntime.jsx(PopoverLayer, { ...rest, __unstable_margins: margins, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: css.popover({
1132
- className
1133
- }), hidden: referenceHidden, maxWidth: widthProp, overflow, padding, placement, radius, ref: setFloating, scheme, shadow, originX, originY, tone, strategy, x, y, zOffset, children: content2 })
1134
- ] }), children = open && (portal ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card.tone : tone, scheme: scheme ?? "light", children: node_1 }) }) : node_1);
1135
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1136
- animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
1137
- child
1138
- ] });
1139
- }
1140
- const DEFAULT_SELECTABLE_ELEMENT = "button";
1141
- function Selectable(props) {
1142
- const $ = compilerRuntime.c(16), t0 = props;
1143
- let className, radius, rest, selected, t1, tone;
1144
- $[0] !== t0 ? ({
1145
- as: t1,
1146
- className,
1147
- radius,
1148
- selected,
1149
- tone,
1150
- ...rest
1151
- } = t0, $[0] = t0, $[1] = className, $[2] = radius, $[3] = rest, $[4] = selected, $[5] = t1, $[6] = tone) : (className = $[1], radius = $[2], rest = $[3], selected = $[4], t1 = $[5], tone = $[6]);
1152
- const as = t1 === void 0 ? DEFAULT_SELECTABLE_ELEMENT : t1;
1153
- let t2;
1154
- $[7] !== className || $[8] !== radius || $[9] !== tone ? (t2 = css._selectable({
1155
- className,
1156
- radius,
1157
- tone
1158
- }), $[7] = className, $[8] = radius, $[9] = tone, $[10] = t2) : t2 = $[10];
1159
- const t3 = selected ? "" : void 0;
1160
- let t4;
1161
- return $[11] !== as || $[12] !== rest || $[13] !== t2 || $[14] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(Box, { ...rest, as, className: t2, "data-selected": t3 }), $[11] = as, $[12] = rest, $[13] = t2, $[14] = t3, $[15] = t4) : t4 = $[15], t4;
1162
- }
1163
- const DEFAULT_STACK_ELEMENT = "div";
1164
- function Stack(props) {
1165
- const $ = compilerRuntime.c(12), t0 = props;
1166
- let className, gap, rest, t1;
1167
- $[0] !== t0 ? ({
1168
- as: t1,
1169
- className,
1170
- gap,
1171
- ...rest
1172
- } = t0, $[0] = t0, $[1] = className, $[2] = gap, $[3] = rest, $[4] = t1) : (className = $[1], gap = $[2], rest = $[3], t1 = $[4]);
1173
- const as = t1 === void 0 ? DEFAULT_STACK_ELEMENT : t1;
1174
- let t2;
1175
- $[5] !== className ? (t2 = css.stack({
1176
- className
1177
- }), $[5] = className, $[6] = t2) : t2 = $[6];
1178
- let t3;
1179
- return $[7] !== as || $[8] !== gap || $[9] !== rest || $[10] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Stack", ...rest, as, gridAutoRows: "min", className: t2, display: "grid", gap }), $[7] = as, $[8] = gap, $[9] = rest, $[10] = t2, $[11] = t3) : t3 = $[11], t3;
1180
- }
1181
- function useCustomValidity(ref, customValidity) {
1182
- const $ = compilerRuntime.c(6);
1183
- let t0;
1184
- $[0] !== customValidity || $[1] !== ref.current ? (t0 = () => {
1185
- ref.current?.setCustomValidity(customValidity || "");
1186
- }, $[0] = customValidity, $[1] = ref.current, $[2] = t0) : t0 = $[2];
1187
- let t1;
1188
- $[3] !== customValidity || $[4] !== ref ? (t1 = [customValidity, ref], $[3] = customValidity, $[4] = ref, $[5] = t1) : t1 = $[5], react.useEffect(t0, t1);
1189
- }
1190
- const DEFAULT_TEXT_INPUT_ELEMENT = "input";
1191
- function TextInput(props) {
1192
- const $ = compilerRuntime.c(88), t0 = props;
1193
- let IconComponent, IconRightComponent, __unstable_disableFocusRing, className, clearButton, customValidity, forwardedRef, onClear, prefix, readOnly, rest, suffix, t1, t2, t3, t4, t5, t6, t7, t8, width;
1194
- if ($[0] !== t0) {
1195
- const {
1196
- __unstable_disableFocusRing: t92,
1197
- as: t102,
1198
- border: t112,
1199
- className: t122,
1200
- clearButton: t132,
1201
- disabled: t142,
1202
- fontSize: t152,
1203
- gap: t162,
1204
- icon: t172,
1205
- iconRight: t182,
1206
- onClear: t192,
1207
- padding: t202,
1208
- prefix: t212,
1209
- radius: t222,
1210
- readOnly: t232,
1211
- ref: t242,
1212
- suffix: t252,
1213
- customValidity: t262,
1214
- type: t272,
1215
- weight: _width,
1216
- width: t282,
1217
- ...t292
1218
- } = t0;
1219
- __unstable_disableFocusRing = t92, t1 = t102, t2 = t112, className = t122, clearButton = t132, t3 = t142, t4 = t152, t5 = t162, IconComponent = t172, IconRightComponent = t182, onClear = t192, t6 = t202, prefix = t212, t7 = t222, readOnly = t232, forwardedRef = t242, suffix = t252, customValidity = t262, t8 = t272, width = t282, rest = t292, $[0] = t0, $[1] = IconComponent, $[2] = IconRightComponent, $[3] = __unstable_disableFocusRing, $[4] = className, $[5] = clearButton, $[6] = customValidity, $[7] = forwardedRef, $[8] = onClear, $[9] = prefix, $[10] = readOnly, $[11] = rest, $[12] = suffix, $[13] = t1, $[14] = t2, $[15] = t3, $[16] = t4, $[17] = t5, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = width;
1220
- } else
1221
- IconComponent = $[1], IconRightComponent = $[2], __unstable_disableFocusRing = $[3], className = $[4], clearButton = $[5], customValidity = $[6], forwardedRef = $[7], onClear = $[8], prefix = $[9], readOnly = $[10], rest = $[11], suffix = $[12], t1 = $[13], t2 = $[14], t3 = $[15], t4 = $[16], t5 = $[17], t6 = $[18], t7 = $[19], t8 = $[20], width = $[21];
1222
- const Element2 = t1 === void 0 ? DEFAULT_TEXT_INPUT_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, disabled = t3 === void 0 ? !1 : t3, fontSize = t4 === void 0 ? 2 : t4, gap = t5 === void 0 ? 3 : t5, padding = t6 === void 0 ? 3 : t6, radius = t7 === void 0 ? 2 : t7, type = t8 === void 0 ? "text" : t8, ref = react.useRef(null), responsivePadding = useResponsiveProp(padding), withClearButton = !!clearButton;
1223
- let t9;
1224
- $[22] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => ref.current, $[22] = t9) : t9 = $[22], react.useImperativeHandle(forwardedRef, t9), useCustomValidity(ref, customValidity);
1225
- const handleClearMouseDown = _temp$8;
1226
- let t10;
1227
- $[23] !== onClear ? (t10 = (event_0) => {
1228
- event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
1229
- }, $[23] = onClear, $[24] = t10) : t10 = $[24];
1230
- const handleClearClick = t10;
1231
- let t11, t12;
1232
- $[25] !== responsivePadding ? (t12 = Object.fromEntries(Object.entries(responsivePadding).map(_temp2$1)), $[25] = responsivePadding, $[26] = t12) : t12 = $[26], t11 = t12;
1233
- const clearButtonBoxPadding = t11;
1234
- let t13, t14;
1235
- $[27] !== responsivePadding ? (t14 = Object.fromEntries(Object.entries(responsivePadding).map(_temp3)), $[27] = responsivePadding, $[28] = t14) : t14 = $[28], t13 = t14;
1236
- const clearButtonPadding = t13;
1237
- let t15;
1238
- t15 = isRecord(clearButton) ? clearButton : EMPTY_RECORD;
1239
- const clearButtonProps = t15;
1240
- let t16;
1241
- $[29] !== border || $[30] !== className || $[31] !== fontSize || $[32] !== gap || $[33] !== padding || $[34] !== radius || $[35] !== width ? (t16 = css.textInput({
1242
- className,
1243
- border,
1244
- fontSize,
1245
- padding,
1246
- radius,
1247
- gap,
1248
- width
1249
- }), $[29] = border, $[30] = className, $[31] = fontSize, $[32] = gap, $[33] = padding, $[34] = radius, $[35] = width, $[36] = t16) : t16 = $[36];
1250
- const t17 = IconComponent ? "" : void 0, t18 = IconRightComponent ? "" : void 0, t19 = customValidity ? "" : void 0, t20 = prefix ? "" : void 0, t21 = !disabled && readOnly ? "" : void 0, t22 = suffix ? "" : void 0;
1251
- let t23;
1252
- $[37] !== prefix ? (t23 = prefix && /* @__PURE__ */ jsxRuntime.jsx(Box, { className: css.textInputPrefix(), sizing: "border", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: prefix }) }), $[37] = prefix, $[38] = t23) : t23 = $[38];
1253
- let t24;
1254
- $[39] === Symbol.for("react.memo_cache_sentinel") ? (t24 = css.textInputElement(), $[39] = t24) : t24 = $[39];
1255
- let t25;
1256
- $[40] === Symbol.for("react.memo_cache_sentinel") ? (t25 = css._inputElement(), $[40] = t25) : t25 = $[40];
1257
- const t26 = __unstable_disableFocusRing ? "" : void 0;
1258
- let t27;
1259
- $[41] !== Element2 || $[42] !== disabled || $[43] !== readOnly || $[44] !== rest || $[45] !== t26 || $[46] !== type ? (t27 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { ...rest, className: t25, "data-no-focus-ring": t26, disabled, readOnly, ref, type }), $[41] = Element2, $[42] = disabled, $[43] = readOnly, $[44] = rest, $[45] = t26, $[46] = type, $[47] = t27) : t27 = $[47];
1260
- let t28;
1261
- $[48] === Symbol.for("react.memo_cache_sentinel") ? (t28 = css._inputPresentation(), $[48] = t28) : t28 = $[48];
1262
- let t29;
1263
- $[49] !== IconComponent || $[50] !== fontSize || $[51] !== padding ? (t29 = IconComponent && /* @__PURE__ */ jsxRuntime.jsx(Box, { padding, position: "absolute", insetTop: 0, insetLeft: 0, children: /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize, children: [
1264
- react.isValidElement(IconComponent) && IconComponent,
1265
- reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
1266
- ] }) }), $[49] = IconComponent, $[50] = fontSize, $[51] = padding, $[52] = t29) : t29 = $[52];
1267
- let t30;
1268
- $[53] !== IconRightComponent || $[54] !== fontSize || $[55] !== padding || $[56] !== withClearButton ? (t30 = !withClearButton && IconRightComponent && /* @__PURE__ */ jsxRuntime.jsx(Box, { padding, position: "absolute", insetTop: 0, insetRight: 0, children: /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize, children: [
1269
- react.isValidElement(IconRightComponent) && IconRightComponent,
1270
- reactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
1271
- ] }) }), $[53] = IconRightComponent, $[54] = fontSize, $[55] = padding, $[56] = withClearButton, $[57] = t30) : t30 = $[57];
1272
- let t31;
1273
- $[58] !== t29 || $[59] !== t30 ? (t31 = /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: t28, position: "absolute", children: [
1274
- t29,
1275
- t30
1276
- ] }), $[58] = t29, $[59] = t30, $[60] = t31) : t31 = $[60];
1277
- let t32;
1278
- $[61] !== clearButton || $[62] !== clearButtonBoxPadding || $[63] !== clearButtonPadding || $[64] !== clearButtonProps || $[65] !== disabled || $[66] !== fontSize || $[67] !== handleClearClick || $[68] !== radius || $[69] !== readOnly ? (t32 = !disabled && !readOnly && clearButton && /* @__PURE__ */ jsxRuntime.jsx(Box, { insetTop: 0, insetRight: 0, padding: clearButtonBoxPadding, position: "absolute", style: {
1279
- zIndex: 2
1280
- }, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { "aria-label": "Clear", "data-qa": "clear-button", display: "block", fontSize, icon: icons.CloseIcon, mode: "bleed", padding: clearButtonPadding, radius, ...clearButtonProps, onClick: handleClearClick, onMouseDown: handleClearMouseDown }) }), $[61] = clearButton, $[62] = clearButtonBoxPadding, $[63] = clearButtonPadding, $[64] = clearButtonProps, $[65] = disabled, $[66] = fontSize, $[67] = handleClearClick, $[68] = radius, $[69] = readOnly, $[70] = t32) : t32 = $[70];
1281
- let t33;
1282
- $[71] !== t27 || $[72] !== t31 || $[73] !== t32 ? (t33 = /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: t24, flex: 1, position: "relative", children: [
1283
- t27,
1284
- t31,
1285
- t32
1286
- ] }), $[71] = t27, $[72] = t31, $[73] = t32, $[74] = t33) : t33 = $[74];
1287
- let t34;
1288
- $[75] !== suffix ? (t34 = suffix && /* @__PURE__ */ jsxRuntime.jsx(Box, { className: css.textInputSuffix(), sizing: "border", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: suffix }) }), $[75] = suffix, $[76] = t34) : t34 = $[76];
1289
- let t35;
1290
- return $[77] !== t16 || $[78] !== t17 || $[79] !== t18 || $[80] !== t19 || $[81] !== t20 || $[82] !== t21 || $[83] !== t22 || $[84] !== t23 || $[85] !== t33 || $[86] !== t34 ? (t35 = /* @__PURE__ */ jsxRuntime.jsxs(Box, { alignItems: "center", className: t16, "data-icon-left": t17, "data-icon-right": t18, "data-invalid": t19, "data-prefix": t20, "data-read-only": t21, "data-suffix": t22, "data-ui": "TextInput", display: "flex", children: [
1291
- t23,
1292
- t33,
1293
- t34
1294
- ] }), $[77] = t16, $[78] = t17, $[79] = t18, $[80] = t19, $[81] = t20, $[82] = t21, $[83] = t22, $[84] = t23, $[85] = t33, $[86] = t34, $[87] = t35) : t35 = $[87], t35;
1295
- }
1296
- function _temp3(t0) {
1297
- const [key_0, value_0] = t0;
1298
- return value_0 === 0 ? [key_0, 0] : value_0 === 1 ? [key_0, 0] : value_0 === 2 ? [key_0, 1] : [key_0, typeof value_0 == "number" ? value_0 - 1 : 0];
1299
- }
1300
- function _temp2$1(t0) {
1301
- const [key2, value] = t0;
1302
- return value === 0 ? [key2, 0] : value === 1 ? [key2, 1] : value === 2 ? [key2, 1] : [key2, typeof value == "number" ? value - 2 : 0];
1303
- }
1304
- function _temp$8(event) {
1305
- event.preventDefault(), event.stopPropagation();
1306
- }
1307
- function AutocompleteOption(props) {
1308
- const $ = compilerRuntime.c(11), {
1309
- children,
1310
- id,
1311
- onSelect,
1312
- selected,
1313
- value
1314
- } = props;
1315
- let t0;
1316
- $[0] !== onSelect || $[1] !== value ? (t0 = () => {
1317
- setTimeout(() => {
1318
- onSelect(value);
1319
- }, 0);
1320
- }, $[0] = onSelect, $[1] = value, $[2] = t0) : t0 = $[2];
1321
- const handleClick = t0;
1322
- let t1;
1323
- $[3] !== handleClick ? (t1 = (event) => {
1324
- event.key === "Enter" && !_isEnterToClickElement(event.currentTarget) && handleClick();
1325
- }, $[3] = handleClick, $[4] = t1) : t1 = $[4];
1326
- const handleKeyDown = t1;
1327
- let t2;
1328
- return $[5] !== children || $[6] !== handleClick || $[7] !== handleKeyDown || $[8] !== id || $[9] !== selected ? (t2 = /* @__PURE__ */ jsxRuntime.jsx("li", { "aria-selected": selected, "data-ui": "AutocompleteOption", id, role: "option", onClick: handleClick, onKeyDown: handleKeyDown, children }), $[5] = children, $[6] = handleClick, $[7] = handleKeyDown, $[8] = id, $[9] = selected, $[10] = t2) : t2 = $[10], t2;
1329
- }
1330
- function autocompleteReducer(state, msg) {
1331
- return msg.type === "input/change" ? {
1332
- ...state,
1333
- activeValue: null,
1334
- focused: !0,
1335
- query: msg.query
1336
- } : msg.type === "input/focus" ? {
1337
- ...state,
1338
- focused: !0
1339
- } : msg.type === "root/blur" ? {
1340
- ...state,
1341
- focused: !1,
1342
- query: null
1343
- } : msg.type === "root/clear" ? {
1344
- ...state,
1345
- activeValue: null,
1346
- query: null,
1347
- value: null
1348
- } : msg.type === "root/escape" ? {
1349
- ...state,
1350
- focused: !1,
1351
- query: null
1352
- } : msg.type === "root/open" ? {
1353
- ...state,
1354
- query: state.query || msg.query
1355
- } : msg.type === "root/setActiveValue" ? {
1356
- ...state,
1357
- activeValue: msg.value,
1358
- listFocused: msg.listFocused || state.listFocused
1359
- } : msg.type === "root/setListFocused" ? {
1360
- ...state,
1361
- listFocused: msg.listFocused
1362
- } : msg.type === "value/change" ? {
1363
- ...state,
1364
- activeValue: msg.value,
1365
- query: null,
1366
- value: msg.value
1367
- } : state;
1368
- }
1369
- const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "Home", "End", "PageUp", "PageDown", "Meta", "Tab", "CapsLock"], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_AUTOCOMPLETE_ELEMENT = "input", DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1;
1370
- function Autocomplete(props) {
1371
- const {
1372
- as = DEFAULT_AUTOCOMPLETE_ELEMENT,
1373
- border = !0,
1374
- customValidity,
1375
- disabled,
1376
- filterOption: filterOptionProp,
1377
- fontSize = 2,
1378
- icon,
1379
- id,
1380
- listBox = EMPTY_RECORD,
1381
- loading,
1382
- onBlur,
1383
- onChange,
1384
- onFocus,
1385
- onQueryChange,
1386
- onSelect,
1387
- openButton,
1388
- openOnFocus,
1389
- options: optionsProp,
1390
- padding: paddingProp = 3,
1391
- popover = EMPTY_RECORD,
1392
- prefix,
1393
- radius = 2,
1394
- readOnly,
1395
- ref: forwardedRef,
1396
- relatedElements,
1397
- renderOption: renderOptionProp,
1398
- renderPopover,
1399
- renderValue = DEFAULT_RENDER_VALUE,
1400
- suffix,
1401
- value: valueProp,
1402
- ...rest
1403
- } = props, [state, dispatch] = react.useReducer(autocompleteReducer, {
1404
- activeValue: valueProp || null,
1405
- focused: !1,
1406
- listFocused: !1,
1407
- query: null,
1408
- value: valueProp || null
1409
- }), {
1410
- activeValue,
1411
- focused,
1412
- listFocused,
1413
- query,
1414
- value
1415
- } = state, defaultRenderOption = react.useCallback(({
1416
- value: value_0
1417
- }) => /* @__PURE__ */ jsxRuntime.jsx(Selectable, { as: "button", padding: paddingProp, radius: 2, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, textOverflow: "ellipsis", children: value_0 }) }), [fontSize, paddingProp]), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1);
1418
- react.useImperativeHandle(forwardedRef, () => inputElementRef.current);
1419
- const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useResponsiveProp(paddingProp), currentOption = react.useMemo(() => value !== null ? options.find((o) => o.value === value) : void 0, [options, value]), filteredOptions = react.useMemo(() => options.filter((option) => query ? filterOption(query, option) : !0), [filterOption, options, query]), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = react.useCallback((event) => {
1420
- setTimeout(() => {
1421
- if (popoverMouseWithinRef.current)
1422
- return;
1423
- const elements = (relatedElements || []).concat(rootElementRef.current ? [rootElementRef.current] : [], resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []);
1424
- let focusInside = !1;
1425
- if (document.activeElement) {
1426
- for (const e of elements)
1427
- if (e === document.activeElement || e.contains(document.activeElement)) {
1428
- focusInside = !0;
1429
- break;
1430
- }
1431
- }
1432
- focusInside === !1 && (dispatch({
1433
- type: "root/blur"
1434
- }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
1435
- }, 0);
1436
- }, [onBlur, onQueryChange, relatedElements]), handleRootFocus = react.useCallback((event_0) => {
1437
- const listBoxElement = listBoxElementRef.current, focusedElement = event_0.target instanceof HTMLElement ? event_0.target : null, listFocused_0 = listBoxElement?.contains(focusedElement) || !1;
1438
- listFocused_0 !== listFocusedRef.current && (listFocusedRef.current = listFocused_0, dispatch({
1439
- type: "root/setListFocused",
1440
- listFocused: listFocused_0
1441
- }));
1442
- }, []), handleOptionSelect = react.useCallback((v) => {
1443
- dispatch({
1444
- type: "value/change",
1445
- value: v
1446
- }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
1447
- }, [onChange, onSelect, onQueryChange]), handleRootKeyDown = react.useCallback((event_1) => {
1448
- if (event_1.key === "ArrowDown") {
1449
- if (event_1.preventDefault(), !filteredOptionsLen) return;
1450
- const activeOption = filteredOptions.find((o_0) => o_0.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
1451
- nextActiveOption && dispatch({
1452
- type: "root/setActiveValue",
1453
- value: nextActiveOption.value,
1454
- listFocused: !0
1455
- });
1456
- return;
1457
- }
1458
- if (event_1.key === "ArrowUp") {
1459
- if (event_1.preventDefault(), !filteredOptionsLen) return;
1460
- const activeOption_0 = filteredOptions.find((o_1) => o_1.value === activeValue), activeIndex_0 = activeOption_0 ? filteredOptions.indexOf(activeOption_0) : -1, nextActiveOption_0 = filteredOptions[activeIndex_0 === -1 ? filteredOptionsLen - 1 : (filteredOptionsLen + activeIndex_0 - 1) % filteredOptionsLen];
1461
- nextActiveOption_0 && dispatch({
1462
- type: "root/setActiveValue",
1463
- value: nextActiveOption_0.value,
1464
- listFocused: !0
1465
- });
1466
- return;
1467
- }
1468
- if (event_1.key === "Escape") {
1469
- dispatch({
1470
- type: "root/escape"
1471
- }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
1472
- return;
1473
- }
1474
- const target = event_1.target, listEl = listBoxElementRef.current;
1475
- if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key)) {
1476
- inputElementRef.current?.focus();
1477
- return;
1478
- }
1479
- }, [activeValue, filteredOptions, filteredOptionsLen, onQueryChange]), handleInputChange = react.useCallback((event_2) => {
1480
- const nextQuery = event_2.currentTarget.value;
1481
- dispatch({
1482
- type: "input/change",
1483
- query: nextQuery
1484
- }), onQueryChange && onQueryChange(nextQuery);
1485
- }, [onQueryChange]), dispatchOpen = react.useCallback(() => {
1486
- dispatch({
1487
- type: "root/open",
1488
- query: value ? renderValue(value, currentOption) : ""
1489
- });
1490
- }, [currentOption, renderValue, value]), handleInputFocus = react.useCallback((event_3) => {
1491
- focused || (dispatch({
1492
- type: "input/focus"
1493
- }), onFocus && onFocus(event_3), openOnFocus && dispatchOpen());
1494
- }, [focused, onFocus, openOnFocus, dispatchOpen]), handlePopoverMouseEnter = react.useCallback(() => {
1495
- popoverMouseWithinRef.current = !0;
1496
- }, []), handlePopoverMouseLeave = react.useCallback(() => {
1497
- popoverMouseWithinRef.current = !1;
1498
- }, []), handleClearButtonClick = react.useCallback(() => {
1499
- dispatch({
1500
- type: "root/clear"
1501
- }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
1502
- }, [onChange, onQueryChange]), handleClearButtonFocus = react.useCallback(() => {
1503
- dispatch({
1504
- type: "input/focus"
1505
- });
1506
- }, []);
1507
- react.useEffect(() => {
1508
- if (valueProp !== valuePropRef.current) {
1509
- valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({
1510
- type: "value/change",
1511
- value: valueProp
1512
- }), valueRef.current = valueProp);
1513
- return;
1514
- }
1515
- valueProp !== valueRef.current && (valueRef.current = valueProp || null, dispatch({
1516
- type: "value/change",
1517
- value: valueProp || null
1518
- }));
1519
- }, [valueProp]), react.useEffect(() => {
1520
- !focused && valueRef.current && dispatch({
1521
- type: "root/setActiveValue",
1522
- value: valueRef.current
1523
- });
1524
- }, [focused]), react.useEffect(() => {
1525
- const listElement = listBoxElementRef.current;
1526
- if (!listElement) return;
1527
- const activeOption_1 = filteredOptions.find((o_2) => o_2.value === activeValue);
1528
- if (activeOption_1) {
1529
- const activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1];
1530
- if (activeItemElement) {
1531
- if (_hasFocus(activeItemElement))
1532
- return;
1533
- focusFirstDescendant(activeItemElement);
1534
- }
1535
- }
1536
- }, [activeValue, filteredOptions]);
1537
- const clearButton = react.useMemo(() => {
1538
- if (!loading && !disabled && value)
1539
- return {
1540
- "aria-label": "Clear",
1541
- onFocus: handleClearButtonFocus
1542
- };
1543
- }, [disabled, handleClearButtonFocus, loading, value]), openButtonBoxPadding = react.useMemo(() => Object.fromEntries(Object.entries(padding).map(([key2, value_1]) => value_1 === 0 ? [key2, 0] : value_1 === 1 ? [key2, 1] : value_1 === 2 ? [key2, 1] : [key2, value_1 - 2])), [padding]), openButtonPadding = react.useMemo(() => Object.values(padding).map((v_0) => Math.max(v_0 - 1, 0)), [padding]), openButtonProps = react.useMemo(() => typeof openButton == "object" ? openButton : EMPTY_RECORD, [openButton]), handleOpenClick = react.useCallback((event_4) => {
1544
- dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus());
1545
- }, [openButtonProps, dispatchOpen]), openButtonNode = react.useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsxRuntime.jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { "aria-label": "Open", disabled: expanded, display: "block", fontSize, icon: icons.ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = react.useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), input = /* @__PURE__ */ jsxRuntime.jsx(TextInput, { ...rest, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", as, border, clearButton, customValidity, disabled, fontSize, icon, iconRight: loading && AnimatedSpinnerIcon, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: inputElementRef, role: "combobox", spellCheck: !1, suffix: suffix || openButtonNode, value: inputValue }), handleListBoxKeyDown = react.useCallback((event_5) => {
1546
- event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
1547
- }, [listFocused]), content2 = react.useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsxRuntime.jsx(Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", gap: 1, id: listBoxId, ref: listBoxElementRef, role: "listbox", children: filteredOptions.map((option_0) => {
1548
- const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
1549
- return /* @__PURE__ */ jsxRuntime.jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: react.cloneElement(renderOption(option_0), {
1550
- disabled: loading,
1551
- selected: active,
1552
- tabIndex: listFocused && active ? 0 : -1
1553
- }) }, option_0.value);
1554
- }) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = react.useMemo(() => renderPopover ? renderPopover({
1555
- content: content2,
1556
- hidden: !expanded,
1557
- inputElement: inputElementRef.current,
1558
- onMouseEnter: handlePopoverMouseEnter,
1559
- onMouseLeave: handlePopoverMouseLeave
1560
- }, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius: 3, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, renderPopover]);
1561
- return (
1562
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
1563
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
1564
- input,
1565
- results
1566
- ] })
1567
- );
1568
- }
1569
- function useClickOutsideEvent(listener, t0, boundaryElement) {
1570
- const $ = compilerRuntime.c(9), elementsArg = t0 === void 0 ? _temp$7 : t0;
1571
- let t1;
1572
- $[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
1573
- if (!listener)
1574
- return;
1575
- const target = evt.target;
1576
- if (!(target instanceof Node))
1577
- return;
1578
- const resolvedBoundaryElement = boundaryElement?.();
1579
- if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target))
1580
- return;
1581
- const elements = elementsArg().flat();
1582
- for (const el of elements)
1583
- if (el && (target === el || el.contains(target)))
1584
- return;
1585
- listener(evt);
1586
- }, $[0] = boundaryElement, $[1] = elementsArg, $[2] = listener, $[3] = t1) : t1 = $[3];
1587
- const onEvent = useEffectEvent.useEffectEvent(t1), hasListener = !!listener;
1588
- let t2;
1589
- $[4] !== hasListener || $[5] !== onEvent ? (t2 = () => {
1590
- if (!hasListener)
1591
- return;
1592
- const handleEvent = (evt_0) => onEvent(evt_0);
1593
- return document.addEventListener("mousedown", handleEvent), () => {
1594
- document.removeEventListener("mousedown", handleEvent);
1595
- };
1596
- }, $[4] = hasListener, $[5] = onEvent, $[6] = t2) : t2 = $[6];
1597
- let t3;
1598
- $[7] !== hasListener ? (t3 = [hasListener], $[7] = hasListener, $[8] = t3) : t3 = $[8], react.useEffect(t2, t3), react.useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
1599
- }
1600
- function _temp$7() {
1601
- return EMPTY_ARRAY;
1602
- }
1603
- const DEFAULT_BREADCRUMBS_ELEMENT = "nav";
1604
- function Breadcrumbs(props) {
1605
- const {
1606
- as = DEFAULT_BREADCRUMBS_ELEMENT,
1607
- children,
1608
- className,
1609
- expandButton: expandButtonProps,
1610
- gap = 2,
1611
- gapX,
1612
- gapY,
1613
- maxLength,
1614
- separator,
1615
- ...rest
1616
- } = props, [open, setOpen] = react.useState(!1), expandElementRef = react.useRef(null), popoverElementRef = react.useRef(null), collapse = react.useCallback(() => setOpen(!1), []), expand = react.useCallback(() => setOpen(!0), []);
1617
- useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current]);
1618
- const rawItems = react.useMemo(() => react.Children.toArray(children).filter(react.isValidElement), [children]), items = react.useMemo(() => {
1619
- const len = rawItems.length;
1620
- if (maxLength && len > maxLength) {
1621
- const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2);
1622
- return [...rawItems.slice(0, beforeLength - 1), /* @__PURE__ */ jsxRuntime.jsx(Popover, { constrainSize: !0, content: /* @__PURE__ */ jsxRuntime.jsx(Stack, { as: "ol", gap: gapY, overflow: "auto", children: rawItems.slice(beforeLength - 1, len - afterLength) }), open, padding: 2, placement: "top", portal: !0, ref: popoverElementRef, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { mode: "bleed", padding: 0, text: "\u2026", ...expandButtonProps, onClick: open ? collapse : expand, ref: expandElementRef, selected: open }) }, "button"), ...rawItems.slice(len - afterLength)];
1623
- }
1624
- return rawItems;
1625
- }, [collapse, expand, expandButtonProps, gapY, maxLength, open, rawItems]);
1626
- return /* @__PURE__ */ jsxRuntime.jsx(Flex, { as, "data-ui": "Breadcrumbs", ...rest, className: css.breadcrumbs({
1627
- className
1628
- }), gap, gapX, gapY, children: items.map((item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
1629
- itemIndex > 0 && /* @__PURE__ */ jsxRuntime.jsx(Box, { "aria-hidden": !0, as: "li", children: separator || /* @__PURE__ */ jsxRuntime.jsx(Text, { muted: !0, children: "/" }) }),
1630
- /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "li", children: item })
1631
- ] }, itemIndex)) });
1632
- }
1633
- const DEFAULT_CONTAINER_ELEMENT = "div";
1634
- function Container(props) {
1635
- const $ = compilerRuntime.c(12), t0 = props;
1636
- let className, rest, t1, t2;
1637
- $[0] !== t0 ? ({
1638
- as: t1,
1639
- className,
1640
- width: t2,
1641
- ...rest
1642
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1, $[4] = t2) : (className = $[1], rest = $[2], t1 = $[3], t2 = $[4]);
1643
- const as = t1 === void 0 ? DEFAULT_CONTAINER_ELEMENT : t1, width = t2 === void 0 ? 2 : t2;
1644
- let t3;
1645
- $[5] !== className || $[6] !== width ? (t3 = css.container({
1646
- className,
1647
- width
1648
- }), $[5] = className, $[6] = width, $[7] = t3) : t3 = $[7];
1649
- let t4;
1650
- return $[8] !== as || $[9] !== rest || $[10] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Container", ...rest, as, className: t3 }), $[8] = as, $[9] = rest, $[10] = t3, $[11] = t4) : t4 = $[11], t4;
1651
- }
1652
- function useGlobalKeyDown(onKeyDown) {
1653
- const $ = compilerRuntime.c(5);
1654
- let t0;
1655
- $[0] !== onKeyDown ? (t0 = (event) => onKeyDown(event), $[0] = onKeyDown, $[1] = t0) : t0 = $[1];
1656
- const handleKeyDown = useEffectEvent.useEffectEvent(t0);
1657
- let t1;
1658
- $[2] !== handleKeyDown ? (t1 = () => {
1659
- const handler = (event_0) => handleKeyDown(event_0);
1660
- return window.addEventListener("keydown", handler), () => window.removeEventListener("keydown", handler);
1661
- }, $[2] = handleKeyDown, $[3] = t1) : t1 = $[3];
1662
- let t2;
1663
- $[4] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[4] = t2) : t2 = $[4], react.useEffect(t1, t2);
1664
- }
1665
- function isTargetWithinScope(boundaryElement, portalElement, target) {
1666
- return !boundaryElement || !portalElement ? !0 : containsOrEqualsElement(boundaryElement, target) || containsOrEqualsElement(portalElement, target);
1667
- }
1668
- const DEFAULT_DIALOG_CARD_ELEMENT = "div";
1669
- function DialogCard(props) {
1670
- const $ = compilerRuntime.c(61), t0 = props;
1671
- let autoFocus, children, footer, forwardedContentRef, forwardedRef, header, hideCloseButton, id, onClickOutside, onClose, portalProp, rest, t1;
1672
- $[0] !== t0 ? ({
1673
- __unstable_autoFocus: autoFocus,
1674
- __unstable_hideCloseButton: hideCloseButton,
1675
- as: t1,
1676
- children,
1677
- contentRef: forwardedContentRef,
1678
- footer,
1679
- header,
1680
- id,
1681
- onClickOutside,
1682
- onClose,
1683
- portal: portalProp,
1684
- ref: forwardedRef,
1685
- ...rest
1686
- } = t0, $[0] = t0, $[1] = autoFocus, $[2] = children, $[3] = footer, $[4] = forwardedContentRef, $[5] = forwardedRef, $[6] = header, $[7] = hideCloseButton, $[8] = id, $[9] = onClickOutside, $[10] = onClose, $[11] = portalProp, $[12] = rest, $[13] = t1) : (autoFocus = $[1], children = $[2], footer = $[3], forwardedContentRef = $[4], forwardedRef = $[5], header = $[6], hideCloseButton = $[7], id = $[8], onClickOutside = $[9], onClose = $[10], portalProp = $[11], rest = $[12], t1 = $[13]);
1687
- const as = t1 === void 0 ? DEFAULT_DIALOG_CARD_ELEMENT : t1, portal = usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = useBoundaryElement().element, ref = react.useRef(null), contentRef = react.useRef(null), layer = useLayer(), {
1688
- isTopLayer
1689
- } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton, [scrollTop, setScrollTop] = react.useState(0), [scrollHeight, setScrollHeight] = react.useState(0), scrollBottom = scrollHeight - scrollTop;
1690
- let t2;
1691
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[14] = t2) : t2 = $[14], react.useImperativeHandle(forwardedRef, t2);
1692
- let t3;
1693
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => contentRef.current, $[15] = t3) : t3 = $[15], react.useImperativeHandle(forwardedContentRef, t3);
1694
- let t4, t5;
1695
- $[16] !== autoFocus ? (t4 = () => {
1696
- autoFocus && ref.current && focusFirstDescendant(ref.current);
1697
- }, t5 = [autoFocus, ref], $[16] = autoFocus, $[17] = t4, $[18] = t5) : (t4 = $[17], t5 = $[18]), react.useEffect(t4, t5);
1698
- let t6;
1699
- $[19] !== boundaryElement || $[20] !== isTopLayer || $[21] !== onClose || $[22] !== portalElement ? (t6 = (event) => {
1700
- if (!isTopLayer || !onClose)
1701
- return;
1702
- const target = document.activeElement;
1703
- target && !isTargetWithinScope(boundaryElement, portalElement, target) || event.key === "Escape" && (event.preventDefault(), event.stopPropagation(), onClose());
1704
- }, $[19] = boundaryElement, $[20] = isTopLayer, $[21] = onClose, $[22] = portalElement, $[23] = t6) : t6 = $[23], useGlobalKeyDown(t6);
1705
- let t7;
1706
- $[24] !== boundaryElement || $[25] !== isTopLayer || $[26] !== onClickOutside || $[27] !== portalElement ? (t7 = isTopLayer && onClickOutside && ((event_0) => {
1707
- const target_0 = event_0.target;
1708
- target_0 && !isTargetWithinScope(boundaryElement, portalElement, target_0) || onClickOutside();
1709
- }), $[24] = boundaryElement, $[25] = isTopLayer, $[26] = onClickOutside, $[27] = portalElement, $[28] = t7) : t7 = $[28];
1710
- let t8;
1711
- $[29] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => [ref.current], $[29] = t8) : t8 = $[29], useClickOutsideEvent(t7, t8);
1712
- let t10, t9;
1713
- $[30] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
1714
- const el = contentRef.current;
1715
- if (!el)
1716
- return;
1717
- const handleScroll = () => {
1718
- setScrollTop(el.scrollTop), setScrollHeight(el.scrollHeight - el.offsetHeight);
1719
- };
1720
- return el.addEventListener("scroll", handleScroll, {
1721
- passive: !0
1722
- }), () => {
1723
- el.removeEventListener("scroll", handleScroll);
1724
- };
1725
- }, t10 = [], $[30] = t10, $[31] = t9) : (t10 = $[30], t9 = $[31]), react.useEffect(t9, t10);
1726
- let t11;
1727
- $[32] === Symbol.for("react.memo_cache_sentinel") ? (t11 = css.dialogCard(), $[32] = t11) : t11 = $[32];
1728
- let t12;
1729
- $[33] !== header || $[34] !== labelId || $[35] !== onClose || $[36] !== showCloseButton || $[37] !== showHeader ? (t12 = showHeader && /* @__PURE__ */ jsxRuntime.jsxs(Flex, { align: "flex-start", className: css.dialogHeader(), padding: 3, position: "relative", children: [
1730
- /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsxRuntime.jsx(Text, { id: labelId, size: 1, weight: "semibold", children: header }) }),
1731
- showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { "aria-label": "Close dialog", disabled: !onClose, icon: icons.CloseIcon, mode: "bleed", onClick: onClose, padding: 2 }) })
1732
- ] }), $[33] = header, $[34] = labelId, $[35] = onClose, $[36] = showCloseButton, $[37] = showHeader, $[38] = t12) : t12 = $[38];
1733
- let t13;
1734
- $[39] === Symbol.for("react.memo_cache_sentinel") ? (t13 = css.dialogContent(), $[39] = t13) : t13 = $[39];
1735
- let t14;
1736
- $[40] !== scrollTop || $[41] !== showHeader ? (t14 = showHeader && /* @__PURE__ */ jsxRuntime.jsx("div", { className: css.dialogScrollerShadowTop(), style: {
1737
- opacity: Math.min(scrollTop, 32) / 32
1738
- } }), $[40] = scrollTop, $[41] = showHeader, $[42] = t14) : t14 = $[42];
1739
- let t15;
1740
- $[43] === Symbol.for("react.memo_cache_sentinel") ? (t15 = css.dialogScroller(), $[43] = t15) : t15 = $[43];
1741
- let t16;
1742
- $[44] !== children ? (t16 = /* @__PURE__ */ jsxRuntime.jsx(Box, { className: t15, overflow: "auto", ref: contentRef, children }), $[44] = children, $[45] = t16) : t16 = $[45];
1743
- let t17;
1744
- $[46] !== footer || $[47] !== scrollBottom ? (t17 = footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: css.dialogScrollerShadowBottom(), style: {
1745
- opacity: Math.min(scrollBottom, 32) / 32
1746
- } }), $[46] = footer, $[47] = scrollBottom, $[48] = t17) : t17 = $[48];
1747
- let t18;
1748
- $[49] !== t14 || $[50] !== t16 || $[51] !== t17 ? (t18 = /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: t13, flex: 1, position: "relative", tabIndex: -1, children: [
1749
- t14,
1750
- t16,
1751
- t17
1752
- ] }), $[49] = t14, $[50] = t16, $[51] = t17, $[52] = t18) : t18 = $[52];
1753
- let t19;
1754
- $[53] !== footer ? (t19 = footer && /* @__PURE__ */ jsxRuntime.jsx(Box, { className: css.dialogFooter(), position: "relative", children: footer }), $[53] = footer, $[54] = t19) : t19 = $[54];
1755
- let t20;
1756
- return $[55] !== as || $[56] !== rest || $[57] !== t12 || $[58] !== t18 || $[59] !== t19 ? (t20 = /* @__PURE__ */ jsxRuntime.jsxs(Card, { ...rest, as, className: t11, display: "flex", flexDirection: "column", ref, children: [
1757
- t12,
1758
- t18,
1759
- t19
1760
- ] }), $[55] = as, $[56] = rest, $[57] = t12, $[58] = t18, $[59] = t19, $[60] = t20) : t20 = $[60], t20;
1761
- }
1762
- const DialogContext = createGlobalScopedContext("@sanity/ui/v3/dialog", {
1763
- version: 0
1764
- });
1765
- function useDialog() {
1766
- return react.useContext(DialogContext);
1767
- }
1768
- const DEFAULT_DIALOG_ELEMENT = "div";
1769
- function Dialog(props) {
1770
- const $ = compilerRuntime.c(69), context = useDialog(), t0 = props;
1771
- let _positionProp, _zOffsetProp, children, className, contentRef, footer, header, id, onActivate, onClickOutside, onClose, onFocus, portalProp, rest, scheme, t1, t2, t3, t4, t5, t6, t7, tone;
1772
- $[0] !== t0 ? ({
1773
- __unstable_autoFocus: t1,
1774
- __unstable_hideCloseButton: t2,
1775
- animate: t3,
1776
- cardRadius: t4,
1777
- children,
1778
- className,
1779
- contentRef,
1780
- footer,
1781
- header,
1782
- id,
1783
- onActivate,
1784
- onClickOutside,
1785
- onClose,
1786
- onFocus,
1787
- padding: t5,
1788
- portal: portalProp,
1789
- position: _positionProp,
1790
- scheme,
1791
- shadow: t6,
1792
- width: t7,
1793
- zOffset: _zOffsetProp,
1794
- tone,
1795
- ...rest
1796
- } = t0, $[0] = t0, $[1] = _positionProp, $[2] = _zOffsetProp, $[3] = children, $[4] = className, $[5] = contentRef, $[6] = footer, $[7] = header, $[8] = id, $[9] = onActivate, $[10] = onClickOutside, $[11] = onClose, $[12] = onFocus, $[13] = portalProp, $[14] = rest, $[15] = scheme, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6, $[22] = t7, $[23] = tone) : (_positionProp = $[1], _zOffsetProp = $[2], children = $[3], className = $[4], contentRef = $[5], footer = $[6], header = $[7], id = $[8], onActivate = $[9], onClickOutside = $[10], onClose = $[11], onFocus = $[12], portalProp = $[13], rest = $[14], scheme = $[15], t1 = $[16], t2 = $[17], t3 = $[18], t4 = $[19], t5 = $[20], t6 = $[21], t7 = $[22], tone = $[23]);
1797
- const autoFocus = t1 === void 0 ? !0 : t1, hideCloseButton = t2 === void 0 ? !1 : t2, _animate = t3 === void 0 ? !1 : t3, cardRadiusProp = t4 === void 0 ? 4 : t4, padding = t5 === void 0 ? 3 : t5, cardShadow = t6 === void 0 ? 4 : t6, width = t7 === void 0 ? 0 : t7, positionProp = _positionProp ?? context.position ?? "fixed", zOffsetProp = _zOffsetProp ?? context.zOffset ?? Z_OFFSETS.dialog, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = useBoundaryElement().element, cardRadius = useResponsiveProp(cardRadiusProp), position = useResponsiveProp(positionProp), zOffset = useResponsiveProp(zOffsetProp), preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null);
1798
- let t8;
1799
- $[24] !== onFocus ? (t8 = (event) => {
1800
- onFocus?.(event);
1801
- const target = event.target, cardElement = cardRef.current;
1802
- if (cardElement && target === preDivRef.current) {
1803
- focusLastDescendant(cardElement);
1804
- return;
1805
- }
1806
- if (cardElement && target === postDivRef.current) {
1807
- focusFirstDescendant(cardElement);
1808
- return;
1809
- }
1810
- isHTMLElement(event.target) && (focusedElementRef.current = event.target);
1811
- }, $[24] = onFocus, $[25] = t8) : t8 = $[25];
1812
- const handleFocus = t8, labelId = `${id}_label`, rootClickTimeoutRef = react.useRef(void 0);
1813
- let t9;
1814
- $[26] !== boundaryElement || $[27] !== portalElement ? (t9 = () => {
1815
- rootClickTimeoutRef.current && clearTimeout(rootClickTimeoutRef.current), rootClickTimeoutRef.current = setTimeout(() => {
1816
- const activeElement = document.activeElement;
1817
- if (activeElement && !isTargetWithinScope(boundaryElement, portalElement, activeElement)) {
1818
- const target_0 = focusedElementRef.current;
1819
- if (!target_0 || !document.body.contains(target_0)) {
1820
- const cardElement_0 = cardRef.current;
1821
- cardElement_0 && focusFirstDescendant(cardElement_0);
1822
- return;
1823
- }
1824
- target_0.focus();
1825
- }
1826
- }, 0);
1827
- }, $[26] = boundaryElement, $[27] = portalElement, $[28] = t9) : t9 = $[28];
1828
- const handleRootClick = t9;
1829
- let t10;
1830
- $[29] !== className ? (t10 = css.dialog({
1831
- className
1832
- }), $[29] = className, $[30] = t10) : t10 = $[30];
1833
- const t11 = animate ? "" : void 0;
1834
- let t12;
1835
- $[31] === Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: preDivRef, tabIndex: 0 }), $[31] = t12) : t12 = $[31];
1836
- let t13;
1837
- $[32] === Symbol.for("react.memo_cache_sentinel") ? (t13 = css.dialogContainer(), $[32] = t13) : t13 = $[32];
1838
- let t14;
1839
- $[33] !== autoFocus || $[34] !== cardRadius || $[35] !== cardShadow || $[36] !== children || $[37] !== contentRef || $[38] !== footer || $[39] !== header || $[40] !== hideCloseButton || $[41] !== id || $[42] !== onClickOutside || $[43] !== onClose || $[44] !== portalProp || $[45] !== scheme || $[46] !== tone || $[47] !== width ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(DialogCard, { __unstable_autoFocus: autoFocus, __unstable_hideCloseButton: hideCloseButton, contentRef, footer, header, id, onClickOutside, onClose, portal: portalProp, radius: cardRadius, ref: cardRef, scheme, shadow: cardShadow, tone, width, children }), $[33] = autoFocus, $[34] = cardRadius, $[35] = cardShadow, $[36] = children, $[37] = contentRef, $[38] = footer, $[39] = header, $[40] = hideCloseButton, $[41] = id, $[42] = onClickOutside, $[43] = onClose, $[44] = portalProp, $[45] = scheme, $[46] = tone, $[47] = width, $[48] = t14) : t14 = $[48];
1840
- let t15;
1841
- $[49] !== t14 || $[50] !== width ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(Container, { alignItems: "center", className: t13, "data-ui": "DialogCard", flexDirection: "column", display: "flex", justifyContent: "center", width, children: t14 }), $[49] = t14, $[50] = width, $[51] = t15) : t15 = $[51];
1842
- let t16;
1843
- $[52] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: postDivRef, tabIndex: 0 }), $[52] = t16) : t16 = $[52];
1844
- let t17;
1845
- $[53] !== handleFocus || $[54] !== handleRootClick || $[55] !== id || $[56] !== labelId || $[57] !== onActivate || $[58] !== padding || $[59] !== position || $[60] !== rest || $[61] !== t10 || $[62] !== t11 || $[63] !== t15 || $[64] !== zOffset ? (t17 = /* @__PURE__ */ jsxRuntime.jsxs(Layer, { ...rest, "aria-labelledby": labelId, "aria-modal": !0, className: t10, "data-animate": t11, "data-ui": "Dialog", display: "flex", id, onActivate, onClick: handleRootClick, onFocus: handleFocus, padding, position, role: "dialog", zOffset, children: [
1846
- t12,
1847
- t15,
1848
- t16
1849
- ] }), $[53] = handleFocus, $[54] = handleRootClick, $[55] = id, $[56] = labelId, $[57] = onActivate, $[58] = padding, $[59] = position, $[60] = rest, $[61] = t10, $[62] = t11, $[63] = t15, $[64] = zOffset, $[65] = t17) : t17 = $[65];
1850
- let t18;
1851
- return $[66] !== portalProp || $[67] !== t17 ? (t18 = /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: portalProp, children: t17 }), $[66] = portalProp, $[67] = t17, $[68] = t18) : t18 = $[68], t18;
1852
- }
1853
- function DialogProvider(props) {
1854
- const $ = compilerRuntime.c(6), {
1855
- children,
1856
- position,
1857
- zOffset
1858
- } = props;
1859
- let t0, t1;
1860
- $[0] !== position || $[1] !== zOffset ? (t1 = {
1861
- version: 0,
1862
- position,
1863
- zOffset
1864
- }, $[0] = position, $[1] = zOffset, $[2] = t1) : t1 = $[2], t0 = t1;
1865
- const contextValue = t0;
1866
- let t2;
1867
- return $[3] !== children || $[4] !== contextValue ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: contextValue, children }), $[3] = children, $[4] = contextValue, $[5] = t2) : t2 = $[5], t2;
1868
- }
1869
- const DEFAULT_KBD_ELEMENT = "kbd";
1870
- function KBD(props) {
1871
- const $ = compilerRuntime.c(22), t0 = props;
1872
- let children, className, rest, t1, t2, t3, t4, t5;
1873
- $[0] !== t0 ? ({
1874
- as: t1,
1875
- children,
1876
- className,
1877
- display: t2,
1878
- fontSize: t3,
1879
- padding: t4,
1880
- radius: t5,
1881
- ...rest
1882
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3, $[7] = t4, $[8] = t5) : (children = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6], t4 = $[7], t5 = $[8]);
1883
- const as = t1 === void 0 ? DEFAULT_KBD_ELEMENT : t1, display = t2 === void 0 ? "inline-block" : t2, fontSize = t3 === void 0 ? 1 : t3, padding = t4 === void 0 ? 1 : t4, radius = t5 === void 0 ? 2 : t5, t6 = as;
1884
- let t7;
1885
- $[9] !== className || $[10] !== radius ? (t7 = css.kbd({
1886
- className,
1887
- radius
1888
- }), $[9] = className, $[10] = radius, $[11] = t7) : t7 = $[11];
1889
- let t8;
1890
- $[12] !== children || $[13] !== fontSize ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Text, { as: "span", muted: !0, size: fontSize, weight: "medium", children }), $[12] = children, $[13] = fontSize, $[14] = t8) : t8 = $[14];
1891
- let t9;
1892
- return $[15] !== display || $[16] !== padding || $[17] !== rest || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "KBD", ...rest, as: t6, className: t7, display, muted: !0, padding, children: t8 }), $[15] = display, $[16] = padding, $[17] = rest, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = t9) : t9 = $[21], t9;
1893
- }
1894
- const DEFAULT_HOTKEYS_ELEMENT = "kbd";
1895
- function Hotkeys(props) {
1896
- const $ = compilerRuntime.c(26), t0 = props;
1897
- let fontSize, gapX, gapY, keys, padding, radius, rest, t1, t2;
1898
- $[0] !== t0 ? ({
1899
- as: t1,
1900
- fontSize,
1901
- gap: t2,
1902
- gapX,
1903
- gapY,
1904
- keys,
1905
- padding,
1906
- radius,
1907
- ...rest
1908
- } = t0, $[0] = t0, $[1] = fontSize, $[2] = gapX, $[3] = gapY, $[4] = keys, $[5] = padding, $[6] = radius, $[7] = rest, $[8] = t1, $[9] = t2) : (fontSize = $[1], gapX = $[2], gapY = $[3], keys = $[4], padding = $[5], radius = $[6], rest = $[7], t1 = $[8], t2 = $[9]);
1909
- const as = t1 === void 0 ? DEFAULT_HOTKEYS_ELEMENT : t1, gap = t2 === void 0 ? 1 : t2;
1910
- if (!keys || keys.length === 0)
1911
- return;
1912
- let t3;
1913
- if ($[10] !== fontSize || $[11] !== keys || $[12] !== padding || $[13] !== radius) {
1914
- let t42;
1915
- $[15] !== fontSize || $[16] !== padding || $[17] !== radius ? (t42 = (key2, i) => /* @__PURE__ */ jsxRuntime.jsx(KBD, { fontSize, padding, radius, children: key2 }, i), $[15] = fontSize, $[16] = padding, $[17] = radius, $[18] = t42) : t42 = $[18], t3 = keys.map(t42), $[10] = fontSize, $[11] = keys, $[12] = padding, $[13] = radius, $[14] = t3;
1916
- } else
1917
- t3 = $[14];
1918
- let t4;
1919
- return $[19] !== as || $[20] !== gap || $[21] !== gapX || $[22] !== gapY || $[23] !== rest || $[24] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(Box, { as, "data-ui": "Hotkeys", ...rest, display: "flex", gap, gapX, gapY, children: t3 }), $[19] = as, $[20] = gap, $[21] = gapX, $[22] = gapY, $[23] = rest, $[24] = t3, $[25] = t4) : t4 = $[25], t4;
1920
- }
1921
- const MenuContext = createGlobalScopedContext("@sanity/ui/v3/menu", null);
1922
- function _isFocusable(element) {
1923
- return isHTMLAnchorElement(element) && element.getAttribute("data-disabled") !== "true" || isHTMLButtonElement(element) && !element.disabled;
1924
- }
1925
- function _getFocusableElements(elements) {
1926
- return elements.filter(_isFocusable);
1927
- }
1928
- function _getDOMPath(rootElement, el) {
1929
- const path = [];
1930
- let e = el;
1931
- for (; e !== rootElement; ) {
1932
- const parentElement = e.parentElement;
1933
- if (!parentElement) return path;
1934
- const index = Array.from(parentElement.childNodes).indexOf(e);
1935
- if (path.unshift(index), parentElement === rootElement)
1936
- return path;
1937
- e = parentElement;
1938
- }
1939
- return path;
1940
- }
1941
- const EMPTY_PATH = [];
1942
- function _sortElements(rootElement, elements) {
1943
- if (!rootElement) return;
1944
- const map = /* @__PURE__ */ new WeakMap();
1945
- for (const el of elements)
1946
- map.set(el, _getDOMPath(rootElement, el));
1947
- const _sort = (a, b) => {
1948
- const _a = map.get(a) || EMPTY_PATH, _b = map.get(b) || EMPTY_PATH, len = Math.max(_a.length, _b.length);
1949
- for (let i = 0; i < len; i += 1) {
1950
- const aIndex = _a[i] || -1, bIndex = _b[i] || -1;
1951
- if (aIndex !== bIndex)
1952
- return aIndex - bIndex;
1953
- }
1954
- return 0;
1955
- };
1956
- elements.sort(_sort);
1957
- }
1958
- function useMenuController(props) {
1959
- const {
1960
- onKeyDown,
1961
- originElement,
1962
- shouldFocus,
1963
- rootElementRef
1964
- } = props, elementsRef = react.useRef([]), [activeIndex, _setActiveIndex] = react.useState(-1), activeIndexRef = react.useRef(activeIndex), activeElement = react.useMemo(() => elementsRef.current[activeIndex] || null, [activeIndex]), mounted = !!rootElementRef.current, setActiveIndex = react.useCallback((nextActiveIndex) => {
1965
- _setActiveIndex(nextActiveIndex), activeIndexRef.current = nextActiveIndex;
1966
- }, []), mount = react.useCallback((element, selected) => {
1967
- if (!element) return () => {
1968
- };
1969
- if (elementsRef.current.indexOf(element) === -1 && (elementsRef.current.push(element), _sortElements(rootElementRef.current, elementsRef.current)), selected) {
1970
- const selectedIndex = elementsRef.current.indexOf(element);
1971
- setActiveIndex(selectedIndex);
1972
- }
1973
- return () => {
1974
- const idx = elementsRef.current.indexOf(element);
1975
- idx > -1 && elementsRef.current.splice(idx, 1);
1976
- };
1977
- }, [rootElementRef, setActiveIndex]), handleKeyDown = react.useCallback((event) => {
1978
- if (event.key === "Tab") {
1979
- originElement && originElement.focus();
1980
- return;
1981
- }
1982
- if (event.key === "Home") {
1983
- event.preventDefault(), event.stopPropagation();
1984
- const el = _getFocusableElements(elementsRef.current)[0];
1985
- if (!el) return;
1986
- const currentIndex = elementsRef.current.indexOf(el);
1987
- setActiveIndex(currentIndex);
1988
- return;
1989
- }
1990
- if (event.key === "End") {
1991
- event.preventDefault(), event.stopPropagation();
1992
- const focusableElements_0 = _getFocusableElements(elementsRef.current), el_0 = focusableElements_0[focusableElements_0.length - 1];
1993
- if (!el_0) return;
1994
- const currentIndex_0 = elementsRef.current.indexOf(el_0);
1995
- setActiveIndex(currentIndex_0);
1996
- return;
1997
- }
1998
- if (event.key === "ArrowUp") {
1999
- event.preventDefault(), event.stopPropagation();
2000
- const focusableElements_1 = _getFocusableElements(elementsRef.current), focusableLen = focusableElements_1.length;
2001
- if (focusableLen === 0) return;
2002
- const focusedElement = elementsRef.current[activeIndexRef.current];
2003
- let focusedIndex = focusableElements_1.indexOf(focusedElement);
2004
- focusedIndex = (focusedIndex - 1 + focusableLen) % focusableLen;
2005
- const el_1 = focusableElements_1[focusedIndex], currentIndex_1 = elementsRef.current.indexOf(el_1);
2006
- setActiveIndex(currentIndex_1);
2007
- return;
2008
- }
2009
- if (event.key === "ArrowDown") {
2010
- event.preventDefault(), event.stopPropagation();
2011
- const focusableElements_2 = _getFocusableElements(elementsRef.current), focusableLen_0 = focusableElements_2.length;
2012
- if (focusableLen_0 === 0) return;
2013
- const focusedElement_0 = elementsRef.current[activeIndexRef.current];
2014
- let focusedIndex_0 = focusableElements_2.indexOf(focusedElement_0);
2015
- focusedIndex_0 = (focusedIndex_0 + 1) % focusableLen_0;
2016
- const el_2 = focusableElements_2[focusedIndex_0], currentIndex_2 = elementsRef.current.indexOf(el_2);
2017
- setActiveIndex(currentIndex_2);
2018
- return;
2019
- }
2020
- onKeyDown && onKeyDown(event);
2021
- }, [onKeyDown, originElement, setActiveIndex]), handleItemMouseEnter = react.useCallback((event_0) => {
2022
- const element_0 = event_0.currentTarget, currentIndex_3 = elementsRef.current.indexOf(element_0);
2023
- setActiveIndex(currentIndex_3);
2024
- }, [setActiveIndex]), handleItemMouseLeave = react.useCallback(() => {
2025
- setActiveIndex(-2), rootElementRef.current?.focus();
2026
- }, [rootElementRef, setActiveIndex]);
2027
- return react.useEffect(() => {
2028
- if (!mounted) return;
2029
- const rafId = requestAnimationFrame(() => {
2030
- if (activeIndex === -1) {
2031
- if (shouldFocus === "first") {
2032
- const el_3 = _getFocusableElements(elementsRef.current)[0];
2033
- if (el_3) {
2034
- const currentIndex_4 = elementsRef.current.indexOf(el_3);
2035
- setActiveIndex(currentIndex_4);
2036
- }
2037
- }
2038
- if (shouldFocus === "last") {
2039
- const focusableElements_4 = _getFocusableElements(elementsRef.current), el_4 = focusableElements_4[focusableElements_4.length - 1];
2040
- if (el_4) {
2041
- const currentIndex_5 = elementsRef.current.indexOf(el_4);
2042
- setActiveIndex(currentIndex_5);
2043
- }
2044
- }
2045
- return;
2046
- }
2047
- (elementsRef.current[activeIndex] || null)?.focus();
2048
- });
2049
- return () => cancelAnimationFrame(rafId);
2050
- }, [activeIndex, mounted, setActiveIndex, shouldFocus]), {
2051
- activeElement,
2052
- activeIndex,
2053
- handleItemMouseEnter,
2054
- handleItemMouseLeave,
2055
- handleKeyDown,
2056
- mount
2057
- };
2058
- }
2059
- const DEFAULT_MENU_ELEMENT = "div";
2060
- function Menu(props) {
2061
- const $ = compilerRuntime.c(57), t0 = props;
2062
- let _shouldFocus, children, className, forwardedRef, onClickOutside, onEscape, onItemClick, onItemSelect, onKeyDown, originElement, registerElement, rest, t1, t2, t3;
2063
- $[0] !== t0 ? ({
2064
- as: t1,
2065
- children,
2066
- className,
2067
- gap: t2,
2068
- onClickOutside,
2069
- onEscape,
2070
- onItemClick,
2071
- onItemSelect,
2072
- onKeyDown,
2073
- originElement,
2074
- padding: t3,
2075
- ref: forwardedRef,
2076
- registerElement,
2077
- shouldFocus: _shouldFocus,
2078
- ...rest
2079
- } = t0, $[0] = t0, $[1] = _shouldFocus, $[2] = children, $[3] = className, $[4] = forwardedRef, $[5] = onClickOutside, $[6] = onEscape, $[7] = onItemClick, $[8] = onItemSelect, $[9] = onKeyDown, $[10] = originElement, $[11] = registerElement, $[12] = rest, $[13] = t1, $[14] = t2, $[15] = t3) : (_shouldFocus = $[1], children = $[2], className = $[3], forwardedRef = $[4], onClickOutside = $[5], onEscape = $[6], onItemClick = $[7], onItemSelect = $[8], onKeyDown = $[9], originElement = $[10], registerElement = $[11], rest = $[12], t1 = $[13], t2 = $[14], t3 = $[15]);
2080
- const as = t1 === void 0 ? DEFAULT_MENU_ELEMENT : t1, gap = t2 === void 0 ? 1 : t2, padding = t3 === void 0 ? 1 : t3, shouldFocus = _shouldFocus ?? null, ref = react.useRef(null);
2081
- let t4;
2082
- $[16] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[16] = t4) : t4 = $[16], react.useImperativeHandle(forwardedRef, t4);
2083
- const {
2084
- isTopLayer
2085
- } = useLayer();
2086
- let t5;
2087
- $[17] !== onKeyDown || $[18] !== originElement || $[19] !== shouldFocus ? (t5 = {
2088
- onKeyDown,
2089
- originElement,
2090
- shouldFocus,
2091
- rootElementRef: ref
2092
- }, $[17] = onKeyDown, $[18] = originElement, $[19] = shouldFocus, $[20] = t5) : t5 = $[20];
2093
- const {
2094
- activeElement,
2095
- activeIndex,
2096
- handleItemMouseEnter,
2097
- handleItemMouseLeave,
2098
- handleKeyDown,
2099
- mount
2100
- } = useMenuController(t5), unregisterElementRef = react.useRef(null);
2101
- let t6;
2102
- $[21] !== registerElement ? (t6 = (el) => {
2103
- unregisterElementRef.current && (unregisterElementRef.current(), unregisterElementRef.current = null), ref.current = el, ref.current && registerElement && (unregisterElementRef.current = registerElement(ref.current));
2104
- }, $[21] = registerElement, $[22] = t6) : t6 = $[22];
2105
- const handleRefChange = t6;
2106
- let t7, t8;
2107
- $[23] !== activeIndex || $[24] !== onItemSelect ? (t7 = () => {
2108
- onItemSelect && onItemSelect(activeIndex);
2109
- }, t8 = [activeIndex, onItemSelect], $[23] = activeIndex, $[24] = onItemSelect, $[25] = t7, $[26] = t8) : (t7 = $[25], t8 = $[26]), react.useEffect(t7, t8);
2110
- let t9;
2111
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => [ref.current], $[27] = t9) : t9 = $[27], useClickOutsideEvent(isTopLayer && onClickOutside, t9);
2112
- let t10;
2113
- $[28] !== isTopLayer || $[29] !== onEscape ? (t10 = (event) => {
2114
- isTopLayer && event.key === "Escape" && (event.stopPropagation(), onEscape && onEscape());
2115
- }, $[28] = isTopLayer, $[29] = onEscape, $[30] = t10) : t10 = $[30], useGlobalKeyDown(t10);
2116
- let t11, t12;
2117
- $[31] !== activeElement || $[32] !== activeIndex || $[33] !== handleItemMouseEnter || $[34] !== handleItemMouseLeave || $[35] !== mount || $[36] !== onClickOutside || $[37] !== onEscape || $[38] !== onItemClick || $[39] !== registerElement ? (t12 = {
2118
- version: 0,
2119
- activeElement,
2120
- activeIndex,
2121
- mount,
2122
- onClickOutside,
2123
- onEscape,
2124
- onItemClick,
2125
- onItemMouseEnter: handleItemMouseEnter,
2126
- onItemMouseLeave: handleItemMouseLeave,
2127
- registerElement,
2128
- onMouseEnter: handleItemMouseEnter,
2129
- onMouseLeave: handleItemMouseLeave
2130
- }, $[31] = activeElement, $[32] = activeIndex, $[33] = handleItemMouseEnter, $[34] = handleItemMouseLeave, $[35] = mount, $[36] = onClickOutside, $[37] = onEscape, $[38] = onItemClick, $[39] = registerElement, $[40] = t12) : t12 = $[40], t11 = t12;
2131
- const value = t11;
2132
- let t13;
2133
- $[41] !== className ? (t13 = css.menu({
2134
- className
2135
- }), $[41] = className, $[42] = t13) : t13 = $[42];
2136
- let t14;
2137
- $[43] !== children || $[44] !== gap ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(Stack, { gap, children }), $[43] = children, $[44] = gap, $[45] = t14) : t14 = $[45];
2138
- let t15;
2139
- $[46] !== as || $[47] !== handleKeyDown || $[48] !== handleRefChange || $[49] !== padding || $[50] !== rest || $[51] !== t13 || $[52] !== t14 ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Menu", ...rest, as, className: t13, onKeyDown: handleKeyDown, overflow: "auto", outline: "none", padding, ref: handleRefChange, role: "menu", tabIndex: -1, children: t14 }), $[46] = as, $[47] = handleKeyDown, $[48] = handleRefChange, $[49] = padding, $[50] = rest, $[51] = t13, $[52] = t14, $[53] = t15) : t15 = $[53];
2140
- let t16;
2141
- return $[54] !== t15 || $[55] !== value ? (t16 = /* @__PURE__ */ jsxRuntime.jsx(MenuContext.Provider, { value, children: t15 }), $[54] = t15, $[55] = value, $[56] = t16) : t16 = $[56], t16;
2142
- }
2143
- function MenuButton(props) {
2144
- const $ = compilerRuntime.c(57), {
2145
- __unstable_disableRestoreFocusOnClose: t0,
2146
- button: buttonProp,
2147
- id,
2148
- menu: menuProp,
2149
- onClose,
2150
- onOpen,
2151
- popover,
2152
- ref: forwardedRef
2153
- } = props, disableRestoreFocusOnClose = t0 === void 0 ? !1 : t0, [open, setOpen] = react.useState(!1), [shouldFocus, setShouldFocus] = react.useState(null), [buttonElement, setButtonElement] = react.useState(null);
2154
- let t1;
2155
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
2156
- const [menuElements, setChildMenuElements] = react.useState(t1), openRef = react.useRef(open);
2157
- let t2, t3;
2158
- $[1] !== onOpen || $[2] !== open ? (t2 = () => {
2159
- onOpen && open && !openRef.current && onOpen();
2160
- }, t3 = [onOpen, open], $[1] = onOpen, $[2] = open, $[3] = t2, $[4] = t3) : (t2 = $[3], t3 = $[4]), react.useEffect(t2, t3);
2161
- let t4, t5;
2162
- $[5] !== onClose || $[6] !== open ? (t4 = () => {
2163
- onClose && !open && openRef.current && onClose();
2164
- }, t5 = [onClose, open], $[5] = onClose, $[6] = open, $[7] = t4, $[8] = t5) : (t4 = $[7], t5 = $[8]), react.useEffect(t4, t5);
2165
- let t6, t7;
2166
- $[9] !== open ? (t6 = () => {
2167
- openRef.current = open;
2168
- }, t7 = [open], $[9] = open, $[10] = t6, $[11] = t7) : (t6 = $[10], t7 = $[11]), react.useEffect(t6, t7);
2169
- let t8;
2170
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => {
2171
- setOpen(_temp$6), setShouldFocus(null);
2172
- }, $[12] = t8) : t8 = $[12];
2173
- const handleButtonClick = t8;
2174
- let t9;
2175
- $[13] !== open ? (t9 = (event) => {
2176
- open && event.preventDefault();
2177
- }, $[13] = open, $[14] = t9) : t9 = $[14];
2178
- const handleMouseDown = t9;
2179
- let t10;
2180
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t10 = (event_0) => {
2181
- if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") {
2182
- event_0.preventDefault(), setOpen(!0), setShouldFocus("first");
2183
- return;
2184
- }
2185
- if (event_0.key === "ArrowUp") {
2186
- event_0.preventDefault(), setOpen(!0), setShouldFocus("last");
2187
- return;
2188
- }
2189
- }, $[15] = t10) : t10 = $[15];
2190
- const handleButtonKeyDown = t10;
2191
- let t11;
2192
- $[16] !== buttonElement || $[17] !== menuElements ? (t11 = (event_1) => {
2193
- const target = event_1.target;
2194
- if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) {
2195
- for (const el of menuElements)
2196
- if (target === el || el.contains(target))
2197
- return;
2198
- setOpen(!1);
2199
- }
2200
- }, $[16] = buttonElement, $[17] = menuElements, $[18] = t11) : t11 = $[18];
2201
- const handleMenuClickOutside = t11;
2202
- let t12;
2203
- $[19] !== buttonElement || $[20] !== disableRestoreFocusOnClose ? (t12 = () => {
2204
- setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
2205
- }, $[19] = buttonElement, $[20] = disableRestoreFocusOnClose, $[21] = t12) : t12 = $[21];
2206
- const handleMenuEscape = t12;
2207
- let t13;
2208
- $[22] !== menuElements ? (t13 = (event_2) => {
2209
- const target_0 = event_2.relatedTarget;
2210
- if (target_0 instanceof Node) {
2211
- for (const el_0 of menuElements)
2212
- if (el_0 === target_0 || el_0.contains(target_0))
2213
- return;
2214
- setOpen(!1);
2215
- }
2216
- }, $[22] = menuElements, $[23] = t13) : t13 = $[23];
2217
- const handleBlur = t13;
2218
- let t14;
2219
- $[24] !== buttonElement || $[25] !== disableRestoreFocusOnClose ? (t14 = () => {
2220
- setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
2221
- }, $[24] = buttonElement, $[25] = disableRestoreFocusOnClose, $[26] = t14) : t14 = $[26];
2222
- const handleItemClick = t14;
2223
- let t15;
2224
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t15 = (el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), $[27] = t15) : t15 = $[27];
2225
- const registerElement = t15;
2226
- let t16;
2227
- $[28] !== buttonElement || $[29] !== handleBlur || $[30] !== handleItemClick || $[31] !== handleMenuClickOutside || $[32] !== handleMenuEscape || $[33] !== id || $[34] !== menuProp || $[35] !== shouldFocus ? (t16 = menuProp && react.cloneElement(menuProp, {
2228
- "aria-labelledby": id,
2229
- onBlurCapture: handleBlur,
2230
- onClickOutside: handleMenuClickOutside,
2231
- onEscape: handleMenuEscape,
2232
- onItemClick: handleItemClick,
2233
- originElement: buttonElement,
2234
- registerElement,
2235
- shouldFocus
2236
- }), $[28] = buttonElement, $[29] = handleBlur, $[30] = handleItemClick, $[31] = handleMenuClickOutside, $[32] = handleMenuEscape, $[33] = id, $[34] = menuProp, $[35] = shouldFocus, $[36] = t16) : t16 = $[36];
2237
- const menu = t16;
2238
- let t17;
2239
- bb0: {
2240
- if (!buttonProp) {
2241
- t17 = null;
2242
- break bb0;
2243
- }
2244
- const t182 = buttonProp.props.selected ?? open;
2245
- let t192;
2246
- $[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open || $[41] !== t182 ? (t192 = react.cloneElement(buttonProp, {
2247
- "data-ui": "MenuButton",
2248
- id,
2249
- onClick: handleButtonClick,
2250
- onKeyDown: handleButtonKeyDown,
2251
- onMouseDown: handleMouseDown,
2252
- "aria-haspopup": !0,
2253
- "aria-expanded": open,
2254
- ref: setButtonElement,
2255
- selected: t182
2256
- }), $[37] = buttonProp, $[38] = handleMouseDown, $[39] = id, $[40] = open, $[41] = t182, $[42] = t192) : t192 = $[42], t17 = t192;
2257
- }
2258
- const button = t17;
2259
- let t18, t19;
2260
- $[43] !== buttonElement ? (t18 = () => buttonElement, t19 = [buttonElement], $[43] = buttonElement, $[44] = t18, $[45] = t19) : (t18 = $[44], t19 = $[45]), react.useImperativeHandle(forwardedRef, t18, t19);
2261
- let t20, t21;
2262
- $[46] !== popover ? (t21 = popover || {}, $[46] = popover, $[47] = t21) : t21 = $[47];
2263
- let t22;
2264
- $[48] !== t21 ? (t22 = {
2265
- overflow: "auto",
2266
- ...t21
2267
- }, $[48] = t21, $[49] = t22) : t22 = $[49], t20 = t22;
2268
- const popoverProps = t20;
2269
- let t23;
2270
- $[50] !== button ? (t23 = button || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}), $[50] = button, $[51] = t23) : t23 = $[51];
2271
- let t24;
2272
- return $[52] !== menu || $[53] !== open || $[54] !== popoverProps || $[55] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t23 }), $[52] = menu, $[53] = open, $[54] = popoverProps, $[55] = t23, $[56] = t24) : t24 = $[56], t24;
2273
- }
2274
- function _temp$6(v) {
2275
- return !v;
2276
- }
2277
- const DEFAULT_MENU_DIVIDER_ELEMENT = "hr";
2278
- function MenuDivider(props) {
2279
- const $ = compilerRuntime.c(10), t0 = props;
2280
- let className, rest, t1;
2281
- $[0] !== t0 ? ({
2282
- as: t1,
2283
- className,
2284
- ...rest
2285
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
2286
- const Element2 = t1 === void 0 ? DEFAULT_MENU_DIVIDER_ELEMENT : t1;
2287
- let t2;
2288
- $[4] !== className ? (t2 = css.menuDivider({
2289
- className
2290
- }), $[4] = className, $[5] = t2) : t2 = $[5];
2291
- let t3;
2292
- return $[6] !== Element2 || $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { ...rest, className: t2 }), $[6] = Element2, $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
2293
- }
2294
- function useMenu() {
2295
- const value = react.useContext(MenuContext);
2296
- if (!value)
2297
- throw new Error("useMenu(): missing context value");
2298
- if (!isRecord(value) || value.version !== 0)
2299
- throw new Error("useMenu(): the context value is not compatible");
2300
- return value;
2301
- }
2302
- const DEFAULT_MENU_GROUP_ELEMENT = "button";
2303
- function MenuGroup(props) {
2304
- const $ = compilerRuntime.c(77), t0 = props;
2305
- let IconComponent, children, menuProps, onClick, popover, rest, t1, t2, t3, t4, t5, t6, text;
2306
- $[0] !== t0 ? ({
2307
- as: t1,
2308
- children,
2309
- fontSize: t2,
2310
- gap: t3,
2311
- icon: IconComponent,
2312
- menu: menuProps,
2313
- onClick,
2314
- padding: t4,
2315
- popover,
2316
- radius: t5,
2317
- text,
2318
- tone: t6,
2319
- ...rest
2320
- } = t0, $[0] = t0, $[1] = IconComponent, $[2] = children, $[3] = menuProps, $[4] = onClick, $[5] = popover, $[6] = rest, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = t4, $[11] = t5, $[12] = t6, $[13] = text) : (IconComponent = $[1], children = $[2], menuProps = $[3], onClick = $[4], popover = $[5], rest = $[6], t1 = $[7], t2 = $[8], t3 = $[9], t4 = $[10], t5 = $[11], t6 = $[12], text = $[13]);
2321
- const as = t1 === void 0 ? DEFAULT_MENU_GROUP_ELEMENT : t1, fontSize = t2 === void 0 ? 1 : t2, gap = t3 === void 0 ? 3 : t3, padding = t4 === void 0 ? 3 : t4, radius = t5 === void 0 ? 2 : t5, tone = t6 === void 0 ? "default" : t6, {
2322
- activeElement,
2323
- mount,
2324
- onClickOutside,
2325
- onEscape,
2326
- onItemClick,
2327
- onItemMouseEnter,
2328
- registerElement
2329
- } = useMenu(), [rootElement, setRootElement] = react.useState(null), [open, setOpen] = react.useState(!1), [shouldFocus, setShouldFocus] = react.useState(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = react.useState(!1);
2330
- let t7;
2331
- $[14] !== onItemMouseEnter ? (t7 = (event) => {
2332
- setWithinMenu(!1), onItemMouseEnter?.(event), setOpen(!0);
2333
- }, $[14] = onItemMouseEnter, $[15] = t7) : t7 = $[15];
2334
- const handleMouseEnter = t7;
2335
- let t8;
2336
- $[16] !== rootElement ? (t8 = (event_0) => {
2337
- event_0.key === "ArrowLeft" && (event_0.stopPropagation(), setOpen(!1), requestAnimationFrame(() => {
2338
- rootElement?.focus();
2339
- }));
2340
- }, $[16] = rootElement, $[17] = t8) : t8 = $[17];
2341
- const handleMenuKeyDown = t8;
2342
- let t9;
2343
- $[18] !== onClick ? (t9 = (event_1) => {
2344
- onClick?.(event_1), setShouldFocus("first"), setOpen(!0);
2345
- }, $[18] = onClick, $[19] = t9) : t9 = $[19];
2346
- const handleClick = t9;
2347
- let t10;
2348
- $[20] !== onItemClick ? (t10 = () => {
2349
- setOpen(!1), onItemClick?.();
2350
- }, $[20] = onItemClick, $[21] = t10) : t10 = $[21];
2351
- const handleChildItemClick = t10;
2352
- let t11;
2353
- $[22] === Symbol.for("react.memo_cache_sentinel") ? (t11 = () => setWithinMenu(!0), $[22] = t11) : t11 = $[22];
2354
- const handleMenuMouseEnter = t11;
2355
- let t12, t13;
2356
- $[23] !== mount || $[24] !== rootElement ? (t12 = () => mount(rootElement), t13 = [mount, rootElement], $[23] = mount, $[24] = rootElement, $[25] = t12, $[26] = t13) : (t12 = $[25], t13 = $[26]), react.useEffect(t12, t13);
2357
- let t14, t15;
2358
- $[27] !== active ? (t14 = () => {
2359
- active || setOpen(!1);
2360
- }, t15 = [active], $[27] = active, $[28] = t14, $[29] = t15) : (t14 = $[28], t15 = $[29]), react.useEffect(t14, t15);
2361
- let t16, t17;
2362
- $[30] !== open ? (t16 = () => {
2363
- open || setWithinMenu(!1);
2364
- }, t17 = [open], $[30] = open, $[31] = t16, $[32] = t17) : (t16 = $[31], t17 = $[32]), react.useEffect(t16, t17);
2365
- let t18, t19;
2366
- $[33] !== shouldFocus ? (t18 = () => {
2367
- if (!shouldFocus)
2368
- return;
2369
- const rafId = requestAnimationFrame(() => setShouldFocus(null));
2370
- return () => cancelAnimationFrame(rafId);
2371
- }, t19 = [shouldFocus], $[33] = shouldFocus, $[34] = t18, $[35] = t19) : (t18 = $[34], t19 = $[35]), react.useEffect(t18, t19);
2372
- let t20;
2373
- $[36] !== children || $[37] !== handleChildItemClick || $[38] !== handleMenuKeyDown || $[39] !== menuProps || $[40] !== onClickOutside || $[41] !== onEscape || $[42] !== registerElement || $[43] !== shouldFocus ? (t20 = /* @__PURE__ */ jsxRuntime.jsx(Menu, { ...menuProps, onClickOutside, onEscape, onItemClick: handleChildItemClick, onKeyDown: handleMenuKeyDown, onMouseEnter: handleMenuMouseEnter, registerElement, shouldFocus, children }), $[36] = children, $[37] = handleChildItemClick, $[38] = handleMenuKeyDown, $[39] = menuProps, $[40] = onClickOutside, $[41] = onEscape, $[42] = registerElement, $[43] = shouldFocus, $[44] = t20) : t20 = $[44];
2374
- const childMenu = t20;
2375
- let t21;
2376
- $[45] === Symbol.for("react.memo_cache_sentinel") ? (t21 = (event_2) => {
2377
- const target = event_2.currentTarget;
2378
- if (document.activeElement === target && event_2.key === "ArrowRight") {
2379
- setShouldFocus("first"), setOpen(!0), setWithinMenu(!0);
2380
- return;
2381
- }
2382
- }, $[45] = t21) : t21 = $[45];
2383
- const handleKeyDown = t21, t22 = as === "button" ? withinMenu : void 0, t23 = as === "button" ? "button" : void 0;
2384
- let t24;
2385
- $[46] !== IconComponent || $[47] !== fontSize ? (t24 = IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize, children: [
2386
- react.isValidElement(IconComponent) && IconComponent,
2387
- reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
2388
- ] }), $[46] = IconComponent, $[47] = fontSize, $[48] = t24) : t24 = $[48];
2389
- let t25;
2390
- $[49] !== fontSize || $[50] !== text ? (t25 = /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, textOverflow: "ellipsis", weight: "medium", children: text }) }), $[49] = fontSize, $[50] = text, $[51] = t25) : t25 = $[51];
2391
- let t26;
2392
- $[52] === Symbol.for("react.memo_cache_sentinel") ? (t26 = /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}), $[52] = t26) : t26 = $[52];
2393
- let t27;
2394
- $[53] !== fontSize ? (t27 = /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, children: t26 }), $[53] = fontSize, $[54] = t27) : t27 = $[54];
2395
- let t28;
2396
- $[55] !== gap || $[56] !== padding || $[57] !== t24 || $[58] !== t25 || $[59] !== t27 ? (t28 = /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap, padding, children: [
2397
- t24,
2398
- t25,
2399
- t27
2400
- ] }), $[55] = gap, $[56] = padding, $[57] = t24, $[58] = t25, $[59] = t27, $[60] = t28) : t28 = $[60];
2401
- let t29;
2402
- $[61] !== as || $[62] !== handleClick || $[63] !== handleMouseEnter || $[64] !== radius || $[65] !== rest || $[66] !== t22 || $[67] !== t23 || $[68] !== t28 || $[69] !== tone || $[70] !== withinMenu ? (t29 = /* @__PURE__ */ jsxRuntime.jsx(Selectable, { "data-ui": "MenuGroup", ...rest, "aria-pressed": t22, as, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, radius, ref: setRootElement, selected: withinMenu, tabIndex: -1, tone, type: t23, children: t28 }), $[61] = as, $[62] = handleClick, $[63] = handleMouseEnter, $[64] = radius, $[65] = rest, $[66] = t22, $[67] = t23, $[68] = t28, $[69] = tone, $[70] = withinMenu, $[71] = t29) : t29 = $[71];
2403
- let t30;
2404
- return $[72] !== childMenu || $[73] !== open || $[74] !== popover || $[75] !== t29 ? (t30 = /* @__PURE__ */ jsxRuntime.jsx(Popover, { ...popover, content: childMenu, "data-ui": "MenuGroup__popover", open, children: t29 }), $[72] = childMenu, $[73] = open, $[74] = popover, $[75] = t29, $[76] = t30) : t30 = $[76], t30;
2405
- }
2406
- const DEFAULT_MENU_ITEM_ELEMENT = "button";
2407
- function MenuItem(props) {
2408
- const $ = compilerRuntime.c(75), t0 = props;
2409
- let IconComponent, IconRightComponent, children, disabled, forwardedRef, gapX, gapY, hotkeys, onClick, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, pressed, rest, selectedProp, t1, t2, t3, t4, t5, t6, t7, text;
2410
- $[0] !== t0 ? ({
2411
- as: t1,
2412
- children,
2413
- disabled,
2414
- fontSize: t2,
2415
- gap: t3,
2416
- gapX,
2417
- gapY,
2418
- hotkeys,
2419
- icon: IconComponent,
2420
- iconRight: IconRightComponent,
2421
- onClick,
2422
- padding: t4,
2423
- paddingX,
2424
- paddingY,
2425
- paddingTop,
2426
- paddingRight,
2427
- paddingBottom,
2428
- paddingLeft,
2429
- pressed,
2430
- radius: t5,
2431
- ref: forwardedRef,
2432
- role: t6,
2433
- selected: selectedProp,
2434
- text,
2435
- tone: t7,
2436
- ...rest
2437
- } = t0, $[0] = t0, $[1] = IconComponent, $[2] = IconRightComponent, $[3] = children, $[4] = disabled, $[5] = forwardedRef, $[6] = gapX, $[7] = gapY, $[8] = hotkeys, $[9] = onClick, $[10] = paddingBottom, $[11] = paddingLeft, $[12] = paddingRight, $[13] = paddingTop, $[14] = paddingX, $[15] = paddingY, $[16] = pressed, $[17] = rest, $[18] = selectedProp, $[19] = t1, $[20] = t2, $[21] = t3, $[22] = t4, $[23] = t5, $[24] = t6, $[25] = t7, $[26] = text) : (IconComponent = $[1], IconRightComponent = $[2], children = $[3], disabled = $[4], forwardedRef = $[5], gapX = $[6], gapY = $[7], hotkeys = $[8], onClick = $[9], paddingBottom = $[10], paddingLeft = $[11], paddingRight = $[12], paddingTop = $[13], paddingX = $[14], paddingY = $[15], pressed = $[16], rest = $[17], selectedProp = $[18], t1 = $[19], t2 = $[20], t3 = $[21], t4 = $[22], t5 = $[23], t6 = $[24], t7 = $[25], text = $[26]);
2438
- const as = t1 === void 0 ? DEFAULT_MENU_ITEM_ELEMENT : t1, fontSize = t2 === void 0 ? 1 : t2, gap = t3 === void 0 ? 3 : t3, padding = t4 === void 0 ? 3 : t4, radius = t5 === void 0 ? 2 : t5, role = t6 === void 0 ? "menuitem" : t6, tone = t7 === void 0 ? "default" : t7, menu = useMenu(), {
2439
- activeElement,
2440
- mount,
2441
- onItemClick,
2442
- onItemMouseEnter,
2443
- onItemMouseLeave
2444
- } = menu, [rootElement, setRootElement] = react.useState(null), active = !!activeElement && activeElement === rootElement, ref = react.useRef(null);
2445
- let t8;
2446
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => ref.current, $[27] = t8) : t8 = $[27], react.useImperativeHandle(forwardedRef, t8);
2447
- let t10, t9;
2448
- $[28] !== mount || $[29] !== rootElement || $[30] !== selectedProp ? (t9 = () => mount(rootElement, selectedProp), t10 = [mount, rootElement, selectedProp], $[28] = mount, $[29] = rootElement, $[30] = selectedProp, $[31] = t10, $[32] = t9) : (t10 = $[31], t9 = $[32]), react.useEffect(t9, t10);
2449
- let t11;
2450
- $[33] !== disabled || $[34] !== onClick || $[35] !== onItemClick ? (t11 = (event) => {
2451
- disabled || (onClick && onClick(event), onItemClick && onItemClick());
2452
- }, $[33] = disabled, $[34] = onClick, $[35] = onItemClick, $[36] = t11) : t11 = $[36];
2453
- const handleClick = t11;
2454
- let t12, t13;
2455
- $[37] !== padding || $[38] !== paddingBottom || $[39] !== paddingLeft || $[40] !== paddingRight || $[41] !== paddingTop || $[42] !== paddingX || $[43] !== paddingY ? (t13 = {
2456
- padding,
2457
- paddingX,
2458
- paddingY,
2459
- paddingTop,
2460
- paddingRight,
2461
- paddingBottom,
2462
- paddingLeft
2463
- }, $[37] = padding, $[38] = paddingBottom, $[39] = paddingLeft, $[40] = paddingRight, $[41] = paddingTop, $[42] = paddingX, $[43] = paddingY, $[44] = t13) : t13 = $[44], t12 = t13;
2464
- const paddingProps = t12;
2465
- let t14;
2466
- $[45] === Symbol.for("react.memo_cache_sentinel") ? (t14 = (el) => {
2467
- ref.current = el, setRootElement(el);
2468
- }, $[45] = t14) : t14 = $[45];
2469
- const setRef = t14, t15 = pressed ? "" : void 0, t16 = active ? "" : void 0, t17 = disabled ? "" : void 0, t18 = as === "button" ? "button" : void 0;
2470
- let t19;
2471
- $[46] !== IconComponent || $[47] !== IconRightComponent || $[48] !== fontSize || $[49] !== gap || $[50] !== gapX || $[51] !== gapY || $[52] !== hotkeys || $[53] !== paddingProps || $[54] !== text ? (t19 = (IconComponent || text || IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsxs(Flex, { as: "span", gap, gapX, gapY, align: "center", ...paddingProps, children: [
2472
- IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { muted: !0, size: fontSize, children: [
2473
- react.isValidElement(IconComponent) && IconComponent,
2474
- reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
2475
- ] }),
2476
- text && /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, textOverflow: "ellipsis", weight: "medium", children: text }) }),
2477
- hotkeys && /* @__PURE__ */ jsxRuntime.jsx(Hotkeys, { keys: hotkeys, style: {
2478
- marginTop: -4,
2479
- marginBottom: -4
2480
- } }),
2481
- IconRightComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { muted: !0, size: fontSize, children: [
2482
- react.isValidElement(IconRightComponent) && IconRightComponent,
2483
- reactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
2484
- ] })
2485
- ] }), $[46] = IconComponent, $[47] = IconRightComponent, $[48] = fontSize, $[49] = gap, $[50] = gapX, $[51] = gapY, $[52] = hotkeys, $[53] = paddingProps, $[54] = text, $[55] = t19) : t19 = $[55];
2486
- let t20;
2487
- $[56] !== children || $[57] !== paddingProps ? (t20 = children && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", ...paddingProps, children }), $[56] = children, $[57] = paddingProps, $[58] = t20) : t20 = $[58];
2488
- let t21;
2489
- return $[59] !== as || $[60] !== disabled || $[61] !== handleClick || $[62] !== onItemMouseEnter || $[63] !== onItemMouseLeave || $[64] !== radius || $[65] !== rest || $[66] !== role || $[67] !== t15 || $[68] !== t16 || $[69] !== t17 || $[70] !== t18 || $[71] !== t19 || $[72] !== t20 || $[73] !== tone ? (t21 = /* @__PURE__ */ jsxRuntime.jsxs(Selectable, { "data-ui": "MenuItem", ...rest, as, "data-pressed": t15, "data-selected": t16, "data-disabled": t17, radius, disabled, onClick: handleClick, onMouseEnter: onItemMouseEnter, onMouseLeave: onItemMouseLeave, ref: setRef, role, tabIndex: -1, tone, type: t18, children: [
2490
- t19,
2491
- t20
2492
- ] }), $[59] = as, $[60] = disabled, $[61] = handleClick, $[62] = onItemMouseEnter, $[63] = onItemMouseLeave, $[64] = radius, $[65] = rest, $[66] = role, $[67] = t15, $[68] = t16, $[69] = t17, $[70] = t18, $[71] = t19, $[72] = t20, $[73] = tone, $[74] = t21) : t21 = $[74], t21;
2493
- }
2494
- const DEFAULT_TAB_ELEMENT = "button";
2495
- function Tab(props) {
2496
- const $ = compilerRuntime.c(33), t0 = props;
2497
- let focused, forwardedRef, icon, id, label, onClick, onFocus, rest, selected, t1, t2, t3;
2498
- $[0] !== t0 ? ({
2499
- as: t1,
2500
- icon,
2501
- id,
2502
- focused,
2503
- fontSize: t2,
2504
- label,
2505
- onClick,
2506
- onFocus,
2507
- padding: t3,
2508
- ref: forwardedRef,
2509
- selected,
2510
- ...rest
2511
- } = t0, $[0] = t0, $[1] = focused, $[2] = forwardedRef, $[3] = icon, $[4] = id, $[5] = label, $[6] = onClick, $[7] = onFocus, $[8] = rest, $[9] = selected, $[10] = t1, $[11] = t2, $[12] = t3) : (focused = $[1], forwardedRef = $[2], icon = $[3], id = $[4], label = $[5], onClick = $[6], onFocus = $[7], rest = $[8], selected = $[9], t1 = $[10], t2 = $[11], t3 = $[12]);
2512
- const as = t1 === void 0 ? DEFAULT_TAB_ELEMENT : t1, fontSize = t2 === void 0 ? 1 : t2, padding = t3 === void 0 ? 2 : t3, ref = react.useRef(null), focusedRef = react.useRef(!1);
2513
- let t4;
2514
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[13] = t4) : t4 = $[13], react.useImperativeHandle(forwardedRef, t4);
2515
- let t5;
2516
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
2517
- focusedRef.current = !1;
2518
- }, $[14] = t5) : t5 = $[14];
2519
- const handleBlur = t5;
2520
- let t6;
2521
- $[15] !== onFocus ? (t6 = (event) => {
2522
- focusedRef.current = !0, onFocus && onFocus(event);
2523
- }, $[15] = onFocus, $[16] = t6) : t6 = $[16];
2524
- const handleFocus = t6;
2525
- let t7, t8;
2526
- $[17] !== focused ? (t7 = () => {
2527
- focused && !focusedRef.current && (ref.current && ref.current.focus(), focusedRef.current = !0);
2528
- }, t8 = [focused], $[17] = focused, $[18] = t7, $[19] = t8) : (t7 = $[18], t8 = $[19]), react.useEffect(t7, t8);
2529
- const t9 = selected ? "true" : "false", t10 = selected ? 0 : -1;
2530
- let t11;
2531
- return $[20] !== as || $[21] !== fontSize || $[22] !== handleFocus || $[23] !== icon || $[24] !== id || $[25] !== label || $[26] !== onClick || $[27] !== padding || $[28] !== rest || $[29] !== selected || $[30] !== t10 || $[31] !== t9 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(Button, { "data-ui": "Tab", ...rest, "aria-selected": t9, as, fontSize, icon, id, mode: "bleed", onClick, onBlur: handleBlur, onFocus: handleFocus, padding, ref, role: "tab", selected, tabIndex: t10, text: label, type: "button" }), $[20] = as, $[21] = fontSize, $[22] = handleFocus, $[23] = icon, $[24] = id, $[25] = label, $[26] = onClick, $[27] = padding, $[28] = rest, $[29] = selected, $[30] = t10, $[31] = t9, $[32] = t11) : t11 = $[32], t11;
2532
- }
2533
- const DEFAULT_TAB_LIST_ELEMENT = "div";
2534
- function TabList(props) {
2535
- const $ = compilerRuntime.c(20), t0 = props;
2536
- let childrenProp, rest, t1, t2, t3;
2537
- $[0] !== t0 ? ({
2538
- as: t1,
2539
- children: childrenProp,
2540
- gap: t2,
2541
- wrap: t3,
2542
- ...rest
2543
- } = t0, $[0] = t0, $[1] = childrenProp, $[2] = rest, $[3] = t1, $[4] = t2, $[5] = t3) : (childrenProp = $[1], rest = $[2], t1 = $[3], t2 = $[4], t3 = $[5]);
2544
- const as = t1 === void 0 ? DEFAULT_TAB_LIST_ELEMENT : t1, gap = t2 === void 0 ? 1 : t2, wrap = t3 === void 0 ? "nowrap" : t3, [focusedIndex, setFocusedIndex] = react.useState(-1);
2545
- let t4;
2546
- if ($[6] !== childrenProp || $[7] !== focusedIndex) {
2547
- const children = react.Children.toArray(childrenProp).filter(_isReactElement);
2548
- let t52;
2549
- $[9] !== focusedIndex ? (t52 = (child, childIndex) => react.cloneElement(child, {
2550
- focused: focusedIndex === childIndex,
2551
- key: childIndex,
2552
- onFocus: () => setFocusedIndex(childIndex)
2553
- }), $[9] = focusedIndex, $[10] = t52) : t52 = $[10], t4 = children.map(t52), $[6] = childrenProp, $[7] = focusedIndex, $[8] = t4;
2554
- } else
2555
- t4 = $[8];
2556
- const tabs = t4, numTabs = tabs.length;
2557
- let t5;
2558
- $[11] !== numTabs ? (t5 = (event) => {
2559
- event.key === "ArrowLeft" && setFocusedIndex((prevIndex) => (prevIndex + numTabs - 1) % numTabs), event.key === "ArrowRight" && setFocusedIndex((prevIndex_0) => (prevIndex_0 + 1) % numTabs);
2560
- }, $[11] = numTabs, $[12] = t5) : t5 = $[12];
2561
- const handleKeyDown = t5;
2562
- let t6;
2563
- return $[13] !== as || $[14] !== gap || $[15] !== handleKeyDown || $[16] !== rest || $[17] !== tabs || $[18] !== wrap ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(Flex, { "data-ui": "TabList", ...rest, as, gap, onKeyDown: handleKeyDown, role: "tablist", wrap, children: tabs }), $[13] = as, $[14] = gap, $[15] = handleKeyDown, $[16] = rest, $[17] = tabs, $[18] = wrap, $[19] = t6) : t6 = $[19], t6;
2564
- }
2565
- function _isReactElement(node) {
2566
- return !!node;
2567
- }
2568
- const DEFAULT_TAB_PANEL_ELEMENT = "div";
2569
- function TabPanel(props) {
2570
- const $ = compilerRuntime.c(10), t0 = props;
2571
- let children, rest, t1, tabIndex;
2572
- $[0] !== t0 ? ({
2573
- as: t1,
2574
- children,
2575
- tabIndex,
2576
- ...rest
2577
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1, $[4] = tabIndex) : (children = $[1], rest = $[2], t1 = $[3], tabIndex = $[4]);
2578
- const as = t1 === void 0 ? DEFAULT_TAB_PANEL_ELEMENT : t1, t2 = tabIndex === void 0 ? 0 : tabIndex;
2579
- let t3;
2580
- return $[5] !== as || $[6] !== children || $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "TabPanel", ...rest, as, role: "tabpanel", tabIndex: t2, children }), $[5] = as, $[6] = children, $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
2581
- }
2582
- const DEFAULT_TOAST_ELEMENT = "li", LONG_ENOUGH_BUT_NOT_TOO_LONG = 1e3 * 60 * 60 * 24 * 24, ROLES = {
2583
- error: "alert",
2584
- warning: "alert",
2585
- success: "alert",
2586
- info: "alert"
2587
- }, STATUS_CARD_TONE = {
2588
- error: "critical",
2589
- warning: "caution",
2590
- success: "positive",
2591
- info: "neutral"
2592
- }, BUTTON_TONE = {
2593
- error: "critical",
2594
- warning: "caution",
2595
- success: "positive",
2596
- info: "neutral"
2597
- };
2598
- function Toast(props) {
2599
- const $ = compilerRuntime.c(42), t0 = props;
2600
- let closable, description, duration, onClose, rest, status, t1, t2, title;
2601
- $[0] !== t0 ? ({
2602
- as: t1,
2603
- closable,
2604
- description,
2605
- duration,
2606
- onClose,
2607
- radius: t2,
2608
- title,
2609
- status,
2610
- ...rest
2611
- } = t0, $[0] = t0, $[1] = closable, $[2] = description, $[3] = duration, $[4] = onClose, $[5] = rest, $[6] = status, $[7] = t1, $[8] = t2, $[9] = title) : (closable = $[1], description = $[2], duration = $[3], onClose = $[4], rest = $[5], status = $[6], t1 = $[7], t2 = $[8], title = $[9]);
2612
- const as = t1 === void 0 ? DEFAULT_TOAST_ELEMENT : t1, radius = t2 === void 0 ? 3 : t2, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status", visualDuration = usePrefersReducedMotion() ? 0 : 0.26;
2613
- let t3;
2614
- $[10] !== visualDuration ? (t3 = visualDuration ? {
2615
- type: "spring",
2616
- visualDuration,
2617
- bounce: 0.25
2618
- } : {
2619
- duration: 0
2620
- }, $[10] = visualDuration, $[11] = t3) : t3 = $[11];
2621
- const transition = t3, hasDuration = duration && isFinite(duration) && duration < LONG_ENOUGH_BUT_NOT_TOO_LONG;
2622
- let t4;
2623
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t4 = ["hidden", "initial"], $[12] = t4) : t4 = $[12];
2624
- const initial = t4;
2625
- let t5;
2626
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t5 = ["visible", "slideIn"], $[13] = t5) : t5 = $[13];
2627
- const animate = t5;
2628
- let t6;
2629
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t6 = ["hidden", "slideOut"], $[14] = t6) : t6 = $[14];
2630
- const exit = t6;
2631
- let t7;
2632
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t7 = css.toast(), $[15] = t7) : t7 = $[15];
2633
- const t8 = hasDuration ? "" : void 0;
2634
- let t9;
2635
- $[16] !== title ? (t9 = title && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: 1, weight: "medium", children: title }), $[16] = title, $[17] = t9) : t9 = $[17];
2636
- let t10;
2637
- $[18] !== description || $[19] !== transition ? (t10 = description && /* @__PURE__ */ jsxRuntime.jsx(MotionText, { muted: !0, size: 1, variants: content, transition, children: description }), $[18] = description, $[19] = transition, $[20] = t10) : t10 = $[20];
2638
- let t11;
2639
- $[21] !== t10 || $[22] !== t9 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(Flex, { flex: 1, overflowX: "auto", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(Stack, { gap: 3, children: [
2640
- t9,
2641
- t10
2642
- ] }) }), $[21] = t10, $[22] = t9, $[23] = t11) : t11 = $[23];
2643
- let t12;
2644
- $[24] !== buttonTone || $[25] !== closable || $[26] !== onClose ? (t12 = closable && /* @__PURE__ */ jsxRuntime.jsx(Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { as: "button", icon: icons.CloseIcon, mode: "bleed", padding: 2, tone: buttonTone, onClick: onClose, style: {
2645
- verticalAlign: "top"
2646
- } }) }), $[24] = buttonTone, $[25] = closable, $[26] = onClose, $[27] = t12) : t12 = $[27];
2647
- let t13;
2648
- $[28] !== t11 || $[29] !== t12 || $[30] !== transition ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
2649
- t11,
2650
- t12
2651
- ] }), $[28] = t11, $[29] = t12, $[30] = transition, $[31] = t13) : t13 = $[31];
2652
- let t14;
2653
- return $[32] !== as || $[33] !== cardTone || $[34] !== radius || $[35] !== rest || $[36] !== role || $[37] !== t13 || $[38] !== t8 || $[39] !== transition || $[40] !== visualDuration ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(MotionCard, { as, className: t7, "data-ui": "Toast", role, ...rest, custom: visualDuration, "data-has-duration": t8, radius, shadow: 2, tone: cardTone, layout: "position", variants: container, initial, animate, exit, transition, position: "relative", children: t13 }), $[32] = as, $[33] = cardTone, $[34] = radius, $[35] = rest, $[36] = role, $[37] = t13, $[38] = t8, $[39] = transition, $[40] = visualDuration, $[41] = t14) : t14 = $[41], t14;
2654
- }
2655
- const container = {
2656
- initial: {
2657
- y: 32,
2658
- scale: 0.5,
2659
- zIndex: 1
2660
- },
2661
- hidden: {
2662
- opacity: 0
2663
- },
2664
- visible: (visualDuration) => visualDuration ? {
2665
- opacity: 1,
2666
- transition: {
2667
- when: "beforeChildren",
2668
- staggerChildren: visualDuration / 3,
2669
- duration: visualDuration / 3
2670
- }
2671
- } : {
2672
- opacity: 1
2673
- },
2674
- slideIn: {
2675
- y: 0,
2676
- scale: 1
2677
- },
2678
- slideOut: {
2679
- zIndex: 0,
2680
- scale: 0.75
2681
- }
2682
- }, content = {
2683
- initial: {
2684
- willChange: "transform"
2685
- },
2686
- hidden: {
2687
- opacity: 0
2688
- },
2689
- visible: {
2690
- opacity: 1
2691
- }
2692
- }, MotionCard = framerMotion.motion.create(Card), MotionFlex = framerMotion.motion.create(Flex), MotionText = framerMotion.motion.create(Text);
2693
- function useMounted() {
2694
- return react.useSyncExternalStore(subscribe, _temp$5, _temp2);
2695
- }
2696
- function _temp2() {
2697
- return !1;
2698
- }
2699
- function _temp$5() {
2700
- return !0;
2701
- }
2702
- const subscribe = () => () => {
2703
- }, ToastContext = createGlobalScopedContext("@sanity/ui/v3/toast", null), DEFAULT_GRID_ELEMENT = "div";
2704
- function Grid(props) {
2705
- const $ = compilerRuntime.c(8), t0 = props;
2706
- let children, rest, t1;
2707
- $[0] !== t0 ? ({
2708
- as: t1,
2709
- children,
2710
- ...rest
2711
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
2712
- const as = t1 === void 0 ? DEFAULT_GRID_ELEMENT : t1;
2713
- let t2;
2714
- return $[4] !== as || $[5] !== children || $[6] !== rest ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Grid", ...rest, as, display: "grid", children }), $[4] = as, $[5] = children, $[6] = rest, $[7] = t2) : t2 = $[7], t2;
2715
- }
2716
- const DEFAULT_TOAST_LAYER_ELEMENT = "ul";
2717
- function ToastLayer(props) {
2718
- const $ = compilerRuntime.c(11), {
2719
- as: t0,
2720
- children,
2721
- padding: t1,
2722
- paddingX,
2723
- paddingY,
2724
- gap: t2
2725
- } = props, as = t0 === void 0 ? DEFAULT_TOAST_LAYER_ELEMENT : t0, padding = t1 === void 0 ? 4 : t1, gap = t2 === void 0 ? 3 : t2, {
2726
- zIndex
2727
- } = useLayer();
2728
- let t3;
2729
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t3 = css.toastLayer(), $[0] = t3) : t3 = $[0];
2730
- let t4;
2731
- $[1] !== zIndex ? (t4 = {
2732
- zIndex
2733
- }, $[1] = zIndex, $[2] = t4) : t4 = $[2];
2734
- let t5;
2735
- return $[3] !== as || $[4] !== children || $[5] !== gap || $[6] !== padding || $[7] !== paddingX || $[8] !== paddingY || $[9] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(Grid, { as, className: t3, "data-ui": "ToastProvider", padding, paddingX, paddingY, gap, gridTemplateColumns: 1, style: t4, children }), $[3] = as, $[4] = children, $[5] = gap, $[6] = padding, $[7] = paddingX, $[8] = paddingY, $[9] = t4, $[10] = t5) : t5 = $[10], t5;
2736
- }
2737
- let toastId = 0;
2738
- function generateToastId() {
2739
- return String(toastId++);
2740
- }
2741
- function ToastProvider(props) {
2742
- const $ = compilerRuntime.c(13), {
2743
- children,
2744
- padding,
2745
- paddingX,
2746
- paddingY,
2747
- gap,
2748
- zOffset: t0
2749
- } = props, zOffset = t0 === void 0 ? 1 : t0;
2750
- let t1;
2751
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
2752
- const [state, setState] = react.useState(t1), mounted = useMounted();
2753
- let t2, t3;
2754
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
2755
- version: 0,
2756
- push: (params) => {
2757
- const id = params.id ?? generateToastId(), duration = params.duration ?? 5e3;
2758
- return react.startTransition(() => {
2759
- setState((prevState) => {
2760
- if (duration === 0.01)
2761
- return prevState.filter((toast) => toast.id !== id);
2762
- const dismiss = () => {
2763
- react.startTransition(() => {
2764
- timeoutId && clearTimeout(timeoutId), setState((currentState) => currentState.filter((toast_0) => toast_0.id !== id));
2765
- });
2766
- }, timeoutId = setTimeout(dismiss, duration);
2767
- return [...prevState.filter((toast_1) => toast_1.id !== id), {
2768
- dismiss,
2769
- id,
2770
- params: {
2771
- ...params,
2772
- duration
2773
- }
2774
- }];
2775
- });
2776
- }), id;
2777
- }
2778
- }, $[1] = t3) : t3 = $[1], t2 = t3;
2779
- const value = t2;
2780
- let t4;
2781
- $[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t4 = mounted && /* @__PURE__ */ jsxRuntime.jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsxRuntime.jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp$4) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t4) : t4 = $[9];
2782
- let t5;
2783
- return $[10] !== children || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
2784
- children,
2785
- t4
2786
- ] }), $[10] = children, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
2787
- }
2788
- function _temp$4(t0) {
2789
- const {
2790
- dismiss: dismiss_0,
2791
- id: id_0,
2792
- params: params_0
2793
- } = t0;
2794
- return /* @__PURE__ */ jsxRuntime.jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration }, id_0);
2795
- }
2796
- function useToast() {
2797
- const value = react.useContext(ToastContext);
2798
- if (!value)
2799
- throw new Error("useToast(): missing context value");
2800
- if (!isRecord(value) || value.version !== 0)
2801
- throw new Error("useToast(): the context value is not compatible");
2802
- return value;
2803
- }
2804
- function _findPrevItemElement(state, itemElements, focusedElement) {
2805
- const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(0, idx), len = els.length;
2806
- for (let i = len - 1; i >= 0; i -= 1) {
2807
- const itemKey = els[i].getAttribute("data-tree-key");
2808
- if (!itemKey)
2809
- continue;
2810
- const segments = itemKey.split("/");
2811
- segments.pop();
2812
- const p = [];
2813
- let expanded = !0;
2814
- for (let j = 0; j < segments.length; j += 1) {
2815
- p.push(segments[j]);
2816
- const k = p.join("/");
2817
- if (!state[k]?.expanded) {
2818
- expanded = !1;
2819
- break;
2820
- }
2821
- }
2822
- if (expanded)
2823
- return els[i];
2824
- }
2825
- return null;
2826
- }
2827
- function _findNextItemElement(state, itemElements, focusedElement) {
2828
- const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(idx), len = itemElements.length;
2829
- for (let i = 1; i < len; i += 1) {
2830
- if (!els[i])
2831
- continue;
2832
- const itemKey = els[i].getAttribute("data-tree-key");
2833
- if (!itemKey)
2834
- continue;
2835
- const segments = itemKey.split("/");
2836
- segments.pop();
2837
- const p = [];
2838
- let expanded = !0;
2839
- for (let j = 0; j < segments.length; j += 1) {
2840
- p.push(segments[j]);
2841
- const k = p.join("/");
2842
- if (!state[k]?.expanded) {
2843
- expanded = !1;
2844
- break;
2845
- }
2846
- }
2847
- if (expanded)
2848
- return els[i];
2849
- }
2850
- return null;
2851
- }
2852
- function _focusItemElement(el) {
2853
- if (el.getAttribute("role") === "treeitem" && el.focus(), el.getAttribute("role") === "none") {
2854
- const firstChild = el.firstChild;
2855
- firstChild && firstChild instanceof HTMLElement && firstChild.focus();
2856
- }
2857
- }
2858
- const TreeContext = createGlobalScopedContext("@sanity/ui/v3/tree", null), DEFAULT_TREE_ELEMENT = "div";
2859
- function Tree(props) {
2860
- const $ = compilerRuntime.c(38), t0 = props;
2861
- let children, forwardedRef, onFocus, rest, t1;
2862
- $[0] !== t0 ? ({
2863
- children,
2864
- gap: t1,
2865
- onFocus,
2866
- ref: forwardedRef,
2867
- ...rest
2868
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = onFocus, $[4] = rest, $[5] = t1) : (children = $[1], forwardedRef = $[2], onFocus = $[3], rest = $[4], t1 = $[5]);
2869
- const gap = t1 === void 0 ? 1 : t1, ref = react.useRef(null), [focusedElement, setFocusedElement] = react.useState(null), focusedElementRef = react.useRef(focusedElement);
2870
- let t2, t3;
2871
- $[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[6] = t3) : t3 = $[6], t2 = t3;
2872
- const path = t2;
2873
- let t4;
2874
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = [], $[7] = t4) : t4 = $[7];
2875
- const [itemElements, setItemElements] = react.useState(t4);
2876
- let t5;
2877
- $[8] === Symbol.for("react.memo_cache_sentinel") ? (t5 = {}, $[8] = t5) : t5 = $[8];
2878
- const [state, setState] = react.useState(t5), stateRef = react.useRef(state);
2879
- let t6;
2880
- $[9] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => ref.current, $[9] = t6) : t6 = $[9], react.useImperativeHandle(forwardedRef, t6);
2881
- let t7, t8;
2882
- $[10] !== focusedElement ? (t7 = () => {
2883
- focusedElementRef.current = focusedElement;
2884
- }, t8 = [focusedElement], $[10] = focusedElement, $[11] = t7, $[12] = t8) : (t7 = $[11], t8 = $[12]), react.useEffect(t7, t8);
2885
- let t10, t9;
2886
- $[13] !== state ? (t9 = () => {
2887
- stateRef.current = state;
2888
- }, t10 = [state], $[13] = state, $[14] = t10, $[15] = t9) : (t10 = $[14], t9 = $[15]), react.useEffect(t9, t10);
2889
- let t11;
2890
- $[16] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (element, path_0, expanded, selected) => (setState((s) => ({
2891
- ...s,
2892
- [path_0]: {
2893
- element,
2894
- expanded
2895
- }
2896
- })), selected && setFocusedElement(element), () => {
2897
- setState((s_0) => {
2898
- const newState = {
2899
- ...s_0
2900
- };
2901
- return delete newState[path_0], newState;
2902
- });
2903
- }), $[16] = t11) : t11 = $[16];
2904
- const registerItem = t11;
2905
- let t12;
2906
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = (path_1, expanded_0) => {
2907
- setState((s_1) => {
2908
- const itemState = s_1[path_1];
2909
- return itemState ? {
2910
- ...s_1,
2911
- [path_1]: {
2912
- ...itemState,
2913
- expanded: expanded_0
2914
- }
2915
- } : s_1;
2916
- });
2917
- }, $[17] = t12) : t12 = $[17];
2918
- const setExpanded = t12;
2919
- let t13;
2920
- const t14 = focusedElement || itemElements[0] || null;
2921
- let t15;
2922
- $[18] !== gap || $[19] !== state || $[20] !== t14 ? (t15 = {
2923
- version: 0,
2924
- focusedElement: t14,
2925
- gap,
2926
- level: 0,
2927
- path,
2928
- registerItem,
2929
- setExpanded,
2930
- setFocusedElement,
2931
- state
2932
- }, $[18] = gap, $[19] = state, $[20] = t14, $[21] = t15) : t15 = $[21], t13 = t15;
2933
- const contextValue = t13;
2934
- let t16;
2935
- $[22] !== itemElements ? (t16 = (event) => {
2936
- if (focusedElementRef.current) {
2937
- if (event.key === "ArrowDown") {
2938
- event.preventDefault();
2939
- const nextEl = _findNextItemElement(stateRef.current, itemElements, focusedElementRef.current);
2940
- nextEl && (_focusItemElement(nextEl), setFocusedElement(nextEl));
2941
- return;
2942
- }
2943
- if (event.key === "ArrowUp") {
2944
- event.preventDefault();
2945
- const prevEl = _findPrevItemElement(stateRef.current, itemElements, focusedElementRef.current);
2946
- prevEl && (_focusItemElement(prevEl), setFocusedElement(prevEl));
2947
- return;
2948
- }
2949
- if (event.key === "ArrowLeft") {
2950
- event.preventDefault();
2951
- const itemKey = focusedElementRef.current.getAttribute("data-tree-key");
2952
- if (!itemKey)
2953
- return;
2954
- const itemState_0 = stateRef.current[itemKey];
2955
- if (!itemState_0)
2956
- return;
2957
- if (itemState_0.expanded)
2958
- setState((s_2) => {
2959
- const itemState_1 = s_2[itemKey];
2960
- return itemState_1 ? {
2961
- ...s_2,
2962
- [itemKey]: {
2963
- ...itemState_1,
2964
- expanded: !1
2965
- }
2966
- } : s_2;
2967
- });
2968
- else {
2969
- const itemPath = itemKey.split("/");
2970
- itemPath.pop();
2971
- const parentKey = itemPath.join("/"), parentState = parentKey && stateRef.current[parentKey];
2972
- parentState && (parentState.element.focus(), setFocusedElement(parentState.element));
2973
- }
2974
- return;
2975
- }
2976
- if (event.key === "ArrowRight") {
2977
- event.preventDefault();
2978
- const focusedKey = focusedElementRef.current.getAttribute("data-tree-key");
2979
- if (!focusedKey)
2980
- return;
2981
- stateRef.current[focusedKey]?.expanded || setState((s_3) => {
2982
- const itemState_2 = s_3[focusedKey];
2983
- return itemState_2 ? {
2984
- ...s_3,
2985
- [focusedKey]: {
2986
- ...itemState_2,
2987
- expanded: !0
2988
- }
2989
- } : s_3;
2990
- });
2991
- return;
2992
- }
2993
- }
2994
- }, $[22] = itemElements, $[23] = t16) : t16 = $[23];
2995
- const handleKeyDown = t16;
2996
- let t17;
2997
- $[24] !== onFocus ? (t17 = (event_0) => {
2998
- setFocusedElement(event_0.target), onFocus?.(event_0);
2999
- }, $[24] = onFocus, $[25] = t17) : t17 = $[25];
3000
- const handleFocus = t17;
3001
- let t18;
3002
- $[26] === Symbol.for("react.memo_cache_sentinel") ? (t18 = () => {
3003
- if (!ref.current)
3004
- return;
3005
- const _itemElements = Array.from(ref.current.querySelectorAll('[data-ui="TreeItem"]'));
3006
- setItemElements(_itemElements);
3007
- }, $[26] = t18) : t18 = $[26];
3008
- let t19;
3009
- $[27] !== children ? (t19 = [children], $[27] = children, $[28] = t19) : t19 = $[28], react.useEffect(t18, t19);
3010
- let t20;
3011
- $[29] !== children || $[30] !== gap || $[31] !== handleFocus || $[32] !== handleKeyDown || $[33] !== rest ? (t20 = /* @__PURE__ */ jsxRuntime.jsx(Stack, { as: "ul", "data-ui": "Tree", ...rest, gap, onFocus: handleFocus, onKeyDown: handleKeyDown, ref, role: "tree", children }), $[29] = children, $[30] = gap, $[31] = handleFocus, $[32] = handleKeyDown, $[33] = rest, $[34] = t20) : t20 = $[34];
3012
- let t21;
3013
- return $[35] !== contextValue || $[36] !== t20 ? (t21 = /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: t20 }), $[35] = contextValue, $[36] = t20, $[37] = t21) : t21 = $[37], t21;
3014
- }
3015
- function useTree() {
3016
- const tree = react.useContext(TreeContext);
3017
- if (!tree)
3018
- throw new Error("Tree: missing context value");
3019
- return tree;
3020
- }
3021
- const TreeGroup = function(props) {
3022
- const $ = compilerRuntime.c(9), t0 = props;
3023
- let children, rest, t1;
3024
- $[0] !== t0 ? ({
3025
- children,
3026
- expanded: t1,
3027
- ...rest
3028
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
3029
- const expanded = t1 === void 0 ? !1 : t1, tree = useTree(), t2 = !expanded;
3030
- let t3;
3031
- return $[4] !== children || $[5] !== rest || $[6] !== t2 || $[7] !== tree.gap ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Stack, { as: "ul", "data-ui": "TreeGroup", ...rest, hidden: t2, marginTop: tree.gap, role: "group", gap: tree.gap, children }), $[4] = children, $[5] = rest, $[6] = t2, $[7] = tree.gap, $[8] = t3) : t3 = $[8], t3;
3032
- }, DEFAULT_TREE_ITEM_ELEMENT = "a";
3033
- function TreeItem(props) {
3034
- const {
3035
- children,
3036
- className,
3037
- expanded: expandedProp = !1,
3038
- fontSize = 1,
3039
- href,
3040
- icon: IconComponent,
3041
- id: idProp,
3042
- linkAs = "a",
3043
- muted,
3044
- onClick,
3045
- padding = 2,
3046
- radius = 2,
3047
- selected = !1,
3048
- space = 2,
3049
- text,
3050
- weight,
3051
- ...rest
3052
- } = props, rootRef = react.useRef(null), treeitemRef = react.useRef(null), tree = useTree(), {
3053
- path,
3054
- registerItem,
3055
- setExpanded,
3056
- setFocusedElement
3057
- } = tree, _id = react.useId(), id = idProp || _id, itemPath = react.useMemo(() => path.concat([id || ""]), [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], expanded = itemState?.expanded === void 0 ? expandedProp : itemState?.expanded || !1, focused = tree.focusedElement && tree.focusedElement === rootRef.current, tabIndex = focused ? 0 : -1, contextValue = react.useMemo(() => ({
3058
- ...tree,
3059
- level: tree.level + 1,
3060
- path: itemPath
3061
- }), [itemPath, tree]), handleClick = react.useCallback((event) => {
3062
- onClick && onClick(event);
3063
- const target = event.target;
3064
- target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]')) && (event.stopPropagation(), setExpanded(itemKey, !expanded), setFocusedElement(rootRef.current));
3065
- }, [expanded, itemKey, onClick, setExpanded, setFocusedElement]), handleKeyDown = react.useCallback((event_0) => {
3066
- focused && event_0.key === "Enter" && (treeitemRef.current || rootRef.current)?.click();
3067
- }, [focused]);
3068
- react.useEffect(() => {
3069
- if (rootRef.current)
3070
- return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
3071
- }, [expanded, itemPath, registerItem, selected]);
3072
- const content2 = /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: space, padding, children: [
3073
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { style: {
3074
- visibility: IconComponent || children ? "visible" : "hidden",
3075
- pointerEvents: "none"
3076
- }, children: [
3077
- IconComponent && /* @__PURE__ */ jsxRuntime.jsx(Text, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {}) }),
3078
- !IconComponent && /* @__PURE__ */ jsxRuntime.jsx(Text, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ToggleArrowRightIcon, { style: {
3079
- transform: expanded ? "rotate(90deg)" : void 0
3080
- } }) })
3081
- ] }),
3082
- /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
3083
- ] });
3084
- return href ? /* @__PURE__ */ jsxRuntime.jsxs(Box, { "data-selected": selected ? "" : void 0, "data-tree-id": id, "data-tree-key": itemKey, "data-ui": "TreeItem", ...rest, as: "li", className: css.treeItem({
3085
- className
3086
- }), onClick: handleClick, ref: rootRef, role: "none", children: [
3087
- /* @__PURE__ */ jsxRuntime.jsx(
3088
- Selectable,
3089
- {
3090
- "aria-expanded": expanded,
3091
- as: linkAs,
3092
- "data-ui": "TreeItem__box",
3093
- href,
3094
- radius,
3095
- ref: treeitemRef,
3096
- role: "treeitem",
3097
- selected,
3098
- tabIndex,
3099
- style: {
3100
- paddingLeft: `calc(${css.vars.space[2]} * ${tree.level})`
3101
- },
3102
- children: content2
3103
- }
3104
- ),
3105
- /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { hidden: !expanded, children }) })
3106
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(Box, { "data-selected": selected ? "" : void 0, "data-ui": "TreeItem", "data-tree-id": id, "data-tree-key": itemKey, ...rest, "aria-expanded": expanded, className: css.treeItem({
3107
- className
3108
- }), onClick: handleClick, onKeyDown: handleKeyDown, ref: rootRef, role: "treeitem", tabIndex, children: [
3109
- /* @__PURE__ */ jsxRuntime.jsx(
3110
- Selectable,
3111
- {
3112
- as: "button",
3113
- "data-focused": focused ? "" : void 0,
3114
- "data-ui": "TreeItem__box",
3115
- radius,
3116
- selected,
3117
- style: {
3118
- paddingLeft: `calc(${css.vars.space[2]} * ${tree.level})`
3119
- },
3120
- children: content2
3121
- }
3122
- ),
3123
- /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { expanded, children }) })
3124
- ] });
3125
- }
3126
- function _isScrollable(el) {
3127
- if (!(el instanceof Element)) return !1;
3128
- const style = window.getComputedStyle(el);
3129
- return style.overflowX.includes("auto") || style.overflowX.includes("scroll") || style.overflowY.includes("auto") || style.overflowY.includes("scroll");
3130
- }
3131
- const _ResizeObserver = typeof document < "u" && typeof window < "u" && window.ResizeObserver ? window.ResizeObserver : resizeObserver.ResizeObserver, DEFAULT_VIRTUAL_LIST_ELEMENT = "div";
3132
- function VirtualList(props) {
3133
- const $ = compilerRuntime.c(61), t0 = props;
3134
- let forwardedRef, getItemKey, onChange, renderItem, rest, t1, t2, t3;
3135
- $[0] !== t0 ? ({
3136
- as: t1,
3137
- gap: t2,
3138
- getItemKey,
3139
- items: t3,
3140
- onChange,
3141
- renderItem,
3142
- ref: forwardedRef,
3143
- ...rest
3144
- } = t0, $[0] = t0, $[1] = forwardedRef, $[2] = getItemKey, $[3] = onChange, $[4] = renderItem, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3) : (forwardedRef = $[1], getItemKey = $[2], onChange = $[3], renderItem = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8]);
3145
- const as = t1 === void 0 ? DEFAULT_VIRTUAL_LIST_ELEMENT : t1, gap = t2 === void 0 ? 0 : t2;
3146
- let t4;
3147
- $[9] !== t3 ? (t4 = t3 === void 0 ? [] : t3, $[9] = t3, $[10] = t4) : t4 = $[10];
3148
- const items = t4, ref = react.useRef(null), wrapperRef = react.useRef(null), [scrollTop, setScrollTop] = react.useState(0), [scrollHeight, setScrollHeight] = react.useState(0), [itemHeight, setItemHeight] = react.useState(-1), [gapValue, setGapValue] = react.useState(0);
3149
- let t5;
3150
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => ref.current, $[11] = t5) : t5 = $[11], react.useImperativeHandle(forwardedRef, t5);
3151
- let t6, t7;
3152
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => {
3153
- if (!ref.current)
3154
- return;
3155
- const scrollEl = findScrollable(ref.current.parentNode);
3156
- if (scrollEl) {
3157
- if (!(scrollEl instanceof HTMLElement))
3158
- return;
3159
- const handleScroll = () => {
3160
- setScrollTop(scrollEl.scrollTop);
3161
- };
3162
- scrollEl.addEventListener("scroll", handleScroll, {
3163
- passive: !0
3164
- });
3165
- const ro = new _ResizeObserver((entries) => {
3166
- setScrollHeight(entries[0].contentRect.height);
3167
- });
3168
- return ro.observe(scrollEl), handleScroll(), () => {
3169
- scrollEl.removeEventListener("scroll", handleScroll), ro.unobserve(scrollEl), ro.disconnect();
3170
- };
3171
- }
3172
- const handleScroll_0 = () => {
3173
- setScrollTop(window.scrollY);
3174
- }, handleResize = () => {
3175
- setScrollHeight(window.innerHeight);
3176
- };
3177
- return window.addEventListener("scroll", handleScroll_0, {
3178
- passive: !0
3179
- }), window.addEventListener("resize", handleResize), setScrollHeight(window.innerHeight), handleScroll_0(), () => {
3180
- window.removeEventListener("scroll", handleScroll_0), window.removeEventListener("resize", handleResize);
3181
- };
3182
- }, t7 = [], $[12] = t6, $[13] = t7) : (t6 = $[12], t7 = $[13]), react.useEffect(t6, t7);
3183
- const len = items.length, height = itemHeight ? len * (itemHeight + gapValue) - gapValue : 0, fromIndex = height ? Math.max(Math.floor(scrollTop / height * len) - 2, 0) : 0, toIndex = height ? Math.ceil((scrollTop + scrollHeight) / height * len) + 1 : 0;
3184
- let t8, t9;
3185
- $[14] !== fromIndex || $[15] !== gapValue || $[16] !== itemHeight || $[17] !== onChange || $[18] !== scrollHeight || $[19] !== scrollTop || $[20] !== toIndex ? (t8 = () => {
3186
- onChange?.({
3187
- fromIndex,
3188
- gap: gapValue,
3189
- itemHeight,
3190
- scrollHeight,
3191
- scrollTop,
3192
- toIndex
3193
- });
3194
- }, t9 = [fromIndex, gapValue, itemHeight, onChange, scrollHeight, scrollTop, toIndex], $[14] = fromIndex, $[15] = gapValue, $[16] = itemHeight, $[17] = onChange, $[18] = scrollHeight, $[19] = scrollTop, $[20] = toIndex, $[21] = t8, $[22] = t9) : (t8 = $[21], t9 = $[22]), react.useEffect(t8, t9);
3195
- let t10;
3196
- $[23] === Symbol.for("react.memo_cache_sentinel") ? (t10 = () => {
3197
- setItemHeight(-1);
3198
- }, $[23] = t10) : t10 = $[23];
3199
- let t11;
3200
- $[24] !== renderItem ? (t11 = [renderItem], $[24] = renderItem, $[25] = t11) : t11 = $[25], react.useEffect(t10, t11);
3201
- let t12;
3202
- bb0: {
3203
- if (!renderItem || items.length === 0) {
3204
- t12 = null;
3205
- break bb0;
3206
- }
3207
- if (itemHeight === -1) {
3208
- let t133;
3209
- $[26] === Symbol.for("react.memo_cache_sentinel") ? (t133 = (el) => el ? setItemHeight(el.offsetHeight) : void 0, $[26] = t133) : t133 = $[26];
3210
- let t142;
3211
- $[27] !== items[0] || $[28] !== renderItem ? (t142 = renderItem(items[0]), $[27] = items[0], $[28] = renderItem, $[29] = t142) : t142 = $[29];
3212
- let t152;
3213
- $[30] !== t142 ? (t152 = /* @__PURE__ */ jsxRuntime.jsx(Box, { ref: t133, insetTop: 0, insetLeft: 0, insetRight: 0, position: "absolute", children: t142 }, 0), $[30] = t142, $[31] = t152) : t152 = $[31];
3214
- let t162;
3215
- $[32] === Symbol.for("react.memo_cache_sentinel") ? (t162 = (el_0) => el_0 ? setGapValue(el_0.offsetHeight) : void 0, $[32] = t162) : t162 = $[32];
3216
- const t17 = css.vars.space[gap];
3217
- let t18;
3218
- $[33] !== t17 ? (t18 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: t162, style: {
3219
- height: t17
3220
- } }), $[33] = t17, $[34] = t18) : t18 = $[34];
3221
- let t19;
3222
- $[35] !== t152 || $[36] !== t18 ? (t19 = [/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3223
- t152,
3224
- t18
3225
- ] })], $[35] = t152, $[36] = t18, $[37] = t19) : t19 = $[37], t12 = t19;
3226
- break bb0;
3227
- }
3228
- let t132;
3229
- if ($[38] !== fromIndex || $[39] !== gapValue || $[40] !== getItemKey || $[41] !== itemHeight || $[42] !== items || $[43] !== renderItem || $[44] !== toIndex) {
3230
- let t142;
3231
- $[46] !== fromIndex || $[47] !== gapValue || $[48] !== getItemKey || $[49] !== itemHeight || $[50] !== renderItem ? (t142 = (item, _itemIndex) => {
3232
- const itemIndex = fromIndex + _itemIndex, node = renderItem(item), key2 = getItemKey ? getItemKey(item, itemIndex) : itemIndex;
3233
- return /* @__PURE__ */ jsxRuntime.jsx(Box, { insetLeft: 0, insetRight: 0, position: "absolute", style: {
3234
- top: itemIndex * (itemHeight + gapValue)
3235
- }, children: node }, key2);
3236
- }, $[46] = fromIndex, $[47] = gapValue, $[48] = getItemKey, $[49] = itemHeight, $[50] = renderItem, $[51] = t142) : t142 = $[51], t132 = items.slice(fromIndex, toIndex).map(t142), $[38] = fromIndex, $[39] = gapValue, $[40] = getItemKey, $[41] = itemHeight, $[42] = items, $[43] = renderItem, $[44] = toIndex, $[45] = t132;
3237
- } else
3238
- t132 = $[45];
3239
- t12 = t132;
3240
- }
3241
- const children = t12;
3242
- let t13, t14;
3243
- $[52] !== height ? (t14 = {
3244
- height
3245
- }, $[52] = height, $[53] = t14) : t14 = $[53], t13 = t14;
3246
- const wrapperStyle = t13;
3247
- let t15;
3248
- $[54] !== children || $[55] !== wrapperStyle ? (t15 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: wrapperRef, style: wrapperStyle, children }), $[54] = children, $[55] = wrapperStyle, $[56] = t15) : t15 = $[56];
3249
- let t16;
3250
- return $[57] !== as || $[58] !== rest || $[59] !== t15 ? (t16 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "VirtualList", ...rest, as, position: "relative", ref, children: t15 }), $[57] = as, $[58] = rest, $[59] = t15, $[60] = t16) : t16 = $[60], t16;
3251
- }
3252
- function findScrollable(parentNode) {
3253
- let _scrollEl = parentNode;
3254
- for (; _scrollEl && !_isScrollable(_scrollEl); )
3255
- _scrollEl = _scrollEl.parentNode;
3256
- return _scrollEl;
3257
- }
3258
- const _elementSizeObserver = _createElementSizeObserver();
3259
- function _createElementRectValueListener() {
3260
- return {
3261
- subscribe(element, subscriber) {
3262
- const resizeObserver2 = new _ResizeObserver(([entry]) => {
3263
- subscriber({
3264
- _contentRect: entry.contentRect,
3265
- border: {
3266
- width: entry.borderBoxSize[0].inlineSize,
3267
- height: entry.borderBoxSize[0].blockSize
3268
- },
3269
- content: {
3270
- width: entry.contentRect.width,
3271
- height: entry.contentRect.height
3272
- }
3273
- });
3274
- });
3275
- return resizeObserver2.observe(element), () => {
3276
- resizeObserver2.unobserve(element), resizeObserver2.disconnect();
3277
- };
3278
- }
3279
- };
3280
- }
3281
- function _createElementSizeObserver() {
3282
- const disposeCache = /* @__PURE__ */ new WeakMap(), subscribersCache = /* @__PURE__ */ new WeakMap();
3283
- return {
3284
- subscribe(element, subscriber) {
3285
- const subscribers = subscribersCache.get(element) || [];
3286
- let dispose = disposeCache.get(element);
3287
- return subscribersCache.has(element) || (subscribersCache.set(element, subscribers), dispose = _createElementRectValueListener().subscribe(element, (elementRect) => {
3288
- for (const sub of subscribers)
3289
- sub(elementRect);
3290
- })), subscribers.push(subscriber), () => {
3291
- const idx = subscribers.indexOf(subscriber);
3292
- idx > -1 && subscribers.splice(idx, 1), subscribers.length === 0 && dispose && dispose();
3293
- };
3294
- }
3295
- };
3296
- }
3297
- function useElementSize(element) {
3298
- const $ = compilerRuntime.c(3), [size2, setSize] = react.useState(null);
3299
- let t0, t1;
3300
- return $[0] !== element ? (t0 = () => {
3301
- if (element)
3302
- return _elementSizeObserver.subscribe(element, setSize);
3303
- }, t1 = [element], $[0] = element, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), react.useEffect(t0, t1), size2;
3304
- }
3305
- function usePrefersDark(t0) {
3306
- return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$3 : t0);
3307
- }
3308
- function _temp$3() {
3309
- return !1;
3310
- }
3311
- const DEFAULT_LABEL_ELEMENT = "div";
3312
- function Label(props) {
3313
- const $ = compilerRuntime.c(26);
3314
- let align, children, className, rest, t0, t1, t2, t3, textOverflowProp;
3315
- $[0] !== props ? ({
3316
- align,
3317
- as: t0,
3318
- children,
3319
- className,
3320
- muted: t1,
3321
- size: t2,
3322
- textOverflow: textOverflowProp,
3323
- weight: t3,
3324
- ...rest
3325
- } = props, $[0] = props, $[1] = align, $[2] = children, $[3] = className, $[4] = rest, $[5] = t0, $[6] = t1, $[7] = t2, $[8] = t3, $[9] = textOverflowProp) : (align = $[1], children = $[2], className = $[3], rest = $[4], t0 = $[5], t1 = $[6], t2 = $[7], t3 = $[8], textOverflowProp = $[9]);
3326
- const Element2 = t0 === void 0 ? DEFAULT_LABEL_ELEMENT : t0, muted = t1 === void 0 ? !1 : t1, size2 = t2 === void 0 ? 1 : t2, weight = t3 === void 0 ? "regular" : t3;
3327
- let t4;
3328
- $[10] !== align || $[11] !== className || $[12] !== muted || $[13] !== size2 || $[14] !== weight ? (t4 = css.label({
3329
- className,
3330
- align,
3331
- muted,
3332
- size: size2,
3333
- weight
3334
- }), $[10] = align, $[11] = className, $[12] = muted, $[13] = size2, $[14] = weight, $[15] = t4) : t4 = $[15];
3335
- let t5;
3336
- $[16] !== textOverflowProp ? (t5 = css.textOverflow({
3337
- textOverflow: textOverflowProp
3338
- }), $[16] = textOverflowProp, $[17] = t5) : t5 = $[17];
3339
- let t6;
3340
- $[18] !== children || $[19] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t5, children }), $[18] = children, $[19] = t5, $[20] = t6) : t6 = $[20];
3341
- let t7;
3342
- return $[21] !== Element2 || $[22] !== rest || $[23] !== t4 || $[24] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { "data-ui": "Label", ...rest, className: t4, children: t6 }), $[21] = Element2, $[22] = rest, $[23] = t4, $[24] = t6, $[25] = t7) : t7 = $[25], t7;
3343
- }
3344
- const DEFAULT_AVATAR_ELEMENT = "span";
3345
- function Avatar(props) {
3346
- const $ = compilerRuntime.c(50), t0 = props;
3347
- let __unstable_hideInnerStroke, animateArrowFrom, arrowPositionProp, className, initials, onImageLoadError, rest, src, t1, t2, t3, title;
3348
- $[0] !== t0 ? ({
3349
- __unstable_hideInnerStroke,
3350
- as: t1,
3351
- className,
3352
- color: t2,
3353
- src,
3354
- title,
3355
- initials,
3356
- onImageLoadError,
3357
- arrowPosition: arrowPositionProp,
3358
- animateArrowFrom,
3359
- size: t3,
3360
- ...rest
3361
- } = t0, $[0] = t0, $[1] = __unstable_hideInnerStroke, $[2] = animateArrowFrom, $[3] = arrowPositionProp, $[4] = className, $[5] = initials, $[6] = onImageLoadError, $[7] = rest, $[8] = src, $[9] = t1, $[10] = t2, $[11] = t3, $[12] = title) : (__unstable_hideInnerStroke = $[1], animateArrowFrom = $[2], arrowPositionProp = $[3], className = $[4], initials = $[5], onImageLoadError = $[6], rest = $[7], src = $[8], t1 = $[9], t2 = $[10], t3 = $[11], title = $[12]);
3362
- const Element2 = t1 === void 0 ? DEFAULT_AVATAR_ELEMENT : t1, color = t2 === void 0 ? "magenta" : t2, sizeProp = t3 === void 0 ? 1 : t3, size2 = useResponsiveProp(sizeProp), [arrowPosition, setArrowPosition] = react.useState(animateArrowFrom || arrowPositionProp || "inside"), [imageError, setImageError] = react.useState(!1);
3363
- let t4, t5;
3364
- $[13] !== arrowPosition || $[14] !== arrowPositionProp ? (t4 = () => {
3365
- if (arrowPosition === arrowPositionProp)
3366
- return;
3367
- const raf = requestAnimationFrame(() => setArrowPosition(arrowPositionProp));
3368
- return () => cancelAnimationFrame(raf);
3369
- }, t5 = [arrowPosition, arrowPositionProp], $[13] = arrowPosition, $[14] = arrowPositionProp, $[15] = t4, $[16] = t5) : (t4 = $[15], t5 = $[16]), react.useEffect(t4, t5);
3370
- let t6, t7;
3371
- $[17] !== src ? (t6 = () => {
3372
- src && setImageError(!1);
3373
- }, t7 = [src], $[17] = src, $[18] = t6, $[19] = t7) : (t6 = $[18], t7 = $[19]), react.useEffect(t6, t7);
3374
- let t8;
3375
- $[20] !== onImageLoadError ? (t8 = () => {
3376
- setImageError(!0), onImageLoadError && onImageLoadError(new Error("Avatar: the image failed to load"));
3377
- }, $[20] = onImageLoadError, $[21] = t8) : t8 = $[21];
3378
- const handleImageError = t8;
3379
- let t9, t10;
3380
- $[22] !== size2 ? (t10 = Object.values(size2).map(_temp$2), $[22] = size2, $[23] = t10) : t10 = $[23], t9 = t10;
3381
- const initialsSize = t9, t11 = __unstable_hideInnerStroke ? "" : void 0;
3382
- let t12;
3383
- $[24] !== className || $[25] !== color || $[26] !== sizeProp ? (t12 = css.avatar({
3384
- className,
3385
- color,
3386
- size: sizeProp
3387
- }), $[24] = className, $[25] = color, $[26] = sizeProp, $[27] = t12) : t12 = $[27];
3388
- const t13 = imageError ? "" : void 0;
3389
- let t14;
3390
- $[28] === Symbol.for("react.memo_cache_sentinel") ? (t14 = css.avatarArrow(), $[28] = t14) : t14 = $[28];
3391
- let t15;
3392
- $[29] !== color ? (t15 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t14, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "11", height: "7", viewBox: "0 0 11 7", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6.67948 1.50115L11 7L0 7L4.32052 1.50115C4.92109 0.736796 6.07891 0.736795 6.67948 1.50115Z", fill: color }) }) }), $[29] = color, $[30] = t15) : t15 = $[30];
3393
- let t16;
3394
- $[31] === Symbol.for("react.memo_cache_sentinel") ? (t16 = css.avatarInitials(), $[31] = t16) : t16 = $[31];
3395
- let t17;
3396
- $[32] !== initials || $[33] !== initialsSize ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(Box, { alignItems: "center", as: "span", className: t16, display: "flex", justifyContent: "center", position: "absolute", inset: 0, children: /* @__PURE__ */ jsxRuntime.jsx(Label, { align: "center", as: "span", size: initialsSize, weight: "medium", children: initials }) }), $[32] = initials, $[33] = initialsSize, $[34] = t17) : t17 = $[34];
3397
- let t18;
3398
- $[35] !== handleImageError || $[36] !== initials || $[37] !== src ? (t18 = src && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: css.avatarImage(), inset: 0, position: "absolute", children: [
3399
- /* @__PURE__ */ jsxRuntime.jsx("img", { alt: initials, onError: handleImageError, src }),
3400
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: css.avatarImageOutline() })
3401
- ] }), $[35] = handleImageError, $[36] = initials, $[37] = src, $[38] = t18) : t18 = $[38];
3402
- let t19;
3403
- return $[39] !== Element2 || $[40] !== arrowPosition || $[41] !== rest || $[42] !== t11 || $[43] !== t12 || $[44] !== t13 || $[45] !== t15 || $[46] !== t17 || $[47] !== t18 || $[48] !== title ? (t19 = /* @__PURE__ */ jsxRuntime.jsxs(Element2, { "data-hide-inner-stroke": t11, "data-ui": "Avatar", ...rest, "aria-label": title, className: t12, "data-arrow-position": arrowPosition, "data-image-error": t13, title, children: [
3404
- t15,
3405
- t17,
3406
- t18
3407
- ] }), $[39] = Element2, $[40] = arrowPosition, $[41] = rest, $[42] = t11, $[43] = t12, $[44] = t13, $[45] = t15, $[46] = t17, $[47] = t18, $[48] = title, $[49] = t19) : t19 = $[49], t19;
3408
- }
3409
- function _temp$2(s) {
3410
- return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
3411
- }
3412
- const DEFAULT_AVATAR_COUNTER_ELEMENT = "span";
3413
- function AvatarCounter(props) {
3414
- const $ = compilerRuntime.c(19), t0 = props;
3415
- let className, count, rest, t1, t2;
3416
- $[0] !== t0 ? ({
3417
- as: t1,
3418
- className,
3419
- count,
3420
- size: t2,
3421
- ...rest
3422
- } = t0, $[0] = t0, $[1] = className, $[2] = count, $[3] = rest, $[4] = t1, $[5] = t2) : (className = $[1], count = $[2], rest = $[3], t1 = $[4], t2 = $[5]);
3423
- const as = t1 === void 0 ? DEFAULT_AVATAR_COUNTER_ELEMENT : t1, size2 = useResponsiveProp(t2 === void 0 ? 1 : t2);
3424
- let t3, t4;
3425
- $[6] !== size2 ? (t4 = Object.values(size2).map(_temp$1), $[6] = size2, $[7] = t4) : t4 = $[7], t3 = t4;
3426
- const labelSize = t3;
3427
- let t5;
3428
- $[8] !== className || $[9] !== size2 ? (t5 = css.avatarCounter({
3429
- className,
3430
- size: size2
3431
- }), $[8] = className, $[9] = size2, $[10] = t5) : t5 = $[10];
3432
- let t6;
3433
- $[11] !== count || $[12] !== labelSize ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(Label, { align: "center", as: "span", size: labelSize, weight: "medium", children: count }), $[11] = count, $[12] = labelSize, $[13] = t6) : t6 = $[13];
3434
- let t7;
3435
- return $[14] !== as || $[15] !== rest || $[16] !== t5 || $[17] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "AvatarCounter", ...rest, alignItems: "center", as, className: t5, display: "flex", flex: "none", justifyContent: "center", paddingX: 2, sizing: "border", children: t6 }), $[14] = as, $[15] = rest, $[16] = t5, $[17] = t6, $[18] = t7) : t7 = $[18], t7;
3436
- }
3437
- function _temp$1(s) {
3438
- return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
3439
- }
3440
- const DEFAULT_AVATAR_STACK_ELEMENT = "span";
3441
- function AvatarStack(props) {
3442
- const $ = compilerRuntime.c(20), t0 = props;
3443
- let childrenProp, className, rest, t1, t2, t3;
3444
- $[0] !== t0 ? ({
3445
- as: t1,
3446
- children: childrenProp,
3447
- className,
3448
- maxLength: t2,
3449
- size: t3,
3450
- ...rest
3451
- } = t0, $[0] = t0, $[1] = childrenProp, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3) : (childrenProp = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6]);
3452
- const as = t1 === void 0 ? DEFAULT_AVATAR_STACK_ELEMENT : t1, maxLengthProp = t2 === void 0 ? 4 : t2, sizeProp = t3 === void 0 ? 1 : t3, children = react.Children.toArray(childrenProp).filter(react.isValidElement), maxLength = Math.max(maxLengthProp, 0), size2 = useResponsiveProp(sizeProp), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children, T0 = Box, t4 = "AvatarStack", t5 = "center";
3453
- let t6;
3454
- $[7] !== className || $[8] !== size2 ? (t6 = css.avatarStack({
3455
- className,
3456
- size: size2
3457
- }), $[7] = className, $[8] = size2, $[9] = t6) : t6 = $[9];
3458
- const t7 = "flex", t8 = "flex-start", t9 = len === 0 && /* @__PURE__ */ jsxRuntime.jsx(AvatarCounter, { count: len, size: size2 }), t10 = len !== 0 && extraCount > 1 && /* @__PURE__ */ jsxRuntime.jsx(AvatarCounter, { count: extraCount, size: size2 });
3459
- let t11;
3460
- $[10] !== size2 ? (t11 = (child, childIndex) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: react.cloneElement(child, {
3461
- size: size2
3462
- }) }, String(childIndex)), $[10] = size2, $[11] = t11) : t11 = $[11];
3463
- const t12 = visibleChildren.map(t11);
3464
- let t13;
3465
- return $[12] !== T0 || $[13] !== as || $[14] !== rest || $[15] !== t10 || $[16] !== t12 || $[17] !== t6 || $[18] !== t9 ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs(T0, { "data-ui": t4, ...rest, alignItems: t5, as, className: t6, display: t7, justifyContent: t8, children: [
3466
- t9,
3467
- t10,
3468
- t12
3469
- ] }), $[12] = T0, $[13] = as, $[14] = rest, $[15] = t10, $[16] = t12, $[17] = t6, $[18] = t9, $[19] = t13) : t13 = $[19], t13;
3470
- }
3471
- const DEFAULT_BADGE_ELEMENT = "span";
3472
- function Badge(props) {
3473
- const $ = compilerRuntime.c(24), t0 = props;
3474
- let children, className, rest, t1, t2, t3, t4, t5, t6;
3475
- $[0] !== t0 ? ({
3476
- as: t1,
3477
- children,
3478
- className,
3479
- flex: t2,
3480
- fontSize: t3,
3481
- padding: t4,
3482
- radius: t5,
3483
- tone: t6,
3484
- ...rest
3485
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3, $[7] = t4, $[8] = t5, $[9] = t6) : (children = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6], t4 = $[7], t5 = $[8], t6 = $[9]);
3486
- const as = t1 === void 0 ? DEFAULT_BADGE_ELEMENT : t1, flex = t2 === void 0 ? "none" : t2, fontSize = t3 === void 0 ? 1 : t3, padding = t4 === void 0 ? 1 : t4, radius = t5 === void 0 ? 2 : t5, tone = t6 === void 0 ? "default" : t6;
3487
- let t7;
3488
- $[10] !== className || $[11] !== tone ? (t7 = css.badge({
3489
- className,
3490
- tone
3491
- }), $[10] = className, $[11] = tone, $[12] = t7) : t7 = $[12];
3492
- let t8;
3493
- $[13] !== children || $[14] !== fontSize ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, children }), $[13] = children, $[14] = fontSize, $[15] = t8) : t8 = $[15];
3494
- let t9;
3495
- return $[16] !== as || $[17] !== flex || $[18] !== padding || $[19] !== radius || $[20] !== rest || $[21] !== t7 || $[22] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Badge", ...rest, as, className: t7, flex, display: "flex", maxWidth: "fill", padding, radius, width: "min", children: t8 }), $[16] = as, $[17] = flex, $[18] = padding, $[19] = radius, $[20] = rest, $[21] = t7, $[22] = t8, $[23] = t9) : t9 = $[23], t9;
3496
- }
3497
- const DEFAULT_CHECKBOX_ELEMENT = "input";
3498
- function Checkbox(props) {
3499
- const $ = compilerRuntime.c(29), t0 = props;
3500
- let className, customValidity, disabled, forwardedRef, indeterminate, readOnly, rest, style, t1;
3501
- $[0] !== t0 ? ({
3502
- as: t1,
3503
- className,
3504
- disabled,
3505
- indeterminate,
3506
- customValidity,
3507
- readOnly,
3508
- ref: forwardedRef,
3509
- style,
3510
- ...rest
3511
- } = t0, $[0] = t0, $[1] = className, $[2] = customValidity, $[3] = disabled, $[4] = forwardedRef, $[5] = indeterminate, $[6] = readOnly, $[7] = rest, $[8] = style, $[9] = t1) : (className = $[1], customValidity = $[2], disabled = $[3], forwardedRef = $[4], indeterminate = $[5], readOnly = $[6], rest = $[7], style = $[8], t1 = $[9]);
3512
- const Element2 = t1 === void 0 ? DEFAULT_CHECKBOX_ELEMENT : t1, ref = react.useRef(null);
3513
- let t2;
3514
- $[10] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[10] = t2) : t2 = $[10], react.useImperativeHandle(forwardedRef, t2);
3515
- let t3, t4;
3516
- $[11] !== indeterminate ? (t3 = () => {
3517
- ref.current && (ref.current.indeterminate = indeterminate || !1);
3518
- }, t4 = [indeterminate], $[11] = indeterminate, $[12] = t3, $[13] = t4) : (t3 = $[12], t4 = $[13]), react.useEffect(t3, t4), useCustomValidity(ref, customValidity);
3519
- let t5;
3520
- $[14] !== className ? (t5 = css.checkbox({
3521
- className
3522
- }), $[14] = className, $[15] = t5) : t5 = $[15];
3523
- let t6;
3524
- $[16] === Symbol.for("react.memo_cache_sentinel") ? (t6 = css.checkboxInput(), $[16] = t6) : t6 = $[16];
3525
- const t7 = customValidity ? "" : void 0, t8 = !disabled && readOnly ? "" : void 0, t9 = disabled || readOnly;
3526
- let t10;
3527
- $[17] !== Element2 || $[18] !== readOnly || $[19] !== rest || $[20] !== t7 || $[21] !== t8 || $[22] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { ...rest, className: t6, "data-invalid": t7, "data-read-only": t8, disabled: t9, type: "checkbox", readOnly, ref }), $[17] = Element2, $[18] = readOnly, $[19] = rest, $[20] = t7, $[21] = t8, $[22] = t9, $[23] = t10) : t10 = $[23];
3528
- let t11;
3529
- $[24] === Symbol.for("react.memo_cache_sentinel") ? (t11 = /* @__PURE__ */ jsxRuntime.jsxs("span", { className: css.checkboxPresentation(), children: [
3530
- /* @__PURE__ */ jsxRuntime.jsx(icons.CheckmarkIcon, {}),
3531
- /* @__PURE__ */ jsxRuntime.jsx(icons.RemoveIcon, {})
3532
- ] }), $[24] = t11) : t11 = $[24];
3533
- let t12;
3534
- return $[25] !== style || $[26] !== t10 || $[27] !== t5 ? (t12 = /* @__PURE__ */ jsxRuntime.jsxs("span", { className: t5, "data-ui": "Checkbox", style, children: [
3535
- t10,
3536
- t11
3537
- ] }), $[25] = style, $[26] = t10, $[27] = t5, $[28] = t12) : t12 = $[28], t12;
3538
- }
3539
- const LazyRefractor = react.lazy(() => Promise.resolve().then(function() {
3540
- return require("./_chunks-cjs/refractor.cjs");
3541
- })), DEFAULT_CODE_ELEMENT = "pre";
3542
- function Code(props) {
3543
- const $ = compilerRuntime.c(25), t0 = props;
3544
- let children, className, languageProp, rest, t1, t2, t3;
3545
- $[0] !== t0 ? ({
3546
- as: t1,
3547
- children,
3548
- className,
3549
- language: languageProp,
3550
- size: t2,
3551
- weight: t3,
3552
- ...rest
3553
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = languageProp, $[4] = rest, $[5] = t1, $[6] = t2, $[7] = t3) : (children = $[1], className = $[2], languageProp = $[3], rest = $[4], t1 = $[5], t2 = $[6], t3 = $[7]);
3554
- const Element2 = t1 === void 0 ? DEFAULT_CODE_ELEMENT : t1, size2 = t2 === void 0 ? 2 : t2, weight = t3 === void 0 ? "regular" : t3, language = typeof languageProp == "string" ? languageProp : void 0;
3555
- let t4;
3556
- $[8] !== className || $[9] !== size2 || $[10] !== weight ? (t4 = css.code({
3557
- className,
3558
- size: size2,
3559
- weight
3560
- }), $[8] = className, $[9] = size2, $[10] = weight, $[11] = t4) : t4 = $[11];
3561
- let t5;
3562
- $[12] !== children ? (t5 = /* @__PURE__ */ jsxRuntime.jsx("code", { children }), $[12] = children, $[13] = t5) : t5 = $[13];
3563
- let t6;
3564
- $[14] !== children || $[15] !== language ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(LazyRefractor, { language, value: children }), $[14] = children, $[15] = language, $[16] = t6) : t6 = $[16];
3565
- let t7;
3566
- $[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: t5, children: t6 }), $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19];
3567
- let t8;
3568
- return $[20] !== Element2 || $[21] !== rest || $[22] !== t4 || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { "data-ui": "Code", ...rest, className: t4, children: t7 }), $[20] = Element2, $[21] = rest, $[22] = t4, $[23] = t7, $[24] = t8) : t8 = $[24], t8;
3569
- }
3570
- const DEFAULT_HEADING_ELEMENT = "div";
3571
- function Heading(props) {
3572
- const $ = compilerRuntime.c(28), t0 = props;
3573
- let align, children, className, flex, rest, t1, t2, t3, t4, textOverflowProp;
3574
- $[0] !== t0 ? ({
3575
- align,
3576
- as: t1,
3577
- children,
3578
- className,
3579
- flex,
3580
- muted: t2,
3581
- size: t3,
3582
- textOverflow: textOverflowProp,
3583
- weight: t4,
3584
- ...rest
3585
- } = t0, $[0] = t0, $[1] = align, $[2] = children, $[3] = className, $[4] = flex, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3, $[9] = t4, $[10] = textOverflowProp) : (align = $[1], children = $[2], className = $[3], flex = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8], t4 = $[9], textOverflowProp = $[10]);
3586
- const Element2 = t1 === void 0 ? DEFAULT_HEADING_ELEMENT : t1, muted = t2 === void 0 ? !1 : t2, size2 = t3 === void 0 ? 2 : t3, weight = t4 === void 0 ? "regular" : t4;
3587
- let t5;
3588
- $[11] !== align || $[12] !== className || $[13] !== flex || $[14] !== muted || $[15] !== size2 || $[16] !== weight ? (t5 = css.heading({
3589
- className,
3590
- align,
3591
- flex,
3592
- muted,
3593
- size: size2,
3594
- weight
3595
- }), $[11] = align, $[12] = className, $[13] = flex, $[14] = muted, $[15] = size2, $[16] = weight, $[17] = t5) : t5 = $[17];
3596
- let t6;
3597
- $[18] !== textOverflowProp ? (t6 = css.textOverflow({
3598
- textOverflow: textOverflowProp
3599
- }), $[18] = textOverflowProp, $[19] = t6) : t6 = $[19];
3600
- let t7;
3601
- $[20] !== children || $[21] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t6, children }), $[20] = children, $[21] = t6, $[22] = t7) : t7 = $[22];
3602
- let t8;
3603
- return $[23] !== Element2 || $[24] !== rest || $[25] !== t5 || $[26] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { "data-ui": "Heading", ...rest, className: t5, children: t7 }), $[23] = Element2, $[24] = rest, $[25] = t5, $[26] = t7, $[27] = t8) : t8 = $[27], t8;
3604
- }
3605
- const DEFAULT_INLINE_ELEMENT = "div";
3606
- function Inline(props) {
3607
- const $ = compilerRuntime.c(10), t0 = props;
3608
- let children, gap, rest, t1;
3609
- $[0] !== t0 ? ({
3610
- as: t1,
3611
- children,
3612
- gap,
3613
- ...rest
3614
- } = t0, $[0] = t0, $[1] = children, $[2] = gap, $[3] = rest, $[4] = t1) : (children = $[1], gap = $[2], rest = $[3], t1 = $[4]);
3615
- const as = t1 === void 0 ? DEFAULT_INLINE_ELEMENT : t1;
3616
- let t2;
3617
- return $[5] !== as || $[6] !== children || $[7] !== gap || $[8] !== rest ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Inline", ...rest, alignItems: "center", as, display: "flex", gap, flexWrap: "wrap", children }), $[5] = as, $[6] = children, $[7] = gap, $[8] = rest, $[9] = t2) : t2 = $[9], t2;
3618
- }
3619
- const DEFAULT_RADIO_ELEMENT = "input";
3620
- function Radio(props) {
3621
- const $ = compilerRuntime.c(25), t0 = props;
3622
- let className, customValidity, disabled, forwardedRef, readOnly, rest, style, t1;
3623
- $[0] !== t0 ? ({
3624
- as: t1,
3625
- className,
3626
- disabled,
3627
- style,
3628
- customValidity,
3629
- readOnly,
3630
- ref: forwardedRef,
3631
- ...rest
3632
- } = t0, $[0] = t0, $[1] = className, $[2] = customValidity, $[3] = disabled, $[4] = forwardedRef, $[5] = readOnly, $[6] = rest, $[7] = style, $[8] = t1) : (className = $[1], customValidity = $[2], disabled = $[3], forwardedRef = $[4], readOnly = $[5], rest = $[6], style = $[7], t1 = $[8]);
3633
- const Element2 = t1 === void 0 ? DEFAULT_RADIO_ELEMENT : t1, ref = react.useRef(null);
3634
- let t2;
3635
- $[9] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[9] = t2) : t2 = $[9], react.useImperativeHandle(forwardedRef, t2), useCustomValidity(ref, customValidity);
3636
- let t3;
3637
- $[10] !== className ? (t3 = css.radio({
3638
- className
3639
- }), $[10] = className, $[11] = t3) : t3 = $[11];
3640
- let t4;
3641
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t4 = css.radioInput(), $[12] = t4) : t4 = $[12];
3642
- const t5 = customValidity ? "" : void 0, t6 = !disabled && readOnly ? "" : void 0, t7 = disabled || readOnly;
3643
- let t8;
3644
- $[13] !== Element2 || $[14] !== readOnly || $[15] !== rest || $[16] !== t5 || $[17] !== t6 || $[18] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { ...rest, className: t4, "data-invalid": t5, "data-read-only": t6, disabled: t7, readOnly, ref, type: "radio" }), $[13] = Element2, $[14] = readOnly, $[15] = rest, $[16] = t5, $[17] = t6, $[18] = t7, $[19] = t8) : t8 = $[19];
3645
- let t9;
3646
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: css.radioPresentation() }), $[20] = t9) : t9 = $[20];
3647
- let t10;
3648
- return $[21] !== style || $[22] !== t3 || $[23] !== t8 ? (t10 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t3, "data-ui": "Radio", style, children: [
3649
- t8,
3650
- t9
3651
- ] }), $[21] = style, $[22] = t3, $[23] = t8, $[24] = t10) : t10 = $[24], t10;
3652
- }
3653
- const DEFAULT_SELECT_ELEMENT = "select";
3654
- function Select(props) {
3655
- const $ = compilerRuntime.c(37), t0 = props;
3656
- let children, customValidity, disabled, forwardedRef, readOnly, rest, t1, t2, t3, t4, t5, t6;
3657
- $[0] !== t0 ? ({
3658
- as: t1,
3659
- border: t2,
3660
- children,
3661
- customValidity,
3662
- disabled,
3663
- fontSize: t3,
3664
- gap: t4,
3665
- padding: t5,
3666
- radius: t6,
3667
- readOnly,
3668
- ref: forwardedRef,
3669
- ...rest
3670
- } = t0, $[0] = t0, $[1] = children, $[2] = customValidity, $[3] = disabled, $[4] = forwardedRef, $[5] = readOnly, $[6] = rest, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = t4, $[11] = t5, $[12] = t6) : (children = $[1], customValidity = $[2], disabled = $[3], forwardedRef = $[4], readOnly = $[5], rest = $[6], t1 = $[7], t2 = $[8], t3 = $[9], t4 = $[10], t5 = $[11], t6 = $[12]);
3671
- const Element2 = t1 === void 0 ? DEFAULT_SELECT_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, fontSize = t3 === void 0 ? 2 : t3, gap = t4 === void 0 ? 2 : t4, padding = t5 === void 0 ? 3 : t5, radius = t6 === void 0 ? 1 : t6, ref = react.useRef(null);
3672
- let t7;
3673
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[13] = t7) : t7 = $[13], react.useImperativeHandle(forwardedRef, t7), useCustomValidity(ref, customValidity);
3674
- let t8;
3675
- $[14] !== border || $[15] !== fontSize || $[16] !== gap || $[17] !== padding || $[18] !== radius ? (t8 = css.select({
3676
- border,
3677
- fontSize,
3678
- gap,
3679
- padding,
3680
- radius
3681
- }), $[14] = border, $[15] = fontSize, $[16] = gap, $[17] = padding, $[18] = radius, $[19] = t8) : t8 = $[19];
3682
- let t9;
3683
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t9 = css._inputElement(), $[20] = t9) : t9 = $[20];
3684
- const t10 = disabled || readOnly;
3685
- let t11;
3686
- $[21] !== Element2 || $[22] !== children || $[23] !== rest || $[24] !== t10 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { ...rest, className: t9, disabled: t10, ref, children }), $[21] = Element2, $[22] = children, $[23] = rest, $[24] = t10, $[25] = t11) : t11 = $[25];
3687
- let t12;
3688
- $[26] === Symbol.for("react.memo_cache_sentinel") ? (t12 = css.selectPresentation(), $[26] = t12) : t12 = $[26];
3689
- let t13;
3690
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDownIcon, {}), $[27] = t13) : t13 = $[27];
3691
- let t14;
3692
- $[28] !== fontSize ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, children: t13 }), $[28] = fontSize, $[29] = t14) : t14 = $[29];
3693
- let t15;
3694
- $[30] !== padding || $[31] !== t14 ? (t15 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t12, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", display: "inline-block", padding, children: t14 }) }), $[30] = padding, $[31] = t14, $[32] = t15) : t15 = $[32];
3695
- let t16;
3696
- return $[33] !== t11 || $[34] !== t15 || $[35] !== t8 ? (t16 = /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-ui": "Select", className: t8, "data-icon-right": "", children: [
3697
- t11,
3698
- t15
3699
- ] }), $[33] = t11, $[34] = t15, $[35] = t8, $[36] = t16) : t16 = $[36], t16;
3700
- }
3701
- const DEFAULT_SKELETON_ELEMENT = "div";
3702
- function Skeleton(props) {
3703
- const $ = compilerRuntime.c(18), t0 = props;
3704
- let className, delay, rest, t1, t2;
3705
- $[0] !== t0 ? ({
3706
- as: t1,
3707
- animated: t2,
3708
- className,
3709
- delay,
3710
- ...rest
3711
- } = t0, $[0] = t0, $[1] = className, $[2] = delay, $[3] = rest, $[4] = t1, $[5] = t2) : (className = $[1], delay = $[2], rest = $[3], t1 = $[4], t2 = $[5]);
3712
- const As = t1 === void 0 ? DEFAULT_SKELETON_ELEMENT : t1, animated = t2 === void 0 ? !1 : t2, [visible, setVisible] = react.useState(!delay);
3713
- let t3, t4;
3714
- $[6] !== delay ? (t3 = () => {
3715
- if (!delay)
3716
- return setVisible(!0);
3717
- const timeout = setTimeout(() => {
3718
- setVisible(!0);
3719
- }, delay);
3720
- return () => {
3721
- clearTimeout(timeout);
3722
- };
3723
- }, t4 = [delay], $[6] = delay, $[7] = t3, $[8] = t4) : (t3 = $[7], t4 = $[8]), react.useEffect(t3, t4);
3724
- let t5;
3725
- $[9] !== className || $[10] !== rest ? (t5 = css.skeleton({
3726
- className,
3727
- ...rest
3728
- }), $[9] = className, $[10] = rest, $[11] = t5) : t5 = $[11];
3729
- const t6 = animated ? "" : void 0, t7 = visible ? "" : void 0;
3730
- let t8;
3731
- return $[12] !== As || $[13] !== rest || $[14] !== t5 || $[15] !== t6 || $[16] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(As, { "data-ui": "Skeleton", ...rest, className: t5, "data-animated": t6, "data-visible": t7 }), $[12] = As, $[13] = rest, $[14] = t5, $[15] = t6, $[16] = t7, $[17] = t8) : t8 = $[17], t8;
3732
- }
3733
- const DEFAULT_CODE_SKELETON_ELEMENT = "div";
3734
- function CodeSkeleton(props) {
3735
- const $ = compilerRuntime.c(10), t0 = props;
3736
- let className, rest, t1;
3737
- $[0] !== t0 ? ({
3738
- className,
3739
- size: t1,
3740
- ...rest
3741
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
3742
- const size2 = t1 === void 0 ? 2 : t1;
3743
- let t2;
3744
- $[4] !== className || $[5] !== size2 ? (t2 = css.codeSkeleton({
3745
- className,
3746
- size: size2
3747
- }), $[4] = className, $[5] = size2, $[6] = t2) : t2 = $[6];
3748
- let t3;
3749
- return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
3750
- }
3751
- const DEFAULT_HEADING_SKELETON_ELEMENT = "div";
3752
- function HeadingSkeleton(props) {
3753
- const $ = compilerRuntime.c(10), t0 = props;
3754
- let className, rest, t1;
3755
- $[0] !== t0 ? ({
3756
- className,
3757
- size: t1,
3758
- ...rest
3759
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
3760
- const size2 = t1 === void 0 ? 2 : t1;
3761
- let t2;
3762
- $[4] !== className || $[5] !== size2 ? (t2 = css.headingSkeleton({
3763
- className,
3764
- size: size2
3765
- }), $[4] = className, $[5] = size2, $[6] = t2) : t2 = $[6];
3766
- let t3;
3767
- return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
3768
- }
3769
- const DEFAULT_LABEL_SKELETON_ELEMENT = "div";
3770
- function LabelSkeleton(props) {
3771
- const $ = compilerRuntime.c(10), t0 = props;
3772
- let className, rest, t1;
3773
- $[0] !== t0 ? ({
3774
- className,
3775
- size: t1,
3776
- ...rest
3777
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
3778
- const size2 = t1 === void 0 ? 2 : t1;
3779
- let t2;
3780
- $[4] !== className || $[5] !== size2 ? (t2 = css.labelSkeleton({
3781
- className,
3782
- size: size2
3783
- }), $[4] = className, $[5] = size2, $[6] = t2) : t2 = $[6];
3784
- let t3;
3785
- return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
3786
- }
3787
- const DEFAULT_TEXT_SKELETON_ELEMENT = "div";
3788
- function TextSkeleton(props) {
3789
- const $ = compilerRuntime.c(10), t0 = props;
3790
- let className, rest, t1;
3791
- $[0] !== t0 ? ({
3792
- className,
3793
- size: t1,
3794
- ...rest
3795
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
3796
- const size2 = t1 === void 0 ? 2 : t1;
3797
- let t2;
3798
- $[4] !== className || $[5] !== size2 ? (t2 = css.textSkeleton({
3799
- className,
3800
- size: size2
3801
- }), $[4] = className, $[5] = size2, $[6] = t2) : t2 = $[6];
3802
- let t3;
3803
- return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
3804
- }
3805
- const DEFAULT_SR_ONLY_ELEMENT = "span";
3806
- function SrOnly(props) {
3807
- const $ = compilerRuntime.c(12), t0 = props;
3808
- let children, className, rest, t1;
3809
- $[0] !== t0 ? ({
3810
- as: t1,
3811
- children,
3812
- className,
3813
- ...rest
3814
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1) : (children = $[1], className = $[2], rest = $[3], t1 = $[4]);
3815
- const Element2 = t1 === void 0 ? DEFAULT_SR_ONLY_ELEMENT : t1;
3816
- let t2;
3817
- $[5] !== className ? (t2 = css.srOnly({
3818
- className
3819
- }), $[5] = className, $[6] = t2) : t2 = $[6];
3820
- let t3;
3821
- return $[7] !== Element2 || $[8] !== children || $[9] !== rest || $[10] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { "data-ui": "SrOnly", ...rest, "aria-hidden": !0, className: t2, children }), $[7] = Element2, $[8] = children, $[9] = rest, $[10] = t2, $[11] = t3) : t3 = $[11], t3;
3822
- }
3823
- const DEFAULT_SWITCH_ELEMENT = "input";
3824
- function Switch(props) {
3825
- const $ = compilerRuntime.c(26), t0 = props;
3826
- let className, disabled, forwardedRef, indeterminate, readOnly, rest, style, t1;
3827
- $[0] !== t0 ? ({
3828
- as: t1,
3829
- className,
3830
- disabled,
3831
- indeterminate,
3832
- readOnly,
3833
- ref: forwardedRef,
3834
- style,
3835
- ...rest
3836
- } = t0, $[0] = t0, $[1] = className, $[2] = disabled, $[3] = forwardedRef, $[4] = indeterminate, $[5] = readOnly, $[6] = rest, $[7] = style, $[8] = t1) : (className = $[1], disabled = $[2], forwardedRef = $[3], indeterminate = $[4], readOnly = $[5], rest = $[6], style = $[7], t1 = $[8]);
3837
- const Element2 = t1 === void 0 ? DEFAULT_SWITCH_ELEMENT : t1, ref = react.useRef(null);
3838
- let t2;
3839
- $[9] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[9] = t2) : t2 = $[9], react.useImperativeHandle(forwardedRef, t2);
3840
- let t3, t4;
3841
- $[10] !== indeterminate ? (t3 = () => {
3842
- ref.current && (ref.current.indeterminate = indeterminate || !1);
3843
- }, t4 = [indeterminate], $[10] = indeterminate, $[11] = t3, $[12] = t4) : (t3 = $[11], t4 = $[12]), react.useEffect(t3, t4);
3844
- let t5;
3845
- $[13] !== className ? (t5 = css._switch({
3846
- className
3847
- }), $[13] = className, $[14] = t5) : t5 = $[14];
3848
- let t6;
3849
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t6 = css._switchElement(), $[15] = t6) : t6 = $[15];
3850
- const t7 = !disabled && readOnly ? "" : void 0, t8 = disabled || readOnly;
3851
- let t9;
3852
- $[16] !== Element2 || $[17] !== rest || $[18] !== t7 || $[19] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { ...rest, className: t6, "data-read-only": t7, disabled: t8, type: "checkbox", ref }), $[16] = Element2, $[17] = rest, $[18] = t7, $[19] = t8, $[20] = t9) : t9 = $[20];
3853
- let t10;
3854
- $[21] === Symbol.for("react.memo_cache_sentinel") ? (t10 = /* @__PURE__ */ jsxRuntime.jsxs("span", { "aria-hidden": !0, className: css._switchPresentation(), children: [
3855
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: css._switchTrack() }),
3856
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: css._switchThumb() })
3857
- ] }), $[21] = t10) : t10 = $[21];
3858
- let t11;
3859
- return $[22] !== style || $[23] !== t5 || $[24] !== t9 ? (t11 = /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: t5, "data-ui": "Switch", display: "block", position: "relative", style, children: [
3860
- t9,
3861
- t10
3862
- ] }), $[22] = style, $[23] = t5, $[24] = t9, $[25] = t11) : t11 = $[25], t11;
3863
- }
3864
- const DEFAULT_TEXT_AREA_ELEMENT = "textarea";
3865
- function TextArea(props) {
3866
- const $ = compilerRuntime.c(33), t0 = props;
3867
- let __unstable_disableFocusRing, customValidity, forwardedRef, readOnly, rest, t1, t2, t3, t4, t5, t6, t7;
3868
- $[0] !== t0 ? ({
3869
- __unstable_disableFocusRing,
3870
- as: t1,
3871
- border: t2,
3872
- customValidity,
3873
- disabled: t3,
3874
- fontSize: t4,
3875
- gap: t5,
3876
- padding: t6,
3877
- radius: t7,
3878
- readOnly,
3879
- ref: forwardedRef,
3880
- ...rest
3881
- } = t0, $[0] = t0, $[1] = __unstable_disableFocusRing, $[2] = customValidity, $[3] = forwardedRef, $[4] = readOnly, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3, $[9] = t4, $[10] = t5, $[11] = t6, $[12] = t7) : (__unstable_disableFocusRing = $[1], customValidity = $[2], forwardedRef = $[3], readOnly = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8], t4 = $[9], t5 = $[10], t6 = $[11], t7 = $[12]);
3882
- const Element2 = t1 === void 0 ? DEFAULT_TEXT_AREA_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, disabled = t3 === void 0 ? !1 : t3, fontSize = t4 === void 0 ? 2 : t4, gap = t5 === void 0 ? 3 : t5, padding = t6 === void 0 ? 3 : t6, radius = t7 === void 0 ? 2 : t7, ref = react.useRef(null);
3883
- let t8;
3884
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => ref.current, $[13] = t8) : t8 = $[13], react.useImperativeHandle(forwardedRef, t8), useCustomValidity(ref, customValidity);
3885
- let t9;
3886
- $[14] !== border || $[15] !== fontSize || $[16] !== gap || $[17] !== padding || $[18] !== radius ? (t9 = css.textArea({
3887
- border,
3888
- fontSize,
3889
- padding,
3890
- radius,
3891
- gap
3892
- }), $[14] = border, $[15] = fontSize, $[16] = gap, $[17] = padding, $[18] = radius, $[19] = t9) : t9 = $[19];
3893
- const t10 = customValidity ? "" : void 0, t11 = !disabled && readOnly ? "" : void 0;
3894
- let t12;
3895
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t12 = css._inputElement(), $[20] = t12) : t12 = $[20];
3896
- const t13 = __unstable_disableFocusRing ? "" : void 0;
3897
- let t14;
3898
- $[21] !== Element2 || $[22] !== disabled || $[23] !== readOnly || $[24] !== rest || $[25] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { ...rest, className: t12, "data-no-focus-ring": t13, disabled, readOnly, ref }), $[21] = Element2, $[22] = disabled, $[23] = readOnly, $[24] = rest, $[25] = t13, $[26] = t14) : t14 = $[26];
3899
- let t15;
3900
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t15 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: css._inputPresentation() }), $[27] = t15) : t15 = $[27];
3901
- let t16;
3902
- return $[28] !== t10 || $[29] !== t11 || $[30] !== t14 || $[31] !== t9 ? (t16 = /* @__PURE__ */ jsxRuntime.jsxs("span", { className: t9, "data-invalid": t10, "data-read-only": t11, "data-ui": "TextArea", children: [
3903
- t14,
3904
- t15
3905
- ] }), $[28] = t10, $[29] = t11, $[30] = t14, $[31] = t9, $[32] = t16) : t16 = $[32], t16;
3906
- }
3907
- function useDelayedState(initialState) {
3908
- const $ = compilerRuntime.c(3), [state, setState] = react.useState(initialState), delayedAction = react.useRef(void 0);
3909
- let t0;
3910
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (nextState, delay) => {
3911
- const action = () => {
3912
- setState(nextState);
3913
- };
3914
- if (delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), !delay)
3915
- return action();
3916
- delayedAction.current = setTimeout(action, delay);
3917
- }, $[0] = t0) : t0 = $[0];
3918
- const onStateChange = t0;
3919
- let t1;
3920
- return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
3921
- }
3922
- const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAULT_TOOLTIP_ARROW_RADIUS = 2, DEFAULT_TOOLTIP_DISTANCE = 4, DEFAULT_TOOLTIP_PADDING = 4, DEFAULT_FALLBACK_PLACEMENTS = {
3923
- top: ["top-end", "top-start", "bottom", "left", "right"],
3924
- "top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
3925
- "top-end": ["top", "top-start", "bottom-end", "left-end", "right-end"],
3926
- bottom: ["bottom-end", "bottom-start", "top", "left", "right"],
3927
- "bottom-start": ["bottom", "bottom-end", "top-start", "left-start", "right-start"],
3928
- "bottom-end": ["bottom", "bottom-start", "top-end", "left-end", "right-end"],
3929
- left: ["left-end", "left-start", "right", "top", "bottom"],
3930
- "left-start": ["left", "left-end", "right-start", "top-start", "bottom-start"],
3931
- "left-end": ["left", "left-start", "right-end", "top-end", "bottom-end"],
3932
- right: ["right-end", "right-start", "left", "top", "bottom"],
3933
- "right-start": ["right", "right-end", "left-start", "top-start", "bottom-start"],
3934
- "right-end": ["right", "right-start", "left-end", "top-end", "bottom-end"]
3935
- }, TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/v3/tooltipDelayGroup", null);
3936
- function TooltipDelayGroupProvider(props) {
3937
- const $ = compilerRuntime.c(9), {
3938
- children,
3939
- delay
3940
- } = props, [isGroupActive, setIsGroupActive] = useDelayedState(!1), [openTooltipId, setOpenTooltipId] = useDelayedState(null), openDelay = typeof delay == "number" ? delay : delay?.open || 0, closeDelay = typeof delay == "number" ? delay : delay?.close || 0;
3941
- let t0;
3942
- const t1 = isGroupActive ? 1 : openDelay;
3943
- let t2;
3944
- $[0] !== closeDelay || $[1] !== openTooltipId || $[2] !== setIsGroupActive || $[3] !== setOpenTooltipId || $[4] !== t1 ? (t2 = {
3945
- setIsGroupActive,
3946
- openTooltipId,
3947
- setOpenTooltipId,
3948
- openDelay: t1,
3949
- closeDelay
3950
- }, $[0] = closeDelay, $[1] = openTooltipId, $[2] = setIsGroupActive, $[3] = setOpenTooltipId, $[4] = t1, $[5] = t2) : t2 = $[5], t0 = t2;
3951
- const value = t0;
3952
- let t3;
3953
- return $[6] !== children || $[7] !== value ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupContext.Provider, { value, children }), $[6] = children, $[7] = value, $[8] = t3) : t3 = $[8], t3;
3954
- }
3955
- function useTooltipDelayGroup() {
3956
- return react.useContext(TooltipDelayGroupContext);
3957
- }
3958
- function TooltipLayer(props) {
3959
- const $ = compilerRuntime.c(50);
3960
- let animate, arrow, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, rest, scheme, shadow, style, t0;
3961
- $[0] !== props ? ({
3962
- animate,
3963
- arrow,
3964
- arrowRef,
3965
- arrowX,
3966
- arrowY,
3967
- children,
3968
- originX,
3969
- originY,
3970
- padding,
3971
- placement,
3972
- radius,
3973
- scheme,
3974
- shadow,
3975
- style,
3976
- tone: t0,
3977
- ...rest
3978
- } = props, $[0] = props, $[1] = animate, $[2] = arrow, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = originX, $[8] = originY, $[9] = padding, $[10] = placement, $[11] = radius, $[12] = rest, $[13] = scheme, $[14] = shadow, $[15] = style, $[16] = t0) : (animate = $[1], arrow = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], originX = $[7], originY = $[8], padding = $[9], placement = $[10], radius = $[11], rest = $[12], scheme = $[13], shadow = $[14], style = $[15], t0 = $[16]);
3979
- const tone = t0 === void 0 ? "inherit" : t0;
3980
- let t1;
3981
- const t2 = animate ? "transform" : void 0;
3982
- let t3;
3983
- $[17] !== originX || $[18] !== originY || $[19] !== style || $[20] !== t2 ? (t3 = {
3984
- originX,
3985
- originY,
3986
- willChange: t2,
3987
- ...style
3988
- }, $[17] = originX, $[18] = originY, $[19] = style, $[20] = t2, $[21] = t3) : t3 = $[21], t1 = t3;
3989
- const rootStyle = t1;
3990
- let t4;
3991
- const t5 = arrowX !== null ? arrowX : void 0, t6 = arrowY !== null ? arrowY : void 0;
3992
- let t7;
3993
- $[22] !== t5 || $[23] !== t6 ? (t7 = {
3994
- left: t5,
3995
- top: t6,
3996
- right: void 0,
3997
- bottom: void 0
3998
- }, $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24], t4 = t7;
3999
- const arrowStyle = t4, t8 = animate ? "" : void 0;
4000
- let t9;
4001
- $[25] !== animate ? (t9 = animate ? ["hidden", "initial"] : void 0, $[25] = animate, $[26] = t9) : t9 = $[26];
4002
- let t10;
4003
- $[27] !== animate ? (t10 = animate ? ["visible", "scaleIn"] : void 0, $[27] = animate, $[28] = t10) : t10 = $[28];
4004
- let t11;
4005
- $[29] !== animate ? (t11 = animate ? ["hidden", "scaleOut"] : void 0, $[29] = animate, $[30] = t11) : t11 = $[30];
4006
- let t12;
4007
- $[31] !== arrow || $[32] !== arrowRef || $[33] !== arrowStyle ? (t12 = arrow && /* @__PURE__ */ jsxRuntime.jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[31] = arrow, $[32] = arrowRef, $[33] = arrowStyle, $[34] = t12) : t12 = $[34];
4008
- let t13;
4009
- return $[35] !== children || $[36] !== padding || $[37] !== placement || $[38] !== radius || $[39] !== rest || $[40] !== rootStyle || $[41] !== scheme || $[42] !== shadow || $[43] !== t10 || $[44] !== t11 || $[45] !== t12 || $[46] !== t8 || $[47] !== t9 || $[48] !== tone ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs(Layer, { "data-ui": "Tooltip__layer", ...rest, as: framerMotion.motion.div, "data-animate": t8, "data-placement": placement, padding, radius, scheme, shadow, style: rootStyle, variants: POPOVER_MOTION_PROPS.card, transition: POPOVER_MOTION_PROPS.transition, initial: t9, animate: t10, exit: t11, tone, children: [
4010
- children,
4011
- t12
4012
- ] }), $[35] = children, $[36] = padding, $[37] = placement, $[38] = radius, $[39] = rest, $[40] = rootStyle, $[41] = scheme, $[42] = shadow, $[43] = t10, $[44] = t11, $[45] = t12, $[46] = t8, $[47] = t9, $[48] = tone, $[49] = t13) : t13 = $[49], t13;
4013
- }
4014
- const DEFAULT_TOOLTIP_ELEMENT = "div";
4015
- function Tooltip(props) {
4016
- const boundaryElementContext = useBoundaryElement(), {
4017
- animate: _animate = !1,
4018
- arrow: arrowProp = !1,
4019
- as = DEFAULT_TOOLTIP_ELEMENT,
4020
- boundaryElement = boundaryElementContext?.element,
4021
- children: childProp,
4022
- className,
4023
- content: content2,
4024
- delay,
4025
- disabled,
4026
- fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"],
4027
- padding = 2,
4028
- placement: placementProp = "bottom",
4029
- portal: portalProp,
4030
- radius = 3,
4031
- ref: forwardedRef,
4032
- scheme,
4033
- shadow = 2,
4034
- zOffset = Z_OFFSETS.tooltip,
4035
- tone = "inherit",
4036
- ...rest
4037
- } = props, card = useCard(), animate = usePrefersReducedMotion() ? !1 : _animate, ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = react.useState(0);
4038
- react.useImperativeHandle(forwardedRef, () => ref.current);
4039
- const portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, middleware = react.useMemo(() => {
4040
- const ret = [];
4041
- return ret.push(reactDom$1.flip({
4042
- boundary: boundaryElement || void 0,
4043
- fallbackPlacements,
4044
- padding: DEFAULT_TOOLTIP_PADDING,
4045
- rootBoundary
4046
- })), ret.push(reactDom$1.offset({
4047
- mainAxis: DEFAULT_TOOLTIP_DISTANCE
4048
- })), ret.push(reactDom$1.shift({
4049
- boundary: boundaryElement || void 0,
4050
- rootBoundary,
4051
- padding: DEFAULT_TOOLTIP_PADDING
4052
- })), arrowProp && ret.push(reactDom$1.arrow({
4053
- element: arrowRef,
4054
- padding: DEFAULT_TOOLTIP_PADDING
4055
- })), animate && ret.push(origin), ret;
4056
- }, [animate, arrowProp, boundaryElement, fallbackPlacements]), {
4057
- floatingStyles,
4058
- placement,
4059
- middlewareData,
4060
- refs,
4061
- update
4062
- } = reactDom$1.useFloating({
4063
- middleware,
4064
- placement: placementProp,
4065
- whileElementsMounted: reactDom$1.autoUpdate,
4066
- elements: {
4067
- reference: referenceElement
4068
- },
4069
- transform: !1
4070
- }), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = react.useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), {
4071
- setIsGroupActive,
4072
- setOpenTooltipId
4073
- } = delayGroupContext || {}, showTooltip = isOpen || delayGroupContext?.openTooltipId === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : delay?.open || 0, closeDelayProp = typeof delay == "number" ? delay : delay?.close || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = react.useCallback((open, immediate) => {
4074
- if (isInsideGroup)
4075
- if (open) {
4076
- const groupedOpenDelay = immediate ? 0 : openDelay;
4077
- setIsGroupActive?.(open, groupedOpenDelay), setOpenTooltipId?.(tooltipId, groupedOpenDelay);
4078
- } else {
4079
- const groupDeactivateDelay = closeDelay > 200 ? closeDelay : 200;
4080
- setIsGroupActive?.(open, groupDeactivateDelay), setOpenTooltipId?.(null, immediate ? 0 : closeDelay);
4081
- }
4082
- else
4083
- setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
4084
- }, [isInsideGroup, openDelay, setIsGroupActive, setOpenTooltipId, tooltipId, closeDelay, setIsOpen]), handleBlur = react.useCallback((e) => {
4085
- handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
4086
- }, [childProp?.props, handleIsOpenChange]), handleClick = react.useCallback((e_0) => {
4087
- handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
4088
- }, [childProp?.props, handleIsOpenChange]), handleContextMenu = react.useCallback((e_1) => {
4089
- handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
4090
- }, [childProp?.props, handleIsOpenChange]), handleFocus = react.useCallback((e_2) => {
4091
- handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
4092
- }, [childProp?.props, handleIsOpenChange]), handleMouseEnter = react.useCallback((e_3) => {
4093
- handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
4094
- }, [childProp?.props, handleIsOpenChange]), handleMouseLeave = react.useCallback((e_4) => {
4095
- handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
4096
- }, [childProp?.props, handleIsOpenChange]);
4097
- useCloseOnMouseLeave({
4098
- handleIsOpenChange,
4099
- referenceElement,
4100
- showTooltip,
4101
- isInsideGroup
4102
- }), react.useEffect(() => {
4103
- disabled && showTooltip && handleIsOpenChange(!1);
4104
- }, [disabled, handleIsOpenChange, showTooltip]), react.useEffect(() => {
4105
- !content2 && showTooltip && handleIsOpenChange(!1);
4106
- }, [content2, handleIsOpenChange, showTooltip]), react.useEffect(() => {
4107
- if (!showTooltip) return;
4108
- function handleWindowKeyDown(event) {
4109
- event.key === "Escape" && handleIsOpenChange(!1, !0);
4110
- }
4111
- return window.addEventListener("keydown", handleWindowKeyDown), () => {
4112
- window.removeEventListener("keydown", handleWindowKeyDown);
4113
- };
4114
- }, [handleIsOpenChange, showTooltip]), react.useLayoutEffect(() => {
4115
- const availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
4116
- setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
4117
- }, [boundaryElement, portalElement]);
4118
- const setArrow = react.useCallback((arrowEl) => {
4119
- arrowRef.current = arrowEl, update();
4120
- }, [update]), setFloating = react.useCallback((node) => {
4121
- ref.current = node, refs.setFloating(node);
4122
- }, [refs]), child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
4123
- onBlur: handleBlur,
4124
- onFocus: handleFocus,
4125
- onMouseEnter: handleMouseEnter,
4126
- onMouseLeave: handleMouseLeave,
4127
- onClick: handleClick,
4128
- onContextMenu: handleContextMenu,
4129
- ref: setReferenceElement
4130
- }) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
4131
- if (react.useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
4132
- if (disabled) return child;
4133
- const node_0 = /* @__PURE__ */ jsxRuntime.jsx(TooltipLayer, { "data-ui": "Tooltip", ...rest, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: css.tooltip({
4134
- className
4135
- }), originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: {
4136
- ...floatingStyles,
4137
- maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
4138
- }, tone, zOffset, children: content2 }), children = showTooltip && (portalProp ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portalProp == "string" ? portalProp : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card.tone : tone, scheme: scheme ?? "light", children: node_0 }) }) : node_0);
4139
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4140
- animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
4141
- child
4142
- ] });
4143
- }
4144
- function useCloseOnMouseLeave(t0) {
4145
- const $ = compilerRuntime.c(10), {
4146
- handleIsOpenChange,
4147
- referenceElement,
4148
- showTooltip,
4149
- isInsideGroup
4150
- } = t0;
4151
- let t1;
4152
- $[0] !== handleIsOpenChange || $[1] !== referenceElement ? (t1 = (target, teardown) => {
4153
- referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
4154
- }, $[0] = handleIsOpenChange, $[1] = referenceElement, $[2] = t1) : t1 = $[2];
4155
- const onMouseMove = useEffectEvent.useEffectEvent(t1);
4156
- let t2;
4157
- $[3] !== isInsideGroup || $[4] !== onMouseMove || $[5] !== showTooltip ? (t2 = () => {
4158
- if (!showTooltip || isInsideGroup)
4159
- return;
4160
- const handleMouseMove = (event) => {
4161
- onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
4162
- };
4163
- return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
4164
- }, $[3] = isInsideGroup, $[4] = onMouseMove, $[5] = showTooltip, $[6] = t2) : t2 = $[6];
4165
- let t3;
4166
- $[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], react.useEffect(t2, t3);
4167
- }
4168
- function BoundaryElementProvider(props) {
4169
- const $ = compilerRuntime.c(5), {
4170
- children,
4171
- element
4172
- } = props;
4173
- let t0, t1;
4174
- $[0] !== element ? (t1 = {
4175
- version: 0,
4176
- element
4177
- }, $[0] = element, $[1] = t1) : t1 = $[1], t0 = t1;
4178
- const value = t0;
4179
- let t2;
4180
- return $[2] !== children || $[3] !== value ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(BoundaryElementContext.Provider, { value, children }), $[2] = children, $[3] = value, $[4] = t2) : t2 = $[4], t2;
4181
- }
4182
- function findMaxBreakpoints(media2, width) {
4183
- const ret = [];
4184
- for (let i = 0; i < media2.length; i += 1)
4185
- media2[i] > width && ret.push(i);
4186
- return ret;
4187
- }
4188
- function findMinBreakpoints(media2, width) {
4189
- const ret = [];
4190
- for (let i = 0; i < media2.length; i += 1)
4191
- media2[i] <= width && ret.push(i);
4192
- return ret;
4193
- }
4194
- const DEFAULT_ELEMENT_QUERY_ELEMENT = "div", DEFAULT_BREAKPOINTS = Object.values(css.BREAKPOINTS);
4195
- function ElementQuery(props) {
4196
- const $ = compilerRuntime.c(21), t0 = props;
4197
- let children, forwardedRef, mediaProp, rest, t1;
4198
- $[0] !== t0 ? ({
4199
- as: t1,
4200
- children,
4201
- media: mediaProp,
4202
- ref: forwardedRef,
4203
- ...rest
4204
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = mediaProp, $[4] = rest, $[5] = t1) : (children = $[1], forwardedRef = $[2], mediaProp = $[3], rest = $[4], t1 = $[5]);
4205
- const Element2 = t1 === void 0 ? DEFAULT_ELEMENT_QUERY_ELEMENT : t1, breakpoints = mediaProp ?? DEFAULT_BREAKPOINTS, [element, setElement] = react.useState(null), elementSize = useElementSize(element);
4206
- let t2;
4207
- t2 = elementSize?.border.width ?? window.innerWidth;
4208
- const width = t2;
4209
- let t3, t4;
4210
- if ($[6] !== breakpoints || $[7] !== width) {
4211
- const eq = findMaxBreakpoints(breakpoints, width);
4212
- t4 = eq.length ? eq.join(" ") : void 0, $[6] = breakpoints, $[7] = width, $[8] = t4;
4213
- } else
4214
- t4 = $[8];
4215
- t3 = t4;
4216
- const max = t3;
4217
- let t5, t6;
4218
- if ($[9] !== breakpoints || $[10] !== width) {
4219
- const eq_0 = findMinBreakpoints(breakpoints, width);
4220
- t6 = eq_0.length ? eq_0.join(" ") : void 0, $[9] = breakpoints, $[10] = width, $[11] = t6;
4221
- } else
4222
- t6 = $[11];
4223
- t5 = t6;
4224
- const min = t5;
4225
- let t7, t8;
4226
- $[12] !== element ? (t7 = () => element, t8 = [element], $[12] = element, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), react.useImperativeHandle(forwardedRef, t7, t8);
4227
- let t9;
4228
- return $[15] !== Element2 || $[16] !== children || $[17] !== max || $[18] !== min || $[19] !== rest ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(Element2, { "data-ui": "ElementQuery", ...rest, "data-eq-max": max, "data-eq-min": min, ref: setElement, children }), $[15] = Element2, $[16] = children, $[17] = max, $[18] = min, $[19] = rest, $[20] = t9) : t9 = $[20], t9;
4229
- }
4230
- class ErrorBoundary extends react.Component {
4231
- state = {
4232
- error: null
4233
- };
4234
- static displayName = "ErrorBoundary";
4235
- static getDerivedStateFromError(error) {
4236
- return {
4237
- error
4238
- };
4239
- }
4240
- componentDidCatch(error, info) {
4241
- this.props.onCatch({
4242
- error,
4243
- info
4244
- });
4245
- }
4246
- render() {
4247
- const {
4248
- error
4249
- } = this.state;
4250
- if (error) {
4251
- const message = typeof error?.message == "string" ? error.message : "Error";
4252
- return /* @__PURE__ */ jsxRuntime.jsx(Code, { children: message });
4253
- }
4254
- return this.props.children;
4255
- }
4256
- }
4257
- function PortalProvider(props) {
4258
- const $ = compilerRuntime.c(9), {
4259
- children,
4260
- element,
4261
- __unstable_elements: elementsProp
4262
- } = props, elements = useUnique(elementsProp), parentPortal = react.useContext(PortalContext);
4263
- let t0;
4264
- $[0] !== elements || $[1] !== parentPortal ? (t0 = () => elements?.default ?? (parentPortal.element || document.body), $[0] = elements, $[1] = parentPortal, $[2] = t0) : t0 = $[2];
4265
- const fallbackElement = react.useSyncExternalStore(emptySubscribe, t0, _temp);
4266
- let t1;
4267
- const t2 = element || fallbackElement;
4268
- let t3;
4269
- $[3] !== elements || $[4] !== t2 ? (t3 = {
4270
- version: 0,
4271
- boundaryElement: null,
4272
- element: t2,
4273
- elements
4274
- }, $[3] = elements, $[4] = t2, $[5] = t3) : t3 = $[5], t1 = t3;
4275
- const value = t1;
4276
- let t4;
4277
- return $[6] !== children || $[7] !== value ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children }), $[6] = children, $[7] = value, $[8] = t4) : t4 = $[8], t4;
4278
- }
4279
- function _temp() {
4280
- return null;
4281
- }
4282
- const emptySubscribe = () => () => {
4283
- };
4284
- function useUnique(value) {
4285
- const valueRef = react.useRef(value);
4286
- return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
4287
- }
4288
- function _isEqual(objA, objB) {
4289
- if (!objA || !objB)
4290
- return objA === objB;
4291
- const keysA = Object.keys(objA), keysB = Object.keys(objB);
4292
- return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
4293
- }
4294
- function RootProvider(props) {
4295
- const $ = compilerRuntime.c(10), {
4296
- boundaryElement: t0,
4297
- children,
4298
- portalElement: t1,
4299
- scheme: t2,
4300
- tone: t3
4301
- } = props, boundaryElement = t0 === void 0 ? null : t0, portalElement = t1 === void 0 ? null : t1, scheme = t2 === void 0 ? "light" : t2, tone = t3 === void 0 ? "transparent" : t3;
4302
- let t4;
4303
- $[0] !== children || $[1] !== portalElement ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(PortalProvider, { element: portalElement, children }), $[0] = children, $[1] = portalElement, $[2] = t4) : t4 = $[2];
4304
- let t5;
4305
- $[3] !== boundaryElement || $[4] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(ToastProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(BoundaryElementProvider, { element: boundaryElement, children: t4 }) }), $[3] = boundaryElement, $[4] = t4, $[5] = t5) : t5 = $[5];
4306
- let t6;
4307
- return $[6] !== scheme || $[7] !== t5 || $[8] !== tone ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(LayerProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { scheme, tone, children: t5 }) }), $[6] = scheme, $[7] = t5, $[8] = tone, $[9] = t6) : t6 = $[9], t6;
4308
- }
4309
- const DEFAULT_ROOT_ELEMENT = "html";
4310
- function Root(props) {
4311
- const $ = compilerRuntime.c(35), t0 = props;
4312
- let children, className, forwardedRef, height, rest, t1, t2, t3, t4;
4313
- $[0] !== t0 ? ({
4314
- as: t1,
4315
- children,
4316
- className,
4317
- height,
4318
- overflow: t2,
4319
- ref: forwardedRef,
4320
- scheme: t3,
4321
- tone: t4,
4322
- ...rest
4323
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = forwardedRef, $[4] = height, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3, $[9] = t4) : (children = $[1], className = $[2], forwardedRef = $[3], height = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8], t4 = $[9]);
4324
- const as = t1 === void 0 ? DEFAULT_ROOT_ELEMENT : t1, overflow = t2 === void 0 ? "hidden" : t2, scheme = t3 === void 0 ? "light" : t3, tone = t4 === void 0 ? "default" : t4, ref = react.useRef(null);
4325
- let t5;
4326
- $[10] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => ref.current, $[10] = t5) : t5 = $[10], react.useImperativeHandle(forwardedRef, t5);
4327
- const [portalElement, setPortalElement] = react.useState(null), [boundaryElement, setBoundaryElement] = react.useState(null);
4328
- let t6;
4329
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t6 = (el) => {
4330
- setBoundaryElement(el), ref.current = el;
4331
- }, $[11] = t6) : t6 = $[11];
4332
- const handleRef = t6;
4333
- let t7;
4334
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { "data-portal": "", ref: setPortalElement }), $[12] = t7) : t7 = $[12];
4335
- let t8;
4336
- $[13] !== boundaryElement || $[14] !== children || $[15] !== portalElement || $[16] !== scheme || $[17] !== tone ? (t8 = /* @__PURE__ */ jsxRuntime.jsxs(RootProvider, { boundaryElement, portalElement, scheme, tone, children: [
4337
- children,
4338
- t7
4339
- ] }), $[13] = boundaryElement, $[14] = children, $[15] = portalElement, $[16] = scheme, $[17] = tone, $[18] = t8) : t8 = $[18];
4340
- let node = t8;
4341
- if (as === "html") {
4342
- let t92;
4343
- $[19] !== height ? (t92 = css.box({
4344
- height,
4345
- margin: 0
4346
- }), $[19] = height, $[20] = t92) : t92 = $[20];
4347
- let t102;
4348
- $[21] !== node || $[22] !== t92 ? (t102 = /* @__PURE__ */ jsxRuntime.jsx("body", { className: t92, children: node }), $[21] = node, $[22] = t92, $[23] = t102) : t102 = $[23], node = t102;
4349
- }
4350
- let t9;
4351
- $[24] !== className || $[25] !== height || $[26] !== scheme || $[27] !== tone ? (t9 = css.root({
4352
- className,
4353
- height,
4354
- scheme,
4355
- tone
4356
- }), $[24] = className, $[25] = height, $[26] = scheme, $[27] = tone, $[28] = t9) : t9 = $[28];
4357
- let t10;
4358
- return $[29] !== as || $[30] !== node || $[31] !== overflow || $[32] !== rest || $[33] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(Box, { as, "data-ui": "Root", ...rest, className: t9, overflow, ref: handleRef, children: node }), $[29] = as, $[30] = node, $[31] = overflow, $[32] = rest, $[33] = t9, $[34] = t10) : t10 = $[34], t10;
4359
- }
4360
- exports.Arrow = Arrow;
4361
- exports.Autocomplete = Autocomplete;
4362
- exports.Avatar = Avatar;
4363
- exports.AvatarCounter = AvatarCounter;
4364
- exports.AvatarStack = AvatarStack;
4365
- exports.Badge = Badge;
4366
- exports.BoundaryElementProvider = BoundaryElementProvider;
4367
- exports.Box = Box;
4368
- exports.Breadcrumbs = Breadcrumbs;
4369
- exports.Button = Button;
4370
- exports.Card = Card;
4371
- exports.CardProvider = CardProvider;
4372
- exports.Checkbox = Checkbox;
4373
- exports.Code = Code;
4374
- exports.CodeSkeleton = CodeSkeleton;
4375
- exports.Container = Container;
4376
- exports.DEFAULT_ARROW_ELEMENT = DEFAULT_ARROW_ELEMENT;
4377
- exports.DEFAULT_AUTOCOMPLETE_ELEMENT = DEFAULT_AUTOCOMPLETE_ELEMENT;
4378
- exports.DEFAULT_AVATAR_COUNTER_ELEMENT = DEFAULT_AVATAR_COUNTER_ELEMENT;
4379
- exports.DEFAULT_AVATAR_ELEMENT = DEFAULT_AVATAR_ELEMENT;
4380
- exports.DEFAULT_AVATAR_STACK_ELEMENT = DEFAULT_AVATAR_STACK_ELEMENT;
4381
- exports.DEFAULT_BADGE_ELEMENT = DEFAULT_BADGE_ELEMENT;
4382
- exports.DEFAULT_BOX_ELEMENT = DEFAULT_BOX_ELEMENT;
4383
- exports.DEFAULT_BREADCRUMBS_ELEMENT = DEFAULT_BREADCRUMBS_ELEMENT;
4384
- exports.DEFAULT_BUTTON_ELEMENT = DEFAULT_BUTTON_ELEMENT;
4385
- exports.DEFAULT_CARD_ELEMENT = DEFAULT_CARD_ELEMENT;
4386
- exports.DEFAULT_CHECKBOX_ELEMENT = DEFAULT_CHECKBOX_ELEMENT;
4387
- exports.DEFAULT_CODE_ELEMENT = DEFAULT_CODE_ELEMENT;
4388
- exports.DEFAULT_CODE_SKELETON_ELEMENT = DEFAULT_CODE_SKELETON_ELEMENT;
4389
- exports.DEFAULT_CONTAINER_ELEMENT = DEFAULT_CONTAINER_ELEMENT;
4390
- exports.DEFAULT_DIALOG_ELEMENT = DEFAULT_DIALOG_ELEMENT;
4391
- exports.DEFAULT_ELEMENT_QUERY_ELEMENT = DEFAULT_ELEMENT_QUERY_ELEMENT;
4392
- exports.DEFAULT_FLEX_ELEMENT = DEFAULT_FLEX_ELEMENT;
4393
- exports.DEFAULT_GRID_ELEMENT = DEFAULT_GRID_ELEMENT;
4394
- exports.DEFAULT_HEADING_ELEMENT = DEFAULT_HEADING_ELEMENT;
4395
- exports.DEFAULT_HEADING_SKELETON_ELEMENT = DEFAULT_HEADING_SKELETON_ELEMENT;
4396
- exports.DEFAULT_HOTKEYS_ELEMENT = DEFAULT_HOTKEYS_ELEMENT;
4397
- exports.DEFAULT_INLINE_ELEMENT = DEFAULT_INLINE_ELEMENT;
4398
- exports.DEFAULT_KBD_ELEMENT = DEFAULT_KBD_ELEMENT;
4399
- exports.DEFAULT_LABEL_ELEMENT = DEFAULT_LABEL_ELEMENT;
4400
- exports.DEFAULT_LABEL_SKELETON_ELEMENT = DEFAULT_LABEL_SKELETON_ELEMENT;
4401
- exports.DEFAULT_LAYER_ELEMENT = DEFAULT_LAYER_ELEMENT;
4402
- exports.DEFAULT_MENU_DIVIDER_ELEMENT = DEFAULT_MENU_DIVIDER_ELEMENT;
4403
- exports.DEFAULT_MENU_ELEMENT = DEFAULT_MENU_ELEMENT;
4404
- exports.DEFAULT_MENU_GROUP_ELEMENT = DEFAULT_MENU_GROUP_ELEMENT;
4405
- exports.DEFAULT_MENU_ITEM_ELEMENT = DEFAULT_MENU_ITEM_ELEMENT;
4406
- exports.DEFAULT_POPOVER_ELEMENT = DEFAULT_POPOVER_ELEMENT;
4407
- exports.DEFAULT_RADIO_ELEMENT = DEFAULT_RADIO_ELEMENT;
4408
- exports.DEFAULT_ROOT_ELEMENT = DEFAULT_ROOT_ELEMENT;
4409
- exports.DEFAULT_SELECTABLE_ELEMENT = DEFAULT_SELECTABLE_ELEMENT;
4410
- exports.DEFAULT_SELECT_ELEMENT = DEFAULT_SELECT_ELEMENT;
4411
- exports.DEFAULT_SKELETON_ELEMENT = DEFAULT_SKELETON_ELEMENT;
4412
- exports.DEFAULT_SPINNER_ELEMENT = DEFAULT_SPINNER_ELEMENT;
4413
- exports.DEFAULT_SR_ONLY_ELEMENT = DEFAULT_SR_ONLY_ELEMENT;
4414
- exports.DEFAULT_STACK_ELEMENT = DEFAULT_STACK_ELEMENT;
4415
- exports.DEFAULT_SWITCH_ELEMENT = DEFAULT_SWITCH_ELEMENT;
4416
- exports.DEFAULT_TAB_ELEMENT = DEFAULT_TAB_ELEMENT;
4417
- exports.DEFAULT_TAB_LIST_ELEMENT = DEFAULT_TAB_LIST_ELEMENT;
4418
- exports.DEFAULT_TAB_PANEL_ELEMENT = DEFAULT_TAB_PANEL_ELEMENT;
4419
- exports.DEFAULT_TEXT_AREA_ELEMENT = DEFAULT_TEXT_AREA_ELEMENT;
4420
- exports.DEFAULT_TEXT_ELEMENT = DEFAULT_TEXT_ELEMENT;
4421
- exports.DEFAULT_TEXT_INPUT_ELEMENT = DEFAULT_TEXT_INPUT_ELEMENT;
4422
- exports.DEFAULT_TEXT_SKELETON_ELEMENT = DEFAULT_TEXT_SKELETON_ELEMENT;
4423
- exports.DEFAULT_TOAST_ELEMENT = DEFAULT_TOAST_ELEMENT;
4424
- exports.DEFAULT_TOOLTIP_ELEMENT = DEFAULT_TOOLTIP_ELEMENT;
4425
- exports.DEFAULT_TREE_ELEMENT = DEFAULT_TREE_ELEMENT;
4426
- exports.DEFAULT_TREE_ITEM_ELEMENT = DEFAULT_TREE_ITEM_ELEMENT;
4427
- exports.DEFAULT_VIRTUAL_LIST_ELEMENT = DEFAULT_VIRTUAL_LIST_ELEMENT;
4428
- exports.Dialog = Dialog;
4429
- exports.DialogContext = DialogContext;
4430
- exports.DialogProvider = DialogProvider;
4431
- exports.ElementQuery = ElementQuery;
4432
- exports.ErrorBoundary = ErrorBoundary;
4433
- exports.Flex = Flex;
4434
- exports.Grid = Grid;
4435
- exports.Heading = Heading;
4436
- exports.HeadingSkeleton = HeadingSkeleton;
4437
- exports.Hotkeys = Hotkeys;
4438
- exports.Inline = Inline;
4439
- exports.KBD = KBD;
4440
- exports.Label = Label;
4441
- exports.LabelSkeleton = LabelSkeleton;
4442
- exports.Layer = Layer;
4443
- exports.LayerProvider = LayerProvider;
4444
- exports.Menu = Menu;
4445
- exports.MenuButton = MenuButton;
4446
- exports.MenuDivider = MenuDivider;
4447
- exports.MenuGroup = MenuGroup;
4448
- exports.MenuItem = MenuItem;
4449
- exports.Popover = Popover;
4450
- exports.Portal = Portal;
4451
- exports.PortalProvider = PortalProvider;
4452
- exports.Radio = Radio;
4453
- exports.Root = Root;
4454
- exports.RootProvider = RootProvider;
4455
- exports.Select = Select;
4456
- exports.Selectable = Selectable;
4457
- exports.Skeleton = Skeleton;
4458
- exports.Spinner = Spinner;
4459
- exports.SrOnly = SrOnly;
4460
- exports.Stack = Stack;
4461
- exports.Switch = Switch;
4462
- exports.Tab = Tab;
4463
- exports.TabList = TabList;
4464
- exports.TabPanel = TabPanel;
4465
- exports.Text = Text;
4466
- exports.TextArea = TextArea;
4467
- exports.TextInput = TextInput;
4468
- exports.TextSkeleton = TextSkeleton;
4469
- exports.Toast = Toast;
4470
- exports.ToastProvider = ToastProvider;
4471
- exports.Tooltip = Tooltip;
4472
- exports.TooltipDelayGroupContext = TooltipDelayGroupContext;
4473
- exports.TooltipDelayGroupProvider = TooltipDelayGroupProvider;
4474
- exports.Tree = Tree;
4475
- exports.TreeItem = TreeItem;
4476
- exports.VirtualList = VirtualList;
4477
- exports._ResizeObserver = _ResizeObserver;
4478
- exports._elementSizeObserver = _elementSizeObserver;
4479
- exports._getArrayProp = _getArrayProp;
4480
- exports._getResponsiveProp = _getResponsiveProp;
4481
- exports._hasFocus = _hasFocus;
4482
- exports._isEnterToClickElement = _isEnterToClickElement;
4483
- exports._isScrollable = _isScrollable;
4484
- exports._raf = _raf;
4485
- exports._raf2 = _raf2;
4486
- exports.attemptFocus = attemptFocus;
4487
- exports.containsOrEqualsElement = containsOrEqualsElement;
4488
- exports.focusFirstDescendant = focusFirstDescendant;
4489
- exports.focusLastDescendant = focusLastDescendant;
4490
- exports.isFocusable = isFocusable;
4491
- exports.isHTMLAnchorElement = isHTMLAnchorElement;
4492
- exports.isHTMLButtonElement = isHTMLButtonElement;
4493
- exports.isHTMLElement = isHTMLElement;
4494
- exports.isHTMLInputElement = isHTMLInputElement;
4495
- exports.isHTMLSelectElement = isHTMLSelectElement;
4496
- exports.isHTMLTextAreaElement = isHTMLTextAreaElement;
4497
- exports.useBoundaryElement = useBoundaryElement;
4498
- exports.useCard = useCard;
4499
- exports.useClickOutsideEvent = useClickOutsideEvent;
4500
- exports.useCustomValidity = useCustomValidity;
4501
- exports.useDialog = useDialog;
4502
- exports.useElementSize = useElementSize;
4503
- exports.useGlobalKeyDown = useGlobalKeyDown;
4504
- exports.useLayer = useLayer;
4505
- exports.useMatchMedia = useMatchMedia;
4506
- exports.useMediaIndex = useMediaIndex;
4507
- exports.usePortal = usePortal;
4508
- exports.usePrefersDark = usePrefersDark;
4509
- exports.usePrefersReducedMotion = usePrefersReducedMotion;
4510
- exports.useResponsiveProp = useResponsiveProp;
4511
- exports.useToast = useToast;
4512
- exports.useTooltipDelayGroup = useTooltipDelayGroup;
4513
- exports.useTree = useTree;
4514
- //# sourceMappingURL=index.cjs.map