@sanity/ui 2.3.6 → 2.3.7-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/index.compiled.mjs +7488 -0
  2. package/dist/index.compiled.mjs.map +1 -0
  3. package/dist/index.d.mts +13 -1
  4. package/dist/index.d.ts +13 -1
  5. package/dist/index.esm.js +1047 -1072
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.js +1054 -1079
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +1047 -1072
  10. package/dist/index.mjs.map +1 -1
  11. package/package.json +31 -35
  12. package/src/core/components/autocomplete/autocomplete.tsx +31 -34
  13. package/src/core/components/breadcrumbs/breadcrumbs.tsx +3 -2
  14. package/src/core/components/dialog/dialog.tsx +23 -12
  15. package/src/core/components/hotkeys/hotkeys.tsx +3 -3
  16. package/src/core/components/menu/menu.tsx +5 -1
  17. package/src/core/components/menu/menuButton.tsx +17 -32
  18. package/src/core/components/menu/menuGroup.tsx +7 -5
  19. package/src/core/components/menu/menuItem.tsx +10 -6
  20. package/src/core/components/skeleton/skeleton.tsx +5 -11
  21. package/src/core/components/skeleton/textSkeleton.tsx +6 -7
  22. package/src/core/components/toast/toastProvider.tsx +26 -24
  23. package/src/core/components/tree/treeItem.styles.ts +21 -0
  24. package/src/core/components/tree/treeItem.tsx +31 -44
  25. package/src/core/hooks/useArrayProp.ts +11 -10
  26. package/src/core/primitives/avatar/avatar.tsx +11 -15
  27. package/src/core/primitives/avatar/avatarCounter.tsx +11 -17
  28. package/src/core/primitives/avatar/avatarStack.tsx +3 -7
  29. package/src/core/primitives/badge/badge.tsx +7 -4
  30. package/src/core/primitives/box/box.tsx +53 -27
  31. package/src/core/primitives/button/button.tsx +11 -12
  32. package/src/core/primitives/card/card.tsx +17 -9
  33. package/src/core/primitives/code/code.tsx +4 -3
  34. package/src/core/primitives/container/container.tsx +4 -11
  35. package/src/core/primitives/flex/flex.tsx +13 -7
  36. package/src/core/primitives/grid/grid.tsx +19 -10
  37. package/src/core/primitives/heading/heading.tsx +7 -4
  38. package/src/core/primitives/inline/inline.tsx +3 -2
  39. package/src/core/primitives/kbd/kbd.tsx +4 -3
  40. package/src/core/primitives/label/label.tsx +7 -4
  41. package/src/core/primitives/popover/popover.tsx +49 -49
  42. package/src/core/primitives/select/select.tsx +12 -6
  43. package/src/core/primitives/stack/stack.tsx +4 -3
  44. package/src/core/primitives/text/text.tsx +7 -4
  45. package/src/core/primitives/textArea/textArea.tsx +12 -6
  46. package/src/core/primitives/textInput/textInput.tsx +6 -5
  47. package/src/core/primitives/tooltip/tooltip.tsx +14 -7
  48. package/src/core/theme/themeProvider.tsx +4 -6
  49. package/src/core/utils/elementQuery/elementQuery.tsx +4 -3
  50. package/src/core/utils/layer/getLayerContext.test.ts +0 -4
  51. package/src/core/utils/layer/layer.test.tsx +0 -2
  52. package/src/core/utils/layer/layerProvider.tsx +35 -43
  53. package/src/core/utils/layer/types.ts +0 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var theme = require("@sanity/ui/theme"), jsxRuntime = require("react/jsx-runtime"), react = require("react"), ReactIs = require("react-is"), styledComponents = require("styled-components"), icons = require("@sanity/icons"), Refractor = require("react-refractor"), reactDom$1 = require("@floating-ui/react-dom"), framerMotion = require("framer-motion"), reactDom = require("react-dom");
3
+ var theme = require("@sanity/ui/theme"), jsxRuntime = require("react/jsx-runtime"), react = require("react"), reactIs = require("react-is"), styledComponents = require("styled-components"), icons = require("@sanity/icons"), Refractor = require("react-refractor"), reactDom$1 = require("@floating-ui/react-dom"), framerMotion = require("framer-motion"), reactDom = require("react-dom");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
7
- var ReactIs__default = /* @__PURE__ */ _interopDefaultCompat(ReactIs), Refractor__default = /* @__PURE__ */ _interopDefaultCompat(Refractor);
7
+ var Refractor__default = /* @__PURE__ */ _interopDefaultCompat(Refractor);
8
8
  const createColorTheme = theme.createColorTheme, hexToRgb = theme.hexToRgb, hslToRgb = theme.hslToRgb, multiply = theme.multiply, parseColor = theme.parseColor, rgbToHex = theme.rgbToHex, rgbToHsl = theme.rgbToHsl, rgba = theme.rgba, screen = theme.screen, studioTheme = theme.buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = "--motion-content-opacity", POPOVER_MOTION_PROPS = {
9
9
  initial: {
10
10
  opacity: 0.5,
@@ -117,617 +117,141 @@ function responsiveTextAlignStyle(props) {
117
117
  function responsiveTextFont(props) {
118
118
  return responsiveFont("text", props);
119
119
  }
120
- function useArrayProp(val, defaultVal) {
121
- const __perf_hash__ = react.useMemo(() => JSON.stringify(val != null ? val : defaultVal), [defaultVal, val]);
122
- return react.useMemo(
123
- () => _getArrayProp(val, defaultVal),
124
- // Improve performance: Keep object identify for a given hash of the value
125
- // eslint-disable-next-line react-hooks/exhaustive-deps
126
- [__perf_hash__]
120
+ function getGlobalScope() {
121
+ if (typeof globalThis < "u") return globalThis;
122
+ if (typeof window < "u") return window;
123
+ if (typeof self < "u") return self;
124
+ if (typeof global < "u") return global;
125
+ throw new Error("@sanity/ui: could not locate global scope");
126
+ }
127
+ const globalScope = getGlobalScope();
128
+ function createGlobalScopedContext(key2, defaultValue) {
129
+ return typeof document > "u" ? react.createContext(defaultValue) : (globalScope[key2] = globalScope[key2] || react.createContext(defaultValue), globalScope[key2]);
130
+ }
131
+ const key$8 = Symbol.for("@sanity/ui/context/theme"), ThemeContext = createGlobalScopedContext(key$8, null);
132
+ function ThemeProvider(props) {
133
+ var _a, _b, _c;
134
+ const { children } = props, parentTheme = react.useContext(ThemeContext), scheme = (_a = props.scheme) != null ? _a : (parentTheme == null ? void 0 : parentTheme.scheme) || "light", rootTheme = (_b = props.theme) != null ? _b : (parentTheme == null ? void 0 : parentTheme.theme) || null, tone = (_c = props.tone) != null ? _c : (parentTheme == null ? void 0 : parentTheme.tone) || "default", themeContext = react.useMemo(() => rootTheme ? {
135
+ version: 0,
136
+ theme: rootTheme,
137
+ scheme,
138
+ tone
139
+ } : null, [rootTheme, scheme, tone]), theme$1 = react.useMemo(() => rootTheme ? theme.getScopedTheme(rootTheme, scheme, tone) : null, [scheme, rootTheme, tone]);
140
+ return theme$1 ? /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: themeContext, children: /* @__PURE__ */ jsxRuntime.jsx(styledComponents.ThemeProvider, { theme: theme$1, children }) }) : /* @__PURE__ */ jsxRuntime.jsx("pre", { children: 'ThemeProvider: no "theme" property provided' });
141
+ }
142
+ function useRootTheme() {
143
+ const value = react.useContext(ThemeContext);
144
+ if (!value)
145
+ throw new Error("useRootTheme(): missing context value");
146
+ return value;
147
+ }
148
+ function ThemeColorProvider(props) {
149
+ const { children, scheme, tone } = props, root = useRootTheme();
150
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { scheme: scheme || root.scheme, theme: root.theme, tone, children });
151
+ }
152
+ function useTheme() {
153
+ return styledComponents.useTheme();
154
+ }
155
+ function useTheme_v2() {
156
+ return theme.getTheme_v2(styledComponents.useTheme());
157
+ }
158
+ function responsiveBorderStyle() {
159
+ return [border, borderTop, borderRight, borderBottom, borderLeft];
160
+ }
161
+ function border(props) {
162
+ var _a, _b;
163
+ const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
164
+ return _responsive(
165
+ media,
166
+ props.$border,
167
+ (value) => value ? { "&&": { border: borderStyle } } : { "&&": { border: 0 } }
127
168
  );
128
169
  }
129
- function _getElements(element, elementsArg) {
130
- const ret = [element];
131
- for (const el of elementsArg)
132
- Array.isArray(el) ? ret.push(...el) : ret.push(el);
133
- return ret.filter(Boolean);
170
+ function borderTop(props) {
171
+ var _a, _b;
172
+ const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
173
+ return _responsive(
174
+ media,
175
+ props.$borderTop,
176
+ (value) => value ? { "&&": { borderTop: borderStyle } } : { "&&": { borderTop: 0 } }
177
+ );
134
178
  }
135
- function useClickOutside(listener, elementsArg = EMPTY_ARRAY, boundaryElement) {
136
- const [element, setElement] = react.useState(null), [elements, setElements] = react.useState(() => _getElements(element, elementsArg)), elementsRef = react.useRef(elements);
137
- return react.useEffect(() => {
138
- const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg);
139
- if (prevElements.length !== nextElements.length) {
140
- setElements(nextElements), elementsRef.current = nextElements;
141
- return;
142
- }
143
- for (const el of prevElements)
144
- if (!nextElements.includes(el)) {
145
- setElements(nextElements), elementsRef.current = nextElements;
146
- return;
147
- }
148
- for (const el of nextElements)
149
- if (!prevElements.includes(el)) {
150
- setElements(nextElements), elementsRef.current = nextElements;
151
- return;
152
- }
153
- }, [element, elementsArg]), react.useEffect(() => {
154
- if (!listener) return;
155
- const handleWindowMouseDown = (evt) => {
156
- const target = evt.target;
157
- if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) {
158
- for (const el of elements)
159
- if (target === el || el.contains(target))
160
- return;
161
- listener(evt);
162
- }
163
- };
164
- return window.addEventListener("mousedown", handleWindowMouseDown), () => {
165
- window.removeEventListener("mousedown", handleWindowMouseDown);
166
- };
167
- }, [boundaryElement, listener, elements]), setElement;
179
+ function borderRight(props) {
180
+ var _a, _b;
181
+ const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
182
+ return _responsive(
183
+ media,
184
+ props.$borderRight,
185
+ (value) => value ? { "&&": { borderRight: borderStyle } } : { "&&": { borderRight: 0 } }
186
+ );
168
187
  }
169
- var resizeObservers = [], hasActiveObservations = function() {
170
- return resizeObservers.some(function(ro) {
171
- return ro.activeTargets.length > 0;
172
- });
173
- }, hasSkippedObservations = function() {
174
- return resizeObservers.some(function(ro) {
175
- return ro.skippedTargets.length > 0;
176
- });
177
- }, msg = "ResizeObserver loop completed with undelivered notifications.", deliverResizeLoopError = function() {
178
- var event;
179
- typeof ErrorEvent == "function" ? event = new ErrorEvent("error", {
180
- message: msg
181
- }) : (event = document.createEvent("Event"), event.initEvent("error", !1, !1), event.message = msg), window.dispatchEvent(event);
182
- }, ResizeObserverBoxOptions;
183
- (function(ResizeObserverBoxOptions2) {
184
- ResizeObserverBoxOptions2.BORDER_BOX = "border-box", ResizeObserverBoxOptions2.CONTENT_BOX = "content-box", ResizeObserverBoxOptions2.DEVICE_PIXEL_CONTENT_BOX = "device-pixel-content-box";
185
- })(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
186
- var freeze = function(obj) {
187
- return Object.freeze(obj);
188
- }, ResizeObserverSize = /* @__PURE__ */ function() {
189
- function ResizeObserverSize2(inlineSize, blockSize) {
190
- this.inlineSize = inlineSize, this.blockSize = blockSize, freeze(this);
191
- }
192
- return ResizeObserverSize2;
193
- }(), DOMRectReadOnly = function() {
194
- function DOMRectReadOnly2(x, y, width, height) {
195
- return this.x = x, this.y = y, this.width = width, this.height = height, this.top = this.y, this.left = this.x, this.bottom = this.top + this.height, this.right = this.left + this.width, freeze(this);
196
- }
197
- return DOMRectReadOnly2.prototype.toJSON = function() {
198
- var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
199
- return { x, y, top, right, bottom, left, width, height };
200
- }, DOMRectReadOnly2.fromRect = function(rectangle) {
201
- return new DOMRectReadOnly2(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
202
- }, DOMRectReadOnly2;
203
- }(), isSVG = function(target) {
204
- return target instanceof SVGElement && "getBBox" in target;
205
- }, isHidden = function(target) {
206
- if (isSVG(target)) {
207
- var _a = target.getBBox(), width = _a.width, height = _a.height;
208
- return !width && !height;
188
+ function borderBottom(props) {
189
+ var _a, _b;
190
+ const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
191
+ return _responsive(
192
+ media,
193
+ props.$borderBottom,
194
+ (value) => value ? { "&&": { borderBottom: borderStyle } } : { "&&": { borderBottom: 0 } }
195
+ );
196
+ }
197
+ function borderLeft(props) {
198
+ var _a, _b;
199
+ const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
200
+ return _responsive(
201
+ media,
202
+ props.$borderLeft,
203
+ (value) => value ? { "&&": { borderLeft: borderStyle } } : { "&&": { borderLeft: 0 } }
204
+ );
205
+ }
206
+ const BASE_STYLE$4 = {
207
+ '&[data-as="ul"],&[data-as="ol"]': {
208
+ listStyle: "none"
209
209
  }
210
- var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
211
- return !(offsetWidth || offsetHeight || target.getClientRects().length);
212
- }, isElement = function(obj) {
213
- var _a;
214
- if (obj instanceof Element)
215
- return !0;
216
- var scope = (_a = obj == null ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
217
- return !!(scope && obj instanceof scope.Element);
218
- }, isReplacedElement = function(target) {
219
- switch (target.tagName) {
220
- case "INPUT":
221
- if (target.type !== "image")
222
- break;
223
- case "VIDEO":
224
- case "AUDIO":
225
- case "EMBED":
226
- case "OBJECT":
227
- case "CANVAS":
228
- case "IFRAME":
229
- case "IMG":
230
- return !0;
231
- }
232
- return !1;
233
- }, global$1 = typeof window < "u" ? window : {}, cache = /* @__PURE__ */ new WeakMap(), scrollRegexp = /auto|scroll/, verticalRegexp = /^tb|vertical/, IE = /msie|trident/i.test(global$1.navigator && global$1.navigator.userAgent), parseDimension = function(pixel) {
234
- return parseFloat(pixel || "0");
235
- }, size$1 = function(inlineSize, blockSize, switchSizes) {
236
- return inlineSize === void 0 && (inlineSize = 0), blockSize === void 0 && (blockSize = 0), switchSizes === void 0 && (switchSizes = !1), new ResizeObserverSize((switchSizes ? blockSize : inlineSize) || 0, (switchSizes ? inlineSize : blockSize) || 0);
237
- }, zeroBoxes = freeze({
238
- devicePixelContentBoxSize: size$1(),
239
- borderBoxSize: size$1(),
240
- contentBoxSize: size$1(),
241
- contentRect: new DOMRectReadOnly(0, 0, 0, 0)
242
- }), calculateBoxSizes = function(target, forceRecalculation) {
243
- if (forceRecalculation === void 0 && (forceRecalculation = !1), cache.has(target) && !forceRecalculation)
244
- return cache.get(target);
245
- if (isHidden(target))
246
- return cache.set(target, zeroBoxes), zeroBoxes;
247
- var cs = getComputedStyle(target), svg = isSVG(target) && target.ownerSVGElement && target.getBBox(), removePadding = !IE && cs.boxSizing === "border-box", switchSizes = verticalRegexp.test(cs.writingMode || ""), canScrollVertically = !svg && scrollRegexp.test(cs.overflowY || ""), canScrollHorizontally = !svg && scrollRegexp.test(cs.overflowX || ""), paddingTop = svg ? 0 : parseDimension(cs.paddingTop), paddingRight = svg ? 0 : parseDimension(cs.paddingRight), paddingBottom = svg ? 0 : parseDimension(cs.paddingBottom), paddingLeft = svg ? 0 : parseDimension(cs.paddingLeft), borderTop2 = svg ? 0 : parseDimension(cs.borderTopWidth), borderRight2 = svg ? 0 : parseDimension(cs.borderRightWidth), borderBottom2 = svg ? 0 : parseDimension(cs.borderBottomWidth), borderLeft2 = svg ? 0 : parseDimension(cs.borderLeftWidth), horizontalPadding = paddingLeft + paddingRight, verticalPadding = paddingTop + paddingBottom, horizontalBorderArea = borderLeft2 + borderRight2, verticalBorderArea = borderTop2 + borderBottom2, horizontalScrollbarThickness = canScrollHorizontally ? target.offsetHeight - verticalBorderArea - target.clientHeight : 0, verticalScrollbarThickness = canScrollVertically ? target.offsetWidth - horizontalBorderArea - target.clientWidth : 0, widthReduction = removePadding ? horizontalPadding + horizontalBorderArea : 0, heightReduction = removePadding ? verticalPadding + verticalBorderArea : 0, contentWidth = svg ? svg.width : parseDimension(cs.width) - widthReduction - verticalScrollbarThickness, contentHeight = svg ? svg.height : parseDimension(cs.height) - heightReduction - horizontalScrollbarThickness, borderBoxWidth = contentWidth + horizontalPadding + verticalScrollbarThickness + horizontalBorderArea, borderBoxHeight = contentHeight + verticalPadding + horizontalScrollbarThickness + verticalBorderArea, boxes = freeze({
248
- devicePixelContentBoxSize: size$1(Math.round(contentWidth * devicePixelRatio), Math.round(contentHeight * devicePixelRatio), switchSizes),
249
- borderBoxSize: size$1(borderBoxWidth, borderBoxHeight, switchSizes),
250
- contentBoxSize: size$1(contentWidth, contentHeight, switchSizes),
251
- contentRect: new DOMRectReadOnly(paddingLeft, paddingTop, contentWidth, contentHeight)
252
- });
253
- return cache.set(target, boxes), boxes;
254
- }, calculateBoxSize = function(target, observedBox, forceRecalculation) {
255
- var _a = calculateBoxSizes(target, forceRecalculation), borderBoxSize = _a.borderBoxSize, contentBoxSize = _a.contentBoxSize, devicePixelContentBoxSize = _a.devicePixelContentBoxSize;
256
- switch (observedBox) {
257
- case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:
258
- return devicePixelContentBoxSize;
259
- case ResizeObserverBoxOptions.BORDER_BOX:
260
- return borderBoxSize;
261
- default:
262
- return contentBoxSize;
263
- }
264
- }, ResizeObserverEntry = /* @__PURE__ */ function() {
265
- function ResizeObserverEntry2(target) {
266
- var boxes = calculateBoxSizes(target);
267
- this.target = target, this.contentRect = boxes.contentRect, this.borderBoxSize = freeze([boxes.borderBoxSize]), this.contentBoxSize = freeze([boxes.contentBoxSize]), this.devicePixelContentBoxSize = freeze([boxes.devicePixelContentBoxSize]);
268
- }
269
- return ResizeObserverEntry2;
270
- }(), calculateDepthForNode = function(node) {
271
- if (isHidden(node))
272
- return 1 / 0;
273
- for (var depth = 0, parent = node.parentNode; parent; )
274
- depth += 1, parent = parent.parentNode;
275
- return depth;
276
- }, broadcastActiveObservations = function() {
277
- var shallowestDepth = 1 / 0, callbacks2 = [];
278
- resizeObservers.forEach(function(ro) {
279
- if (ro.activeTargets.length !== 0) {
280
- var entries = [];
281
- ro.activeTargets.forEach(function(ot) {
282
- var entry = new ResizeObserverEntry(ot.target), targetDepth = calculateDepthForNode(ot.target);
283
- entries.push(entry), ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox), targetDepth < shallowestDepth && (shallowestDepth = targetDepth);
284
- }), callbacks2.push(function() {
285
- ro.callback.call(ro.observer, entries, ro.observer);
286
- }), ro.activeTargets.splice(0, ro.activeTargets.length);
287
- }
288
- });
289
- for (var _i = 0, callbacks_1 = callbacks2; _i < callbacks_1.length; _i++) {
290
- var callback = callbacks_1[_i];
291
- callback();
292
- }
293
- return shallowestDepth;
294
- }, gatherActiveObservationsAtDepth = function(depth) {
295
- resizeObservers.forEach(function(ro) {
296
- ro.activeTargets.splice(0, ro.activeTargets.length), ro.skippedTargets.splice(0, ro.skippedTargets.length), ro.observationTargets.forEach(function(ot) {
297
- ot.isActive() && (calculateDepthForNode(ot.target) > depth ? ro.activeTargets.push(ot) : ro.skippedTargets.push(ot));
298
- });
299
- });
300
- }, process = function() {
301
- var depth = 0;
302
- for (gatherActiveObservationsAtDepth(depth); hasActiveObservations(); )
303
- depth = broadcastActiveObservations(), gatherActiveObservationsAtDepth(depth);
304
- return hasSkippedObservations() && deliverResizeLoopError(), depth > 0;
305
- }, trigger, callbacks = [], notify = function() {
306
- return callbacks.splice(0).forEach(function(cb) {
307
- return cb();
308
- });
309
- }, queueMicroTask = function(callback) {
310
- if (!trigger) {
311
- var toggle_1 = 0, el_1 = document.createTextNode(""), config = { characterData: !0 };
312
- new MutationObserver(function() {
313
- return notify();
314
- }).observe(el_1, config), trigger = function() {
315
- el_1.textContent = "".concat(toggle_1 ? toggle_1-- : toggle_1++);
316
- };
317
- }
318
- callbacks.push(callback), trigger();
319
- }, queueResizeObserver = function(cb) {
320
- queueMicroTask(function() {
321
- requestAnimationFrame(cb);
322
- });
323
- }, watching = 0, isWatching = function() {
324
- return !!watching;
325
- }, CATCH_PERIOD = 250, observerConfig = { attributes: !0, characterData: !0, childList: !0, subtree: !0 }, events = [
326
- "resize",
327
- "load",
328
- "transitionend",
329
- "animationend",
330
- "animationstart",
331
- "animationiteration",
332
- "keyup",
333
- "keydown",
334
- "mouseup",
335
- "mousedown",
336
- "mouseover",
337
- "mouseout",
338
- "blur",
339
- "focus"
340
- ], time = function(timeout) {
341
- return timeout === void 0 && (timeout = 0), Date.now() + timeout;
342
- }, scheduled = !1, Scheduler = function() {
343
- function Scheduler2() {
344
- var _this = this;
345
- this.stopped = !0, this.listener = function() {
346
- return _this.schedule();
347
- };
348
- }
349
- return Scheduler2.prototype.run = function(timeout) {
350
- var _this = this;
351
- if (timeout === void 0 && (timeout = CATCH_PERIOD), !scheduled) {
352
- scheduled = !0;
353
- var until = time(timeout);
354
- queueResizeObserver(function() {
355
- var elementsHaveResized = !1;
356
- try {
357
- elementsHaveResized = process();
358
- } finally {
359
- if (scheduled = !1, timeout = until - time(), !isWatching())
360
- return;
361
- elementsHaveResized ? _this.run(1e3) : timeout > 0 ? _this.run(timeout) : _this.start();
362
- }
363
- });
364
- }
365
- }, Scheduler2.prototype.schedule = function() {
366
- this.stop(), this.run();
367
- }, Scheduler2.prototype.observe = function() {
368
- var _this = this, cb = function() {
369
- return _this.observer && _this.observer.observe(document.body, observerConfig);
370
- };
371
- document.body ? cb() : global$1.addEventListener("DOMContentLoaded", cb);
372
- }, Scheduler2.prototype.start = function() {
373
- var _this = this;
374
- this.stopped && (this.stopped = !1, this.observer = new MutationObserver(this.listener), this.observe(), events.forEach(function(name) {
375
- return global$1.addEventListener(name, _this.listener, !0);
376
- }));
377
- }, Scheduler2.prototype.stop = function() {
378
- var _this = this;
379
- this.stopped || (this.observer && this.observer.disconnect(), events.forEach(function(name) {
380
- return global$1.removeEventListener(name, _this.listener, !0);
381
- }), this.stopped = !0);
382
- }, Scheduler2;
383
- }(), scheduler = new Scheduler(), updateCount = function(n) {
384
- !watching && n > 0 && scheduler.start(), watching += n, !watching && scheduler.stop();
385
- }, skipNotifyOnElement = function(target) {
386
- return !isSVG(target) && !isReplacedElement(target) && getComputedStyle(target).display === "inline";
387
- }, ResizeObservation = function() {
388
- function ResizeObservation2(target, observedBox) {
389
- this.target = target, this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX, this.lastReportedSize = {
390
- inlineSize: 0,
391
- blockSize: 0
392
- };
393
- }
394
- return ResizeObservation2.prototype.isActive = function() {
395
- var size2 = calculateBoxSize(this.target, this.observedBox, !0);
396
- return skipNotifyOnElement(this.target) && (this.lastReportedSize = size2), this.lastReportedSize.inlineSize !== size2.inlineSize || this.lastReportedSize.blockSize !== size2.blockSize;
397
- }, ResizeObservation2;
398
- }(), ResizeObserverDetail = /* @__PURE__ */ function() {
399
- function ResizeObserverDetail2(resizeObserver, callback) {
400
- this.activeTargets = [], this.skippedTargets = [], this.observationTargets = [], this.observer = resizeObserver, this.callback = callback;
401
- }
402
- return ResizeObserverDetail2;
403
- }(), observerMap = /* @__PURE__ */ new WeakMap(), getObservationIndex = function(observationTargets, target) {
404
- for (var i = 0; i < observationTargets.length; i += 1)
405
- if (observationTargets[i].target === target)
406
- return i;
407
- return -1;
408
- }, ResizeObserverController = function() {
409
- function ResizeObserverController2() {
410
- }
411
- return ResizeObserverController2.connect = function(resizeObserver, callback) {
412
- var detail = new ResizeObserverDetail(resizeObserver, callback);
413
- observerMap.set(resizeObserver, detail);
414
- }, ResizeObserverController2.observe = function(resizeObserver, target, options) {
415
- var detail = observerMap.get(resizeObserver), firstObservation = detail.observationTargets.length === 0;
416
- getObservationIndex(detail.observationTargets, target) < 0 && (firstObservation && resizeObservers.push(detail), detail.observationTargets.push(new ResizeObservation(target, options && options.box)), updateCount(1), scheduler.schedule());
417
- }, ResizeObserverController2.unobserve = function(resizeObserver, target) {
418
- var detail = observerMap.get(resizeObserver), index = getObservationIndex(detail.observationTargets, target), lastObservation = detail.observationTargets.length === 1;
419
- index >= 0 && (lastObservation && resizeObservers.splice(resizeObservers.indexOf(detail), 1), detail.observationTargets.splice(index, 1), updateCount(-1));
420
- }, ResizeObserverController2.disconnect = function(resizeObserver) {
421
- var _this = this, detail = observerMap.get(resizeObserver);
422
- detail.observationTargets.slice().forEach(function(ot) {
423
- return _this.unobserve(resizeObserver, ot.target);
424
- }), detail.activeTargets.splice(0, detail.activeTargets.length);
425
- }, ResizeObserverController2;
426
- }(), ResizeObserver = function() {
427
- function ResizeObserver2(callback) {
428
- if (arguments.length === 0)
429
- throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
430
- if (typeof callback != "function")
431
- throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
432
- ResizeObserverController.connect(this, callback);
433
- }
434
- return ResizeObserver2.prototype.observe = function(target, options) {
435
- if (arguments.length === 0)
436
- throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
437
- if (!isElement(target))
438
- throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
439
- ResizeObserverController.observe(this, target, options);
440
- }, ResizeObserver2.prototype.unobserve = function(target) {
441
- if (arguments.length === 0)
442
- throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
443
- if (!isElement(target))
444
- throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
445
- ResizeObserverController.unobserve(this, target);
446
- }, ResizeObserver2.prototype.disconnect = function() {
447
- ResizeObserverController.disconnect(this);
448
- }, ResizeObserver2.toString = function() {
449
- return "function ResizeObserver () { [polyfill code] }";
450
- }, ResizeObserver2;
451
- }();
452
- const _ResizeObserver = typeof document < "u" && typeof window < "u" && window.ResizeObserver ? window.ResizeObserver : ResizeObserver, _elementSizeObserver = _createElementSizeObserver();
453
- function _createElementRectValueListener() {
454
- return {
455
- subscribe(element, subscriber) {
456
- const resizeObserver = new _ResizeObserver(([entry]) => {
457
- subscriber({
458
- _contentRect: entry.contentRect,
459
- border: {
460
- width: entry.borderBoxSize[0].inlineSize,
461
- height: entry.borderBoxSize[0].blockSize
462
- },
463
- content: {
464
- width: entry.contentRect.width,
465
- height: entry.contentRect.height
466
- }
467
- });
468
- });
469
- return resizeObserver.observe(element), () => {
470
- resizeObserver.unobserve(element), resizeObserver.disconnect();
471
- };
472
- }
473
- };
474
- }
475
- function _createElementSizeObserver() {
476
- const disposeCache = /* @__PURE__ */ new WeakMap(), subscribersCache = /* @__PURE__ */ new WeakMap();
477
- return {
478
- subscribe(element, subscriber) {
479
- const subscribers = subscribersCache.get(element) || [];
480
- let dispose = disposeCache.get(element);
481
- return subscribersCache.has(element) || (subscribersCache.set(element, subscribers), dispose = _createElementRectValueListener().subscribe(element, (elementRect) => {
482
- for (const sub of subscribers)
483
- sub(elementRect);
484
- })), subscribers.push(subscriber), () => {
485
- const idx = subscribers.indexOf(subscriber);
486
- idx > -1 && subscribers.splice(idx, 1), subscribers.length === 0 && dispose && dispose();
487
- };
488
- }
489
- };
490
- }
491
- function useElementSize(element) {
492
- const [size2, setSize] = react.useState(null);
493
- return react.useEffect(() => {
494
- if (element)
495
- return _elementSizeObserver.subscribe(element, setSize);
496
- }, [element]), size2;
497
- }
498
- function useElementRect(element) {
499
- const elementSize = useElementSize(element);
500
- return (elementSize == null ? void 0 : elementSize._contentRect) || null;
501
- }
502
- function useGlobalKeyDown(onKeyDown) {
503
- return react.useEffect(() => (addEventListener("keydown", onKeyDown), () => removeEventListener("keydown", onKeyDown)), [onKeyDown]);
504
- }
505
- function getGlobalScope() {
506
- if (typeof globalThis < "u") return globalThis;
507
- if (typeof window < "u") return window;
508
- if (typeof self < "u") return self;
509
- if (typeof global < "u") return global;
510
- throw new Error("@sanity/ui: could not locate global scope");
511
- }
512
- const globalScope = getGlobalScope();
513
- function createGlobalScopedContext(key2, defaultValue) {
514
- return typeof document > "u" ? react.createContext(defaultValue) : (globalScope[key2] = globalScope[key2] || react.createContext(defaultValue), globalScope[key2]);
515
- }
516
- const key$8 = Symbol.for("@sanity/ui/context/theme"), ThemeContext = createGlobalScopedContext(key$8, null);
517
- function ThemeProvider(props) {
518
- const parentTheme = react.useContext(ThemeContext), {
519
- children,
520
- scheme = (parentTheme == null ? void 0 : parentTheme.scheme) || "light",
521
- theme: rootTheme = (parentTheme == null ? void 0 : parentTheme.theme) || null,
522
- tone = (parentTheme == null ? void 0 : parentTheme.tone) || "default"
523
- } = props, themeContext = react.useMemo(() => rootTheme ? {
524
- version: 0,
525
- theme: rootTheme,
526
- scheme,
527
- tone
528
- } : null, [rootTheme, scheme, tone]), theme$1 = react.useMemo(() => rootTheme ? theme.getScopedTheme(rootTheme, scheme, tone) : null, [scheme, rootTheme, tone]);
529
- return theme$1 ? /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: themeContext, children: /* @__PURE__ */ jsxRuntime.jsx(styledComponents.ThemeProvider, { theme: theme$1, children }) }) : /* @__PURE__ */ jsxRuntime.jsx("pre", { children: 'ThemeProvider: no "theme" property provided' });
530
- }
531
- function useRootTheme() {
532
- const value = react.useContext(ThemeContext);
533
- if (!value)
534
- throw new Error("useRootTheme(): missing context value");
535
- return value;
536
- }
537
- function ThemeColorProvider(props) {
538
- const { children, scheme, tone } = props, root = useRootTheme();
539
- return /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { scheme: scheme || root.scheme, theme: root.theme, tone, children });
540
- }
541
- function useTheme() {
542
- return styledComponents.useTheme();
543
- }
544
- function useTheme_v2() {
545
- return theme.getTheme_v2(styledComponents.useTheme());
546
- }
547
- const MEDIA_STORE_CACHE = /* @__PURE__ */ new WeakMap();
548
- function _getMediaQuery(media, index) {
549
- return index === 0 ? `screen and (max-width: ${media[index] - 1}px)` : index === media.length ? `screen and (min-width: ${media[index - 1]}px)` : `screen and (min-width: ${media[index - 1]}px) and (max-width: ${media[index] - 1}px)`;
550
- }
551
- function _createMediaStore(media) {
552
- const mediaLen = media.length;
553
- let sizes;
554
- const getSizes = () => {
555
- if (!sizes) {
556
- sizes = [];
557
- for (let index = mediaLen; index > -1; index -= 1) {
558
- const mediaQuery = _getMediaQuery(media, index);
559
- sizes.push({ index, mq: window.matchMedia(mediaQuery) });
560
- }
561
- }
562
- return sizes;
563
- };
564
- return { getSnapshot: () => {
565
- for (const { index, mq } of getSizes())
566
- if (mq.matches) return index;
567
- return 0;
568
- }, subscribe: (onStoreChange) => {
569
- const disposeFns = [];
570
- for (const { mq } of getSizes()) {
571
- const handleChange = () => {
572
- mq.matches && onStoreChange();
573
- };
574
- mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
575
- }
576
- return () => {
577
- for (const disposeFn of disposeFns)
578
- disposeFn();
579
- };
580
- } };
581
- }
582
- function getServerSnapshot$2() {
583
- return 0;
584
- }
585
- function useMediaIndex() {
586
- const { media } = useTheme_v2();
587
- let store = MEDIA_STORE_CACHE.get(media);
588
- return store || (store = _createMediaStore(media), MEDIA_STORE_CACHE.set(media, store)), react.useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot$2);
589
- }
590
- let MEDIA_QUERY_CACHE$1;
591
- function getMatchMedia$1() {
592
- return MEDIA_QUERY_CACHE$1 || (MEDIA_QUERY_CACHE$1 = window.matchMedia("(prefers-color-scheme: dark)")), MEDIA_QUERY_CACHE$1;
593
- }
594
- function subscribe$2(onStoreChange) {
595
- const matchMedia = getMatchMedia$1();
596
- return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
597
- }
598
- function getSnapshot$1() {
599
- return getMatchMedia$1().matches;
600
- }
601
- function getServerSnapshot$1() {
602
- return !1;
603
- }
604
- function usePrefersDark() {
605
- return react.useSyncExternalStore(subscribe$2, getSnapshot$1, getServerSnapshot$1);
606
- }
607
- let MEDIA_QUERY_CACHE;
608
- function getMatchMedia() {
609
- return MEDIA_QUERY_CACHE || (MEDIA_QUERY_CACHE = window.matchMedia("(prefers-reduced-motion: reduce)")), MEDIA_QUERY_CACHE;
610
- }
611
- function subscribe$1(onStoreChange) {
612
- const matchMedia = getMatchMedia();
613
- return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
614
- }
615
- function getSnapshot() {
616
- return getMatchMedia().matches;
617
- }
618
- function getServerSnapshot() {
619
- return !1;
620
- }
621
- function usePrefersReducedMotion() {
622
- return react.useSyncExternalStore(subscribe$1, getSnapshot, getServerSnapshot);
623
- }
624
- function useForwardedRef(ref) {
625
- const innerRef = react.useRef(null);
626
- return react.useImperativeHandle(ref, () => innerRef.current), innerRef;
627
- }
628
- function useCustomValidity(ref, customValidity) {
629
- react.useEffect(() => {
630
- var _a;
631
- (_a = ref.current) == null || _a.setCustomValidity(customValidity || "");
632
- }, [customValidity, ref]);
633
- }
634
- function responsiveBorderStyle() {
635
- return [border, borderTop, borderRight, borderBottom, borderLeft];
636
- }
637
- function border(props) {
638
- var _a, _b;
639
- const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
640
- return _responsive(
641
- media,
642
- props.$border,
643
- (value) => value ? { "&&": { border: borderStyle } } : { "&&": { border: 0 } }
644
- );
645
- }
646
- function borderTop(props) {
647
- var _a, _b;
648
- const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
649
- return _responsive(
650
- media,
651
- props.$borderTop,
652
- (value) => value ? { "&&": { borderTop: borderStyle } } : { "&&": { borderTop: 0 } }
653
- );
654
- }
655
- function borderRight(props) {
656
- var _a, _b;
657
- const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
658
- return _responsive(
659
- media,
660
- props.$borderRight,
661
- (value) => value ? { "&&": { borderRight: borderStyle } } : { "&&": { borderRight: 0 } }
662
- );
663
- }
664
- function borderBottom(props) {
665
- var _a, _b;
666
- const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
667
- return _responsive(
668
- media,
669
- props.$borderBottom,
670
- (value) => value ? { "&&": { borderBottom: borderStyle } } : { "&&": { borderBottom: 0 } }
671
- );
672
- }
673
- function borderLeft(props) {
674
- var _a, _b;
675
- const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
676
- return _responsive(
677
- media,
678
- props.$borderLeft,
679
- (value) => value ? { "&&": { borderLeft: borderStyle } } : { "&&": { borderLeft: 0 } }
680
- );
681
- }
682
- const BASE_STYLE$4 = {
683
- '&[data-as="ul"],&[data-as="ol"]': {
684
- listStyle: "none"
685
- }
686
- }, BOX_SIZING = {
687
- content: "content-box",
688
- border: "border-box"
689
- }, BOX_HEIGHT = {
690
- stretch: "stretch",
691
- fill: "100%"
692
- };
693
- function boxStyle() {
694
- return BASE_STYLE$4;
695
- }
696
- function responsiveBoxStyle() {
697
- return [
698
- responsiveBoxSizingStyle,
699
- responsiveBoxHeightStyle,
700
- responsiveBoxOverflowStyle,
701
- responsiveBoxDisplayStyle
702
- ];
703
- }
704
- function responsiveBoxDisplayStyle(props) {
705
- const { media } = theme.getTheme_v2(props.theme);
706
- return _responsive(media, props.$display, (display) => ({
707
- "&:not([hidden])": { display }
708
- }));
709
- }
710
- function responsiveBoxSizingStyle(props) {
711
- const { media } = theme.getTheme_v2(props.theme);
712
- return _responsive(media, props.$sizing, (sizing) => ({
713
- boxSizing: BOX_SIZING[sizing]
714
- }));
715
- }
716
- function responsiveBoxHeightStyle(props) {
717
- const { media } = theme.getTheme_v2(props.theme);
718
- return _responsive(media, props.$height, (height) => ({
719
- height: BOX_HEIGHT[height]
720
- }));
721
- }
722
- function responsiveBoxOverflowStyle(props) {
723
- const { media } = theme.getTheme_v2(props.theme);
724
- return _responsive(media, props.$overflow, (overflow) => ({
725
- overflow
726
- }));
727
- }
728
- const BASE_STYLE$3 = {
729
- "&&:not([hidden])": {
730
- display: "flex"
210
+ }, BOX_SIZING = {
211
+ content: "content-box",
212
+ border: "border-box"
213
+ }, BOX_HEIGHT = {
214
+ stretch: "stretch",
215
+ fill: "100%"
216
+ };
217
+ function boxStyle() {
218
+ return BASE_STYLE$4;
219
+ }
220
+ function responsiveBoxStyle() {
221
+ return [
222
+ responsiveBoxSizingStyle,
223
+ responsiveBoxHeightStyle,
224
+ responsiveBoxOverflowStyle,
225
+ responsiveBoxDisplayStyle
226
+ ];
227
+ }
228
+ function responsiveBoxDisplayStyle(props) {
229
+ const { media } = theme.getTheme_v2(props.theme);
230
+ return _responsive(media, props.$display, (display) => ({
231
+ "&:not([hidden])": { display }
232
+ }));
233
+ }
234
+ function responsiveBoxSizingStyle(props) {
235
+ const { media } = theme.getTheme_v2(props.theme);
236
+ return _responsive(media, props.$sizing, (sizing) => ({
237
+ boxSizing: BOX_SIZING[sizing]
238
+ }));
239
+ }
240
+ function responsiveBoxHeightStyle(props) {
241
+ const { media } = theme.getTheme_v2(props.theme);
242
+ return _responsive(media, props.$height, (height) => ({
243
+ height: BOX_HEIGHT[height]
244
+ }));
245
+ }
246
+ function responsiveBoxOverflowStyle(props) {
247
+ const { media } = theme.getTheme_v2(props.theme);
248
+ return _responsive(media, props.$overflow, (overflow) => ({
249
+ overflow
250
+ }));
251
+ }
252
+ const BASE_STYLE$3 = {
253
+ "&&:not([hidden])": {
254
+ display: "flex"
731
255
  }
732
256
  };
733
257
  function responsiveFlexStyle() {
@@ -1241,7 +765,7 @@ const Root$C = styledComponents.styled.div(responsiveLabelFont, responsiveTextAl
1241
765
  textOverflow,
1242
766
  weight,
1243
767
  ...restProps
1244
- } = props;
768
+ } = props, $size = react.useMemo(() => _getArrayProp(size2), [size2]), $align = react.useMemo(() => _getArrayProp(align), [align]);
1245
769
  let children = childrenProp;
1246
770
  return textOverflow === "ellipsis" ? children = /* @__PURE__ */ jsxRuntime.jsx(SpanWithTextOverflow$2, { children }) : children = /* @__PURE__ */ jsxRuntime.jsx("span", { children }), /* @__PURE__ */ jsxRuntime.jsx(
1247
771
  Root$C,
@@ -1249,9 +773,9 @@ const Root$C = styledComponents.styled.div(responsiveLabelFont, responsiveTextAl
1249
773
  "data-ui": "Label",
1250
774
  ...restProps,
1251
775
  $accent: accent,
1252
- $align: useArrayProp(align),
776
+ $align,
777
+ $size,
1253
778
  $muted: muted,
1254
- $size: useArrayProp(size2),
1255
779
  $weight: weight,
1256
780
  ref,
1257
781
  children
@@ -1410,7 +934,7 @@ const Root$B = styledComponents.styled.div(
1410
934
  status = "online",
1411
935
  size: sizeProp = 1,
1412
936
  ...restProps
1413
- } = props, { avatar } = useTheme_v2(), as = ReactIs__default.default.isValidElementType(asProp) ? asProp : "div", size2 = useArrayProp(sizeProp), _sizeRem = (avatar.sizes[size2[0]] || avatar.sizes[0]).size, _radius = _sizeRem / 2, elementId = react.useId(), [arrowPosition, setArrowPosition] = react.useState(
937
+ } = props, { avatar } = useTheme_v2(), as = reactIs.isValidElementType(asProp) ? asProp : "div", size2 = _getArrayProp(sizeProp), _sizeRem = (avatar.sizes[size2[0]] || avatar.sizes[0]).size, _radius = _sizeRem / 2, elementId = react.useId(), [arrowPosition, setArrowPosition] = react.useState(
1414
938
  animateArrowFrom || arrowPositionProp || "inside"
1415
939
  ), [imageFailed, setImageFailed] = react.useState(!1), imageId = `avatar-image-${elementId}`;
1416
940
  react.useEffect(() => {
@@ -1422,10 +946,7 @@ const Root$B = styledComponents.styled.div(
1422
946
  }, [src]);
1423
947
  const handleImageError = react.useCallback(() => {
1424
948
  setImageFailed(!0), onImageLoadError && onImageLoadError(new Error("Avatar: the image failed to load"));
1425
- }, [onImageLoadError]), initialsSize = react.useMemo(
1426
- () => size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0),
1427
- [size2]
1428
- );
949
+ }, [onImageLoadError]), initialsSize = size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0);
1429
950
  return /* @__PURE__ */ jsxRuntime.jsxs(
1430
951
  Root$B,
1431
952
  {
@@ -1520,11 +1041,8 @@ const Root$A = styledComponents.styled.div(
1520
1041
  _responsiveAvatarCounterSizeStyle,
1521
1042
  _avatarCounterBaseStyle
1522
1043
  ), AvatarCounter = react.forwardRef(function(props, ref) {
1523
- const { count, size: sizeProp = 1 } = props, size2 = useArrayProp(sizeProp), fontSize2 = react.useMemo(
1524
- () => size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0),
1525
- [size2]
1526
- );
1527
- return /* @__PURE__ */ jsxRuntime.jsx(Root$A, { $size: size2, "data-ui": "AvatarCounter", ref, children: /* @__PURE__ */ jsxRuntime.jsx(Label, { as: "span", size: fontSize2, weight: "medium", children: count }) });
1044
+ const { count, size: size2 } = props, $size = _getArrayProp(size2 != null ? size2 : 1), fontSize2 = $size.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0);
1045
+ return /* @__PURE__ */ jsxRuntime.jsx(Root$A, { $size, "data-ui": "AvatarCounter", ref, children: /* @__PURE__ */ jsxRuntime.jsx(Label, { as: "span", size: fontSize2, weight: "medium", children: count }) });
1528
1046
  }), BASE_STYLES = styledComponents.css`
1529
1047
  white-space: nowrap;
1530
1048
 
@@ -1556,10 +1074,7 @@ const Root$z = styledComponents.styled.div(responsiveAvatarStackSizeStyle, avata
1556
1074
  maxLength: maxLengthProp = 4,
1557
1075
  size: sizeProp = 1,
1558
1076
  ...restProps
1559
- } = props, children = react.useMemo(
1560
- () => react.Children.toArray(childrenProp).filter(react.isValidElement),
1561
- [childrenProp]
1562
- ), maxLength = Math.max(maxLengthProp, 0), size2 = useArrayProp(sizeProp), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
1077
+ } = props, children = react.Children.toArray(childrenProp).filter(react.isValidElement), maxLength = Math.max(maxLengthProp, 0), size2 = react.useMemo(() => _getArrayProp(sizeProp), [sizeProp]), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
1563
1078
  return /* @__PURE__ */ jsxRuntime.jsxs(Root$z, { "data-ui": "AvatarStack", ...restProps, ref, $size: size2, children: [
1564
1079
  len === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(AvatarCounter, { count: len, size: size2 }) }),
1565
1080
  len !== 0 && extraCount > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(AvatarCounter, { count: extraCount, size: size2 }) }),
@@ -1601,38 +1116,38 @@ const Root$z = styledComponents.styled.div(responsiveAvatarStackSizeStyle, avata
1601
1116
  rowEnd,
1602
1117
  sizing,
1603
1118
  ...restProps
1604
- } = props;
1119
+ } = props, $column = react.useMemo(() => _getArrayProp(column), [column]), $columnStart = react.useMemo(() => _getArrayProp(columnStart), [columnStart]), $columnEnd = react.useMemo(() => _getArrayProp(columnEnd), [columnEnd]), $display = react.useMemo(() => _getArrayProp(display), [display]), $flex = react.useMemo(() => _getArrayProp(flex), [flex]), $height = react.useMemo(() => _getArrayProp(height), [height]), $margin = react.useMemo(() => _getArrayProp(margin), [margin]), $marginX = react.useMemo(() => _getArrayProp(marginX), [marginX]), $marginY = react.useMemo(() => _getArrayProp(marginY), [marginY]), $marginTop = react.useMemo(() => _getArrayProp(marginTop), [marginTop]), $marginRight = react.useMemo(() => _getArrayProp(marginRight), [marginRight]), $marginBottom = react.useMemo(() => _getArrayProp(marginBottom), [marginBottom]), $marginLeft = react.useMemo(() => _getArrayProp(marginLeft), [marginLeft]), $overflow = react.useMemo(() => _getArrayProp(overflow), [overflow]), $padding = react.useMemo(() => _getArrayProp(padding), [padding]), $paddingX = react.useMemo(() => _getArrayProp(paddingX), [paddingX]), $paddingY = react.useMemo(() => _getArrayProp(paddingY), [paddingY]), $paddingTop = react.useMemo(() => _getArrayProp(paddingTop), [paddingTop]), $paddingRight = react.useMemo(() => _getArrayProp(paddingRight), [paddingRight]), $paddingBottom = react.useMemo(() => _getArrayProp(paddingBottom), [paddingBottom]), $paddingLeft = react.useMemo(() => _getArrayProp(paddingLeft), [paddingLeft]), $row = react.useMemo(() => _getArrayProp(row), [row]), $rowStart = react.useMemo(() => _getArrayProp(rowStart), [rowStart]), $rowEnd = react.useMemo(() => _getArrayProp(rowEnd), [rowEnd]), $sizing = react.useMemo(() => _getArrayProp(sizing), [sizing]);
1605
1120
  return /* @__PURE__ */ jsxRuntime.jsx(
1606
1121
  Root$y,
1607
1122
  {
1608
1123
  "data-as": typeof asProp == "string" ? asProp : void 0,
1609
1124
  "data-ui": "Box",
1610
1125
  ...restProps,
1611
- $column: useArrayProp(column),
1612
- $columnStart: useArrayProp(columnStart),
1613
- $columnEnd: useArrayProp(columnEnd),
1614
- $display: useArrayProp(display),
1615
- $flex: useArrayProp(flex),
1616
- $height: useArrayProp(height),
1617
- $margin: useArrayProp(margin),
1618
- $marginX: useArrayProp(marginX),
1619
- $marginY: useArrayProp(marginY),
1620
- $marginTop: useArrayProp(marginTop),
1621
- $marginRight: useArrayProp(marginRight),
1622
- $marginBottom: useArrayProp(marginBottom),
1623
- $marginLeft: useArrayProp(marginLeft),
1624
- $overflow: useArrayProp(overflow),
1625
- $padding: useArrayProp(padding),
1626
- $paddingX: useArrayProp(paddingX),
1627
- $paddingY: useArrayProp(paddingY),
1628
- $paddingTop: useArrayProp(paddingTop),
1629
- $paddingRight: useArrayProp(paddingRight),
1630
- $paddingBottom: useArrayProp(paddingBottom),
1631
- $paddingLeft: useArrayProp(paddingLeft),
1632
- $row: useArrayProp(row),
1633
- $rowStart: useArrayProp(rowStart),
1634
- $rowEnd: useArrayProp(rowEnd),
1635
- $sizing: useArrayProp(sizing),
1126
+ $column,
1127
+ $columnStart,
1128
+ $columnEnd,
1129
+ $display,
1130
+ $flex,
1131
+ $height,
1132
+ $margin,
1133
+ $marginX,
1134
+ $marginY,
1135
+ $marginTop,
1136
+ $marginRight,
1137
+ $marginBottom,
1138
+ $marginLeft,
1139
+ $overflow,
1140
+ $padding,
1141
+ $paddingX,
1142
+ $paddingY,
1143
+ $paddingTop,
1144
+ $paddingRight,
1145
+ $paddingBottom,
1146
+ $paddingLeft,
1147
+ $row,
1148
+ $rowStart,
1149
+ $rowEnd,
1150
+ $sizing,
1636
1151
  as: asProp,
1637
1152
  ref,
1638
1153
  children: props.children
@@ -1722,7 +1237,7 @@ const Root$x = styledComponents.styled.div(
1722
1237
  textOverflow,
1723
1238
  weight,
1724
1239
  ...restProps
1725
- } = props;
1240
+ } = props, $size = react.useMemo(() => _getArrayProp(size2), [size2]), $align = react.useMemo(() => _getArrayProp(align), [align]);
1726
1241
  let children = childrenProp;
1727
1242
  return textOverflow === "ellipsis" && (children = /* @__PURE__ */ jsxRuntime.jsx(SpanWithTextOverflow$1, { children })), /* @__PURE__ */ jsxRuntime.jsx(
1728
1243
  Root$x,
@@ -1730,10 +1245,10 @@ const Root$x = styledComponents.styled.div(
1730
1245
  "data-ui": "Text",
1731
1246
  ...restProps,
1732
1247
  $accent: accent,
1733
- $align: useArrayProp(align),
1248
+ $align,
1249
+ $size,
1734
1250
  $muted: muted,
1735
1251
  ref,
1736
- $size: useArrayProp(size2),
1737
1252
  $weight: weight,
1738
1253
  children: /* @__PURE__ */ jsxRuntime.jsx("span", { children })
1739
1254
  }
@@ -1765,15 +1280,15 @@ const Root$w = styledComponents.styled(Box)(
1765
1280
  radius = "full",
1766
1281
  tone = "default",
1767
1282
  ...restProps
1768
- } = props;
1283
+ } = props, $radius = react.useMemo(() => _getArrayProp(radius), [radius]), $padding = react.useMemo(() => _getArrayProp(padding), [padding]);
1769
1284
  return /* @__PURE__ */ jsxRuntime.jsx(
1770
1285
  Root$w,
1771
1286
  {
1772
1287
  "data-ui": "Badge",
1773
1288
  ...restProps,
1774
1289
  $tone: tone,
1775
- $radius: useArrayProp(radius),
1776
- padding: useArrayProp(padding),
1290
+ $radius,
1291
+ padding: $padding,
1777
1292
  ref,
1778
1293
  children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, children })
1779
1294
  }
@@ -1782,17 +1297,17 @@ const Root$w = styledComponents.styled(Box)(
1782
1297
  flexItemStyle,
1783
1298
  responsiveFlexStyle
1784
1299
  ), Flex = react.forwardRef(function(props, ref) {
1785
- const { align, as, direction = "row", gap, justify, wrap, ...restProps } = props;
1300
+ const { align, as, direction = "row", gap, justify, wrap, ...restProps } = props, $align = react.useMemo(() => _getArrayProp(align), [align]), $direction = react.useMemo(() => _getArrayProp(direction), [direction]), $gap = react.useMemo(() => _getArrayProp(gap), [gap]), $justify = react.useMemo(() => _getArrayProp(justify), [justify]), $wrap = react.useMemo(() => _getArrayProp(wrap), [wrap]);
1786
1301
  return /* @__PURE__ */ jsxRuntime.jsx(
1787
1302
  Root$v,
1788
1303
  {
1789
1304
  "data-ui": "Flex",
1790
1305
  ...restProps,
1791
- $align: useArrayProp(align),
1792
- $direction: useArrayProp(direction),
1793
- $gap: useArrayProp(gap),
1794
- $justify: useArrayProp(justify),
1795
- $wrap: useArrayProp(wrap),
1306
+ $align,
1307
+ $direction,
1308
+ $gap,
1309
+ $justify,
1310
+ $wrap,
1796
1311
  forwardedAs: as,
1797
1312
  ref
1798
1313
  }
@@ -2010,7 +1525,7 @@ const Root$t = styledComponents.styled.button(responsiveRadiusStyle, buttonBaseS
2010
1525
  muted = !1,
2011
1526
  width,
2012
1527
  ...restProps
2013
- } = props, { button } = useTheme_v2(), justify = useArrayProp(justifyProp), padding = useArrayProp(paddingProp), paddingX = useArrayProp(paddingXProp), paddingY = useArrayProp(paddingYProp), paddingTop = useArrayProp(paddingTopProp), paddingBottom = useArrayProp(paddingBottomProp), paddingLeft = useArrayProp(paddingLeftProp), paddingRight = useArrayProp(paddingRightProp), radius = useArrayProp(radiusProp), space = useArrayProp(spaceProp), boxProps = react.useMemo(
1528
+ } = props, { button } = useTheme_v2(), justify = react.useMemo(() => _getArrayProp(justifyProp), [justifyProp]), padding = react.useMemo(() => _getArrayProp(paddingProp), [paddingProp]), paddingX = react.useMemo(() => _getArrayProp(paddingXProp), [paddingXProp]), paddingY = react.useMemo(() => _getArrayProp(paddingYProp), [paddingYProp]), paddingTop = react.useMemo(() => _getArrayProp(paddingTopProp), [paddingTopProp]), paddingBottom = react.useMemo(() => _getArrayProp(paddingBottomProp), [paddingBottomProp]), paddingLeft = react.useMemo(() => _getArrayProp(paddingLeftProp), [paddingLeftProp]), paddingRight = react.useMemo(() => _getArrayProp(paddingRightProp), [paddingRightProp]), radius = react.useMemo(() => _getArrayProp(radiusProp), [radiusProp]), space = react.useMemo(() => _getArrayProp(spaceProp), [spaceProp]), boxProps = react.useMemo(
2014
1529
  () => ({
2015
1530
  // flex: 1,
2016
1531
  padding,
@@ -2042,7 +1557,7 @@ const Root$t = styledComponents.styled.button(responsiveRadiusStyle, buttonBaseS
2042
1557
  (IconComponent || text || IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", ...boxProps, children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { as: "span", justify, gap: space, children: [
2043
1558
  IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
2044
1559
  react.isValidElement(IconComponent) && IconComponent,
2045
- ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
1560
+ reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
2046
1561
  ] }),
2047
1562
  text && /* @__PURE__ */ jsxRuntime.jsx(
2048
1563
  Text,
@@ -2057,187 +1572,653 @@ const Root$t = styledComponents.styled.button(responsiveRadiusStyle, buttonBaseS
2057
1572
  ),
2058
1573
  IconRightComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
2059
1574
  react.isValidElement(IconRightComponent) && IconRightComponent,
2060
- ReactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
1575
+ reactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
2061
1576
  ] })
2062
1577
  ] }) }),
2063
1578
  children && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", ...boxProps, children })
2064
1579
  ]
2065
1580
  }
2066
- );
1581
+ );
1582
+ });
1583
+ function cardStyle(props) {
1584
+ return [cardBaseStyle(props), cardColorStyle(props)];
1585
+ }
1586
+ function cardBaseStyle(props) {
1587
+ const { $checkered } = props, { space } = theme.getTheme_v2(props.theme);
1588
+ return styledComponents.css`
1589
+ ${$checkered && styledComponents.css`
1590
+ background-size: ${space[3]}px ${space[3]}px;
1591
+ background-position: 50% 50%;
1592
+ background-image: var(--card-bg-image);
1593
+ `}
1594
+
1595
+ &[data-as='button'] {
1596
+ -webkit-font-smoothing: inherit;
1597
+ appearance: none;
1598
+ outline: none;
1599
+ font: inherit;
1600
+ text-align: inherit;
1601
+ border: 0;
1602
+ width: -moz-available;
1603
+ width: -webkit-fill-available;
1604
+ width: stretch;
1605
+ }
1606
+
1607
+ /* &:is(a) */
1608
+ &[data-as='a'] {
1609
+ outline: none;
1610
+ text-decoration: none;
1611
+ }
1612
+
1613
+ /* &:is(pre) */
1614
+ &[data-as='pre'] {
1615
+ font: inherit;
1616
+ }
1617
+ `;
1618
+ }
1619
+ function cardColorStyle(props) {
1620
+ var _a;
1621
+ const { $checkered, $focusRing, $muted } = props, { card, color, style } = theme.getTheme_v2(props.theme), border2 = { width: card.border.width, color: "var(--card-border-color)" };
1622
+ return styledComponents.css`
1623
+ color-scheme: ${color._dark ? "dark" : "light"};
1624
+
1625
+ ${_cardColorStyle(color, color, $checkered)}
1626
+
1627
+ background-color: ${$muted ? "var(--card-muted-bg-color)" : "var(--card-bg-color)"};
1628
+ color: var(--card-fg-color);
1629
+
1630
+ /* &:is(button) */
1631
+ &[data-as='button'] {
1632
+ --card-focus-ring-box-shadow: none;
1633
+
1634
+ cursor: default;
1635
+ box-shadow: var(--card-focus-ring-box-shadow);
1636
+
1637
+ &:disabled {
1638
+ ${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}
1639
+ }
1640
+
1641
+ &:not(:disabled) {
1642
+ &[data-pressed] {
1643
+ ${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
1644
+ }
1645
+
1646
+ &[data-selected] {
1647
+ ${_cardColorStyle(color, color.selectable.default.selected, $checkered)}
1648
+ }
1649
+
1650
+ @media (hover: hover) {
1651
+ &:not([data-pressed]):not([data-selected]) {
1652
+ &[data-hovered],
1653
+ &:hover {
1654
+ ${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}
1655
+ }
1656
+
1657
+ &:active {
1658
+ ${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
1659
+ }
1660
+ }
1661
+ }
1662
+
1663
+ &:focus-visible {
1664
+ --card-focus-ring-box-shadow: ${$focusRing ? focusRingStyle({ base: color, border: border2, focusRing: card.focusRing }) : void 0};
1665
+ }
1666
+ }
1667
+ }
1668
+
1669
+ /* &:is(a) */
1670
+ &[data-as='a'] {
1671
+ cursor: pointer;
1672
+ box-shadow: var(--card-focus-ring-box-shadow);
1673
+
1674
+ &[data-disabled] {
1675
+ ${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}
1676
+ }
1677
+
1678
+ &:not([data-disabled]) {
1679
+ &[data-pressed] {
1680
+ ${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
1681
+ }
1682
+
1683
+ &[data-selected] {
1684
+ ${_cardColorStyle(color, color.selectable.default.selected, $checkered)}
1685
+ }
1686
+
1687
+ @media (hover: hover) {
1688
+ &:not([data-pressed]):not([data-selected]) {
1689
+ &[data-hovered],
1690
+ &:hover {
1691
+ ${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}
1692
+ }
1693
+
1694
+ &:active {
1695
+ ${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
1696
+ }
1697
+ }
1698
+ }
1699
+
1700
+ &:focus-visible {
1701
+ --card-focus-ring-box-shadow: ${$focusRing ? focusRingStyle({ base: color, border: border2, focusRing: card.focusRing }) : void 0};
1702
+ }
1703
+ }
1704
+ }
1705
+
1706
+ ${(_a = style == null ? void 0 : style.card) == null ? void 0 : _a.root}
1707
+ `;
1708
+ }
1709
+ const Root$s = styledComponents.styled(Box)(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle), Card = react.forwardRef(function(props, ref) {
1710
+ const {
1711
+ __unstable_checkered: checkered = !1,
1712
+ __unstable_focusRing: focusRing = !1,
1713
+ as: asProp,
1714
+ border: border2,
1715
+ borderTop: borderTop2,
1716
+ borderRight: borderRight2,
1717
+ borderBottom: borderBottom2,
1718
+ borderLeft: borderLeft2,
1719
+ muted,
1720
+ pressed,
1721
+ radius = 0,
1722
+ scheme,
1723
+ selected,
1724
+ shadow,
1725
+ tone: toneProp = "default",
1726
+ ...restProps
1727
+ } = props, as = reactIs.isValidElementType(asProp) ? asProp : "div", rootTheme = useRootTheme(), tone = toneProp === "inherit" ? rootTheme.tone : toneProp, $border = react.useMemo(() => _getArrayProp(border2), [border2]), $borderTop = react.useMemo(() => _getArrayProp(borderTop2), [borderTop2]), $borderRight = react.useMemo(() => _getArrayProp(borderRight2), [borderRight2]), $borderBottom = react.useMemo(() => _getArrayProp(borderBottom2), [borderBottom2]), $borderLeft = react.useMemo(() => _getArrayProp(borderLeft2), [borderLeft2]), $radius = react.useMemo(() => _getArrayProp(radius), [radius]), $shadow = react.useMemo(() => _getArrayProp(shadow), [shadow]);
1728
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeColorProvider, { scheme, tone, children: /* @__PURE__ */ jsxRuntime.jsx(
1729
+ Root$s,
1730
+ {
1731
+ "data-as": typeof as == "string" ? as : void 0,
1732
+ "data-scheme": rootTheme.scheme,
1733
+ "data-ui": "Card",
1734
+ "data-tone": tone,
1735
+ ...restProps,
1736
+ $border,
1737
+ $borderTop,
1738
+ $borderRight,
1739
+ $borderBottom,
1740
+ $borderLeft,
1741
+ $radius,
1742
+ $shadow,
1743
+ $checkered: checkered,
1744
+ $focusRing: focusRing,
1745
+ $muted: muted,
1746
+ $tone: tone,
1747
+ "data-checkered": checkered ? "" : void 0,
1748
+ "data-pressed": pressed ? "" : void 0,
1749
+ "data-selected": selected ? "" : void 0,
1750
+ forwardedAs: as,
1751
+ ref,
1752
+ selected
1753
+ }
1754
+ ) });
2067
1755
  });
2068
- function cardStyle(props) {
2069
- return [cardBaseStyle(props), cardColorStyle(props)];
1756
+ function useArrayProp(val, defaultVal) {
1757
+ return react.useMemo(() => _getArrayProp(val, defaultVal), [defaultVal, val]);
2070
1758
  }
2071
- function cardBaseStyle(props) {
2072
- const { $checkered } = props, { space } = theme.getTheme_v2(props.theme);
2073
- return styledComponents.css`
2074
- ${$checkered && styledComponents.css`
2075
- background-size: ${space[3]}px ${space[3]}px;
2076
- background-position: 50% 50%;
2077
- background-image: var(--card-bg-image);
2078
- `}
2079
-
2080
- &[data-as='button'] {
2081
- -webkit-font-smoothing: inherit;
2082
- appearance: none;
2083
- outline: none;
2084
- font: inherit;
2085
- text-align: inherit;
2086
- border: 0;
2087
- width: -moz-available;
2088
- width: -webkit-fill-available;
2089
- width: stretch;
1759
+ function _getElements(element, elementsArg) {
1760
+ const ret = [element];
1761
+ for (const el of elementsArg)
1762
+ Array.isArray(el) ? ret.push(...el) : ret.push(el);
1763
+ return ret.filter(Boolean);
1764
+ }
1765
+ function useClickOutside(listener, elementsArg = EMPTY_ARRAY, boundaryElement) {
1766
+ const [element, setElement] = react.useState(null), [elements, setElements] = react.useState(() => _getElements(element, elementsArg)), elementsRef = react.useRef(elements);
1767
+ return react.useEffect(() => {
1768
+ const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg);
1769
+ if (prevElements.length !== nextElements.length) {
1770
+ setElements(nextElements), elementsRef.current = nextElements;
1771
+ return;
2090
1772
  }
2091
-
2092
- /* &:is(a) */
2093
- &[data-as='a'] {
2094
- outline: none;
2095
- text-decoration: none;
1773
+ for (const el of prevElements)
1774
+ if (!nextElements.includes(el)) {
1775
+ setElements(nextElements), elementsRef.current = nextElements;
1776
+ return;
1777
+ }
1778
+ for (const el of nextElements)
1779
+ if (!prevElements.includes(el)) {
1780
+ setElements(nextElements), elementsRef.current = nextElements;
1781
+ return;
1782
+ }
1783
+ }, [element, elementsArg]), react.useEffect(() => {
1784
+ if (!listener) return;
1785
+ const handleWindowMouseDown = (evt) => {
1786
+ const target = evt.target;
1787
+ if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) {
1788
+ for (const el of elements)
1789
+ if (target === el || el.contains(target))
1790
+ return;
1791
+ listener(evt);
1792
+ }
1793
+ };
1794
+ return window.addEventListener("mousedown", handleWindowMouseDown), () => {
1795
+ window.removeEventListener("mousedown", handleWindowMouseDown);
1796
+ };
1797
+ }, [boundaryElement, listener, elements]), setElement;
1798
+ }
1799
+ var resizeObservers = [], hasActiveObservations = function() {
1800
+ return resizeObservers.some(function(ro) {
1801
+ return ro.activeTargets.length > 0;
1802
+ });
1803
+ }, hasSkippedObservations = function() {
1804
+ return resizeObservers.some(function(ro) {
1805
+ return ro.skippedTargets.length > 0;
1806
+ });
1807
+ }, msg = "ResizeObserver loop completed with undelivered notifications.", deliverResizeLoopError = function() {
1808
+ var event;
1809
+ typeof ErrorEvent == "function" ? event = new ErrorEvent("error", {
1810
+ message: msg
1811
+ }) : (event = document.createEvent("Event"), event.initEvent("error", !1, !1), event.message = msg), window.dispatchEvent(event);
1812
+ }, ResizeObserverBoxOptions;
1813
+ (function(ResizeObserverBoxOptions2) {
1814
+ ResizeObserverBoxOptions2.BORDER_BOX = "border-box", ResizeObserverBoxOptions2.CONTENT_BOX = "content-box", ResizeObserverBoxOptions2.DEVICE_PIXEL_CONTENT_BOX = "device-pixel-content-box";
1815
+ })(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
1816
+ var freeze = function(obj) {
1817
+ return Object.freeze(obj);
1818
+ }, ResizeObserverSize = /* @__PURE__ */ function() {
1819
+ function ResizeObserverSize2(inlineSize, blockSize) {
1820
+ this.inlineSize = inlineSize, this.blockSize = blockSize, freeze(this);
1821
+ }
1822
+ return ResizeObserverSize2;
1823
+ }(), DOMRectReadOnly = function() {
1824
+ function DOMRectReadOnly2(x, y, width, height) {
1825
+ return this.x = x, this.y = y, this.width = width, this.height = height, this.top = this.y, this.left = this.x, this.bottom = this.top + this.height, this.right = this.left + this.width, freeze(this);
1826
+ }
1827
+ return DOMRectReadOnly2.prototype.toJSON = function() {
1828
+ var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
1829
+ return { x, y, top, right, bottom, left, width, height };
1830
+ }, DOMRectReadOnly2.fromRect = function(rectangle) {
1831
+ return new DOMRectReadOnly2(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
1832
+ }, DOMRectReadOnly2;
1833
+ }(), isSVG = function(target) {
1834
+ return target instanceof SVGElement && "getBBox" in target;
1835
+ }, isHidden = function(target) {
1836
+ if (isSVG(target)) {
1837
+ var _a = target.getBBox(), width = _a.width, height = _a.height;
1838
+ return !width && !height;
1839
+ }
1840
+ var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
1841
+ return !(offsetWidth || offsetHeight || target.getClientRects().length);
1842
+ }, isElement = function(obj) {
1843
+ var _a;
1844
+ if (obj instanceof Element)
1845
+ return !0;
1846
+ var scope = (_a = obj == null ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
1847
+ return !!(scope && obj instanceof scope.Element);
1848
+ }, isReplacedElement = function(target) {
1849
+ switch (target.tagName) {
1850
+ case "INPUT":
1851
+ if (target.type !== "image")
1852
+ break;
1853
+ case "VIDEO":
1854
+ case "AUDIO":
1855
+ case "EMBED":
1856
+ case "OBJECT":
1857
+ case "CANVAS":
1858
+ case "IFRAME":
1859
+ case "IMG":
1860
+ return !0;
1861
+ }
1862
+ return !1;
1863
+ }, global$1 = typeof window < "u" ? window : {}, cache = /* @__PURE__ */ new WeakMap(), scrollRegexp = /auto|scroll/, verticalRegexp = /^tb|vertical/, IE = /msie|trident/i.test(global$1.navigator && global$1.navigator.userAgent), parseDimension = function(pixel) {
1864
+ return parseFloat(pixel || "0");
1865
+ }, size$1 = function(inlineSize, blockSize, switchSizes) {
1866
+ return inlineSize === void 0 && (inlineSize = 0), blockSize === void 0 && (blockSize = 0), switchSizes === void 0 && (switchSizes = !1), new ResizeObserverSize((switchSizes ? blockSize : inlineSize) || 0, (switchSizes ? inlineSize : blockSize) || 0);
1867
+ }, zeroBoxes = freeze({
1868
+ devicePixelContentBoxSize: size$1(),
1869
+ borderBoxSize: size$1(),
1870
+ contentBoxSize: size$1(),
1871
+ contentRect: new DOMRectReadOnly(0, 0, 0, 0)
1872
+ }), calculateBoxSizes = function(target, forceRecalculation) {
1873
+ if (forceRecalculation === void 0 && (forceRecalculation = !1), cache.has(target) && !forceRecalculation)
1874
+ return cache.get(target);
1875
+ if (isHidden(target))
1876
+ return cache.set(target, zeroBoxes), zeroBoxes;
1877
+ var cs = getComputedStyle(target), svg = isSVG(target) && target.ownerSVGElement && target.getBBox(), removePadding = !IE && cs.boxSizing === "border-box", switchSizes = verticalRegexp.test(cs.writingMode || ""), canScrollVertically = !svg && scrollRegexp.test(cs.overflowY || ""), canScrollHorizontally = !svg && scrollRegexp.test(cs.overflowX || ""), paddingTop = svg ? 0 : parseDimension(cs.paddingTop), paddingRight = svg ? 0 : parseDimension(cs.paddingRight), paddingBottom = svg ? 0 : parseDimension(cs.paddingBottom), paddingLeft = svg ? 0 : parseDimension(cs.paddingLeft), borderTop2 = svg ? 0 : parseDimension(cs.borderTopWidth), borderRight2 = svg ? 0 : parseDimension(cs.borderRightWidth), borderBottom2 = svg ? 0 : parseDimension(cs.borderBottomWidth), borderLeft2 = svg ? 0 : parseDimension(cs.borderLeftWidth), horizontalPadding = paddingLeft + paddingRight, verticalPadding = paddingTop + paddingBottom, horizontalBorderArea = borderLeft2 + borderRight2, verticalBorderArea = borderTop2 + borderBottom2, horizontalScrollbarThickness = canScrollHorizontally ? target.offsetHeight - verticalBorderArea - target.clientHeight : 0, verticalScrollbarThickness = canScrollVertically ? target.offsetWidth - horizontalBorderArea - target.clientWidth : 0, widthReduction = removePadding ? horizontalPadding + horizontalBorderArea : 0, heightReduction = removePadding ? verticalPadding + verticalBorderArea : 0, contentWidth = svg ? svg.width : parseDimension(cs.width) - widthReduction - verticalScrollbarThickness, contentHeight = svg ? svg.height : parseDimension(cs.height) - heightReduction - horizontalScrollbarThickness, borderBoxWidth = contentWidth + horizontalPadding + verticalScrollbarThickness + horizontalBorderArea, borderBoxHeight = contentHeight + verticalPadding + horizontalScrollbarThickness + verticalBorderArea, boxes = freeze({
1878
+ devicePixelContentBoxSize: size$1(Math.round(contentWidth * devicePixelRatio), Math.round(contentHeight * devicePixelRatio), switchSizes),
1879
+ borderBoxSize: size$1(borderBoxWidth, borderBoxHeight, switchSizes),
1880
+ contentBoxSize: size$1(contentWidth, contentHeight, switchSizes),
1881
+ contentRect: new DOMRectReadOnly(paddingLeft, paddingTop, contentWidth, contentHeight)
1882
+ });
1883
+ return cache.set(target, boxes), boxes;
1884
+ }, calculateBoxSize = function(target, observedBox, forceRecalculation) {
1885
+ var _a = calculateBoxSizes(target, forceRecalculation), borderBoxSize = _a.borderBoxSize, contentBoxSize = _a.contentBoxSize, devicePixelContentBoxSize = _a.devicePixelContentBoxSize;
1886
+ switch (observedBox) {
1887
+ case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:
1888
+ return devicePixelContentBoxSize;
1889
+ case ResizeObserverBoxOptions.BORDER_BOX:
1890
+ return borderBoxSize;
1891
+ default:
1892
+ return contentBoxSize;
1893
+ }
1894
+ }, ResizeObserverEntry = /* @__PURE__ */ function() {
1895
+ function ResizeObserverEntry2(target) {
1896
+ var boxes = calculateBoxSizes(target);
1897
+ this.target = target, this.contentRect = boxes.contentRect, this.borderBoxSize = freeze([boxes.borderBoxSize]), this.contentBoxSize = freeze([boxes.contentBoxSize]), this.devicePixelContentBoxSize = freeze([boxes.devicePixelContentBoxSize]);
1898
+ }
1899
+ return ResizeObserverEntry2;
1900
+ }(), calculateDepthForNode = function(node) {
1901
+ if (isHidden(node))
1902
+ return 1 / 0;
1903
+ for (var depth = 0, parent = node.parentNode; parent; )
1904
+ depth += 1, parent = parent.parentNode;
1905
+ return depth;
1906
+ }, broadcastActiveObservations = function() {
1907
+ var shallowestDepth = 1 / 0, callbacks2 = [];
1908
+ resizeObservers.forEach(function(ro) {
1909
+ if (ro.activeTargets.length !== 0) {
1910
+ var entries = [];
1911
+ ro.activeTargets.forEach(function(ot) {
1912
+ var entry = new ResizeObserverEntry(ot.target), targetDepth = calculateDepthForNode(ot.target);
1913
+ entries.push(entry), ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox), targetDepth < shallowestDepth && (shallowestDepth = targetDepth);
1914
+ }), callbacks2.push(function() {
1915
+ ro.callback.call(ro.observer, entries, ro.observer);
1916
+ }), ro.activeTargets.splice(0, ro.activeTargets.length);
1917
+ }
1918
+ });
1919
+ for (var _i = 0, callbacks_1 = callbacks2; _i < callbacks_1.length; _i++) {
1920
+ var callback = callbacks_1[_i];
1921
+ callback();
1922
+ }
1923
+ return shallowestDepth;
1924
+ }, gatherActiveObservationsAtDepth = function(depth) {
1925
+ resizeObservers.forEach(function(ro) {
1926
+ ro.activeTargets.splice(0, ro.activeTargets.length), ro.skippedTargets.splice(0, ro.skippedTargets.length), ro.observationTargets.forEach(function(ot) {
1927
+ ot.isActive() && (calculateDepthForNode(ot.target) > depth ? ro.activeTargets.push(ot) : ro.skippedTargets.push(ot));
1928
+ });
1929
+ });
1930
+ }, process = function() {
1931
+ var depth = 0;
1932
+ for (gatherActiveObservationsAtDepth(depth); hasActiveObservations(); )
1933
+ depth = broadcastActiveObservations(), gatherActiveObservationsAtDepth(depth);
1934
+ return hasSkippedObservations() && deliverResizeLoopError(), depth > 0;
1935
+ }, trigger, callbacks = [], notify = function() {
1936
+ return callbacks.splice(0).forEach(function(cb) {
1937
+ return cb();
1938
+ });
1939
+ }, queueMicroTask = function(callback) {
1940
+ if (!trigger) {
1941
+ var toggle_1 = 0, el_1 = document.createTextNode(""), config = { characterData: !0 };
1942
+ new MutationObserver(function() {
1943
+ return notify();
1944
+ }).observe(el_1, config), trigger = function() {
1945
+ el_1.textContent = "".concat(toggle_1 ? toggle_1-- : toggle_1++);
1946
+ };
1947
+ }
1948
+ callbacks.push(callback), trigger();
1949
+ }, queueResizeObserver = function(cb) {
1950
+ queueMicroTask(function() {
1951
+ requestAnimationFrame(cb);
1952
+ });
1953
+ }, watching = 0, isWatching = function() {
1954
+ return !!watching;
1955
+ }, CATCH_PERIOD = 250, observerConfig = { attributes: !0, characterData: !0, childList: !0, subtree: !0 }, events = [
1956
+ "resize",
1957
+ "load",
1958
+ "transitionend",
1959
+ "animationend",
1960
+ "animationstart",
1961
+ "animationiteration",
1962
+ "keyup",
1963
+ "keydown",
1964
+ "mouseup",
1965
+ "mousedown",
1966
+ "mouseover",
1967
+ "mouseout",
1968
+ "blur",
1969
+ "focus"
1970
+ ], time = function(timeout) {
1971
+ return timeout === void 0 && (timeout = 0), Date.now() + timeout;
1972
+ }, scheduled = !1, Scheduler = function() {
1973
+ function Scheduler2() {
1974
+ var _this = this;
1975
+ this.stopped = !0, this.listener = function() {
1976
+ return _this.schedule();
1977
+ };
1978
+ }
1979
+ return Scheduler2.prototype.run = function(timeout) {
1980
+ var _this = this;
1981
+ if (timeout === void 0 && (timeout = CATCH_PERIOD), !scheduled) {
1982
+ scheduled = !0;
1983
+ var until = time(timeout);
1984
+ queueResizeObserver(function() {
1985
+ var elementsHaveResized = !1;
1986
+ try {
1987
+ elementsHaveResized = process();
1988
+ } finally {
1989
+ if (scheduled = !1, timeout = until - time(), !isWatching())
1990
+ return;
1991
+ elementsHaveResized ? _this.run(1e3) : timeout > 0 ? _this.run(timeout) : _this.start();
1992
+ }
1993
+ });
2096
1994
  }
2097
-
2098
- /* &:is(pre) */
2099
- &[data-as='pre'] {
2100
- font: inherit;
1995
+ }, Scheduler2.prototype.schedule = function() {
1996
+ this.stop(), this.run();
1997
+ }, Scheduler2.prototype.observe = function() {
1998
+ var _this = this, cb = function() {
1999
+ return _this.observer && _this.observer.observe(document.body, observerConfig);
2000
+ };
2001
+ document.body ? cb() : global$1.addEventListener("DOMContentLoaded", cb);
2002
+ }, Scheduler2.prototype.start = function() {
2003
+ var _this = this;
2004
+ this.stopped && (this.stopped = !1, this.observer = new MutationObserver(this.listener), this.observe(), events.forEach(function(name) {
2005
+ return global$1.addEventListener(name, _this.listener, !0);
2006
+ }));
2007
+ }, Scheduler2.prototype.stop = function() {
2008
+ var _this = this;
2009
+ this.stopped || (this.observer && this.observer.disconnect(), events.forEach(function(name) {
2010
+ return global$1.removeEventListener(name, _this.listener, !0);
2011
+ }), this.stopped = !0);
2012
+ }, Scheduler2;
2013
+ }(), scheduler = new Scheduler(), updateCount = function(n) {
2014
+ !watching && n > 0 && scheduler.start(), watching += n, !watching && scheduler.stop();
2015
+ }, skipNotifyOnElement = function(target) {
2016
+ return !isSVG(target) && !isReplacedElement(target) && getComputedStyle(target).display === "inline";
2017
+ }, ResizeObservation = function() {
2018
+ function ResizeObservation2(target, observedBox) {
2019
+ this.target = target, this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX, this.lastReportedSize = {
2020
+ inlineSize: 0,
2021
+ blockSize: 0
2022
+ };
2023
+ }
2024
+ return ResizeObservation2.prototype.isActive = function() {
2025
+ var size2 = calculateBoxSize(this.target, this.observedBox, !0);
2026
+ return skipNotifyOnElement(this.target) && (this.lastReportedSize = size2), this.lastReportedSize.inlineSize !== size2.inlineSize || this.lastReportedSize.blockSize !== size2.blockSize;
2027
+ }, ResizeObservation2;
2028
+ }(), ResizeObserverDetail = /* @__PURE__ */ function() {
2029
+ function ResizeObserverDetail2(resizeObserver, callback) {
2030
+ this.activeTargets = [], this.skippedTargets = [], this.observationTargets = [], this.observer = resizeObserver, this.callback = callback;
2031
+ }
2032
+ return ResizeObserverDetail2;
2033
+ }(), observerMap = /* @__PURE__ */ new WeakMap(), getObservationIndex = function(observationTargets, target) {
2034
+ for (var i = 0; i < observationTargets.length; i += 1)
2035
+ if (observationTargets[i].target === target)
2036
+ return i;
2037
+ return -1;
2038
+ }, ResizeObserverController = function() {
2039
+ function ResizeObserverController2() {
2040
+ }
2041
+ return ResizeObserverController2.connect = function(resizeObserver, callback) {
2042
+ var detail = new ResizeObserverDetail(resizeObserver, callback);
2043
+ observerMap.set(resizeObserver, detail);
2044
+ }, ResizeObserverController2.observe = function(resizeObserver, target, options) {
2045
+ var detail = observerMap.get(resizeObserver), firstObservation = detail.observationTargets.length === 0;
2046
+ getObservationIndex(detail.observationTargets, target) < 0 && (firstObservation && resizeObservers.push(detail), detail.observationTargets.push(new ResizeObservation(target, options && options.box)), updateCount(1), scheduler.schedule());
2047
+ }, ResizeObserverController2.unobserve = function(resizeObserver, target) {
2048
+ var detail = observerMap.get(resizeObserver), index = getObservationIndex(detail.observationTargets, target), lastObservation = detail.observationTargets.length === 1;
2049
+ index >= 0 && (lastObservation && resizeObservers.splice(resizeObservers.indexOf(detail), 1), detail.observationTargets.splice(index, 1), updateCount(-1));
2050
+ }, ResizeObserverController2.disconnect = function(resizeObserver) {
2051
+ var _this = this, detail = observerMap.get(resizeObserver);
2052
+ detail.observationTargets.slice().forEach(function(ot) {
2053
+ return _this.unobserve(resizeObserver, ot.target);
2054
+ }), detail.activeTargets.splice(0, detail.activeTargets.length);
2055
+ }, ResizeObserverController2;
2056
+ }(), ResizeObserver = function() {
2057
+ function ResizeObserver2(callback) {
2058
+ if (arguments.length === 0)
2059
+ throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
2060
+ if (typeof callback != "function")
2061
+ throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
2062
+ ResizeObserverController.connect(this, callback);
2063
+ }
2064
+ return ResizeObserver2.prototype.observe = function(target, options) {
2065
+ if (arguments.length === 0)
2066
+ throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
2067
+ if (!isElement(target))
2068
+ throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
2069
+ ResizeObserverController.observe(this, target, options);
2070
+ }, ResizeObserver2.prototype.unobserve = function(target) {
2071
+ if (arguments.length === 0)
2072
+ throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
2073
+ if (!isElement(target))
2074
+ throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
2075
+ ResizeObserverController.unobserve(this, target);
2076
+ }, ResizeObserver2.prototype.disconnect = function() {
2077
+ ResizeObserverController.disconnect(this);
2078
+ }, ResizeObserver2.toString = function() {
2079
+ return "function ResizeObserver () { [polyfill code] }";
2080
+ }, ResizeObserver2;
2081
+ }();
2082
+ const _ResizeObserver = typeof document < "u" && typeof window < "u" && window.ResizeObserver ? window.ResizeObserver : ResizeObserver, _elementSizeObserver = _createElementSizeObserver();
2083
+ function _createElementRectValueListener() {
2084
+ return {
2085
+ subscribe(element, subscriber) {
2086
+ const resizeObserver = new _ResizeObserver(([entry]) => {
2087
+ subscriber({
2088
+ _contentRect: entry.contentRect,
2089
+ border: {
2090
+ width: entry.borderBoxSize[0].inlineSize,
2091
+ height: entry.borderBoxSize[0].blockSize
2092
+ },
2093
+ content: {
2094
+ width: entry.contentRect.width,
2095
+ height: entry.contentRect.height
2096
+ }
2097
+ });
2098
+ });
2099
+ return resizeObserver.observe(element), () => {
2100
+ resizeObserver.unobserve(element), resizeObserver.disconnect();
2101
+ };
2101
2102
  }
2102
- `;
2103
+ };
2103
2104
  }
2104
- function cardColorStyle(props) {
2105
- var _a;
2106
- const { $checkered, $focusRing, $muted } = props, { card, color, style } = theme.getTheme_v2(props.theme), border2 = { width: card.border.width, color: "var(--card-border-color)" };
2107
- return styledComponents.css`
2108
- color-scheme: ${color._dark ? "dark" : "light"};
2109
-
2110
- ${_cardColorStyle(color, color, $checkered)}
2111
-
2112
- background-color: ${$muted ? "var(--card-muted-bg-color)" : "var(--card-bg-color)"};
2113
- color: var(--card-fg-color);
2114
-
2115
- /* &:is(button) */
2116
- &[data-as='button'] {
2117
- --card-focus-ring-box-shadow: none;
2118
-
2119
- cursor: default;
2120
- box-shadow: var(--card-focus-ring-box-shadow);
2121
-
2122
- &:disabled {
2123
- ${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}
2124
- }
2125
-
2126
- &:not(:disabled) {
2127
- &[data-pressed] {
2128
- ${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
2129
- }
2130
-
2131
- &[data-selected] {
2132
- ${_cardColorStyle(color, color.selectable.default.selected, $checkered)}
2133
- }
2134
-
2135
- @media (hover: hover) {
2136
- &:not([data-pressed]):not([data-selected]) {
2137
- &[data-hovered],
2138
- &:hover {
2139
- ${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}
2140
- }
2141
-
2142
- &:active {
2143
- ${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
2144
- }
2145
- }
2146
- }
2147
-
2148
- &:focus-visible {
2149
- --card-focus-ring-box-shadow: ${$focusRing ? focusRingStyle({ base: color, border: border2, focusRing: card.focusRing }) : void 0};
2150
- }
2151
- }
2105
+ function _createElementSizeObserver() {
2106
+ const disposeCache = /* @__PURE__ */ new WeakMap(), subscribersCache = /* @__PURE__ */ new WeakMap();
2107
+ return {
2108
+ subscribe(element, subscriber) {
2109
+ const subscribers = subscribersCache.get(element) || [];
2110
+ let dispose = disposeCache.get(element);
2111
+ return subscribersCache.has(element) || (subscribersCache.set(element, subscribers), dispose = _createElementRectValueListener().subscribe(element, (elementRect) => {
2112
+ for (const sub of subscribers)
2113
+ sub(elementRect);
2114
+ })), subscribers.push(subscriber), () => {
2115
+ const idx = subscribers.indexOf(subscriber);
2116
+ idx > -1 && subscribers.splice(idx, 1), subscribers.length === 0 && dispose && dispose();
2117
+ };
2152
2118
  }
2153
-
2154
- /* &:is(a) */
2155
- &[data-as='a'] {
2156
- cursor: pointer;
2157
- box-shadow: var(--card-focus-ring-box-shadow);
2158
-
2159
- &[data-disabled] {
2160
- ${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}
2161
- }
2162
-
2163
- &:not([data-disabled]) {
2164
- &[data-pressed] {
2165
- ${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
2166
- }
2167
-
2168
- &[data-selected] {
2169
- ${_cardColorStyle(color, color.selectable.default.selected, $checkered)}
2170
- }
2171
-
2172
- @media (hover: hover) {
2173
- &:not([data-pressed]):not([data-selected]) {
2174
- &[data-hovered],
2175
- &:hover {
2176
- ${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}
2177
- }
2178
-
2179
- &:active {
2180
- ${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
2181
- }
2182
- }
2183
- }
2184
-
2185
- &:focus-visible {
2186
- --card-focus-ring-box-shadow: ${$focusRing ? focusRingStyle({ base: color, border: border2, focusRing: card.focusRing }) : void 0};
2187
- }
2119
+ };
2120
+ }
2121
+ function useElementSize(element) {
2122
+ const [size2, setSize] = react.useState(null);
2123
+ return react.useEffect(() => {
2124
+ if (element)
2125
+ return _elementSizeObserver.subscribe(element, setSize);
2126
+ }, [element]), size2;
2127
+ }
2128
+ function useElementRect(element) {
2129
+ const elementSize = useElementSize(element);
2130
+ return (elementSize == null ? void 0 : elementSize._contentRect) || null;
2131
+ }
2132
+ function useGlobalKeyDown(onKeyDown) {
2133
+ return react.useEffect(() => (addEventListener("keydown", onKeyDown), () => removeEventListener("keydown", onKeyDown)), [onKeyDown]);
2134
+ }
2135
+ const MEDIA_STORE_CACHE = /* @__PURE__ */ new WeakMap();
2136
+ function _getMediaQuery(media, index) {
2137
+ return index === 0 ? `screen and (max-width: ${media[index] - 1}px)` : index === media.length ? `screen and (min-width: ${media[index - 1]}px)` : `screen and (min-width: ${media[index - 1]}px) and (max-width: ${media[index] - 1}px)`;
2138
+ }
2139
+ function _createMediaStore(media) {
2140
+ const mediaLen = media.length;
2141
+ let sizes;
2142
+ const getSizes = () => {
2143
+ if (!sizes) {
2144
+ sizes = [];
2145
+ for (let index = mediaLen; index > -1; index -= 1) {
2146
+ const mediaQuery = _getMediaQuery(media, index);
2147
+ sizes.push({ index, mq: window.matchMedia(mediaQuery) });
2188
2148
  }
2189
2149
  }
2190
-
2191
- ${(_a = style == null ? void 0 : style.card) == null ? void 0 : _a.root}
2192
- `;
2193
- }
2194
- const Root$s = styledComponents.styled(Box)(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle), Card = react.forwardRef(function(props, ref) {
2195
- const {
2196
- __unstable_checkered: checkered = !1,
2197
- __unstable_focusRing: focusRing = !1,
2198
- as: asProp,
2199
- border: border2,
2200
- borderTop: borderTop2,
2201
- borderRight: borderRight2,
2202
- borderBottom: borderBottom2,
2203
- borderLeft: borderLeft2,
2204
- muted,
2205
- pressed,
2206
- radius = 0,
2207
- scheme,
2208
- selected,
2209
- shadow,
2210
- tone: toneProp = "default",
2211
- ...restProps
2212
- } = props, as = ReactIs.isValidElementType(asProp) ? asProp : "div", rootTheme = useRootTheme(), tone = toneProp === "inherit" ? rootTheme.tone : toneProp;
2213
- return /* @__PURE__ */ jsxRuntime.jsx(ThemeColorProvider, { scheme, tone, children: /* @__PURE__ */ jsxRuntime.jsx(
2214
- Root$s,
2215
- {
2216
- "data-as": typeof as == "string" ? as : void 0,
2217
- "data-scheme": rootTheme.scheme,
2218
- "data-ui": "Card",
2219
- "data-tone": tone,
2220
- ...restProps,
2221
- $border: useArrayProp(border2),
2222
- $borderTop: useArrayProp(borderTop2),
2223
- $borderRight: useArrayProp(borderRight2),
2224
- $borderBottom: useArrayProp(borderBottom2),
2225
- $borderLeft: useArrayProp(borderLeft2),
2226
- $checkered: checkered,
2227
- $focusRing: focusRing,
2228
- $muted: muted,
2229
- $radius: useArrayProp(radius),
2230
- $shadow: useArrayProp(shadow),
2231
- $tone: tone,
2232
- "data-checkered": checkered ? "" : void 0,
2233
- "data-pressed": pressed ? "" : void 0,
2234
- "data-selected": selected ? "" : void 0,
2235
- forwardedAs: as,
2236
- ref,
2237
- selected
2150
+ return sizes;
2151
+ };
2152
+ return { getSnapshot: () => {
2153
+ for (const { index, mq } of getSizes())
2154
+ if (mq.matches) return index;
2155
+ return 0;
2156
+ }, subscribe: (onStoreChange) => {
2157
+ const disposeFns = [];
2158
+ for (const { mq } of getSizes()) {
2159
+ const handleChange = () => {
2160
+ mq.matches && onStoreChange();
2161
+ };
2162
+ mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
2238
2163
  }
2239
- ) });
2240
- });
2164
+ return () => {
2165
+ for (const disposeFn of disposeFns)
2166
+ disposeFn();
2167
+ };
2168
+ } };
2169
+ }
2170
+ function getServerSnapshot$2() {
2171
+ return 0;
2172
+ }
2173
+ function useMediaIndex() {
2174
+ const { media } = useTheme_v2();
2175
+ let store = MEDIA_STORE_CACHE.get(media);
2176
+ return store || (store = _createMediaStore(media), MEDIA_STORE_CACHE.set(media, store)), react.useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot$2);
2177
+ }
2178
+ let MEDIA_QUERY_CACHE$1;
2179
+ function getMatchMedia$1() {
2180
+ return MEDIA_QUERY_CACHE$1 || (MEDIA_QUERY_CACHE$1 = window.matchMedia("(prefers-color-scheme: dark)")), MEDIA_QUERY_CACHE$1;
2181
+ }
2182
+ function subscribe$2(onStoreChange) {
2183
+ const matchMedia = getMatchMedia$1();
2184
+ return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
2185
+ }
2186
+ function getSnapshot$1() {
2187
+ return getMatchMedia$1().matches;
2188
+ }
2189
+ function getServerSnapshot$1() {
2190
+ return !1;
2191
+ }
2192
+ function usePrefersDark() {
2193
+ return react.useSyncExternalStore(subscribe$2, getSnapshot$1, getServerSnapshot$1);
2194
+ }
2195
+ let MEDIA_QUERY_CACHE;
2196
+ function getMatchMedia() {
2197
+ return MEDIA_QUERY_CACHE || (MEDIA_QUERY_CACHE = window.matchMedia("(prefers-reduced-motion: reduce)")), MEDIA_QUERY_CACHE;
2198
+ }
2199
+ function subscribe$1(onStoreChange) {
2200
+ const matchMedia = getMatchMedia();
2201
+ return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
2202
+ }
2203
+ function getSnapshot() {
2204
+ return getMatchMedia().matches;
2205
+ }
2206
+ function getServerSnapshot() {
2207
+ return !1;
2208
+ }
2209
+ function usePrefersReducedMotion() {
2210
+ return react.useSyncExternalStore(subscribe$1, getSnapshot, getServerSnapshot);
2211
+ }
2212
+ function useForwardedRef(ref) {
2213
+ const innerRef = react.useRef(null);
2214
+ return react.useImperativeHandle(ref, () => innerRef.current), innerRef;
2215
+ }
2216
+ function useCustomValidity(ref, customValidity) {
2217
+ react.useEffect(() => {
2218
+ var _a;
2219
+ (_a = ref.current) == null || _a.setCustomValidity(customValidity || "");
2220
+ }, [customValidity, ref]);
2221
+ }
2241
2222
  function checkboxBaseStyles() {
2242
2223
  return styledComponents.css`
2243
2224
  position: relative;
@@ -2466,8 +2447,8 @@ function codeBaseStyle() {
2466
2447
  `;
2467
2448
  }
2468
2449
  const Root$q = styledComponents.styled.pre(codeBaseStyle, responsiveCodeFontStyle), Code = react.forwardRef(function(props, ref) {
2469
- const { children, language: languageProp, size: size2 = 2, weight, ...restProps } = props, language = typeof languageProp == "string" ? languageProp : void 0, registered = language ? Refractor__default.default.hasLanguage(language) : !1;
2470
- return /* @__PURE__ */ jsxRuntime.jsxs(Root$q, { "data-ui": "Code", ...restProps, $size: useArrayProp(size2), $weight: weight, ref, children: [
2450
+ const { children, language: languageProp, size: size2 = 2, weight, ...restProps } = props, language = typeof languageProp == "string" ? languageProp : void 0, registered = language ? Refractor__default.default.hasLanguage(language) : !1, $size = react.useMemo(() => _getArrayProp(size2), [size2]);
2451
+ return /* @__PURE__ */ jsxRuntime.jsxs(Root$q, { "data-ui": "Code", ...restProps, $size, $weight: weight, ref, children: [
2471
2452
  !(language && registered) && /* @__PURE__ */ jsxRuntime.jsx("code", { children }),
2472
2453
  language && registered && /* @__PURE__ */ jsxRuntime.jsx(Refractor__default.default, { inline: !0, language, value: String(children) })
2473
2454
  ] });
@@ -2488,33 +2469,24 @@ const Root$p = styledComponents.styled(Box)(
2488
2469
  containerBaseStyle,
2489
2470
  responsiveContainerWidthStyle
2490
2471
  ), Container = react.forwardRef(function(props, ref) {
2491
- const { as, width = 2, ...restProps } = props;
2492
- return /* @__PURE__ */ jsxRuntime.jsx(
2493
- Root$p,
2494
- {
2495
- "data-ui": "Container",
2496
- ...restProps,
2497
- $width: useArrayProp(width),
2498
- forwardedAs: as,
2499
- ref
2500
- }
2501
- );
2472
+ const { as, width = 2, ...restProps } = props, $width = react.useMemo(() => _getArrayProp(width), [width]);
2473
+ return /* @__PURE__ */ jsxRuntime.jsx(Root$p, { "data-ui": "Container", ...restProps, $width, forwardedAs: as, ref });
2502
2474
  }), Root$o = styledComponents.styled(Box)(responsiveGridStyle), Grid = react.forwardRef(function(props, ref) {
2503
- const { as, autoRows, autoCols, autoFlow, columns, gap, gapX, gapY, rows, children, ...restProps } = props;
2475
+ const { as, autoRows, autoCols, autoFlow, columns, gap, gapX, gapY, rows, children, ...restProps } = props, $autoRows = react.useMemo(() => _getArrayProp(autoRows), [autoRows]), $autoCols = react.useMemo(() => _getArrayProp(autoCols), [autoCols]), $autoFlow = react.useMemo(() => _getArrayProp(autoFlow), [autoFlow]), $columns = react.useMemo(() => _getArrayProp(columns), [columns]), $gap = react.useMemo(() => _getArrayProp(gap), [gap]), $gapX = react.useMemo(() => _getArrayProp(gapX), [gapX]), $gapY = react.useMemo(() => _getArrayProp(gapY), [gapY]), $rows = react.useMemo(() => _getArrayProp(rows), [rows]);
2504
2476
  return /* @__PURE__ */ jsxRuntime.jsx(
2505
2477
  Root$o,
2506
2478
  {
2507
2479
  "data-as": typeof as == "string" ? as : void 0,
2508
2480
  "data-ui": "Grid",
2509
2481
  ...restProps,
2510
- $autoRows: useArrayProp(autoRows),
2511
- $autoCols: useArrayProp(autoCols),
2512
- $autoFlow: useArrayProp(autoFlow),
2513
- $columns: useArrayProp(columns),
2514
- $gap: useArrayProp(gap),
2515
- $gapX: useArrayProp(gapX),
2516
- $gapY: useArrayProp(gapY),
2517
- $rows: useArrayProp(rows),
2482
+ $autoRows,
2483
+ $autoCols,
2484
+ $autoFlow,
2485
+ $columns,
2486
+ $gap,
2487
+ $gapX,
2488
+ $gapY,
2489
+ $rows,
2518
2490
  forwardedAs: as,
2519
2491
  ref,
2520
2492
  children
@@ -2591,7 +2563,7 @@ const Root$n = styledComponents.styled.div(headingBaseStyle, responsiveTextAlign
2591
2563
  textOverflow,
2592
2564
  weight,
2593
2565
  ...restProps
2594
- } = props;
2566
+ } = props, $size = react.useMemo(() => _getArrayProp(size2), [size2]), $align = react.useMemo(() => _getArrayProp(align), [align]);
2595
2567
  let children = childrenProp;
2596
2568
  return textOverflow === "ellipsis" && (children = /* @__PURE__ */ jsxRuntime.jsx(SpanWithTextOverflow, { children })), /* @__PURE__ */ jsxRuntime.jsx(
2597
2569
  Root$n,
@@ -2599,9 +2571,9 @@ const Root$n = styledComponents.styled.div(headingBaseStyle, responsiveTextAlign
2599
2571
  "data-ui": "Heading",
2600
2572
  ...restProps,
2601
2573
  $accent: accent,
2602
- $align: useArrayProp(align),
2574
+ $align,
2575
+ $size,
2603
2576
  $muted: muted,
2604
- $size: useArrayProp(size2),
2605
2577
  $weight: weight,
2606
2578
  ref,
2607
2579
  children: /* @__PURE__ */ jsxRuntime.jsx("span", { children })
@@ -2631,7 +2603,7 @@ function inlineSpaceStyle(props) {
2631
2603
  });
2632
2604
  }
2633
2605
  const Root$m = styledComponents.styled(Box)(inlineBaseStyle, inlineSpaceStyle), Inline = react.forwardRef(function(props, ref) {
2634
- const { as, children: childrenProp, space, ...restProps } = props, children = react.useMemo(
2606
+ const { as, children: childrenProp, space, ...restProps } = props, $space = react.useMemo(() => _getArrayProp(space), [space]), children = react.useMemo(
2635
2607
  () => react.Children.map(childrenProp, (child) => child && /* @__PURE__ */ jsxRuntime.jsx("div", { children: child })),
2636
2608
  [childrenProp]
2637
2609
  );
@@ -2640,7 +2612,7 @@ const Root$m = styledComponents.styled(Box)(inlineBaseStyle, inlineSpaceStyle),
2640
2612
  {
2641
2613
  "data-ui": "Inline",
2642
2614
  ...restProps,
2643
- $space: useArrayProp(space),
2615
+ $space,
2644
2616
  forwardedAs: as,
2645
2617
  ref,
2646
2618
  children
@@ -2665,8 +2637,8 @@ function kbdStyle() {
2665
2637
  `;
2666
2638
  }
2667
2639
  const Root$l = styledComponents.styled.kbd(responsiveRadiusStyle, kbdStyle), KBD = react.forwardRef(function(props, ref) {
2668
- const { children, fontSize: fontSize2 = 0, padding = 1, radius = 2, ...restProps } = props;
2669
- return /* @__PURE__ */ jsxRuntime.jsx(Root$l, { "data-ui": "KBD", ...restProps, $radius: useArrayProp(radius), ref, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", padding, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { as: "span", size: fontSize2, weight: "semibold", children }) }) });
2640
+ const { children, fontSize: fontSize2 = 0, padding = 1, radius = 2, ...restProps } = props, $radius = react.useMemo(() => _getArrayProp(radius), [radius]);
2641
+ return /* @__PURE__ */ jsxRuntime.jsx(Root$l, { "data-ui": "KBD", ...restProps, $radius, ref, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", padding, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { as: "span", size: fontSize2, weight: "semibold", children }) }) });
2670
2642
  }), origin = {
2671
2643
  name: "@sanity/ui/origin",
2672
2644
  fn({ middlewareData, placement, rects }) {
@@ -2849,10 +2821,10 @@ function findMinBreakpoints(media, width) {
2849
2821
  return ret;
2850
2822
  }
2851
2823
  const ElementQuery = react.forwardRef(function(props, forwardedRef) {
2852
- const theme2 = useTheme_v2(), { children, media = theme2.media, ...restProps } = props, ref = react.useRef(null), [element, setElement] = react.useState(null), elementSize = useElementSize(element), width = react.useMemo(() => {
2824
+ const theme2 = useTheme_v2(), { children, media: _media, ...restProps } = props, media = _media != null ? _media : theme2.media, ref = react.useRef(null), [element, setElement] = react.useState(null), elementSize = useElementSize(element), width = react.useMemo(() => {
2853
2825
  var _a;
2854
2826
  return (_a = elementSize == null ? void 0 : elementSize.border.width) != null ? _a : window.innerWidth;
2855
- }, [elementSize]), max = react.useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = react.useMemo(() => findMinBreakpoints(media, width), [media, width]);
2827
+ }, [elementSize]), max = findMaxBreakpoints(media, width), min = findMinBreakpoints(media, width);
2856
2828
  react.useImperativeHandle(forwardedRef, () => ref.current);
2857
2829
  const setRef = react.useCallback((el) => {
2858
2830
  ref.current = el, setElement(el);
@@ -2986,18 +2958,18 @@ function _isScrollable(el) {
2986
2958
  }
2987
2959
  function LayerProvider(props) {
2988
2960
  var _a;
2989
- const { children, zOffset: zOffsetProp = 0 } = props, parentContextValue = react.useContext(LayerContext), parent = parentContextValue && getLayerContext(parentContextValue), parentRegisterChild = parent == null ? void 0 : parent.registerChild, level = ((_a = parent == null ? void 0 : parent.level) != null ? _a : 0) + 1, zOffset = useArrayProp(zOffsetProp), maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex], [, setChildLayers] = react.useState({}), [size2, setSize] = react.useState(0), isTopLayer = size2 === 0, registerChild = react.useCallback(
2961
+ const { children, zOffset: zOffsetProp = 0 } = props, parentContextValue = react.useContext(LayerContext), parentRegisterChild = react.useContext(LayerContextRegisterChild), parent = parentContextValue && getLayerContext(parentContextValue), level = ((_a = parent == null ? void 0 : parent.level) != null ? _a : 0) + 1, zOffset = react.useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex], [childLayers, setChildLayers] = react.useState({}), size2 = react.useMemo(() => Object.keys(childLayers).length, [childLayers]), isTopLayer = size2 === 0, registerChild = react.useCallback(
2990
2962
  (childLevel) => {
2991
2963
  const parentDispose = parentRegisterChild == null ? void 0 : parentRegisterChild(childLevel);
2992
- return childLevel !== void 0 ? setChildLayers((state) => {
2964
+ return setChildLayers((state) => {
2993
2965
  var _a2;
2994
- const prevLen = (_a2 = state[childLevel]) != null ? _a2 : 0, nextState = { ...state, [childLevel]: prevLen + 1 };
2995
- return setSize(Object.keys(nextState).length), nextState;
2996
- }) : setSize((v) => v + 1), () => {
2997
- childLevel !== void 0 ? setChildLayers((state) => {
2966
+ const prevLen = (_a2 = state[childLevel]) != null ? _a2 : 0;
2967
+ return { ...state, [childLevel]: prevLen + 1 };
2968
+ }), () => {
2969
+ setChildLayers((state) => {
2998
2970
  const nextState = { ...state };
2999
- return nextState[childLevel] === 1 ? (delete nextState[childLevel], setSize(Object.keys(nextState).length)) : nextState[childLevel] -= 1, nextState;
3000
- }) : setSize((v) => v - 1), parentDispose == null || parentDispose();
2971
+ return nextState[childLevel] === 1 ? delete nextState[childLevel] : nextState[childLevel] -= 1, nextState;
2972
+ }), parentDispose == null || parentDispose();
3001
2973
  };
3002
2974
  },
3003
2975
  [parentRegisterChild]
@@ -3008,15 +2980,14 @@ function LayerProvider(props) {
3008
2980
  version: 0,
3009
2981
  isTopLayer,
3010
2982
  level,
3011
- registerChild,
3012
2983
  size: size2,
3013
2984
  zIndex
3014
2985
  }),
3015
- [isTopLayer, level, registerChild, size2, zIndex]
2986
+ [isTopLayer, level, size2, zIndex]
3016
2987
  );
3017
- return /* @__PURE__ */ jsxRuntime.jsx(LayerContext.Provider, { value, children });
2988
+ return /* @__PURE__ */ jsxRuntime.jsx(LayerContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(LayerContextRegisterChild.Provider, { value: registerChild, children }) });
3018
2989
  }
3019
- const Root$j = styledComponents.styled.div({ position: "relative" }), LayerChildren = react.forwardRef(function(props, forwardedRef) {
2990
+ const LayerContextRegisterChild = react.createContext(null), Root$j = styledComponents.styled.div({ position: "relative" }), LayerChildren = react.forwardRef(function(props, forwardedRef) {
3020
2991
  const { children, onActivate, onFocus, style = EMPTY_RECORD, ...restProps } = props, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = react.useRef(null), ref = react.useRef(null), isTopLayerRef = react.useRef(isTopLayer);
3021
2992
  react.useImperativeHandle(forwardedRef, () => ref.current), react.useEffect(() => {
3022
2993
  isTopLayerRef.current !== isTopLayer && isTopLayer && (onActivate == null || onActivate({ activeElement: lastFocusedRef.current })), isTopLayerRef.current = isTopLayer;
@@ -3284,19 +3255,19 @@ const MotionCard$1 = styledComponents.styled(framerMotion.motion(Card))`
3284
3255
  PopoverCard.displayName = "PopoverCard";
3285
3256
  const Popover = react.memo(
3286
3257
  react.forwardRef(function(props, forwardedRef) {
3287
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3258
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3288
3259
  const { container, layer } = useTheme_v2(), boundaryElementContext = useBoundaryElement(), {
3289
3260
  __unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
3290
3261
  animate: _animate = !1,
3291
3262
  arrow: arrowProp = !1,
3292
- boundaryElement = boundaryElementContext.element,
3293
- children: childProp,
3263
+ boundaryElement: _boundaryElement,
3264
+ children: _children,
3294
3265
  constrainSize = !1,
3295
3266
  content,
3296
3267
  disabled,
3297
- fallbackPlacements = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS$1[(_a = props.placement) != null ? _a : "bottom"],
3268
+ fallbackPlacements: _fallbackPlacements,
3298
3269
  matchReferenceWidth,
3299
- floatingBoundary = (_c = props.boundaryElement) != null ? _c : boundaryElementContext.element,
3270
+ floatingBoundary: _floatingBoundary,
3300
3271
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3301
3272
  onActivate,
3302
3273
  open,
@@ -3306,16 +3277,16 @@ const Popover = react.memo(
3306
3277
  portal,
3307
3278
  preventOverflow = !0,
3308
3279
  radius: radiusProp = 3,
3309
- referenceBoundary = (_d = props.boundaryElement) != null ? _d : boundaryElementContext.element,
3280
+ referenceBoundary: _referenceBoundary,
3310
3281
  referenceElement,
3311
3282
  scheme,
3312
3283
  shadow: shadowProp = 3,
3313
3284
  tone = "inherit",
3314
3285
  width: widthProp = "auto",
3315
- zOffset: zOffsetProp = layer.popover.zOffset,
3286
+ zOffset: _zOffset,
3316
3287
  updateRef,
3317
3288
  ...restProps
3318
- } = props, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = (_e = useElementSize(boundaryElement)) == null ? void 0 : _e.border, padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), widthArrayProp = useArrayProp(widthProp), zOffset = useArrayProp(zOffsetProp), ref = react.useRef(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
3289
+ } = props, boundaryElement = _boundaryElement != null ? _boundaryElement : boundaryElementContext.element, referenceBoundary = (_a = _referenceBoundary != null ? _referenceBoundary : props.boundaryElement) != null ? _a : boundaryElementContext.element, floatingBoundary = (_b = _floatingBoundary != null ? _floatingBoundary : props.boundaryElement) != null ? _b : boundaryElementContext.element, fallbackPlacements = _fallbackPlacements != null ? _fallbackPlacements : DEFAULT_FALLBACK_PLACEMENTS$1[(_c = props.placement) != null ? _c : "bottom"], zOffsetProp = _zOffset != null ? _zOffset : layer.popover.zOffset, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = (_d = useElementSize(boundaryElement)) == null ? void 0 : _d.border, padding = react.useMemo(() => _getArrayProp(paddingProp), [paddingProp]), radius = react.useMemo(() => _getArrayProp(radiusProp), [radiusProp]), shadow = react.useMemo(() => _getArrayProp(shadowProp), [shadowProp]), widthArrayProp = _getArrayProp(widthProp), zOffset = react.useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), ref = react.useRef(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
3319
3290
  react.useImperativeHandle(
3320
3291
  forwardedRef,
3321
3292
  () => ref.current
@@ -3396,27 +3367,24 @@ const Popover = react.memo(
3396
3367
  middleware,
3397
3368
  placement: placementProp,
3398
3369
  whileElementsMounted: reactDom$1.autoUpdate
3399
- }), referenceHidden = (_f = middlewareData.hide) == null ? void 0 : _f.referenceHidden, arrowX = (_g = middlewareData.arrow) == null ? void 0 : _g.x, arrowY = (_h = middlewareData.arrow) == null ? void 0 : _h.y, originX = (_i = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _i.originX, originY = (_j = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _j.originY, setArrow = react.useCallback((arrowEl) => {
3370
+ }), referenceHidden = (_e = middlewareData.hide) == null ? void 0 : _e.referenceHidden, arrowX = (_f = middlewareData.arrow) == null ? void 0 : _f.x, arrowY = (_g = middlewareData.arrow) == null ? void 0 : _g.y, originX = (_h = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _h.originX, originY = (_i = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _i.originY, setArrow = react.useCallback((arrowEl) => {
3400
3371
  arrowRef.current = arrowEl;
3401
3372
  }, []), setFloating = react.useCallback(
3402
3373
  (node) => {
3403
3374
  ref.current = node, refs.setFloating(node);
3404
3375
  },
3405
3376
  [refs]
3406
- ), setReference = react.useCallback(
3407
- (node) => {
3408
- refs.setReference(node);
3409
- const childRef = childProp == null ? void 0 : childProp.ref;
3410
- typeof childRef == "function" ? childRef(node) : childRef && (childRef.current = node);
3411
- },
3412
- [childProp, refs]
3413
- ), child = react.useMemo(() => !childProp || referenceElement ? null : react.cloneElement(childProp, { ref: setReference }), [childProp, referenceElement, setReference]);
3414
- if (react.useEffect(() => {
3415
- updateRef && (typeof updateRef == "function" ? updateRef(update) : updateRef && (updateRef.current = update));
3416
- }, [update, updateRef]), react.useEffect(() => {
3417
- child || refs.setReference(referenceElement || null);
3418
- }, [referenceElement, refs, child]), disabled)
3419
- return childProp || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
3377
+ );
3378
+ react.useImperativeHandle(updateRef, () => update, [update]), react.useEffect(() => {
3379
+ _children || refs.setReference(referenceElement || null);
3380
+ }, [_children, referenceElement, refs]);
3381
+ const children = react.useMemo(() => !_children || referenceElement ? null : react.cloneElement(_children, {
3382
+ ref: (node) => {
3383
+ logDeprecatedWarning(), refs.setReference(node);
3384
+ }
3385
+ }), [_children, referenceElement, refs]);
3386
+ if (disabled)
3387
+ return _children || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
3420
3388
  const popover = /* @__PURE__ */ jsxRuntime.jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsxRuntime.jsx(
3421
3389
  PopoverCard,
3422
3390
  {
@@ -3450,22 +3418,26 @@ const Popover = react.memo(
3450
3418
  ConditionalWrapper,
3451
3419
  {
3452
3420
  condition: animate,
3453
- wrapper: (children) => /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }),
3421
+ wrapper: (children2) => /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: children2 }),
3454
3422
  children: open && /* @__PURE__ */ jsxRuntime.jsx(
3455
3423
  ConditionalWrapper,
3456
3424
  {
3457
3425
  condition: !!portal,
3458
- wrapper: (children) => /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children }),
3426
+ wrapper: (children2) => /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: children2 }),
3459
3427
  children: popover
3460
3428
  }
3461
3429
  )
3462
3430
  }
3463
3431
  ),
3464
- child
3432
+ children
3465
3433
  ] });
3466
3434
  })
3467
3435
  );
3468
3436
  Popover.displayName = "Popover";
3437
+ let didWarn = !1;
3438
+ function logDeprecatedWarning() {
3439
+ didWarn || (console.warn("Popover: Please use the `referenceElement` prop instead of passing a children."), didWarn = !0);
3440
+ }
3469
3441
  function radioBaseStyle() {
3470
3442
  return styledComponents.css`
3471
3443
  position: relative;
@@ -3741,20 +3713,22 @@ const selectStyle = {
3741
3713
  space = 3,
3742
3714
  ...restProps
3743
3715
  } = props, ref = react.useRef(null);
3744
- return react.useImperativeHandle(
3716
+ react.useImperativeHandle(
3745
3717
  forwardedRef,
3746
3718
  () => ref.current
3747
- ), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxRuntime.jsxs(Root$f, { "data-ui": "Select", children: [
3719
+ ), useCustomValidity(ref, customValidity);
3720
+ const $fontSize = react.useMemo(() => _getArrayProp(fontSize2), [fontSize2]), $padding = react.useMemo(() => _getArrayProp(padding), [padding]), $radius = react.useMemo(() => _getArrayProp(radius), [radius]), $space = react.useMemo(() => _getArrayProp(space), [space]);
3721
+ return /* @__PURE__ */ jsxRuntime.jsxs(Root$f, { "data-ui": "Select", children: [
3748
3722
  /* @__PURE__ */ jsxRuntime.jsx(
3749
3723
  Input$3,
3750
3724
  {
3751
3725
  "data-read-only": !disabled && readOnly ? "" : void 0,
3752
3726
  "data-ui": "Select",
3753
3727
  ...restProps,
3754
- $fontSize: useArrayProp(fontSize2),
3755
- $padding: useArrayProp(padding),
3756
- $radius: useArrayProp(radius),
3757
- $space: useArrayProp(space),
3728
+ $fontSize,
3729
+ $padding,
3730
+ $radius,
3731
+ $space,
3758
3732
  disabled: disabled || readOnly,
3759
3733
  ref,
3760
3734
  children
@@ -3782,14 +3756,14 @@ function responsiveStackSpaceStyle(props) {
3782
3756
  }));
3783
3757
  }
3784
3758
  const Root$e = styledComponents.styled(Box)(stackBaseStyle, responsiveStackSpaceStyle), Stack = react.forwardRef(function(props, ref) {
3785
- const { as, space, ...restProps } = props;
3759
+ const { as, space, ...restProps } = props, $space = react.useMemo(() => _getArrayProp(space), [space]);
3786
3760
  return /* @__PURE__ */ jsxRuntime.jsx(
3787
3761
  Root$e,
3788
3762
  {
3789
3763
  "data-as": typeof as == "string" ? as : void 0,
3790
3764
  "data-ui": "Stack",
3791
3765
  ...restProps,
3792
- $space: useArrayProp(space),
3766
+ $space,
3793
3767
  forwardedAs: as,
3794
3768
  ref
3795
3769
  }
@@ -3984,10 +3958,12 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
3984
3958
  weight,
3985
3959
  ...restProps
3986
3960
  } = props, ref = react.useRef(null), rootTheme = useRootTheme();
3987
- return react.useImperativeHandle(
3961
+ react.useImperativeHandle(
3988
3962
  forwardedRef,
3989
3963
  () => ref.current
3990
- ), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxRuntime.jsx(Root$c, { "data-ui": "TextArea", children: /* @__PURE__ */ jsxRuntime.jsxs(InputRoot$1, { children: [
3964
+ ), useCustomValidity(ref, customValidity);
3965
+ const $radius = react.useMemo(() => _getArrayProp(radius), [radius]), $fontSize = react.useMemo(() => _getArrayProp(fontSize2), [fontSize2]), $padding = react.useMemo(() => _getArrayProp(padding), [padding]), $space = react.useMemo(() => _getArrayProp(0), []);
3966
+ return /* @__PURE__ */ jsxRuntime.jsx(Root$c, { "data-ui": "TextArea", children: /* @__PURE__ */ jsxRuntime.jsxs(InputRoot$1, { children: [
3991
3967
  /* @__PURE__ */ jsxRuntime.jsx(
3992
3968
  Input$1,
3993
3969
  {
@@ -3995,10 +3971,10 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
3995
3971
  "data-scheme": rootTheme.scheme,
3996
3972
  "data-tone": rootTheme.tone,
3997
3973
  ...restProps,
3998
- $fontSize: useArrayProp(fontSize2),
3999
- $padding: useArrayProp(padding),
3974
+ $fontSize,
3975
+ $padding,
3976
+ $space,
4000
3977
  $scheme: rootTheme.scheme,
4001
- $space: useArrayProp(0),
4002
3978
  $tone: rootTheme.tone,
4003
3979
  $weight: weight,
4004
3980
  disabled,
@@ -4008,7 +3984,7 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
4008
3984
  /* @__PURE__ */ jsxRuntime.jsx(
4009
3985
  Presentation$1,
4010
3986
  {
4011
- $radius: useArrayProp(radius),
3987
+ $radius,
4012
3988
  $scheme: rootTheme.scheme,
4013
3989
  $tone: rootTheme.tone,
4014
3990
  "data-border": border2 ? "" : void 0,
@@ -4082,7 +4058,7 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
4082
4058
  type = "text",
4083
4059
  weight,
4084
4060
  ...restProps
4085
- } = props, ref = react.useRef(null), rootTheme = useRootTheme(), fontSize2 = useArrayProp(fontSizeProp), padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), space = useArrayProp(spaceProp), $hasClearButton = !!clearButton, $hasIcon = !!IconComponent, $hasIconRight = !!IconRightComponent, $hasSuffix = !!suffix, $hasPrefix = !!prefix;
4061
+ } = props, ref = react.useRef(null), rootTheme = useRootTheme(), fontSize2 = react.useMemo(() => _getArrayProp(fontSizeProp), [fontSizeProp]), padding = react.useMemo(() => _getArrayProp(paddingProp), [paddingProp]), radius = react.useMemo(() => _getArrayProp(radiusProp), [radiusProp]), space = react.useMemo(() => _getArrayProp(spaceProp), [spaceProp]), $hasClearButton = !!clearButton, $hasIcon = !!IconComponent, $hasIconRight = !!IconRightComponent, $hasSuffix = !!suffix, $hasPrefix = !!prefix;
4086
4062
  react.useImperativeHandle(
4087
4063
  forwardedRef,
4088
4064
  () => ref.current
@@ -4114,11 +4090,11 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
4114
4090
  children: [
4115
4091
  IconComponent && /* @__PURE__ */ jsxRuntime.jsx(LeftBox, { padding, children: /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
4116
4092
  react.isValidElement(IconComponent) && IconComponent,
4117
- ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
4093
+ reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
4118
4094
  ] }) }),
4119
4095
  !$hasClearButton && IconRightComponent && /* @__PURE__ */ jsxRuntime.jsx(RightBox, { padding, children: /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
4120
4096
  react.isValidElement(IconRightComponent) && IconRightComponent,
4121
- ReactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
4097
+ reactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
4122
4098
  ] }) })
4123
4099
  ]
4124
4100
  }
@@ -4334,27 +4310,30 @@ const Root$a = styledComponents.styled(Layer)`
4334
4310
  pointer-events: none;
4335
4311
  max-width: ${({ $maxWidth }) => $maxWidth}px;
4336
4312
  `, Tooltip = react.forwardRef(function(props, forwardedRef) {
4337
- var _a, _b, _c, _d, _e, _f, _g;
4313
+ var _a, _b, _c, _d, _e, _f;
4338
4314
  const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
4339
4315
  animate: _animate = !1,
4340
4316
  arrow: arrowProp = !1,
4341
- boundaryElement = boundaryElementContext == null ? void 0 : boundaryElementContext.element,
4317
+ boundaryElement: _boundaryElement,
4342
4318
  children: childProp,
4343
4319
  content,
4344
4320
  disabled,
4345
- fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a = props.placement) != null ? _a : "bottom"],
4321
+ fallbackPlacements: _fallbackPlacements,
4346
4322
  padding = 2,
4347
4323
  placement: placementProp = "bottom",
4348
4324
  portal: portalProp,
4349
4325
  radius = 2,
4350
4326
  scheme,
4351
4327
  shadow = 2,
4352
- zOffset = layer.tooltip.zOffset,
4328
+ zOffset: _zOffset,
4353
4329
  delay,
4354
4330
  ...restProps
4355
- } = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
4331
+ } = props, zOffset = _zOffset != null ? _zOffset : layer.tooltip.zOffset, fallbackPlacementsProp = _fallbackPlacements != null ? _fallbackPlacements : DEFAULT_FALLBACK_PLACEMENTS[(_a = props.placement) != null ? _a : "bottom"], boundaryElement = _boundaryElement != null ? _boundaryElement : boundaryElementContext == null ? void 0 : boundaryElementContext.element, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = react.useMemo(
4332
+ () => _getArrayProp(fallbackPlacementsProp),
4333
+ [fallbackPlacementsProp]
4334
+ ), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
4356
4335
  react.useImperativeHandle(forwardedRef, () => ref.current);
4357
- const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, documentBodyOffsetWidth = react.useSyncExternalStore(
4336
+ const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_b = portal.elements) == null ? void 0 : _b[portalProp]) || null : portal.element, documentBodyOffsetWidth = react.useSyncExternalStore(
4358
4337
  emptySubscribe,
4359
4338
  () => document.body.offsetWidth,
4360
4339
  // We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
@@ -4385,7 +4364,7 @@ const Root$a = styledComponents.styled(Layer)`
4385
4364
  middleware,
4386
4365
  placement: placementProp,
4387
4366
  whileElementsMounted: reactDom$1.autoUpdate
4388
- }), arrowX = (_d = middlewareData.arrow) == null ? void 0 : _d.x, arrowY = (_e = middlewareData.arrow) == null ? void 0 : _e.y, originX = (_f = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _f.originX, originY = (_g = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _g.originY, tooltipId = react.useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), showTooltip = isOpen || (delayGroupContext == null ? void 0 : delayGroupContext.openTooltipId) === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : (delay == null ? void 0 : delay.open) || 0, closeDelayProp = typeof delay == "number" ? delay : (delay == null ? void 0 : delay.close) || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = react.useCallback(
4367
+ }), arrowX = (_c = middlewareData.arrow) == null ? void 0 : _c.x, arrowY = (_d = middlewareData.arrow) == null ? void 0 : _d.y, originX = (_e = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _e.originX, originY = (_f = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _f.originY, tooltipId = react.useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), showTooltip = isOpen || (delayGroupContext == null ? void 0 : delayGroupContext.openTooltipId) === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : (delay == null ? void 0 : delay.open) || 0, closeDelayProp = typeof delay == "number" ? delay : (delay == null ? void 0 : delay.close) || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = react.useCallback(
4389
4368
  (open, immediate) => {
4390
4369
  if (isInsideGroup)
4391
4370
  if (open) {
@@ -4438,9 +4417,9 @@ const Root$a = styledComponents.styled(Layer)`
4438
4417
  );
4439
4418
  react.useEffect(() => {
4440
4419
  if (!showTooltip) return;
4441
- function handleWindowMouseMove(event) {
4420
+ const handleWindowMouseMove = (event) => {
4442
4421
  referenceElement && (referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target) || (handleIsOpenChange(!1), window.removeEventListener("mousemove", handleWindowMouseMove)));
4443
- }
4422
+ };
4444
4423
  return window.addEventListener("mousemove", handleWindowMouseMove), () => {
4445
4424
  window.removeEventListener("mousemove", handleWindowMouseMove);
4446
4425
  };
@@ -4643,37 +4622,34 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4643
4622
  forwardedRef,
4644
4623
  () => inputElementRef.current
4645
4624
  );
4646
- const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useArrayProp(paddingProp), currentOption = react.useMemo(
4625
+ const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = _getArrayProp(paddingProp), currentOption = react.useMemo(
4647
4626
  () => value !== null ? options.find((o) => o.value === value) : void 0,
4648
4627
  [options, value]
4649
4628
  ), filteredOptions = react.useMemo(
4650
4629
  () => options.filter((option) => query ? filterOption(query, option) : !0),
4651
4630
  [filterOption, options, query]
4652
- ), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = react.useCallback(
4653
- (event) => {
4654
- setTimeout(() => {
4655
- if (popoverMouseWithinRef.current)
4656
- return;
4657
- const elements = (relatedElements || []).concat(
4658
- rootElementRef.current ? [rootElementRef.current] : [],
4659
- resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []
4660
- );
4661
- let focusInside = !1;
4662
- if (document.activeElement) {
4663
- for (const e of elements)
4664
- if (e === document.activeElement || e.contains(document.activeElement)) {
4665
- focusInside = !0;
4666
- break;
4667
- }
4668
- }
4669
- focusInside === !1 && (dispatch({ type: "root/blur" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
4670
- }, 0);
4671
- },
4672
- [onBlur, onQueryChange, relatedElements]
4673
- ), handleRootFocus = react.useCallback((event) => {
4631
+ ), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = (event) => {
4632
+ setTimeout(() => {
4633
+ if (popoverMouseWithinRef.current)
4634
+ return;
4635
+ const elements = (relatedElements || []).concat(
4636
+ rootElementRef.current ? [rootElementRef.current] : [],
4637
+ resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []
4638
+ );
4639
+ let focusInside = !1;
4640
+ if (document.activeElement) {
4641
+ for (const e of elements)
4642
+ if (e === document.activeElement || e.contains(document.activeElement)) {
4643
+ focusInside = !0;
4644
+ break;
4645
+ }
4646
+ }
4647
+ focusInside === !1 && (dispatch({ type: "root/blur" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
4648
+ }, 0);
4649
+ }, handleRootFocus = (event) => {
4674
4650
  const listBoxElement = listBoxElementRef.current, focusedElement = event.target instanceof HTMLElement ? event.target : null, listFocused2 = (listBoxElement == null ? void 0 : listBoxElement.contains(focusedElement)) || !1;
4675
4651
  listFocused2 !== listFocusedRef.current && (listFocusedRef.current = listFocused2, dispatch({ type: "root/setListFocused", listFocused: listFocused2 }));
4676
- }, []), handleOptionSelect = react.useCallback(
4652
+ }, handleOptionSelect = react.useCallback(
4677
4653
  (v) => {
4678
4654
  var _a;
4679
4655
  dispatch({ type: "value/change", value: v }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), (_a = inputElementRef.current) == null || _a.focus();
@@ -4949,7 +4925,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4949
4925
  appearance: none;
4950
4926
  margin: -4px;
4951
4927
  `, Breadcrumbs = react.forwardRef(function(props, ref) {
4952
- const { children, maxLength, separator, space: spaceRaw = 2, ...restProps } = props, space = useArrayProp(spaceRaw), [open, setOpen] = react.useState(!1), [expandElement, setExpandElement] = react.useState(null), [popoverElement, setPopoverElement] = react.useState(null), collapse = react.useCallback(() => setOpen(!1), []), expand = react.useCallback(() => setOpen(!0), []);
4928
+ const { children, maxLength, separator, space: spaceRaw = 2, ...restProps } = props, space = react.useMemo(() => _getArrayProp(spaceRaw), [spaceRaw]), [open, setOpen] = react.useState(!1), [expandElement, setExpandElement] = react.useState(null), [popoverElement, setPopoverElement] = react.useState(null), collapse = react.useCallback(() => setOpen(!1), []), expand = react.useCallback(() => setOpen(!0), []);
4953
4929
  useClickOutside(collapse, [expandElement, popoverElement]);
4954
4930
  const rawItems = react.useMemo(() => react.Children.toArray(children).filter(react.isValidElement), [children]), items = react.useMemo(() => {
4955
4931
  const len = rawItems.length;
@@ -5098,7 +5074,7 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
5098
5074
  scheme,
5099
5075
  shadow: shadowProp,
5100
5076
  width: widthProp
5101
- } = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp), ref = react.useRef(null), [rootElement, setRootElement] = react.useState(null), contentRef = react.useRef(null), layer = useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
5077
+ } = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = react.useMemo(() => _getArrayProp(radiusProp), [radiusProp]), shadow = react.useMemo(() => _getArrayProp(shadowProp), [shadowProp]), width = react.useMemo(() => _getArrayProp(widthProp), [widthProp]), ref = react.useRef(null), [rootElement, setRootElement] = react.useState(null), contentRef = react.useRef(null), layer = useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
5102
5078
  react.useImperativeHandle(forwardedRef, () => ref.current), react.useImperativeHandle(
5103
5079
  forwardedContentRef,
5104
5080
  () => contentRef.current
@@ -5163,13 +5139,13 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
5163
5139
  onFocus,
5164
5140
  padding: paddingProp = 3,
5165
5141
  portal: portalProp,
5166
- position: positionProp = dialog.position || "fixed",
5142
+ position: _position,
5167
5143
  scheme,
5168
5144
  width: widthProp = 0,
5169
- zOffset: zOffsetProp = dialog.zOffset || layer.dialog.zOffset,
5145
+ zOffset: _zOffset,
5170
5146
  animate: _animate = !1,
5171
5147
  ...restProps
5172
- } = props, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, cardRadius = useArrayProp(cardRadiusProp), padding = useArrayProp(paddingProp), position = useArrayProp(positionProp), width = useArrayProp(widthProp), zOffset = useArrayProp(zOffsetProp), preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null), handleFocus = react.useCallback(
5148
+ } = props, positionProp = _position != null ? _position : dialog.position || "fixed", zOffsetProp = _zOffset != null ? _zOffset : dialog.zOffset || layer.dialog.zOffset, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, cardRadius = react.useMemo(() => _getArrayProp(cardRadiusProp), [cardRadiusProp]), padding = react.useMemo(() => _getArrayProp(paddingProp), [paddingProp]), position = react.useMemo(() => _getArrayProp(positionProp), [positionProp]), width = react.useMemo(() => _getArrayProp(widthProp), [widthProp]), zOffset = react.useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null), handleFocus = react.useCallback(
5173
5149
  (event) => {
5174
5150
  onFocus == null || onFocus(event);
5175
5151
  const target = event.target, cardElement = cardRef.current;
@@ -5265,7 +5241,7 @@ const Root$6 = styledComponents.styled.kbd`
5265
5241
  display: block;
5266
5242
  }
5267
5243
  `, Hotkeys = react.forwardRef(function(props, ref) {
5268
- const { fontSize: fontSize2, keys, padding, radius, space: spaceProp = 0.5, ...restProps } = props, space = useArrayProp(spaceProp);
5244
+ const { fontSize: fontSize2, keys, padding, radius, space: spaceProp = 0.5, ...restProps } = props, space = react.useMemo(() => _getArrayProp(spaceProp), [spaceProp]);
5269
5245
  return !keys || keys.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) : /* @__PURE__ */ jsxRuntime.jsx(Root$6, { "data-ui": "Hotkeys", ...restProps, ref, children: /* @__PURE__ */ jsxRuntime.jsx(Inline, { as: "span", space, children: keys.map((key2, i) => /* @__PURE__ */ jsxRuntime.jsx(Key, { fontSize: fontSize2, padding, radius, children: key2 }, i)) }) });
5270
5246
  }), key$2 = Symbol.for("@sanity/ui/context/menu"), MenuContext = createGlobalScopedContext(key$2, null);
5271
5247
  function _isFocusable(element) {
@@ -5433,10 +5409,10 @@ const Root$5 = styledComponents.styled(Box)`
5433
5409
  originElement,
5434
5410
  padding = 1,
5435
5411
  registerElement,
5436
- shouldFocus = props.focusFirst && "first" || props.focusLast && "last" || null,
5412
+ shouldFocus: _shouldFocus,
5437
5413
  space = 1,
5438
5414
  ...restProps
5439
- } = props, ref = react.useRef(null);
5415
+ } = props, shouldFocus = _shouldFocus != null ? _shouldFocus : props.focusFirst && "first" || props.focusLast && "last" || null, ref = react.useRef(null);
5440
5416
  react.useImperativeHandle(forwardedRef, () => ref.current);
5441
5417
  const { isTopLayer } = useLayer(), {
5442
5418
  activeElement,
@@ -5580,28 +5556,16 @@ const Root$5 = styledComponents.styled(Box)`
5580
5556
  setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
5581
5557
  }, [buttonElement, disableRestoreFocusOnClose]), registerElement = react.useCallback((el) => (setChildMenuElements((els) => els.concat([el])), () => {
5582
5558
  setChildMenuElements((els) => els.filter((_el) => _el !== el));
5583
- }), []), menuProps = react.useMemo(
5584
- () => ({
5585
- "aria-labelledby": id,
5586
- onBlurCapture: handleBlur,
5587
- onClickOutside: handleMenuClickOutside,
5588
- onEscape: handleMenuEscape,
5589
- onItemClick: handleItemClick,
5590
- originElement: buttonElement,
5591
- registerElement,
5592
- shouldFocus
5593
- }),
5594
- [
5595
- buttonElement,
5596
- handleMenuClickOutside,
5597
- handleMenuEscape,
5598
- handleItemClick,
5599
- id,
5600
- handleBlur,
5601
- registerElement,
5602
- shouldFocus
5603
- ]
5604
- ), menu = menuProp && react.cloneElement(menuProp, menuProps), ref = react.useRef(null), button = react.useMemo(
5559
+ }), []), menu = menuProp && react.cloneElement(menuProp, {
5560
+ "aria-labelledby": id,
5561
+ onBlurCapture: handleBlur,
5562
+ onClickOutside: handleMenuClickOutside,
5563
+ onEscape: handleMenuEscape,
5564
+ onItemClick: handleItemClick,
5565
+ originElement: buttonElement,
5566
+ registerElement,
5567
+ shouldFocus
5568
+ }), button = react.useMemo(
5605
5569
  () => {
5606
5570
  var _a;
5607
5571
  return buttonProp && react.cloneElement(buttonProp, {
@@ -5612,7 +5576,7 @@ const Root$5 = styledComponents.styled(Box)`
5612
5576
  onMouseDown: handleMouseDown,
5613
5577
  "aria-haspopup": !0,
5614
5578
  "aria-expanded": open,
5615
- ref,
5579
+ ref: setButtonElement,
5616
5580
  selected: (_a = buttonProp.props.selected) != null ? _a : open
5617
5581
  });
5618
5582
  },
@@ -5620,11 +5584,9 @@ const Root$5 = styledComponents.styled(Box)`
5620
5584
  );
5621
5585
  react.useImperativeHandle(
5622
5586
  forwardedRef,
5623
- () => ref.current
5624
- ), react.useEffect(() => {
5625
- if (button)
5626
- return setButtonElement(ref.current), () => setButtonElement(null);
5627
- }, [button]);
5587
+ () => buttonElement,
5588
+ [buttonElement]
5589
+ );
5628
5590
  const popoverProps = react.useMemo(
5629
5591
  () => ({
5630
5592
  boundaryElement: deprecated_boundaryElement,
@@ -5646,7 +5608,19 @@ const Root$5 = styledComponents.styled(Box)`
5646
5608
  popover
5647
5609
  ]
5648
5610
  );
5649
- return /* @__PURE__ */ jsxRuntime.jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: button || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) });
5611
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5612
+ /* @__PURE__ */ jsxRuntime.jsx(
5613
+ Popover,
5614
+ {
5615
+ "data-ui": "MenuButton__popover",
5616
+ referenceElement: buttonElement,
5617
+ ...popoverProps,
5618
+ content: menu,
5619
+ open
5620
+ }
5621
+ ),
5622
+ button
5623
+ ] });
5650
5624
  }), MenuDivider = styledComponents.styled.hr`
5651
5625
  height: 1px;
5652
5626
  border: 0;
@@ -5771,7 +5745,7 @@ function MenuGroup(props) {
5771
5745
  onClick,
5772
5746
  padding = 3,
5773
5747
  popover,
5774
- radius = 2,
5748
+ radius: radiusProp = 2,
5775
5749
  space = 3,
5776
5750
  text,
5777
5751
  tone = "default",
@@ -5782,9 +5756,9 @@ function MenuGroup(props) {
5782
5756
  onClickOutside,
5783
5757
  onEscape,
5784
5758
  onItemClick,
5785
- onItemMouseEnter = menu.onMouseEnter,
5759
+ onItemMouseEnter: _onItemMouseEnter,
5786
5760
  registerElement
5787
- } = menu, [rootElement, setRootElement] = react.useState(null), [open, setOpen] = react.useState(!1), shouldFocusRef = react.useRef(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = react.useState(!1), handleMouseEnter = react.useCallback(
5761
+ } = menu, onItemMouseEnter = _onItemMouseEnter != null ? _onItemMouseEnter : menu.onMouseEnter, [rootElement, setRootElement] = react.useState(null), [open, setOpen] = react.useState(!1), shouldFocusRef = react.useRef(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = react.useState(!1), radius = react.useMemo(() => _getArrayProp(radiusProp), [radiusProp]), handleMouseEnter = react.useCallback(
5788
5762
  (event) => {
5789
5763
  setWithinMenu(!1), onItemMouseEnter(event), setOpen(!0);
5790
5764
  },
@@ -5842,7 +5816,7 @@ function MenuGroup(props) {
5842
5816
  "aria-pressed": as === "button" ? withinMenu : void 0,
5843
5817
  "data-pressed": as !== "button" ? withinMenu : void 0,
5844
5818
  "data-selected": !withinMenu && active ? "" : void 0,
5845
- $radius: useArrayProp(radius),
5819
+ $radius: radius,
5846
5820
  $tone: tone,
5847
5821
  $scheme: scheme,
5848
5822
  onClick: handleClick,
@@ -5854,7 +5828,7 @@ function MenuGroup(props) {
5854
5828
  children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: space, padding, children: [
5855
5829
  IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
5856
5830
  react.isValidElement(IconComponent) && IconComponent,
5857
- ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
5831
+ reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
5858
5832
  ] }),
5859
5833
  /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, textOverflow: "ellipsis", weight: "medium", children: text }) }),
5860
5834
  /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}) })
@@ -5890,9 +5864,9 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
5890
5864
  activeElement,
5891
5865
  mount,
5892
5866
  onItemClick,
5893
- onItemMouseEnter = menu.onMouseEnter,
5894
- onItemMouseLeave = menu.onMouseLeave
5895
- } = menu, [rootElement, setRootElement] = react.useState(null), active = !!activeElement && activeElement === rootElement, ref = react.useRef(null);
5867
+ onItemMouseEnter: _onItemMouseEnter,
5868
+ onItemMouseLeave: _onItemMouseLeave
5869
+ } = menu, onItemMouseEnter = _onItemMouseEnter != null ? _onItemMouseEnter : menu.onMouseEnter, onItemMouseLeave = _onItemMouseLeave != null ? _onItemMouseLeave : menu.onMouseLeave, [rootElement, setRootElement] = react.useState(null), active = !!activeElement && activeElement === rootElement, ref = react.useRef(null);
5896
5870
  react.useImperativeHandle(forwardedRef, () => ref.current), react.useEffect(() => mount(rootElement, selectedProp), [mount, rootElement, selectedProp]);
5897
5871
  const handleClick = react.useCallback(
5898
5872
  (event) => {
@@ -5910,7 +5884,7 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
5910
5884
  paddingLeft
5911
5885
  }),
5912
5886
  [padding, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft]
5913
- ), hotkeysFontSize = useArrayProp(fontSize2).map((s) => s - 1), setRef = react.useCallback((el) => {
5887
+ ), hotkeysFontSize = react.useMemo(() => _getArrayProp(fontSize2).map((s) => s - 1), [fontSize2]), $radius = react.useMemo(() => _getArrayProp(radius), [radius]), $padding = react.useMemo(() => _getArrayProp(0), []), setRef = react.useCallback((el) => {
5914
5888
  ref.current = el, setRootElement(el);
5915
5889
  }, []);
5916
5890
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -5923,8 +5897,8 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
5923
5897
  "data-selected": active ? "" : void 0,
5924
5898
  "data-disabled": disabled ? "" : void 0,
5925
5899
  forwardedAs: as,
5926
- $radius: useArrayProp(radius),
5927
- $padding: useArrayProp(0),
5900
+ $radius,
5901
+ $padding,
5928
5902
  $tone: disabled ? "default" : tone,
5929
5903
  $scheme: scheme,
5930
5904
  disabled,
@@ -5939,7 +5913,7 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
5939
5913
  (IconComponent || text || IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsxs(Flex, { as: "span", gap: space, align: "center", ...paddingProps, children: [
5940
5914
  IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
5941
5915
  react.isValidElement(IconComponent) && IconComponent,
5942
- ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
5916
+ reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
5943
5917
  ] }),
5944
5918
  text && /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, textOverflow: "ellipsis", weight: "medium", children: text }) }),
5945
5919
  hotkeys && /* @__PURE__ */ jsxRuntime.jsx(
@@ -5952,7 +5926,7 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
5952
5926
  ),
5953
5927
  IconRightComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
5954
5928
  react.isValidElement(IconRightComponent) && IconRightComponent,
5955
- ReactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
5929
+ reactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
5956
5930
  ] })
5957
5931
  ] }),
5958
5932
  children && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", ...paddingProps, children })
@@ -6000,7 +5974,7 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
6000
5974
  skeletonStyle
6001
5975
  ), Skeleton = react.forwardRef(function(props, ref) {
6002
5976
  const { animated = !1, delay, radius, ...restProps } = props, [visible, setVisible] = react.useState(!delay);
6003
- return react.useEffect(() => {
5977
+ react.useEffect(() => {
6004
5978
  if (!delay)
6005
5979
  return setVisible(!0);
6006
5980
  const timeout = setTimeout(() => {
@@ -6009,16 +5983,9 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
6009
5983
  return () => {
6010
5984
  clearTimeout(timeout);
6011
5985
  };
6012
- }, [delay]), /* @__PURE__ */ jsxRuntime.jsx(
6013
- Root$4,
6014
- {
6015
- ...restProps,
6016
- $animated: animated,
6017
- $radius: useArrayProp(radius),
6018
- $visible: visible,
6019
- ref
6020
- }
6021
- );
5986
+ }, [delay]);
5987
+ const $radius = react.useMemo(() => _getArrayProp(radius), [radius]);
5988
+ return /* @__PURE__ */ jsxRuntime.jsx(Root$4, { ...restProps, $animated: animated, $radius, $visible: visible, ref });
6022
5989
  }), Root$3 = styledComponents.styled(Skeleton)((props) => {
6023
5990
  const { $size, $style } = props, { font, media } = theme.getTheme_v2(props.theme), fontStyle = font[$style];
6024
5991
  return _responsive(media, $size, (sizeIndex) => {
@@ -6026,16 +5993,16 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
6026
5993
  return { height: fontSize2.lineHeight - fontSize2.ascenderHeight - fontSize2.descenderHeight };
6027
5994
  });
6028
5995
  }), TextSkeleton = react.forwardRef(function(props, ref) {
6029
- const { size: size2 = 2, ...restProps } = props, $size = useArrayProp(size2);
5996
+ const { size: size2 = 2, ...restProps } = props, $size = react.useMemo(() => _getArrayProp(size2), [size2]);
6030
5997
  return /* @__PURE__ */ jsxRuntime.jsx(Root$3, { ...restProps, $size, ref, $style: "text" });
6031
5998
  }), LabelSkeleton = react.forwardRef(function(props, ref) {
6032
- const { size: size2 = 2, ...restProps } = props, $size = useArrayProp(size2);
5999
+ const { size: size2 = 2, ...restProps } = props, $size = react.useMemo(() => _getArrayProp(size2), [size2]);
6033
6000
  return /* @__PURE__ */ jsxRuntime.jsx(Root$3, { ...restProps, $size, ref, $style: "label" });
6034
6001
  }), HeadingSkeleton = react.forwardRef(function(props, ref) {
6035
- const { size: size2 = 2, ...restProps } = props, $size = useArrayProp(size2);
6002
+ const { size: size2 = 2, ...restProps } = props, $size = react.useMemo(() => _getArrayProp(size2), [size2]);
6036
6003
  return /* @__PURE__ */ jsxRuntime.jsx(Root$3, { ...restProps, $size, ref, $style: "heading" });
6037
6004
  }), CodeSkeleton = react.forwardRef(function(props, ref) {
6038
- const { size: size2 = 2, ...restProps } = props, $size = useArrayProp(size2);
6005
+ const { size: size2 = 2, ...restProps } = props, $size = react.useMemo(() => _getArrayProp(size2), [size2]);
6039
6006
  return /* @__PURE__ */ jsxRuntime.jsx(Root$3, { ...restProps, $size, ref, $style: "code" });
6040
6007
  }), CustomButton = styledComponents.styled(Button)`
6041
6008
  max-width: 100%;
@@ -6219,33 +6186,12 @@ const subscribe = () => () => {
6219
6186
  max-width: 420px;
6220
6187
  width: 100%;
6221
6188
  `;
6222
- let toastId = 0;
6223
6189
  function ToastProvider(props) {
6224
6190
  const { children, padding = 4, paddingX, paddingY, zOffset } = props, [state, _setState] = react.useState([]), toastsRef = react.useRef({}), mounted = useMounted(), prefersReducedMotion = usePrefersReducedMotion(), variants = react.useMemo(
6225
- () => ({
6226
- initial: {
6227
- opacity: 0,
6228
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
6229
- y: 32,
6230
- scale: 0.25,
6231
- willChange: "transform"
6232
- },
6233
- animate: {
6234
- opacity: [0, 1, 1],
6235
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
6236
- y: 0,
6237
- scale: 1
6238
- },
6239
- exit: {
6240
- opacity: [1, 1, 0],
6241
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [1, 0, 0],
6242
- scale: 0.5,
6243
- transition: prefersReducedMotion ? { duration: 0 } : { duration: 0.2 }
6244
- }
6245
- }),
6191
+ () => getVariants(prefersReducedMotion),
6246
6192
  [prefersReducedMotion]
6247
6193
  ), value = react.useMemo(() => ({ version: 0, push: (params) => {
6248
- const setState = (state2) => react.startTransition(() => _setState(state2)), id = params.id || String(toastId++), duration = params.duration || 5e3, dismiss = () => {
6194
+ const setState = (state2) => react.startTransition(() => _setState(state2)), id = params.id || crypto.randomUUID(), duration = params.duration || 5e3, dismiss = () => {
6249
6195
  var _a;
6250
6196
  const timeoutId = (_a = toastsRef.current[id]) == null ? void 0 : _a.timeoutId;
6251
6197
  setState((prevState) => {
@@ -6298,6 +6244,29 @@ function ToastProvider(props) {
6298
6244
  )) }) }) }) })
6299
6245
  ] });
6300
6246
  }
6247
+ function getVariants(prefersReducedMotion) {
6248
+ return {
6249
+ initial: {
6250
+ opacity: 0,
6251
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
6252
+ y: 32,
6253
+ scale: 0.25,
6254
+ willChange: "transform"
6255
+ },
6256
+ animate: {
6257
+ opacity: [0, 1, 1],
6258
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
6259
+ y: 0,
6260
+ scale: 1
6261
+ },
6262
+ exit: {
6263
+ opacity: [1, 1, 0],
6264
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [1, 0, 0],
6265
+ scale: 0.5,
6266
+ transition: { duration: prefersReducedMotion ? 0 : 0.2 }
6267
+ }
6268
+ };
6269
+ }
6301
6270
  function useToast() {
6302
6271
  const value = react.useContext(ToastContext);
6303
6272
  if (!value)
@@ -6484,6 +6453,28 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
6484
6453
  })
6485
6454
  );
6486
6455
  Tree.displayName = "Tree";
6456
+ function useTree() {
6457
+ const tree = react.useContext(TreeContext);
6458
+ if (!tree)
6459
+ throw new Error("Tree: missing context value");
6460
+ return tree;
6461
+ }
6462
+ const TreeGroup = react.memo(function(props) {
6463
+ const { children, expanded = !1, ...restProps } = props, tree = useTree();
6464
+ return /* @__PURE__ */ jsxRuntime.jsx(
6465
+ Stack,
6466
+ {
6467
+ as: "ul",
6468
+ "data-ui": "TreeGroup",
6469
+ ...restProps,
6470
+ hidden: !expanded,
6471
+ marginTop: tree.space,
6472
+ role: "group",
6473
+ space: tree.space,
6474
+ children
6475
+ }
6476
+ );
6477
+ });
6487
6478
  function treeItemRootStyle() {
6488
6479
  return styledComponents.css`
6489
6480
  &[role='none'] > [role='treeitem'] {
@@ -6570,28 +6561,9 @@ function treeItemBoxStyle(props) {
6570
6561
  }
6571
6562
  `;
6572
6563
  }
6573
- function useTree() {
6574
- const tree = react.useContext(TreeContext);
6575
- if (!tree)
6576
- throw new Error("Tree: missing context value");
6577
- return tree;
6578
- }
6579
- const TreeGroup = react.memo(function(props) {
6580
- const { children, expanded = !1, ...restProps } = props, tree = useTree();
6581
- return /* @__PURE__ */ jsxRuntime.jsx(
6582
- Stack,
6583
- {
6584
- as: "ul",
6585
- "data-ui": "TreeGroup",
6586
- ...restProps,
6587
- hidden: !expanded,
6588
- marginTop: tree.space,
6589
- role: "group",
6590
- space: tree.space,
6591
- children
6592
- }
6593
- );
6594
- }), Root = react.memo(styledComponents.styled.li(treeItemRootStyle, treeItemRootColorStyle)), TreeItemBox = styledComponents.styled(Box).attrs({ forwardedAs: "a" })(treeItemBoxStyle), ToggleArrowText = styledComponents.styled(Text)`
6564
+ const Root = react.memo(styledComponents.styled.li(treeItemRootStyle, treeItemRootColorStyle)), TreeItemBox = styledComponents.styled(Box).attrs({ forwardedAs: "a" })(
6565
+ treeItemBoxStyle
6566
+ ), ToggleArrowText = styledComponents.styled(Text)`
6595
6567
  & > svg {
6596
6568
  transition: transform 100ms;
6597
6569
  }
@@ -6612,12 +6584,12 @@ const TreeGroup = react.memo(function(props) {
6612
6584
  text,
6613
6585
  weight,
6614
6586
  ...restProps
6615
- } = props, rootRef = react.useRef(null), treeitemRef = react.useRef(null), tree = useTree(), { path, registerItem, setExpanded, setFocusedElement } = tree, _id = react.useId(), id = idProp || _id, itemPath = react.useMemo(() => path.concat([id || ""]), [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], focused = tree.focusedElement === rootRef.current, expanded = (itemState == null ? void 0 : itemState.expanded) === void 0 ? expandedProp : (itemState == null ? void 0 : itemState.expanded) || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootRef.current ? 0 : -1, contextValue = react.useMemo(
6587
+ } = props, rootRef = react.useRef(null), treeitemRef = react.useRef(null), tree = useTree(), { path, registerItem, setExpanded, setFocusedElement } = tree, _id = react.useId(), id = idProp || _id, itemPath = react.useMemo(() => [...path, id || ""], [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], focused = tree.focusedElement === rootRef.current, expanded = (itemState == null ? void 0 : itemState.expanded) === void 0 ? expandedProp : (itemState == null ? void 0 : itemState.expanded) || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootRef.current ? 0 : -1, contextValue = react.useMemo(
6616
6588
  () => ({ ...tree, level: tree.level + 1, path: itemPath }),
6617
6589
  [itemPath, tree]
6618
6590
  ), handleClick = react.useCallback(
6619
6591
  (event) => {
6620
- onClick && onClick(event);
6592
+ onClick == null || onClick(event);
6621
6593
  const target = event.target;
6622
6594
  target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]')) && (event.stopPropagation(), setExpanded(itemKey, !expanded), setFocusedElement(rootRef.current));
6623
6595
  },
@@ -6635,23 +6607,26 @@ const TreeGroup = react.memo(function(props) {
6635
6607
  if (rootRef.current)
6636
6608
  return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
6637
6609
  }, [expanded, itemPath, registerItem, selected]);
6638
- const content = /* @__PURE__ */ jsxRuntime.jsxs(Flex, { padding, children: [
6639
- /* @__PURE__ */ jsxRuntime.jsxs(
6640
- Box,
6641
- {
6642
- marginRight: space,
6643
- style: {
6644
- visibility: IconComponent || children ? "visible" : "hidden",
6645
- pointerEvents: "none"
6646
- },
6647
- children: [
6648
- IconComponent && /* @__PURE__ */ jsxRuntime.jsx(Text, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {}) }),
6649
- !IconComponent && /* @__PURE__ */ jsxRuntime.jsx(ToggleArrowText, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ToggleArrowRightIcon, { style: { transform: expanded ? "rotate(90deg)" : void 0 } }) })
6650
- ]
6651
- }
6652
- ),
6653
- /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { muted, size: fontSize2, textOverflow: "ellipsis", weight, children: text }) })
6654
- ] });
6610
+ const content = react.useMemo(
6611
+ () => /* @__PURE__ */ jsxRuntime.jsxs(Flex, { padding, children: [
6612
+ /* @__PURE__ */ jsxRuntime.jsxs(
6613
+ Box,
6614
+ {
6615
+ marginRight: space,
6616
+ style: {
6617
+ visibility: IconComponent || children ? "visible" : "hidden",
6618
+ pointerEvents: "none"
6619
+ },
6620
+ children: [
6621
+ IconComponent && /* @__PURE__ */ jsxRuntime.jsx(Text, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {}) }),
6622
+ !IconComponent && /* @__PURE__ */ jsxRuntime.jsx(ToggleArrowText, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ToggleArrowRightIcon, { style: { transform: expanded ? "rotate(90deg)" : void 0 } }) })
6623
+ ]
6624
+ }
6625
+ ),
6626
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { muted, size: fontSize2, textOverflow: "ellipsis", weight, children: text }) })
6627
+ ] }),
6628
+ [IconComponent, children, expanded, fontSize2, muted, padding, space, text, weight]
6629
+ );
6655
6630
  return href ? /* @__PURE__ */ jsxRuntime.jsxs(
6656
6631
  Root,
6657
6632
  {