UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

1,083 lines • 192 kB
import { jsx, jsxs, Fragment } from "react/jsx-runtime"; import { c } from "react/compiler-runtime"; import { useSelector, useActorRef } from "@xstate/react"; import { presentationLocaleNamespace, usePresentationTool, PresentationSpinner, API_VERSION, MAX_TIME_TO_OVERLAYS_CONNECTION, usePresentationNavigate, POPUP_CHECK_INTERVAL, DEFAULT_TOOL_NAME, NARROW_MEDIA_INDEX, EDIT_INTENT_MODE } from "./presentation.js"; import { createController, createConnectionMachine } from "@sanity/comlink"; import { createCompatibilityActors } from "@sanity/presentation-comlink"; import { urlSearchParamPreviewPerspective, fetchSharedAccessQuery, urlSearchParamVercelProtectionBypass, urlSearchParamVercelSetBypassCookie, urlSearchParamPreviewSecret, urlSearchParamPreviewPathname, schemaTypeSingleton, schemaIdSingleton, schemaType } from "@sanity/preview-url-secret/constants"; import { Card, Flex, TabList, Text, Stack, Inline, Box, Container as Container$1, Label, Code, TextInput, Spinner, useToast, Grid, Switch, MenuDivider, Menu, Hotkeys, usePrefersReducedMotion, useMediaIndex, BoundaryElementProvider } from "@sanity/ui"; import { memo, useEffect, useRef, useContext, useLayoutEffect, useState, forwardRef, Suspense, useId as useId$1, useImperativeHandle, lazy, useMemo, useCallback, useSyncExternalStore, useEffectEvent, useReducer } from "react"; import { useTranslation, getPublishedId, pathToString, useUnique, useDocumentPreviewStore, usePerspective, getPreviewStateObservable, useSchema, getPreviewValueWithFallback, SanityDefaultPreview, PreviewCard, Translate, CommentsIntentProvider, useActiveWorkspace, useClient, useCurrentUser, useProjectId, useDataset, useWorkspace, COMMENTS_INSPECTOR_NAME, useGrantsStore } from "sanity"; import { StateLink, IntentLink, useRouter, decodeJsonParams } from "sanity/router"; import { styled, createGlobalStyle } from "styled-components"; import { setup, assign, fromPromise, fromObservable, log } from "xstate"; import { PresentationSharedStateContext, PresentationPanelsContext, PresentationNavigateContext, PresentationParamsContext, PresentationContext } from "sanity/_singletons"; import { Tab, Button, ErrorBoundary, Tooltip, MenuItem, MenuButton, TooltipDelayGroupProvider } from "./index.js"; import "react-i18next"; import { WarningOutlineIcon } from "@sanity/icons/WarningOutline"; import { PaneRouterContext, StructureToolProvider, PaneLayout, ORDER_BY_IDS_PARAM_FIELD, DocumentListPane as DocumentListPane$1, DocumentPane as DocumentPane$1 } from "sanity/structure"; import { toString } from "@sanity/util/paths"; import { StructureToolProvider as StructureToolProvider$1 } from "./StructureToolProvider.js"; import { studioPath } from "@sanity/client/csm"; import { DisplayedDocumentBroadcasterProvider } from "./DisplayedDocumentBroadcaster.js"; import { v4 } from "uuid"; import { motion, AnimatePresence, MotionConfig } from "motion/react"; import { flushSync } from "react-dom"; import { DesktopIcon } from "@sanity/icons/Desktop"; import { MobileDeviceIcon } from "@sanity/icons/MobileDevice"; import { PanelLeftIcon } from "@sanity/icons/PanelLeft"; import { RefreshIcon } from "@sanity/icons/Refresh"; import { setSecretSearchParams, withoutSecretSearchParams } from "@sanity/preview-url-secret/without-secret-search-params"; import { LaunchIcon } from "@sanity/icons/Launch"; import { ResetIcon } from "@sanity/icons/Reset"; import { CopyIcon } from "@sanity/icons/Copy"; import { ShareIcon } from "@sanity/icons/Share"; import { SanityMonogram } from "@sanity/logos"; import { disablePreviewAccessSharing, enablePreviewAccessSharing } from "@sanity/preview-url-secret/toggle-preview-access-sharing"; import { validateApiPerspective } from "@sanity/client"; import isEqual from "fast-deep-equal"; import { match } from "path-to-regexp"; import { isAgentBundleName } from "./createAgentBundlesStore.js"; import { createPreviewSecret } from "@sanity/preview-url-secret/create-secret"; import { uuid } from "@sanity/uuid"; import { throwError } from "rxjs"; import { subscribeToVercelProtectionBypass } from "@sanity/preview-url-secret/toggle-vercel-protection-bypass"; const PostMessageFeatures$1 = (props) => { const $ = c(3), { comlink } = props; let t0, t1; return $[0] !== comlink ? (t0 = () => comlink.on("visual-editing/features", _temp$h), t1 = [comlink], $[0] = comlink, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1), null; }; var PostMessageFeatures = memo(PostMessageFeatures$1); function _temp$h() { return { features: { optimistic: !0 } }; } const presentationMachine = setup({ // oxlint-disable-next-line typescript/no-unnecessary-type-assertion types: {}, actions: { // }, actors: { // }, guards: { // } }).createMachine({ // oxlint-disable-next-line tsdoc/syntax /** @xstate-layout N4IgpgJg5mDOIC5QAUBOcwDsAuBDbAlgPaYAEAKkUQDYDEBAZqrgLZinrVG4QDaADAF1EoAA5FYBQiREgAHogAsAJgA0IAJ6IAHAEYAdIoCcJowFY9R-vzPLlAX3vq0GHPmJlKNfVx4FMUPRMrOy+EJACwkgg4pLSmLIKCLoAbIr6Zoop2tqKAMxpJnnF6loIZkbK+uZ5umapKXmK-Cm6js7osFh48RRU1D7c4RC02ERQUNTsAG4EsACuuNSkkFL+UKRE02Co1LgasJGysWsy0UnaZinVyrpGAOx1Rim2efeliPe3hma1Zvy6XT8W4OJwgFxdNy9LwDMKQILMNgcMBMOAACyO0RO8USiAK930LWU-3uiiB9yaKXemkQjW01V+txS-GKqUe7XBnW67hIfW8cJGjER7E4Q0xYgkpwS5zxVMJKWJ-FJ5Mp1LKFn4Pz+DSaLTaYIh3Oh-UGPEg+nQqNgaPWCJCpAF4pikpxMoQKWZ+gp+TSZLy1hSH3deXpNSZLNqVP1HVcPQ8fNhQ3Nor8ATtSMdQmOLo8uPdnu9BUUfoDQY1WrqOuarUcYMwRHC8Gihqh8Zh2biubdAFpAzSEL2OS247yYfodqgiKgO1K8yog7ptATFL9dFljMDrHkh1zW6OTWF1jPXaAkmY1YgKnktfxtC9dPd+Io9DvYzzPAekxBj13T3i7vKirKkqqpBsYVQ1HUFjFs0t6KK+kIjh+-JfvoBAQFMP5nH+CDaMo16KjYyjMvUNh5GWOT6MoLL8A8ygrk0dQIUabafmaEAWiinQ2gEWHSjhjJUYuj73Pcd63noQaNEYFb-Dk2S0cxe7IYm7GcYevFYjm2HyJeeQQb8tFkikVjGNoFGajUt73o+z61vYQA */ id: "Presentation Tool", context: { url: null, error: null, visualEditingOverlaysEnabled: !1 }, on: { "iframe reload": { actions: assign({ url: null }), target: ".loading" } }, states: { error: { description: "Failed to load, either because of a misconfiguration, a network error, or an unexpected error", tags: ["error"] }, loading: { on: { "iframe loaded": { target: "loaded" } }, tags: ["busy"] }, loaded: { on: { "toggle visual editing overlays": { actions: assign({ visualEditingOverlaysEnabled: ({ event }) => event.enabled }) }, "iframe refresh": { target: ".refreshing" }, "iframe reload": { target: ".reloading" } }, states: { idle: {}, refreshing: { on: { "iframe loaded": { target: "idle" } }, tags: ["busy"] }, reloading: { on: { "iframe loaded": { target: "idle" } }, tags: ["busy"] } }, initial: "idle" } }, initial: "loading" }), SharedStateProvider = function(props) { const $ = c(14), { comlink, children } = props; let t0; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0]; const sharedState = useRef(t0); let t1, t2; $[1] !== comlink ? (t1 = () => comlink?.on("visual-editing/shared-state", () => ({ state: sharedState.current })), t2 = [comlink], $[1] = comlink, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2); let t3; $[4] !== comlink ? (t3 = (key, value) => { sharedState.current[key] = value, comlink?.post("presentation/shared-state", { key, value }); }, $[4] = comlink, $[5] = t3) : t3 = $[5]; const setValue = t3; let t4; $[6] !== comlink ? (t4 = (key_0) => { comlink?.post("presentation/shared-state", { key: key_0 }), delete sharedState.current[key_0]; }, $[6] = comlink, $[7] = t4) : t4 = $[7]; const removeValue = t4; let t5; $[8] !== removeValue || $[9] !== setValue ? (t5 = { removeValue, setValue }, $[8] = removeValue, $[9] = setValue, $[10] = t5) : t5 = $[10]; const context = t5; let t6; return $[11] !== children || $[12] !== context ? (t6 = /* @__PURE__ */ jsx(PresentationSharedStateContext.Provider, { value: context, children }), $[11] = children, $[12] = context, $[13] = t6) : t6 = $[13], t6; }, Root$1 = /* @__PURE__ */ styled.div.withConfig({ displayName: "Root", componentId: "sc-1auuvvr-0" })(["overflow:hidden;flex-basis:0;flex-shrink:1;"]), Panel = function(t0) { const $ = c(17), { children, defaultSize: t1, id, htmlId, minWidth, maxWidth, order: t2, hidden: t3 } = t0, defaultSize = t1 === void 0 ? null : t1, order = t2 === void 0 ? 0 : t2, hidden = t3 === void 0 ? !1 : t3, context = useContext(PresentationPanelsContext); if (context === null) throw Error("Panel components must be rendered within a PanelGroup container"); const { getPanelStyle, registerElement, unregisterElement } = context; let t4; $[0] !== getPanelStyle || $[1] !== hidden || $[2] !== id ? (t4 = hidden ? { display: "none" } : getPanelStyle(id), $[0] = getPanelStyle, $[1] = hidden, $[2] = id, $[3] = t4) : t4 = $[3]; const style = t4; let t5, t6; $[4] !== defaultSize || $[5] !== id || $[6] !== maxWidth || $[7] !== minWidth || $[8] !== order || $[9] !== registerElement || $[10] !== unregisterElement ? (t5 = () => (registerElement(id, { id, type: "panel", defaultSize, maxWidth: maxWidth ?? null, minWidth: minWidth ?? 0, order }), () => { unregisterElement(id); }), t6 = [id, defaultSize, order, maxWidth, minWidth, registerElement, unregisterElement], $[4] = defaultSize, $[5] = id, $[6] = maxWidth, $[7] = minWidth, $[8] = order, $[9] = registerElement, $[10] = unregisterElement, $[11] = t5, $[12] = t6) : (t5 = $[11], t6 = $[12]), useLayoutEffect(t5, t6); let t7; return $[13] !== children || $[14] !== htmlId || $[15] !== style ? (t7 = /* @__PURE__ */ jsx(Root$1, { id: htmlId, style, children }), $[13] = children, $[14] = htmlId, $[15] = style, $[16] = t7) : t7 = $[16], t7; }; function debounce(fn, timeout) { let timer; return (...args) => { clearTimeout(timer), timer = setTimeout(() => { fn.apply(fn, args); }, timeout); }; } const itemKey = "presentation/panels", getStoredItem = () => JSON.parse(localStorage.getItem(itemKey) || "{}"), setStoredItem = (data) => { localStorage.setItem(itemKey, JSON.stringify(data)); }, getKeyForPanels = (panels) => panels.map((panel) => [panel.id, panel.order].join(":")).join(","); function usePanelsStorage() { const $ = c(1), get = _temp2$8, set = _temp3$5; let t0; if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) { const setDebounced = debounce(set, 100); t0 = { get, set, setDebounced }, $[0] = t0; } else t0 = $[0]; return t0; } function _temp3$5(panels_0, widths) { const stored_0 = getStoredItem(), key_0 = getKeyForPanels(panels_0), data = { ...stored_0, [key_0]: widths }; setStoredItem(data); } function _temp2$8(panels) { const stored = getStoredItem(), key = getKeyForPanels(panels); return Array.isArray(stored[key]) && stored[key].some(_temp$g) ? void 0 : stored[key]; } function _temp$g(val) { return val === null; } function getNextWidth(panel, nextWidth, containerWidth) { const { maxWidth: maxWidthPx, minWidth: minWidthPx } = panel, maxWidth = maxWidthPx == null ? 100 : maxWidthPx / containerWidth * 100, minWidth = minWidthPx / containerWidth * 100; return Math.min(maxWidth, Math.max(minWidth, nextWidth)); } function getNextWidths(delta, containerWidth, panelBefore, panelAfter, panelsState, initialDragState) { const { panels, widths: prevWidths } = panelsState, { widths: initialWidths } = initialDragState, widths = initialWidths || prevWidths, nextWidths = [...widths]; { const pivotPanel2 = delta < 0 ? panelAfter : panelBefore, index2 = panels.findIndex((panel) => panel.id === pivotPanel2.id), width = widths[index2], nextWidth = getNextWidth(pivotPanel2, width + Math.abs(delta), containerWidth); if (width === nextWidth) return widths; delta = delta < 0 ? width - nextWidth : nextWidth - width; } let deltaApplied = 0, pivotPanel = delta < 0 ? panelBefore : panelAfter, index = panels.findIndex((panel) => panel.id === pivotPanel.id); for (; ; ) { const panel = panels[index], width = widths[index], deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied), nextWidth = getNextWidth(panel, width - deltaRemaining, containerWidth); if (width !== nextWidth && (deltaApplied += width - nextWidth, nextWidths[index] = nextWidth, deltaApplied.toPrecision(10).localeCompare(Math.abs(delta).toPrecision(10), void 0, { numeric: !0 }) >= 0)) break; if (delta < 0) { if (--index < 0) break; } else if (++index >= panels.length) break; } return deltaApplied === 0 ? widths : (pivotPanel = delta < 0 ? panelAfter : panelBefore, index = panels.findIndex((panel) => panel.id === pivotPanel.id), nextWidths[index] = widths[index] + deltaApplied, nextWidths); } function getPanelWidth(panels, id, widths) { if (panels.length === 1) return "100"; const index = panels.findIndex((panel) => panel.id === id), width = widths[index]; return width == null ? "0" : width.toPrecision(10); } function getOffset(event, handleElement, initialOffset = 0, initialHandleElementRect = null) { const pointerOffset = event.clientX, elementOffset = (initialHandleElementRect || handleElement.getBoundingClientRect()).left; return pointerOffset - elementOffset - initialOffset; } function isPanel(element) { return element.type === "panel"; } function isResizer(element) { return element.type === "resizer"; } function getSortedElements(elements) { return Array.from(elements.values()).sort(({ order: a }, { order: b }) => a == null && b == null ? 0 : a == null ? -1 : b == null ? 1 : a - b); } function validateWidths(panels, widthsToValidate, containerWidth) { const total = widthsToValidate.reduce((total2, width) => total2 + width, 0), widths = [...widthsToValidate].map((width) => width / total * 100); let remainingWidth = 0; for (let index = 0; index < panels.length; index++) { const panel = panels[index], width = widths[index], nextWidth = getNextWidth(panel, width, containerWidth); width != nextWidth && (remainingWidth += width - nextWidth, widths[index] = nextWidth); } if (remainingWidth.toFixed(3) !== "0.000") for (let index = 0; index < panels.length; index++) { const panel = panels[index]; let { maxWidth, minWidth } = panel; minWidth = minWidth / containerWidth * 100, maxWidth != null && (maxWidth = maxWidth / containerWidth * 100); const width = Math.min(maxWidth ?? 100, Math.max(minWidth, widths[index] + remainingWidth)); if (width !== widths[index] && (remainingWidth -= width - widths[index], widths[index] = width, Math.abs(remainingWidth).toFixed(3) === "0.000")) break; } return widths; } function getDefaultWidths(panels) { let panelsWithoutWidth = panels.length, remainingWidthTotal = 100; const widthsWithNulls = panels.map((panel) => panel.defaultSize ? (remainingWidthTotal -= panel.defaultSize, panelsWithoutWidth -= 1, panel.defaultSize) : null), defaultWidth = remainingWidthTotal / panelsWithoutWidth; return widthsWithNulls.map((width) => width === null ? defaultWidth : width); } const PanelsWrapper = /* @__PURE__ */ styled.div.withConfig({ displayName: "PanelsWrapper", componentId: "sc-17hl5hb-0" })(["display:flex;flex-direction:row;height:100%;overflow:hidden;width:100%;"]), Panels = function(t0) { const $ = c(46), { children } = t0, panelsEl = useRef(null); let t1; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ new Map(), $[0] = t1) : t1 = $[0]; const [elements, setElements] = useState(t1); let t2; $[1] !== elements ? (t2 = getSortedElements(elements).filter(isPanel), $[1] = elements, $[2] = t2) : t2 = $[2]; const panels = t2; let t3; $[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[3] = t3) : t3 = $[3]; const [widths, setWidths] = useState(t3), [activeResizer, setActiveResizer] = useState(null); let t4; $[4] !== elements || $[5] !== panels || $[6] !== widths ? (t4 = { elements, panels, widths }, $[4] = elements, $[5] = panels, $[6] = widths, $[7] = t4) : t4 = $[7]; const panelsRef = useRef(t4); let t5; $[8] !== activeResizer || $[9] !== panels || $[10] !== widths ? (t5 = (id) => ({ flexGrow: getPanelWidth(panels, id, widths), pointerEvents: activeResizer === null ? void 0 : "none" }), $[8] = activeResizer, $[9] = panels, $[10] = widths, $[11] = t5) : t5 = $[11]; const getPanelStyle = t5; let t6; $[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = (id_0, data) => { setElements((prev) => { if (prev.has(id_0)) return prev; const next = new Map(prev); return next.set(id_0, data), next; }); }, $[12] = t6) : t6 = $[12]; const registerElement = t6; let t7; $[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = (id_1) => { setElements((prev_0) => { if (!prev_0.has(id_1)) return prev_0; const next_0 = new Map(prev_0); return next_0.delete(id_1), next_0; }); }, $[13] = t7) : t7 = $[13]; const unregisterElement = t7; let t8; $[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = { containerWidth: window.innerWidth, dragOffset: 0, panelAfter: null, panelBefore: null, resizerIndex: -1, resizerRect: null, startX: 0, widths: [] }, $[14] = t8) : t8 = $[14]; const dragRef = useRef(t8); let t9; $[15] !== elements ? (t9 = (id_2, event) => { const elementsArr = getSortedElements(elements), index = elementsArr.findIndex((el) => el.id === id_2), resizer = elements.get(id_2); if (!resizer || !isResizer(resizer)) return; const resizeElement = resizer.el.current; resizeElement && (dragRef.current = { resizerIndex: index, panelBefore: elementsArr.reduce((acc, el_0, i) => isPanel(el_0) && i < index ? el_0 : acc, null), panelAfter: elementsArr.reduce((acc_0, el_1, i_0) => acc_0 === null && isPanel(el_1) && i_0 > index ? el_1 : acc_0, null), containerWidth: window.innerWidth, startX: event.pageX, dragOffset: getOffset(event, resizeElement), resizerRect: resizeElement.getBoundingClientRect(), widths: panelsRef.current.widths }, setActiveResizer(id_2)); }, $[15] = elements, $[16] = t9) : t9 = $[16]; const startDragging = t9; let t10; $[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = () => { setActiveResizer(null); }, $[17] = t10) : t10 = $[17]; const stopDragging = t10; let t11; $[18] !== elements ? (t11 = (id_3, event_0) => { event_0.preventDefault(), event_0.stopPropagation(); const { containerWidth, dragOffset, panelBefore, panelAfter, resizerRect } = dragRef.current; if (panelBefore == null || panelAfter == null) return; const resizer_0 = elements.get(id_3); if (!resizer_0 || !isResizer(resizer_0)) return; const resizeElement_0 = resizer_0.el.current; if (!resizeElement_0) return; const offset = getOffset(event_0, resizeElement_0, dragOffset, resizerRect); if (offset === 0) return; const { widths: prevWidths } = panelsRef.current, rect = panelsEl.current.getBoundingClientRect(), delta = offset / rect.width * 100, nextWidths = getNextWidths(delta, containerWidth, panelBefore, panelAfter, panelsRef.current, dragRef.current); prevWidths.some((prevWidth, i_1) => prevWidth !== nextWidths[i_1]) && setWidths(nextWidths); }, $[18] = elements, $[19] = t11) : t11 = $[19]; const drag = t11; let t12, t13; $[20] !== elements || $[21] !== panels || $[22] !== widths ? (t12 = () => { panelsRef.current.elements = elements, panelsRef.current.panels = panels, panelsRef.current.widths = widths; }, t13 = [elements, panels, widths], $[20] = elements, $[21] = panels, $[22] = widths, $[23] = t12, $[24] = t13) : (t12 = $[23], t13 = $[24]), useLayoutEffect(t12, t13); const storage = usePanelsStorage(); let t14, t15; $[25] !== panels || $[26] !== storage ? (t14 = () => { const { widths: widths_0 } = panelsRef.current; if (widths_0.length === panels.length) return; const storedWidths = storage.get(panels); if (storedWidths) { const validatedStoredWidths = validateWidths(panels, storedWidths, window.innerWidth); setWidths(validatedStoredWidths); return; } const defaultWidths = getDefaultWidths(panels); setWidths(defaultWidths); }, t15 = [storage, panels], $[25] = panels, $[26] = storage, $[27] = t14, $[28] = t15) : (t14 = $[27], t15 = $[28]), useLayoutEffect(t14, t15); let t16, t17; $[29] !== panels || $[30] !== storage || $[31] !== widths ? (t16 = () => { widths.length && storage.setDebounced(panels, widths); }, t17 = [storage, panels, widths], $[29] = panels, $[30] = storage, $[31] = widths, $[32] = t16, $[33] = t17) : (t16 = $[32], t17 = $[33]), useEffect(t16, t17); let t18, t19; $[34] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t18 = () => { const resizeObserver = new ResizeObserver(() => { const { panels: panels_0, widths: prevWidths_0 } = panelsRef.current, nextWidths_0 = validateWidths(panels_0, prevWidths_0, window.innerWidth); prevWidths_0.some((prevWidth_0, i_2) => prevWidth_0 !== nextWidths_0[i_2]) && setWidths(nextWidths_0); }); return resizeObserver.observe(panelsEl.current), () => { resizeObserver.disconnect(); }; }, t19 = [], $[34] = t18, $[35] = t19) : (t18 = $[34], t19 = $[35]), useLayoutEffect(t18, t19); let t20; $[36] !== activeResizer || $[37] !== drag || $[38] !== getPanelStyle || $[39] !== startDragging ? (t20 = { activeResizer, drag, getPanelStyle, registerElement, startDragging, stopDragging, unregisterElement }, $[36] = activeResizer, $[37] = drag, $[38] = getPanelStyle, $[39] = startDragging, $[40] = t20) : t20 = $[40]; const context = t20; let t21; $[41] !== children ? (t21 = /* @__PURE__ */ jsx(PanelsWrapper, { ref: panelsEl, children }), $[41] = children, $[42] = t21) : t21 = $[42]; let t22; return $[43] !== context || $[44] !== t21 ? (t22 = /* @__PURE__ */ jsx(PresentationPanelsContext.Provider, { value: context, children: t21 }), $[43] = context, $[44] = t21, $[45] = t22) : t22 = $[45], t22; }; function getPresentationPanelHtmlId(tab) { return `presentation-narrow-panel-${tab}`; } const PresentationNarrowTabBar = function(props) { const $ = c(20), { activeTab, navigatorEnabled, onTabChange } = props, { t } = useTranslation(presentationLocaleNamespace); let t0; $[0] !== t ? (t0 = t("narrow-tabs.preview-tab.label"), $[0] = t, $[1] = t0) : t0 = $[1]; let t1; $[2] !== t0 ? (t1 = { id: "preview", label: t0 }, $[2] = t0, $[3] = t1) : t1 = $[3]; let orderedTabs; if ($[4] !== navigatorEnabled || $[5] !== t || $[6] !== t1) { if (orderedTabs = [t1], navigatorEnabled) { let t23; $[8] !== t ? (t23 = t("narrow-tabs.navigator-tab.label"), $[8] = t, $[9] = t23) : t23 = $[9]; let t32; $[10] !== t23 ? (t32 = { id: "navigator", label: t23 }, $[10] = t23, $[11] = t32) : t32 = $[11], orderedTabs.push(t32); } let t22; $[12] !== t ? (t22 = t("narrow-tabs.content-tab.label"), $[12] = t, $[13] = t22) : t22 = $[13]; let t3; $[14] !== t22 ? (t3 = { id: "content", label: t22 }, $[14] = t22, $[15] = t3) : t3 = $[15], orderedTabs.push(t3), $[4] = navigatorEnabled, $[5] = t, $[6] = t1, $[7] = orderedTabs; } else orderedTabs = $[7]; const tabs = orderedTabs; let t2; return $[16] !== activeTab || $[17] !== onTabChange || $[18] !== tabs ? (t2 = /* @__PURE__ */ jsx(Card, { borderBottom: !0, paddingX: 2, paddingY: 1, children: /* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(TabList, { space: 1, children: tabs.map((tab) => /* @__PURE__ */ jsx(Tab, { "aria-controls": getPresentationPanelHtmlId(tab.id), id: `presentation-narrow-tab-${tab.id}`, label: tab.label, onClick: () => onTabChange(tab.id), selected: activeTab === tab.id }, tab.id)) }) }) }), $[16] = activeTab, $[17] = onTabChange, $[18] = tabs, $[19] = t2) : t2 = $[19], t2; }; function ErrorCard(props) { const $ = c(37); let children, message, onContinueAnyway, onRetry, restProps; $[0] !== props ? ({ children, message, onRetry, onContinueAnyway, ...restProps } = props, $[0] = props, $[1] = children, $[2] = message, $[3] = onContinueAnyway, $[4] = onRetry, $[5] = restProps) : (children = $[1], message = $[2], onContinueAnyway = $[3], onRetry = $[4], restProps = $[5]); const { t } = useTranslation(presentationLocaleNamespace); let t0; $[6] !== t ? (t0 = t("error-card.retry-button.text"), $[6] = t, $[7] = t0) : t0 = $[7]; let t1; $[8] !== onRetry || $[9] !== t0 ? (t1 = /* @__PURE__ */ jsx(Button, { mode: "ghost", onClick: onRetry, text: t0 }), $[8] = onRetry, $[9] = t0, $[10] = t1) : t1 = $[10]; const retryButton = t1; let t2; $[11] !== t ? (t2 = t("error-card.continue-button.text"), $[11] = t, $[12] = t2) : t2 = $[12]; let t3; $[13] !== onContinueAnyway || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsx(Button, { mode: "ghost", tone: "critical", onClick: onContinueAnyway, text: t2 }), $[13] = onContinueAnyway, $[14] = t2, $[15] = t3) : t3 = $[15]; const continueAnywayButton = t3; let t4; $[16] !== t ? (t4 = t("error-card.title"), $[16] = t, $[17] = t4) : t4 = $[17]; let t5; $[18] !== t4 ? (t5 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: t4 }), $[18] = t4, $[19] = t5) : t5 = $[19]; let t6; $[20] !== message ? (t6 = /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: message }), $[20] = message, $[21] = t6) : t6 = $[21]; let t7; $[22] !== t5 || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [ t5, t6 ] }), $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24]; let t8; $[25] !== continueAnywayButton || $[26] !== onContinueAnyway || $[27] !== onRetry || $[28] !== retryButton ? (t8 = onRetry && onContinueAnyway ? /* @__PURE__ */ jsxs(Inline, { space: 2, children: [ retryButton, continueAnywayButton ] }) : onRetry ? /* @__PURE__ */ jsx(Box, { children: retryButton }) : onContinueAnyway ? /* @__PURE__ */ jsx(Box, { children: continueAnywayButton }) : null, $[25] = continueAnywayButton, $[26] = onContinueAnyway, $[27] = onRetry, $[28] = retryButton, $[29] = t8) : t8 = $[29]; let t9; $[30] !== children || $[31] !== t7 || $[32] !== t8 ? (t9 = /* @__PURE__ */ jsx(Flex, { align: "center", height: "fill", justify: "center", children: /* @__PURE__ */ jsx(Container$1, { padding: 4, sizing: "border", width: 0, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [ t7, children, t8 ] }) }) }), $[30] = children, $[31] = t7, $[32] = t8, $[33] = t9) : t9 = $[33]; let t10; return $[34] !== restProps || $[35] !== t9 ? (t10 = /* @__PURE__ */ jsx(Card, { height: "fill", ...restProps, children: t9 }), $[34] = restProps, $[35] = t9, $[36] = t10) : t10 = $[36], t10; } const ChildLink = forwardRef(function(props, ref) { const $ = c(17); let childId, childParameters, childType, rest, searchParams; if ($[0] !== props) { const { childId: t02, childType: t12, childPayload, childParameters: t22, searchParams: t3, ...t4 } = props; childId = t02, childType = t12, childParameters = t22, searchParams = t3, rest = t4, $[0] = props, $[1] = childId, $[2] = childParameters, $[3] = childType, $[4] = rest, $[5] = searchParams; } else childId = $[1], childParameters = $[2], childType = $[3], rest = $[4], searchParams = $[5]; let t0; $[6] !== childParameters || $[7] !== searchParams ? (t0 = Object.entries({ ...searchParams, ...childParameters }), $[6] = childParameters, $[7] = searchParams, $[8] = t0) : t0 = $[8]; let t1; $[9] !== childId || $[10] !== childType || $[11] !== t0 ? (t1 = { id: childId, type: childType, _searchParams: t0 }, $[9] = childId, $[10] = childType, $[11] = t0, $[12] = t1) : t1 = $[12]; let t2; return $[13] !== ref || $[14] !== rest || $[15] !== t1 ? (t2 = /* @__PURE__ */ jsx(StateLink, { ...rest, ref, state: t1 }), $[13] = ref, $[14] = rest, $[15] = t1, $[16] = t2) : t2 = $[16], t2; }), ReferenceChildLink = forwardRef(function(props, ref) { const $ = c(24); let documentId, documentType, parentRefPath, rest, searchParams, template; $[0] !== props ? ({ documentId, documentType, parentRefPath, template, searchParams, ...rest } = props, $[0] = props, $[1] = documentId, $[2] = documentType, $[3] = parentRefPath, $[4] = rest, $[5] = searchParams, $[6] = template) : (documentId = $[1], documentType = $[2], parentRefPath = $[3], rest = $[4], searchParams = $[5], template = $[6]); let t0; $[7] !== documentId ? (t0 = getPublishedId(documentId), $[7] = documentId, $[8] = t0) : t0 = $[8]; const t1 = template?.params; let t2; $[9] !== parentRefPath ? (t2 = pathToString(parentRefPath), $[9] = parentRefPath, $[10] = t2) : t2 = $[10]; let t3; $[11] !== template ? (t3 = template && { template: template?.id }, $[11] = template, $[12] = t3) : t3 = $[12]; let t4; $[13] !== t2 || $[14] !== t3 ? (t4 = { parentRefPath: t2, ...t3 }, $[13] = t2, $[14] = t3, $[15] = t4) : t4 = $[15]; let t5; return $[16] !== documentType || $[17] !== ref || $[18] !== rest || $[19] !== searchParams || $[20] !== t0 || $[21] !== t1 || $[22] !== t4 ? (t5 = /* @__PURE__ */ jsx(ChildLink, { ...rest, ref, childId: t0, childType: documentType, childPayload: t1, childParameters: t4, searchParams }), $[16] = documentType, $[17] = ref, $[18] = rest, $[19] = searchParams, $[20] = t0, $[21] = t1, $[22] = t4, $[23] = t5) : t5 = $[23], t5; }), StructureIntentChildLink = forwardRef(function(props, ref) { const $ = c(19); let childId, childParameters, childPayload, children, rest; if ($[0] !== props ? ({ childId, childParameters, childPayload, children, ...rest } = props, $[0] = props, $[1] = childId, $[2] = childParameters, $[3] = childPayload, $[4] = children, $[5] = rest) : (childId = $[1], childParameters = $[2], childPayload = $[3], children = $[4], rest = $[5]), !childParameters?.type) return null; let t0; $[6] !== childId ? (t0 = getPublishedId(childId), $[6] = childId, $[7] = t0) : t0 = $[7]; let t1; $[8] !== childParameters || $[9] !== t0 ? (t1 = { ...childParameters, id: t0, mode: "structure" }, $[8] = childParameters, $[9] = t0, $[10] = t1) : t1 = $[10]; const intentParams = t1; let t2; $[11] !== childPayload || $[12] !== intentParams ? (t2 = childPayload !== void 0 ? [intentParams, childPayload] : intentParams, $[11] = childPayload, $[12] = intentParams, $[13] = t2) : t2 = $[13]; const params = t2; let t3; return $[14] !== children || $[15] !== params || $[16] !== ref || $[17] !== rest ? (t3 = /* @__PURE__ */ jsx(IntentLink, { ...rest, ref, intent: "edit", params, rel: "noopener noreferrer", target: "_blank", children }), $[14] = children, $[15] = params, $[16] = ref, $[17] = rest, $[18] = t3) : t3 = $[18], t3; }); function encodeQueryString(params = {}) { const parts = Object.entries(params).map(([key, value]) => `${key}=${value}`).join("&"); return parts.length ? `?${parts}` : ""; } function resolveQueryStringFromParams(nextParams) { const allowed = ["comment", "inspect", "instruction", "pathKey", "rev", "since", "template", "view"], safeNextParams = Object.entries(nextParams).filter(([key]) => allowed.includes(key)).reduce((obj, [key, value]) => value == null ? obj : { ...obj, [key]: value }, {}); return encodeQueryString(safeNextParams); } const BackLink = forwardRef(function(props, ref) { const $ = c(9); let restProps, searchParams; $[0] !== props ? ({ searchParams, ...restProps } = props, $[0] = props, $[1] = restProps, $[2] = searchParams) : (restProps = $[1], searchParams = $[2]); let t0; $[3] !== searchParams ? (t0 = { type: void 0, _searchParams: Object.entries(searchParams) }, $[3] = searchParams, $[4] = t0) : t0 = $[4]; let t1; return $[5] !== ref || $[6] !== restProps || $[7] !== t0 ? (t1 = /* @__PURE__ */ jsx(StateLink, { ...restProps, ref, state: t0, title: void 0 }), $[5] = ref, $[6] = restProps, $[7] = t0, $[8] = t1) : t1 = $[8], t1; }); function PresentationPaneRouterProvider(props) { const $ = c(28), { children, onEditReference, onStructureParams, structureParams, searchParams, refs } = props, { state: routerState, resolvePathFromState } = useRouter(); let t0; $[0] !== routerState._searchParams ? (t0 = Object.fromEntries(routerState._searchParams || []), $[0] = routerState._searchParams, $[1] = t0) : t0 = $[1]; const routerSearchParams = useUnique(t0); let t1; $[2] !== resolvePathFromState || $[3] !== routerSearchParams || $[4] !== routerState ? (t1 = (nextParams) => { const path = resolvePathFromState(routerState), qs = resolveQueryStringFromParams({ ...routerSearchParams, ...nextParams }); return `${path}${qs}`; }, $[2] = resolvePathFromState, $[3] = routerSearchParams, $[4] = routerState, $[5] = t1) : t1 = $[5]; const createPathWithParams = t1; let t2; $[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[6] = t2) : t2 = $[6]; const t3 = structureParams; let t4; $[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = [], $[7] = t4) : t4 = $[7]; let t5; $[8] !== refs || $[9] !== searchParams ? (t5 = forwardRef(function(childLinkProps, ref) { const { childId, childParameters, ...rest } = childLinkProps, doc = refs?.find((r) => r._id === childId || getPublishedId(r._id) === childId); return doc ? /* @__PURE__ */ jsx(ChildLink, { ...rest, ref, childId, childType: doc._type, searchParams }) : /* @__PURE__ */ jsx(StructureIntentChildLink, { ...rest, ref, childId, childParameters }); }), $[8] = refs, $[9] = searchParams, $[10] = t5) : t5 = $[10]; let t6; $[11] !== searchParams ? (t6 = forwardRef(function(backLinkProps, ref_0) { return /* @__PURE__ */ jsx(BackLink, { ...backLinkProps, ref: ref_0, searchParams }); }), $[11] = searchParams, $[12] = t6) : t6 = $[12]; let t7; $[13] !== searchParams ? (t7 = forwardRef(function(childLinkProps_0, ref_1) { return /* @__PURE__ */ jsx(ReferenceChildLink, { ...childLinkProps_0, ref: ref_1, searchParams }); }), $[13] = searchParams, $[14] = t7) : t7 = $[14]; let t8; $[15] !== onEditReference ? (t8 = (options) => { const { id, template, type, parentRefPath, version } = options; onEditReference({ state: { id, type }, params: { template: template.id, parentRefPath: toString(parentRefPath), version } }); }, $[15] = onEditReference, $[16] = t8) : t8 = $[16]; let t9; $[17] !== createPathWithParams || $[18] !== onStructureParams || $[19] !== t3 || $[20] !== t5 || $[21] !== t6 || $[22] !== t7 || $[23] !== t8 ? (t9 = { index: 0, groupIndex: 0, siblingIndex: 0, payload: t2, params: t3, hasGroupSiblings: !1, groupLength: 1, routerPanesState: t4, ChildLink: t5, BackLink: t6, ReferenceChildLink: t7, ParameterizedLink: _temp$f, closeCurrentAndAfter: _temp2$7, handleEditReference: t8, replaceCurrent: _temp3$4, closeCurrent: _temp4$2, duplicateCurrent: _temp5$2, setView: _temp6$1, setParams: onStructureParams, setPayload: _temp7$1, navigateIntent: _temp8, createPathWithParams }, $[17] = createPathWithParams, $[18] = onStructureParams, $[19] = t3, $[20] = t5, $[21] = t6, $[22] = t7, $[23] = t8, $[24] = t9) : t9 = $[24]; const context = t9; let t10; return $[25] !== children || $[26] !== context ? (t10 = /* @__PURE__ */ jsx(PaneRouterContext.Provider, { value: context, children }), $[25] = children, $[26] = context, $[27] = t10) : t10 = $[27], t10; } function _temp8(intentName, intentParams, options_0) { console.warn("navigateIntent", intentName, intentParams, options_0); } function _temp7$1(payload) { console.warn("setPayload", payload); } function _temp6$1(viewId) { console.warn("setView", viewId); } function _temp5$2(pane_0) { console.warn("duplicateCurrent", pane_0); } function _temp4$2() { console.warn("closeCurrent"); } function _temp3$4(pane) { console.warn("replaceCurrent", pane); } function _temp2$7() { console.warn("closeCurrentAndAfter"); } function _temp$f() { throw new Error("ParameterizedLink not implemented"); } const RootLayout = /* @__PURE__ */ styled(PaneLayout).withConfig({ displayName: "RootLayout", componentId: "sc-18wb5dr-0" })(["height:100%;"]), Root = /* @__PURE__ */ styled(Flex).withConfig({ displayName: "Root", componentId: "sc-18wb5dr-1" })(["& > div{min-width:none !important;max-width:none !important;}"]), WrappedCode$1 = /* @__PURE__ */ styled(Code).withConfig({ displayName: "WrappedCode", componentId: "sc-18wb5dr-2" })(["white-space:pre-wrap;"]); function deriveOrderedIds({ visualOrderPublishedIds, refs, mainDocumentId }) { const seenPublishedIds = /* @__PURE__ */ new Set(); return [...visualOrderPublishedIds, ...refs.map((ref) => getPublishedId(ref._id))].reduce((accumulatedIds, publishedId) => (publishedId === mainDocumentId || seenPublishedIds.has(publishedId) || (seenPublishedIds.add(publishedId), accumulatedIds.push(publishedId)), accumulatedIds), []); } function DocumentListPane(props) { const $ = c(41), { mainDocumentState, onEditReference, onStructureParams, searchParams, refs, visualOrderPublishedIds } = props, { t } = useTranslation(presentationLocaleNamespace), { devMode } = usePresentationTool(), t0 = mainDocumentState?.document?._id; let t1; $[0] !== refs || $[1] !== t0 || $[2] !== visualOrderPublishedIds ? (t1 = deriveOrderedIds({ visualOrderPublishedIds, refs, mainDocumentId: t0 }), $[0] = refs, $[1] = t0, $[2] = visualOrderPublishedIds, $[3] = t1) : t1 = $[3]; const ids = t1; let t2; $[4] !== ids ? (t2 = { ids }, $[4] = ids, $[5] = t2) : t2 = $[5]; let t3; $[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = [{ field: ORDER_BY_IDS_PARAM_FIELD, direction: "asc" }], $[6] = t3) : t3 = $[6]; let t4; $[7] !== t2 ? (t4 = { filter: "_id in $ids", params: t2, defaultOrdering: t3 }, $[7] = t2, $[8] = t4) : t4 = $[8]; let t5; $[9] !== t ? (t5 = t("document-list-pane.document-list.title"), $[9] = t, $[10] = t5) : t5 = $[10]; let t6; $[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = [{ id: "sorting" }], $[11] = t6) : t6 = $[11]; let t7; $[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = { title: { key: "document-list-pane.ordering.by-appearance", ns: presentationLocaleNamespace } }, $[12] = t7) : t7 = $[12]; let t8; $[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = { group: "sorting", action: "setSortOrder", i18n: t7, title: "By appearance", params: { by: [{ field: ORDER_BY_IDS_PARAM_FIELD, direction: "asc" }] } }, $[13] = t8) : t8 = $[13]; let t9; $[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = { title: { key: "document-list-pane.ordering.last-edited", ns: presentationLocaleNamespace } }, $[14] = t9) : t9 = $[14]; let t10; $[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = [t8, { group: "sorting", action: "setSortOrder", i18n: t9, title: "Last edited", params: { by: [{ field: "_updatedAt", direction: "desc" }] } }], $[15] = t10) : t10 = $[15]; let t11; $[16] !== t4 || $[17] !== t5 ? (t11 = { id: "presentationDocumentsOnPage", options: t4, schemaTypeName: "", title: t5, type: "documentList", menuItemGroups: t6, menuItems: t10, suppressRestoreDefaultMenuItems: !0 }, $[16] = t4, $[17] = t5, $[18] = t11) : t11 = $[18]; const pane = t11, [errorParams, setErrorParams] = useState(null); let t12; $[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = () => setErrorParams(null), $[19] = t12) : t12 = $[19]; const handleRetry = t12, [structureParams] = useState(_temp$e); let t13; $[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t13 = () => setErrorParams(null), $[20] = t13) : t13 = $[20]; let t14; if ($[21] !== refs ? (t14 = [refs], $[21] = refs, $[22] = t14) : t14 = $[22], useEffect(t13, t14), errorParams) { let t152; $[23] !== t ? (t152 = t("document-list-pane.error.text"), $[23] = t, $[24] = t152) : t152 = $[24]; let t162; $[25] !== devMode || $[26] !== errorParams || $[27] !== t ? (t162 = devMode && /* @__PURE__ */ jsx(Card, { overflow: "auto", padding: 3, radius: 2, tone: "critical", children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [ /* @__PURE__ */ jsx(Label, { muted: !0, size: 0, children: t("presentation-error.label") }), /* @__PURE__ */ jsx(WrappedCode$1, { size: 1, children: errorParams.error.message }) ] }) }), $[25] = devMode, $[26] = errorParams, $[27] = t, $[28] = t162) : t162 = $[28]; let t17; return $[29] !== t152 || $[30] !== t162 ? (t17 = /* @__PURE__ */ jsx(ErrorCard, { flex: 1, message: t152, onRetry: handleRetry, children: t162 }), $[29] = t152, $[30] = t162, $[31] = t17) : t17 = $[31], t17; } let t15; $[32] !== pane ? (t15 = /* @__PURE__ */ jsx(Root, { direction: "column", flex: 1, children: /* @__PURE__ */ jsx(DocumentListPane$1, { index: 0, itemId: "$root", pane, paneKey: "$root" }) }), $[32] = pane, $[33] = t15) : t15 = $[33]; let t16; return $[34] !== onEditReference || $[35] !== onStructureParams || $[36] !== refs || $[37] !== searchParams || $[38] !== structureParams || $[39] !== t15 ? (t16 = /* @__PURE__ */ jsx(ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsx(RootLayout, { children: /* @__PURE__ */ jsx(StructureToolProvider, { children: /* @__PURE__ */ jsx(PresentationPaneRouterProvider, { onEditReference, onStructureParams, structureParams, searchParams, refs, children: t15 }) }) }) }), $[34] = onEditReference, $[35] = onStructureParams, $[36] = refs, $[37] = searchParams, $[38] = structureParams, $[39] = t15, $[40] = t16) : t16 = $[40], t16; } function _temp$e() { return {}; } const WrappedCode = /* @__PURE__ */ styled(Code).withConfig({ displayName: "WrappedCode", componentId: "sc-m0u57n-0" })(["white-space:pre-wrap;"]); function DocumentPane(props) { const $ = c(40), { documentId, documentType, onFocusPath, onEditReference, onStructureParams, searchParams, structureParams } = props, { template, templateParams } = structureParams, { t } = useTranslation(presentationLocaleNamespace), { devMode } = usePresentationTool(); let t0; $[0] !== templateParams ? (t0 = decodeJsonParams(templateParams), $[0] = templateParams, $[1] = t0) : t0 = $[1]; let t1; $[2] !== documentId || $[3] !== documentType || $[4] !== t0 || $[5] !== template ? (t1 = { id: documentId, type: documentType, template, templateParameters: t0 }, $[2] = documentId, $[3] = documentType, $[4] = t0, $[5] = template, $[6] = t1) : t1 = $[6]; let t2; $[7] !== documentId || $[8] !== t1 ? (t2 = { id: documentId, options: t1, title: "", type: "document" }, $[7] = documentId, $[8] = t1, $[9] = t2) : t2 = $[9]; const paneDocumentNode = t2; let t3; $[10] !== documentId || $[11] !== documentType || $[12] !== onFocusPath ? (t3 = (path) => onFocusPath({ id: documentId, type: documentType, path: studioPath.toString(path) }), $[10] = documentId, $[11] = documentType, $[12] = onFocusPath, $[13] = t3) : t3 = $[13]; const handleFocusPath = t3, [errorParams, setErrorParams] = useState(null); let t4; $[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setErrorParams(null), $[14] = t4) : t4 = $[14]; const handleRetry = t4; let t5; $[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = () => { setErrorParams(null); }, $[15] = t5) : t5 = $[15]; let t6; if ($[16] !== documentId || $[17] !== documentType || $[18] !== structureParams ? (t6 = [documentId, documentType, structureParams], $[16] = documentId, $[17] = documentType, $[18] = structureParams, $[19] = t6) : t6 = $[19], useEffect(t5, t6), errorParams) { let t72; $[20] !== t ? (t72 = t("document-pane.error.text"), $[20] = t, $[21] = t72) : t72 = $[21]; let t82; $[22] !== devMode || $[23] !== errorParams || $[24] !== t ? (t82 = devMode && /* @__PURE__ */ jsx(Card, { overflow: "auto", padding: 3, radius: 2, tone: "critical", children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [ /* @__PURE__ */ jsx(Label, { muted: !0, size: 0, children: t("presentation-error.label") }), /* @__PURE__ */ jsx(WrappedCode, { size: 1, children: errorParams.error.message }) ] }) }), $[22] = devMode, $[23] = errorParams, $[24] = t, $[25] = t82) : t82 = $[25]; let t92; return $[26] !== t72 || $[27] !== t82 ? (t92 = /* @__PURE__ */ jsx(ErrorCard, { flex: 1, message: t72, onRetry: handleRetry, children: t82 }), $[26] = t72, $[27] = t82, $[28] = t92) : t92 = $[28], t92; } let t7; $[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = { height: "100%" }, $[29] = t7) : t7 = $[29]; let t8; $[30] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = /* @__PURE__ */ jsx(PresentationSpinner, {}), $[30] = t8) : t8 = $[30]; let t9; $[31] !== handleFocusPath || $[32] !== paneDocumentNode ? (t9 = /* @__PURE__ */ jsx(Suspense, { fallback: t8, children: /* @__PURE__ */ jsx(DocumentPane$1, { paneKey: "document", index: 1, itemId: "document", pane: paneDocumentNode, onFocusPath: handleFocusPath }) }), $[31] = handleFocusPath, $[32] = paneDocumentNode, $[33] = t9) : t9 = $[33]; let t10; return $[34] !== onEditReference || $[35] !== onStructureParams || $[36] !== searchParams || $[37] !== structureParams || $[38] !== t9 ? (t10 = /* @__PURE__ */ jsx(ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsx(PaneLayout, { style: t7, children: /* @__PURE__ */ jsx(PresentationPaneRouterProvider, { searchParams, onEditReference, onStructureParams, structureParams, children: t9 }) }) }), $[34] = onEditReference, $[35] = onStructureParams, $[36] = searchParams, $[37] = structureParams, $[38] = t9, $[39] = t10) : t10 = $[39], t10; } function DocumentPanel(props) { const $ = c(8), { documentId, documentType, onFocusPath, onEditReference, onStructureParams, searchParams, structureParams } = props; let t0; return $[0] !== documentId || $[1] !== documentType || $[2] !== onEditReference || $[3] !== onFocusPath || $[4] !== onStructureParams || $[5] !== searchParams || $[6] !== structureParams ? (t0 = /* @__PURE__ */ jsx(StructureToolProvider$1, { children: /* @__PURE__ */ jsx(DocumentPane, { documentId, documentType, onEditReference, onFocusPath, onStructureParams, searchParams, structureParams }) }), $[0] = documentId, $[1] = documentType, $[2] = onEditReference, $[3] = onFocusPath, $[4] = onStructureParams, $[5] = searchParams, $[6] = structureParams, $[7] = t0) : t0 = $[7], t0; } function usePreviewState(documentId, schemaType2) { const $ = c(7), documentPreviewStore = useDocumentPreviewStore(); let t0; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0]; const [preview, setPreview] = useState(t0), { perspectiveStack } = usePerspective(); let t1, t2; return $[1] !== documentId || $[2] !== documentPreviewStore || $[3] !== perspectiveStack || $[4] !== schemaType2 ? (t1 = () => { if (!schemaType2) return; const subscription = getPreviewStateObservable(documentPreviewStore, schemaType2, documentId, perspectiveStack).subscribe((state) => { setPreview(state); }); return () => { subscription?.unsubscribe(); }; }, t2 = [documentPreviewStore, schemaType2, documentId, perspectiveStack], $[1] = documentId, $[2] = documentPreviewStore, $[3] = perspectiveStack, $[4] = schemaType2, $[5] = t1, $[6] = t2) : (t1 = $[5], t2 = $[6]), useEffect(t1, t2), preview; } function ContentEditor(props) { const $ = c(41), { documentId, documentType, mainDocumentState, onEditReference, onFocusPath, onStructureParams, refs, visualOrderPublishedIds, searchParams, structureParams } = props, { t } = useTranslation(presentationLocaleNamespace), schema = useSchema(); let t0; $[0] !== mainDocumentState?.document?._id || $[1] !== mainDocumentState?.document?._type || $[2] !== searchParams ? (t0 = (props_0) => /* @__PURE__ */ jsx(StateLink, { ...props_0, state: { id: mainDocumentState?.document?._id, type: mainDocumentState?.document?._type, _searchParams: Object.entries(searchParams) } }), $[0] = mainDocumentState?.document?._id, $[1] = mainDocumentState?.docume