UNPKG

@sanity/ui

Version:

The Sanity UI components.

895 lines (893 loc) 103 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }); var _visualEditing = require("./_chunks-cjs/_visual-editing.js"), jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), icons = require("@sanity/icons"), react = require("react"), styledComponents = require("styled-components"), theme = require("@sanity/ui/theme"), react$1 = require("motion/react"); function _raf(fn) { const frameId = requestAnimationFrame(fn); return () => { cancelAnimationFrame(frameId); }; } function _raf2(fn) { let innerDispose = null; const outerDispose = _raf(() => { innerDispose = _raf(fn); }); return () => { innerDispose && innerDispose(), outerDispose(); }; } function _hasFocus(element) { return !!document.activeElement && element.contains(document.activeElement); } function isFocusable(element) { return element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute("tabIndex") !== null ? !0 : _visualEditing.isHTMLAnchorElement(element) ? !!element.href && element.rel !== "ignore" : _visualEditing.isHTMLInputElement(element) ? element.type !== "hidden" && element.type !== "file" && !element.disabled : _visualEditing.isHTMLButtonElement(element) || _visualEditing.isHTMLSelectElement(element) || _visualEditing.isHTMLTextAreaElement(element) ? !element.disabled : !1; } function attemptFocus(element) { if (!isFocusable(element)) return !1; try { element.focus(); } catch { } return document.activeElement === element; } function focusFirstDescendant(element) { for (let i = 0; i < element.childNodes.length; i++) { const child = element.childNodes[i]; if (_visualEditing.isHTMLElement(child) && (attemptFocus(child) || focusFirstDescendant(child))) return !0; } return !1; } function focusLastDescendant(element) { for (let i = element.childNodes.length - 1; i >= 0; i--) { const child = element.childNodes[i]; if (_visualEditing.isHTMLElement(child) && (attemptFocus(child) || focusLastDescendant(child))) return !0; } return !1; } function useArrayProp(val, defaultVal) { const $ = reactCompilerRuntime.c(3); let t0; return $[0] !== defaultVal || $[1] !== val ? (t0 = _visualEditing._getArrayProp(val, defaultVal), $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2], t0; } function _getElements(element, elementsArg) { const ret = [element]; for (const el of elementsArg) Array.isArray(el) ? ret.push(...el) : ret.push(el); return ret.filter(Boolean); } function useClickOutside(listener, t0, boundaryElement) { const $ = reactCompilerRuntime.c(12), elementsArg = t0 === void 0 ? _visualEditing.EMPTY_ARRAY : t0, [element, setElement] = react.useState(null); let t1; $[0] !== element || $[1] !== elementsArg ? (t1 = () => _getElements(element, elementsArg), $[0] = element, $[1] = elementsArg, $[2] = t1) : t1 = $[2]; const [elements, setElements] = react.useState(t1), elementsRef = react.useRef(elements); let t2, t3; $[3] !== element || $[4] !== elementsArg ? (t2 = () => { const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg); if (prevElements.length !== nextElements.length) { setElements(nextElements), elementsRef.current = nextElements; return; } for (const el of prevElements) if (!nextElements.includes(el)) { setElements(nextElements), elementsRef.current = nextElements; return; } for (const el_0 of nextElements) if (!prevElements.includes(el_0)) { setElements(nextElements), elementsRef.current = nextElements; return; } }, t3 = [element, elementsArg], $[3] = element, $[4] = elementsArg, $[5] = t2, $[6] = t3) : (t2 = $[5], t3 = $[6]), react.useEffect(t2, t3); let t4, t5; return $[7] !== boundaryElement || $[8] !== elements || $[9] !== listener ? (t4 = () => { if (!listener) return; const handleWindowMouseDown = (evt) => { const target = evt.target; if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) { for (const el_1 of elements) if (target === el_1 || el_1.contains(target)) return; listener(evt); } }; return window.addEventListener("mousedown", handleWindowMouseDown), () => { window.removeEventListener("mousedown", handleWindowMouseDown); }; }, t5 = [boundaryElement, listener, elements], $[7] = boundaryElement, $[8] = elements, $[9] = listener, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), react.useEffect(t4, t5), setElement; } function useElementRect(element) { return _visualEditing.useElementSize(element)?._contentRect || null; } function useForwardedRef(ref) { const $ = reactCompilerRuntime.c(1), innerRef = react.useRef(null); let t0; return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => innerRef.current, $[0] = t0) : t0 = $[0], react.useImperativeHandle(ref, t0), innerRef; } class ErrorBoundary extends react.Component { state = { error: null }; static getDerivedStateFromError(error) { return { error }; } componentDidCatch(error, info) { this.props.onCatch({ error, info }); } render() { const { error } = this.state; if (error) { const message = typeof error?.message == "string" ? error.message : "Error"; return /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Code, { children: message }); } return this.props.children; } } const StyledAutocomplete = styledComponents.styled.div.withConfig({ displayName: "StyledAutocomplete", componentId: "sc-1igauft-0" })`line-height:0;`, ListBox = styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "ListBox", componentId: "sc-1igauft-1" })`& > ul{list-style:none;padding:0;margin:0;}`, rotate = styledComponents.keyframes` from { transform: rotate(0deg); } to { transform: rotate(360deg); } `, AnimatedSpinnerIcon = styledComponents.styled(icons.SpinnerIcon).withConfig({ displayName: "AnimatedSpinnerIcon", componentId: "sc-1igauft-2" })`animation:${rotate} 500ms linear infinite;`; function AutocompleteOption(props) { const $ = reactCompilerRuntime.c(11), { children, id, onSelect, selected, value } = props; let t0; $[0] !== onSelect || $[1] !== value ? (t0 = () => { setTimeout(() => { onSelect(value); }, 0); }, $[0] = onSelect, $[1] = value, $[2] = t0) : t0 = $[2]; const handleClick = t0; let t1; $[3] !== handleClick ? (t1 = (event) => { event.key === "Enter" && !_visualEditing._isEnterToClickElement(event.currentTarget) && handleClick(); }, $[3] = handleClick, $[4] = t1) : t1 = $[4]; const handleKeyDown = t1; let t2; return $[5] !== children || $[6] !== handleClick || $[7] !== handleKeyDown || $[8] !== id || $[9] !== selected ? (t2 = /* @__PURE__ */ jsxRuntime.jsx("li", { "aria-selected": selected, "data-ui": "AutocompleteOption", id, role: "option", onClick: handleClick, onKeyDown: handleKeyDown, children }), $[5] = children, $[6] = handleClick, $[7] = handleKeyDown, $[8] = id, $[9] = selected, $[10] = t2) : t2 = $[10], t2; } function autocompleteReducer(state, msg) { return msg.type === "input/change" ? { ...state, activeValue: null, focused: !0, query: msg.query } : msg.type === "input/focus" ? { ...state, focused: !0 } : msg.type === "root/blur" ? { ...state, focused: !1, query: null } : msg.type === "root/clear" ? { ...state, activeValue: null, query: null, value: null } : msg.type === "root/escape" ? { ...state, focused: !1, query: null } : msg.type === "root/open" ? { ...state, query: state.query || msg.query } : msg.type === "root/setActiveValue" ? { ...state, activeValue: msg.value, listFocused: msg.listFocused || state.listFocused } : msg.type === "root/setListFocused" ? { ...state, listFocused: msg.listFocused } : msg.type === "value/change" ? { ...state, activeValue: msg.value, query: null, value: msg.value } : state; } const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "Home", "End", "PageUp", "PageDown", "Meta", "Tab", "CapsLock"], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1, InnerAutocomplete = react.forwardRef(function(props, forwardedRef) { const $ = reactCompilerRuntime.c(181); let customValidity, disabled, filterOptionProp, icon, id, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, optionsProp, prefix, readOnly, relatedElements, renderOptionProp, renderPopover, restProps, suffix, t0, t1, t2, t3, t4, t5, t6, valueProp; $[0] !== props ? ({ border: t0, customValidity, disabled, filterOption: filterOptionProp, fontSize: t1, icon, id, listBox: t2, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, options: optionsProp, padding: t3, popover: t4, prefix, radius: t5, readOnly, relatedElements, renderOption: renderOptionProp, renderPopover, renderValue: t6, suffix, value: valueProp, ...restProps } = props, $[0] = props, $[1] = customValidity, $[2] = disabled, $[3] = filterOptionProp, $[4] = icon, $[5] = id, $[6] = loading, $[7] = onBlur, $[8] = onChange, $[9] = onFocus, $[10] = onQueryChange, $[11] = onSelect, $[12] = openButton, $[13] = openOnFocus, $[14] = optionsProp, $[15] = prefix, $[16] = readOnly, $[17] = relatedElements, $[18] = renderOptionProp, $[19] = renderPopover, $[20] = restProps, $[21] = suffix, $[22] = t0, $[23] = t1, $[24] = t2, $[25] = t3, $[26] = t4, $[27] = t5, $[28] = t6, $[29] = valueProp) : (customValidity = $[1], disabled = $[2], filterOptionProp = $[3], icon = $[4], id = $[5], loading = $[6], onBlur = $[7], onChange = $[8], onFocus = $[9], onQueryChange = $[10], onSelect = $[11], openButton = $[12], openOnFocus = $[13], optionsProp = $[14], prefix = $[15], readOnly = $[16], relatedElements = $[17], renderOptionProp = $[18], renderPopover = $[19], restProps = $[20], suffix = $[21], t0 = $[22], t1 = $[23], t2 = $[24], t3 = $[25], t4 = $[26], t5 = $[27], t6 = $[28], valueProp = $[29]); const border = t0 === void 0 ? !0 : t0, fontSize = t1 === void 0 ? 2 : t1, listBox = t2 === void 0 ? _visualEditing.EMPTY_RECORD : t2, paddingProp = t3 === void 0 ? 3 : t3, popover = t4 === void 0 ? _visualEditing.EMPTY_RECORD : t4, radius = t5 === void 0 ? 2 : t5, renderValue = t6 === void 0 ? DEFAULT_RENDER_VALUE : t6, t7 = valueProp || null, t8 = valueProp || null; let t9; $[30] !== t7 || $[31] !== t8 ? (t9 = { activeValue: t7, focused: !1, listFocused: !1, query: null, value: t8 }, $[30] = t7, $[31] = t8, $[32] = t9) : t9 = $[32]; const [state, dispatch] = react.useReducer(autocompleteReducer, t9), { activeValue, focused, listFocused, query, value } = state; let t10; $[33] !== fontSize || $[34] !== paddingProp ? (t10 = (t112) => { const { value: value_0 } = t112; return /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { size: fontSize, textOverflow: "ellipsis", children: value_0 }) }); }, $[33] = fontSize, $[34] = paddingProp, $[35] = t10) : t10 = $[35]; const renderOption = typeof renderOptionProp == "function" ? renderOptionProp : t10, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), [inputElement, _setInputElement] = react.useState(null); let t11; $[36] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (node) => { react.startTransition(() => _setInputElement(node)); }, $[36] = t11) : t11 = $[36]; const setInputElement = t11, listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1); let t12, t13; $[37] !== inputElement ? (t12 = () => inputElement, t13 = [inputElement], $[37] = inputElement, $[38] = t12, $[39] = t13) : (t12 = $[38], t13 = $[39]), react.useImperativeHandle(inputElementRef, t12, t13); let t14, t15; $[40] !== inputElement ? (t14 = () => inputElement, t15 = [inputElement], $[40] = inputElement, $[41] = t14, $[42] = t15) : (t14 = $[41], t15 = $[42]), react.useImperativeHandle(forwardedRef, t14, t15); const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : _visualEditing.EMPTY_ARRAY, padding = _visualEditing._getArrayProp(paddingProp); let t16; $[43] !== options || $[44] !== value ? (t16 = value !== null ? options.find((o) => o.value === value) : void 0, $[43] = options, $[44] = value, $[45] = t16) : t16 = $[45]; const currentOption = t16; let t17; if ($[46] !== filterOption || $[47] !== options || $[48] !== query) { let t182; $[50] !== filterOption || $[51] !== query ? (t182 = (option) => query ? filterOption(query, option) : !0, $[50] = filterOption, $[51] = query, $[52] = t182) : t182 = $[52], t17 = options.filter(t182), $[46] = filterOption, $[47] = options, $[48] = query, $[49] = t17; } else t17 = $[49]; const filteredOptions = t17, filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null; let t18; $[53] !== onBlur || $[54] !== onQueryChange || $[55] !== relatedElements ? (t18 = (event) => { setTimeout(() => { if (popoverMouseWithinRef.current) return; const elements = (relatedElements || []).concat(rootElementRef.current ? [rootElementRef.current] : [], resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []); let focusInside = !1; if (document.activeElement) { for (const e of elements) if (e === document.activeElement || e.contains(document.activeElement)) { focusInside = !0; break; } } focusInside === !1 && (dispatch({ type: "root/blur" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event)); }, 0); }, $[53] = onBlur, $[54] = onQueryChange, $[55] = relatedElements, $[56] = t18) : t18 = $[56]; const handleRootBlur = t18; let t19; $[57] === Symbol.for("react.memo_cache_sentinel") ? (t19 = (event_0) => { const listBoxElement = listBoxElementRef.current, focusedElement = event_0.target instanceof HTMLElement ? event_0.target : null, listFocused_0 = listBoxElement?.contains(focusedElement) || !1; listFocused_0 !== listFocusedRef.current && (listFocusedRef.current = listFocused_0, dispatch({ type: "root/setListFocused", listFocused: listFocused_0 })); }, $[57] = t19) : t19 = $[57]; const handleRootFocus = t19; let t20; $[58] !== onChange || $[59] !== onQueryChange || $[60] !== onSelect ? (t20 = (v) => { dispatch({ type: "value/change", value: v }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus(); }, $[58] = onChange, $[59] = onQueryChange, $[60] = onSelect, $[61] = t20) : t20 = $[61]; const handleOptionSelect = t20; let t21; $[62] !== activeValue || $[63] !== filteredOptions || $[64] !== filteredOptionsLen || $[65] !== onQueryChange ? (t21 = (event_1) => { if (event_1.key === "ArrowDown") { if (event_1.preventDefault(), !filteredOptionsLen) return; const activeOption = filteredOptions.find((o_0) => o_0.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]; nextActiveOption && dispatch({ type: "root/setActiveValue", value: nextActiveOption.value, listFocused: !0 }); return; } if (event_1.key === "ArrowUp") { if (event_1.preventDefault(), !filteredOptionsLen) return; const activeOption_0 = filteredOptions.find((o_1) => o_1.value === activeValue), activeIndex_0 = activeOption_0 ? filteredOptions.indexOf(activeOption_0) : -1, nextActiveOption_0 = filteredOptions[activeIndex_0 === -1 ? filteredOptionsLen - 1 : (filteredOptionsLen + activeIndex_0 - 1) % filteredOptionsLen]; nextActiveOption_0 && dispatch({ type: "root/setActiveValue", value: nextActiveOption_0.value, listFocused: !0 }); return; } if (event_1.key === "Escape") { dispatch({ type: "root/escape" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus(); return; } const target = event_1.target, listEl = listBoxElementRef.current; if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key)) { inputElementRef.current?.focus(); return; } }, $[62] = activeValue, $[63] = filteredOptions, $[64] = filteredOptionsLen, $[65] = onQueryChange, $[66] = t21) : t21 = $[66]; const handleRootKeyDown = t21; let t22; $[67] !== onQueryChange ? (t22 = (event_2) => { const nextQuery = event_2.currentTarget.value; dispatch({ type: "input/change", query: nextQuery }), onQueryChange && onQueryChange(nextQuery); }, $[67] = onQueryChange, $[68] = t22) : t22 = $[68]; const handleInputChange = t22; let t23; $[69] !== currentOption || $[70] !== renderValue || $[71] !== value ? (t23 = () => { dispatch({ type: "root/open", query: value ? renderValue(value, currentOption) : "" }); }, $[69] = currentOption, $[70] = renderValue, $[71] = value, $[72] = t23) : t23 = $[72]; const dispatchOpen = t23; let t24; $[73] !== dispatchOpen || $[74] !== focused || $[75] !== onFocus || $[76] !== openOnFocus ? (t24 = (event_3) => { focused || (dispatch({ type: "input/focus" }), onFocus && onFocus(event_3), openOnFocus && dispatchOpen()); }, $[73] = dispatchOpen, $[74] = focused, $[75] = onFocus, $[76] = openOnFocus, $[77] = t24) : t24 = $[77]; const handleInputFocus = t24; let t25; $[78] === Symbol.for("react.memo_cache_sentinel") ? (t25 = () => { popoverMouseWithinRef.current = !0; }, $[78] = t25) : t25 = $[78]; const handlePopoverMouseEnter = t25; let t26; $[79] === Symbol.for("react.memo_cache_sentinel") ? (t26 = () => { popoverMouseWithinRef.current = !1; }, $[79] = t26) : t26 = $[79]; const handlePopoverMouseLeave = t26; let t27; $[80] !== onChange || $[81] !== onQueryChange ? (t27 = () => { dispatch({ type: "root/clear" }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus(); }, $[80] = onChange, $[81] = onQueryChange, $[82] = t27) : t27 = $[82]; const handleClearButtonClick = t27; let t28; $[83] === Symbol.for("react.memo_cache_sentinel") ? (t28 = () => { dispatch({ type: "input/focus" }); }, $[83] = t28) : t28 = $[83]; const handleClearButtonFocus = t28; let t29, t30; $[84] !== valueProp ? (t29 = () => { if (valueProp !== valuePropRef.current) { valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({ type: "value/change", value: valueProp }), valueRef.current = valueProp); return; } valueProp !== valueRef.current && (valueRef.current = valueProp || null, dispatch({ type: "value/change", value: valueProp || null })); }, t30 = [valueProp], $[84] = valueProp, $[85] = t29, $[86] = t30) : (t29 = $[85], t30 = $[86]), react.useEffect(t29, t30); let t31, t32; $[87] !== focused ? (t31 = () => { !focused && valueRef.current && dispatch({ type: "root/setActiveValue", value: valueRef.current }); }, t32 = [focused], $[87] = focused, $[88] = t31, $[89] = t32) : (t31 = $[88], t32 = $[89]), react.useEffect(t31, t32); let t33, t34; $[90] !== activeValue || $[91] !== filteredOptions ? (t33 = () => { const listElement = listBoxElementRef.current; if (!listElement) return; const activeOption_1 = filteredOptions.find((o_2) => o_2.value === activeValue); if (activeOption_1) { const activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1]; if (activeItemElement) { if (_hasFocus(activeItemElement)) return; focusFirstDescendant(activeItemElement); } } }, t34 = [activeValue, filteredOptions], $[90] = activeValue, $[91] = filteredOptions, $[92] = t33, $[93] = t34) : (t33 = $[92], t34 = $[93]), react.useEffect(t33, t34); let t35; bb0: { if (!loading && !disabled && value) { let t362; $[94] === Symbol.for("react.memo_cache_sentinel") ? (t362 = { "aria-label": "Clear", onFocus: handleClearButtonFocus }, $[94] = t362) : t362 = $[94], t35 = t362; break bb0; } t35 = void 0; } const clearButton = t35, openButtonBoxPadding = padding.map(_temp$3), openButtonPadding = padding.map(_temp2$1), openButtonProps = typeof openButton == "object" ? openButton : _visualEditing.EMPTY_RECORD; let t36; $[95] !== dispatchOpen || $[96] !== openButtonProps ? (t36 = (event_4) => { dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus()); }, $[95] = dispatchOpen, $[96] = openButtonProps, $[97] = t36) : t36 = $[97]; const handleOpenClick = t36; let t37; $[98] !== disabled || $[99] !== expanded || $[100] !== fontSize || $[101] !== handleOpenClick || $[102] !== openButton || $[103] !== openButtonBoxPadding || $[104] !== openButtonPadding || $[105] !== openButtonProps || $[106] !== readOnly ? (t37 = !disabled && !readOnly && openButton ? /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { "aria-label": "Open", disabled: expanded, fontSize, icon: icons.ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, $[98] = disabled, $[99] = expanded, $[100] = fontSize, $[101] = handleOpenClick, $[102] = openButton, $[103] = openButtonBoxPadding, $[104] = openButtonPadding, $[105] = openButtonProps, $[106] = readOnly, $[107] = t37) : t37 = $[107]; const openButtonNode = t37; let t38; bb1: { if (query === null) { if (value !== null) { let t392; $[108] !== currentOption || $[109] !== renderValue || $[110] !== value ? (t392 = renderValue(value, currentOption), $[108] = currentOption, $[109] = renderValue, $[110] = value, $[111] = t392) : t392 = $[111], t38 = t392; break bb1; } t38 = ""; break bb1; } t38 = query; } const inputValue = t38; let t39; $[112] !== listFocused ? (t39 = (event_5) => { event_5.key === "Tab" && listFocused && inputElementRef.current?.focus(); }, $[112] = listFocused, $[113] = t39) : t39 = $[113]; const handleListBoxKeyDown = t39; let t40; bb2: { if (filteredOptions.length === 0) { t40 = null; break bb2; } let t412; if ($[114] !== activeValue || $[115] !== currentOption || $[116] !== filteredOptions || $[117] !== handleOptionSelect || $[118] !== id || $[119] !== listFocused || $[120] !== loading || $[121] !== renderOption) { let t423; $[123] !== activeValue || $[124] !== currentOption || $[125] !== handleOptionSelect || $[126] !== id || $[127] !== listFocused || $[128] !== loading || $[129] !== renderOption ? (t423 = (option_0) => { const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0; return /* @__PURE__ */ jsxRuntime.jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: react.cloneElement(renderOption(option_0), { disabled: loading, selected: active, tabIndex: listFocused && active ? 0 : -1 }) }, option_0.value); }, $[123] = activeValue, $[124] = currentOption, $[125] = handleOptionSelect, $[126] = id, $[127] = listFocused, $[128] = loading, $[129] = renderOption, $[130] = t423) : t423 = $[130], t412 = filteredOptions.map(t423), $[114] = activeValue, $[115] = currentOption, $[116] = filteredOptions, $[117] = handleOptionSelect, $[118] = id, $[119] = listFocused, $[120] = loading, $[121] = renderOption, $[122] = t412; } else t412 = $[122]; let t422; $[131] !== listBoxId || $[132] !== t412 ? (t422 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: t412 }), $[131] = listBoxId, $[132] = t412, $[133] = t422) : t422 = $[133]; let t432; $[134] !== handleListBoxKeyDown || $[135] !== listBox || $[136] !== t422 ? (t432 = /* @__PURE__ */ jsxRuntime.jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: t422 }), $[134] = handleListBoxKeyDown, $[135] = listBox, $[136] = t422, $[137] = t432) : t432 = $[137], t40 = t432; } const content2 = t40; let t41; bb3: { if (renderPopover) { const t423 = !expanded; let t432; $[138] !== content2 || $[139] !== handlePopoverMouseEnter || $[140] !== handlePopoverMouseLeave || $[141] !== inputElement || $[142] !== renderPopover || $[143] !== t423 ? (t432 = /* @__PURE__ */ jsxRuntime.jsx(RenderPopover, { content: content2, hidden: t423, inputElement, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, resultsPopoverElementRef, renderPopover }), $[138] = content2, $[139] = handlePopoverMouseEnter, $[140] = handlePopoverMouseLeave, $[141] = inputElement, $[142] = renderPopover, $[143] = t423, $[144] = t432) : t432 = $[144], t41 = t432; break bb3; } if (filteredOptionsLen === 0) { t41 = null; break bb3; } let t422; $[145] !== content2 || $[146] !== expanded || $[147] !== handlePopoverMouseEnter || $[148] !== handlePopoverMouseLeave || $[149] !== inputElement || $[150] !== popover || $[151] !== radius ? (t422 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: resultsPopoverElementRef, referenceElement: inputElement, ...popover }), $[145] = content2, $[146] = expanded, $[147] = handlePopoverMouseEnter, $[148] = handlePopoverMouseLeave, $[149] = inputElement, $[150] = popover, $[151] = radius, $[152] = t422) : t422 = $[152], t41 = t422; } const results = t41, t42 = loading && AnimatedSpinnerIcon, t43 = suffix || openButtonNode; let t44; $[153] !== activeItemId || $[154] !== border || $[155] !== clearButton || $[156] !== customValidity || $[157] !== disabled || $[158] !== expanded || $[159] !== fontSize || $[160] !== handleClearButtonClick || $[161] !== handleInputChange || $[162] !== handleInputFocus || $[163] !== icon || $[164] !== id || $[165] !== inputValue || $[166] !== listBoxId || $[167] !== padding || $[168] !== prefix || $[169] !== radius || $[170] !== readOnly || $[171] !== restProps || $[172] !== t42 || $[173] !== t43 ? (t44 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.TextInput, { ...restProps, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", border, clearButton, customValidity, disabled, fontSize, icon, iconRight: t42, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: setInputElement, role: "combobox", spellCheck: !1, suffix: t43, value: inputValue }), $[153] = activeItemId, $[154] = border, $[155] = clearButton, $[156] = customValidity, $[157] = disabled, $[158] = expanded, $[159] = fontSize, $[160] = handleClearButtonClick, $[161] = handleInputChange, $[162] = handleInputFocus, $[163] = icon, $[164] = id, $[165] = inputValue, $[166] = listBoxId, $[167] = padding, $[168] = prefix, $[169] = radius, $[170] = readOnly, $[171] = restProps, $[172] = t42, $[173] = t43, $[174] = t44) : t44 = $[174]; let t45; return $[175] !== handleRootBlur || $[176] !== handleRootFocus || $[177] !== handleRootKeyDown || $[178] !== results || $[179] !== t44 ? (t45 = /* @__PURE__ */ jsxRuntime.jsxs(StyledAutocomplete, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [ t44, results ] }), $[175] = handleRootBlur, $[176] = handleRootFocus, $[177] = handleRootKeyDown, $[178] = results, $[179] = t44, $[180] = t45) : t45 = $[180], t45; }); function RenderPopover({ renderPopover, content: content2, hidden, inputElement, onMouseEnter, onMouseLeave, resultsPopoverElementRef }) { return renderPopover({ content: content2, hidden, inputElement, onMouseEnter, onMouseLeave }, resultsPopoverElementRef); } InnerAutocomplete.displayName = "ForwardRef(Autocomplete)"; const Autocomplete = InnerAutocomplete; function _temp$3(v_0) { return v_0 === 0 ? 0 : v_0 === 1 || v_0 === 2 ? 1 : v_0 - 2; } function _temp2$1(v_1) { return Math.max(v_1 - 1, 0); } const StyledBreadcrumbs = styledComponents.styled.ol.withConfig({ displayName: "StyledBreadcrumbs", componentId: "sc-1es8h8q-0" })`margin:0;padding:0;display:flex;list-style:none;align-items:center;white-space:nowrap;line-height:0;`, ExpandButton = styledComponents.styled(_visualEditing.Button).withConfig({ displayName: "ExpandButton", componentId: "sc-1es8h8q-1" })`appearance:none;margin:-4px;`, Breadcrumbs = react.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(30); let children, gap, maxLength, restProps, separator, t0; $[0] !== props ? ({ children, gap, maxLength, separator, space: t0, ...restProps } = props, $[0] = props, $[1] = children, $[2] = gap, $[3] = maxLength, $[4] = restProps, $[5] = separator, $[6] = t0) : (children = $[1], gap = $[2], maxLength = $[3], restProps = $[4], separator = $[5], t0 = $[6]); const t1 = gap === void 0 ? t0 === void 0 ? 2 : t0 : gap; let t2; $[7] !== t1 ? (t2 = _visualEditing._getArrayProp(t1), $[7] = t1, $[8] = t2) : t2 = $[8]; const space = t2, [open, setOpen] = react.useState(!1), expandElementRef = react.useRef(null), popoverElementRef = react.useRef(null); let t3; $[9] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setOpen(!1), $[9] = t3) : t3 = $[9]; const collapse = t3; let t4; $[10] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setOpen(!0), $[10] = t4) : t4 = $[10]; const expand = t4; let t5; $[11] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => [expandElementRef.current, popoverElementRef.current], $[11] = t5) : t5 = $[11], _visualEditing.useClickOutsideEvent(collapse, t5); let t6; $[12] !== children ? (t6 = react.Children.toArray(children).filter(react.isValidElement), $[12] = children, $[13] = t6) : t6 = $[13]; const rawItems = t6; let t7; $[14] !== maxLength || $[15] !== open || $[16] !== rawItems || $[17] !== space ? (t7 = { collapse, expand, expandElementRef, maxLength, open, popoverElementRef, rawItems, space }, $[14] = maxLength, $[15] = open, $[16] = rawItems, $[17] = space, $[18] = t7) : t7 = $[18]; const items = useItems(t7); let t8; if ($[19] !== items || $[20] !== separator || $[21] !== space) { let t92; $[23] !== separator || $[24] !== space ? (t92 = (item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [ itemIndex > 0 && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": !0, as: "li", paddingX: space, children: separator || /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted: !0, children: "/" }) }), /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { as: "li", children: item }) ] }, itemIndex), $[23] = separator, $[24] = space, $[25] = t92) : t92 = $[25], t8 = items.map(t92), $[19] = items, $[20] = separator, $[21] = space, $[22] = t8; } else t8 = $[22]; let t9; return $[26] !== ref || $[27] !== restProps || $[28] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: t8 }), $[26] = ref, $[27] = restProps, $[28] = t8, $[29] = t9) : t9 = $[29], t9; }); Breadcrumbs.displayName = "ForwardRef(Breadcrumbs)"; function useItems(t0) { const $ = reactCompilerRuntime.c(28), { collapse, expand, expandElementRef, maxLength, open, popoverElementRef, rawItems, space } = t0, len = rawItems.length; if (maxLength && len > maxLength) { const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2); let t1; if ($[0] !== afterLength || $[1] !== beforeLength || $[2] !== collapse || $[3] !== expand || $[4] !== expandElementRef || $[5] !== len || $[6] !== open || $[7] !== popoverElementRef || $[8] !== rawItems || $[9] !== space) { const t2 = rawItems.slice(0, beforeLength - 1); let t3; $[11] !== afterLength || $[12] !== beforeLength || $[13] !== len || $[14] !== rawItems ? (t3 = rawItems.slice(beforeLength - 1, len - afterLength), $[11] = afterLength, $[12] = beforeLength, $[13] = len, $[14] = rawItems, $[15] = t3) : t3 = $[15]; let t4; $[16] !== space || $[17] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ol", overflow: "auto", padding: space, gap: space, children: t3 }), $[16] = space, $[17] = t3, $[18] = t4) : t4 = $[18]; const t5 = open ? collapse : expand; let t6; $[19] !== expandElementRef || $[20] !== open || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(ExpandButton, { fontSize: 1, mode: "bleed", onClick: t5, padding: 1, ref: expandElementRef, selected: open, text: "\u2026" }), $[19] = expandElementRef, $[20] = open, $[21] = t5, $[22] = t6) : t6 = $[22]; let t7; $[23] !== open || $[24] !== popoverElementRef || $[25] !== t4 || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { constrainSize: !0, content: t4, open, placement: "top", portal: !0, ref: popoverElementRef, children: t6 }, "button"), $[23] = open, $[24] = popoverElementRef, $[25] = t4, $[26] = t6, $[27] = t7) : t7 = $[27], t1 = [...t2, t7, ...rawItems.slice(len - afterLength)], $[0] = afterLength, $[1] = beforeLength, $[2] = collapse, $[3] = expand, $[4] = expandElementRef, $[5] = len, $[6] = open, $[7] = popoverElementRef, $[8] = rawItems, $[9] = space, $[10] = t1; } else t1 = $[10]; return t1; } return rawItems; } function dialogStyle({ theme: theme$1 }) { const { color } = theme.getTheme_v2(theme$1); return { "&:not([hidden])": { display: "flex" }, top: 0, left: 0, right: 0, bottom: 0, alignItems: "center", justifyContent: "center", outline: "none", background: color.backdrop }; } function responsiveDialogPositionStyle(props) { const { media } = theme.getTheme_v2(props.theme); return _visualEditing._responsive(media, props.$position, (position) => ({ "&&": { position } })); } function animationDialogStyle(props) { return props.$animate ? styledComponents.css` @keyframes zoomIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } animation: fadeIn 200ms ease-out; // Animates the dialog card. & > [data-ui='DialogCard'] { animation: zoomIn 200ms ease-out; } ` : styledComponents.css``; } const DialogContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context/dialog", { version: 0 }); function useDialog() { return react.useContext(DialogContext); } function isTargetWithinScope(boundaryElement, portalElement, target) { return !boundaryElement || !portalElement ? !0 : _visualEditing.containsOrEqualsElement(boundaryElement, target) || _visualEditing.containsOrEqualsElement(portalElement, target); } const StyledDialog = /* @__PURE__ */ styledComponents.styled(_visualEditing.Layer).withConfig({ displayName: "StyledDialog", componentId: "sc-4n4xb3-0" })(_visualEditing.responsivePaddingStyle, dialogStyle, responsiveDialogPositionStyle, animationDialogStyle), DialogContainer = styledComponents.styled(_visualEditing.Container).withConfig({ displayName: "DialogContainer", componentId: "sc-4n4xb3-1" })`&:not([hidden]){display:flex;}width:100%;height:100%;flex-direction:column;align-items:center;justify-content:center;`, DialogCardRoot = styledComponents.styled(_visualEditing.Card).withConfig({ displayName: "DialogCardRoot", componentId: "sc-4n4xb3-2" })`&:not([hidden]){display:flex;}width:100%;min-height:0;max-height:100%;overflow:hidden;overflow:clip;`, DialogLayout = styledComponents.styled(_visualEditing.Flex).withConfig({ displayName: "DialogLayout", componentId: "sc-4n4xb3-3" })`flex:1;min-height:0;width:100%;`, DialogHeader = styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "DialogHeader", componentId: "sc-4n4xb3-4" })`position:relative;z-index:2;`, DialogContent = styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "DialogContent", componentId: "sc-4n4xb3-5" })`position:relative;z-index:1;overflow:auto;outline:none;`, DialogFooter = styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "DialogFooter", componentId: "sc-4n4xb3-6" })`position:relative;z-index:3;`, DialogCard = react.forwardRef(function(props, forwardedRef) { const $ = reactCompilerRuntime.c(44), { __unstable_autoFocus: autoFocus, __unstable_hideCloseButton: hideCloseButton, children, contentRef: forwardedContentRef, footer, header, id, onClickOutside, onClose, portal: portalProp, radius: radiusProp, scheme, shadow: shadowProp, width: widthProp } = props, portal = _visualEditing.usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = _visualEditing.useBoundaryElement().element; let t0; $[0] !== radiusProp ? (t0 = _visualEditing._getArrayProp(radiusProp), $[0] = radiusProp, $[1] = t0) : t0 = $[1]; const radius = t0; let t1; $[2] !== shadowProp ? (t1 = _visualEditing._getArrayProp(shadowProp), $[2] = shadowProp, $[3] = t1) : t1 = $[3]; const shadow = t1; let t2; $[4] !== widthProp ? (t2 = _visualEditing._getArrayProp(widthProp), $[4] = widthProp, $[5] = t2) : t2 = $[5]; const width = t2, ref = react.useRef(null), contentRef = react.useRef(null), layer = _visualEditing.useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton; let t3; $[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => ref.current, $[6] = t3) : t3 = $[6], react.useImperativeHandle(forwardedRef, t3); let t4; $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => contentRef.current, $[7] = t4) : t4 = $[7], react.useImperativeHandle(forwardedContentRef, t4); let t5, t6; $[8] !== autoFocus ? (t5 = () => { autoFocus && ref.current && focusFirstDescendant(ref.current); }, t6 = [autoFocus, ref], $[8] = autoFocus, $[9] = t5, $[10] = t6) : (t5 = $[9], t6 = $[10]), react.useEffect(t5, t6); let t7; $[11] !== boundaryElement || $[12] !== isTopLayer || $[13] !== onClose || $[14] !== portalElement ? (t7 = (event) => { if (!isTopLayer || !onClose) return; const target = document.activeElement; target && !isTargetWithinScope(boundaryElement, portalElement, target) || event.key === "Escape" && (event.preventDefault(), event.stopPropagation(), onClose()); }, $[11] = boundaryElement, $[12] = isTopLayer, $[13] = onClose, $[14] = portalElement, $[15] = t7) : t7 = $[15], _visualEditing.useGlobalKeyDown(t7); let t8; $[16] !== boundaryElement || $[17] !== isTopLayer || $[18] !== onClickOutside || $[19] !== portalElement ? (t8 = isTopLayer && onClickOutside && ((event_0) => { const target_0 = event_0.target; target_0 && !isTargetWithinScope(boundaryElement, portalElement, target_0) || onClickOutside(); }), $[16] = boundaryElement, $[17] = isTopLayer, $[18] = onClickOutside, $[19] = portalElement, $[20] = t8) : t8 = $[20]; let t9; $[21] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => [ref.current], $[21] = t9) : t9 = $[21], _visualEditing.useClickOutsideEvent(t8, t9); let t10; $[22] !== header || $[23] !== labelId || $[24] !== onClose || $[25] !== showCloseButton || $[26] !== showHeader ? (t10 = showHeader && /* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { align: "flex-start", padding: 3, children: [ /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { id: labelId, size: 1, weight: "semibold", children: header }) }), showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { "aria-label": "Close dialog", disabled: !onClose, icon: icons.CloseIcon, mode: "bleed", onClick: onClose, padding: 2 }) }) ] }) }), $[22] = header, $[23] = labelId, $[24] = onClose, $[25] = showCloseButton, $[26] = showHeader, $[27] = t10) : t10 = $[27]; let t11; $[28] !== children ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { flex: 1, ref: contentRef, tabIndex: -1, children }), $[28] = children, $[29] = t11) : t11 = $[29]; let t12; $[30] !== footer ? (t12 = footer && /* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: footer }), $[30] = footer, $[31] = t12) : t12 = $[31]; let t13; $[32] !== t10 || $[33] !== t11 || $[34] !== t12 ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs(DialogLayout, { direction: "column", children: [ t10, t11, t12 ] }), $[32] = t10, $[33] = t11, $[34] = t12, $[35] = t13) : t13 = $[35]; let t14; $[36] !== radius || $[37] !== scheme || $[38] !== shadow || $[39] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(DialogCardRoot, { radius, ref, scheme, shadow, children: t13 }), $[36] = radius, $[37] = scheme, $[38] = shadow, $[39] = t13, $[40] = t14) : t14 = $[40]; let t15; return $[41] !== t14 || $[42] !== width ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(DialogContainer, { "data-ui": "DialogCard", width, children: t14 }), $[41] = t14, $[42] = width, $[43] = t15) : t15 = $[43], t15; }); DialogCard.displayName = "ForwardRef(DialogCard)"; const Dialog = react.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(70), dialog = useDialog(), { layer } = _visualEditing.useTheme_v2(); let _positionProp, _zOffsetProp, children, contentRef, footer, header, id, onActivate, onClickOutside, onClose, onFocus, portalProp, restProps, scheme, t0, t1, t2, t3, t4, t5, t6; $[0] !== props ? ({ __unstable_autoFocus: t0, __unstable_hideCloseButton: t1, cardRadius: t2, cardShadow: t3, children, contentRef, footer, header, id, onActivate, onClickOutside, onClose, onFocus, padding: t4, portal: portalProp, position: _positionProp, scheme, width: t5, zOffset: _zOffsetProp, animate: t6, ...restProps } = props, $[0] = props, $[1] = _positionProp, $[2] = _zOffsetProp, $[3] = children, $[4] = contentRef, $[5] = footer, $[6] = header, $[7] = id, $[8] = onActivate, $[9] = onClickOutside, $[10] = onClose, $[11] = onFocus, $[12] = portalProp, $[13] = restProps, $[14] = scheme, $[15] = t0, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6) : (_positionProp = $[1], _zOffsetProp = $[2], children = $[3], contentRef = $[4], footer = $[5], header = $[6], id = $[7], onActivate = $[8], onClickOutside = $[9], onClose = $[10], onFocus = $[11], portalProp = $[12], restProps = $[13], scheme = $[14], t0 = $[15], t1 = $[16], t2 = $[17], t3 = $[18], t4 = $[19], t5 = $[20], t6 = $[21]); const autoFocus = t0 === void 0 ? !0 : t0, hideCloseButton = t1 === void 0 ? !1 : t1, cardRadiusProp = t2 === void 0 ? 4 : t2, cardShadow = t3 === void 0 ? 3 : t3, paddingProp = t4 === void 0 ? 3 : t4, widthProp = t5 === void 0 ? 0 : t5, _animate = t6 === void 0 ? !1 : t6, positionProp = _positionProp ?? (dialog.position || "fixed"), zOffsetProp = _zOffsetProp ?? (dialog.zOffset || layer.dialog.zOffset), animate = _visualEditing.usePrefersReducedMotion() ? !1 : _animate, portal = _visualEditing.usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = _visualEditing.useBoundaryElement().element; let t7; $[22] !== cardRadiusProp ? (t7 = _visualEditing._getArrayProp(cardRadiusProp), $[22] = cardRadiusProp, $[23] = t7) : t7 = $[23]; const cardRadius = t7; let t8; $[24] !== paddingProp ? (t8 = _visualEditing._getArrayProp(paddingProp), $[24] = paddingProp, $[25] = t8) : t8 = $[25]; const padding = t8; let t9; $[26] !== positionProp ? (t9 = _visualEditing._getArrayProp(positionProp), $[26] = positionProp, $[27] = t9) : t9 = $[27]; const position = t9; let t10; $[28] !== widthProp ? (t10 = _visualEditing._getArrayProp(widthProp), $[28] = widthProp, $[29] = t10) : t10 = $[29]; const width = t10; let t11; $[30] !== zOffsetProp ? (t11 = _visualEditing._getArrayProp(zOffsetProp), $[30] = zOffsetProp, $[31] = t11) : t11 = $[31]; const zOffset = t11, preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null); let t12; $[32] !== onFocus ? (t12 = (event) => { onFocus?.(event); const target = event.target, cardElement = cardRef.current; if (cardElement && target === preDivRef.current) { focusLastDescendant(cardElement); return; } if (cardElement && target === postDivRef.current) { focusFirstDescendant(cardElement); return; } _visualEditing.isHTMLElement(event.target) && (focusedElementRef.current = event.target); }, $[32] = onFocus, $[33] = t12) : t12 = $[33]; const handleFocus = t12, labelId = `${id}_label`, rootClickTimeoutRef = react.useRef(void 0); let t13; $[34] !== boundaryElement || $[35] !== portalElement ? (t13 = () => { rootClickTimeoutRef.current && clearTimeout(rootClickTimeoutRef.current), rootClickTimeoutRef.current = setTimeout(() => { const activeElement = document.activeElement; if (activeElement && !isTargetWithinScope(boundaryElement, portalElement, activeElement)) { const target_0 = focusedElementRef.current; if (!target_0 || !document.body.contains(target_0)) { const cardElement_0 = cardRef.current; cardElement_0 && focusFirstDescendant(cardElement_0); return; } target_0.focus(); } }, 0); }, $[34] = boundaryElement, $[35] = portalElement, $[36] = t13) : t13 = $[36]; const handleRootClick = t13; let t14; $[37] === Symbol.for("react.memo_cache_sentinel") ? (t14 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: preDivRef, tabIndex: 0 }), $[37] = t14) : t14 = $[37]; let t15; $[38] !== autoFocus || $[39] !== cardRadius || $[40] !== cardShadow || $[41] !== children || $[42] !== contentRef || $[43] !== footer || $[44] !== header || $[45] !== hideCloseButton || $[46] !== id || $[47] !== onClickOutside || $[48] !== onClose || $[49] !== portalProp || $[50] !== scheme || $[51] !== width ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(DialogCard, { __unstable_autoFocus: autoFocus, __unstable_hideCloseButton: hideCloseButton, contentRef, footer, header, id, onClickOutside, onClose, portal: portalProp, radius: cardRadius, ref: cardRef, scheme, shadow: cardShadow, width, children }), $[38] = autoFocus, $[39] = cardRadius, $[40] = cardShadow, $[41] = children, $[42] = contentRef, $[43] = footer, $[44] = header, $[45] = hideCloseButton, $[46] = id, $[47] = onClickOutside, $[48] = onClose, $[49] = portalProp, $[50] = scheme, $[51] = width, $[52] = t15) : t15 = $[52]; let t16; $[53] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: postDivRef, tabIndex: 0 }), $[53] = t16) : t16 = $[53]; let t17; $[54] !== animate || $[55] !== handleFocus || $[56] !== handleRootClick || $[57] !== id || $[58] !== labelId || $[59] !== onActivate || $[60] !== padding || $[61] !== position || $[62] !== ref || $[63] !== restProps || $[64] !== t15 || $[65] !== zOffset ? (t17 = /* @__PURE__ */ jsxRuntime.jsxs(StyledDialog, { ...restProps, $animate: animate, $p