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,092 lines (1,089 loc) • 165 kB
JavaScript
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, EDIT_INTENT_MODE, DEFAULT_TOOL_NAME } from "./presentation.mjs";
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, Text, Stack, Inline, Box, Flex, Container as Container$1, Code, Label, TextInput, Spinner, useToast, Menu, Grid, Switch, MenuDivider, Hotkeys, usePrefersReducedMotion, BoundaryElementProvider } from "@sanity/ui";
import { memo, useEffect, useRef, useContext, useLayoutEffect, useState, forwardRef, Suspense, useId as useId$1, useImperativeHandle, lazy, useMemo, useCallback, useSyncExternalStore, useReducer } from "react";
import { useTranslation, pathToString, useUnique, getPublishedId, useDocumentPreviewStore, usePerspective, getPreviewStateObservable, useSchema, getPreviewValueWithFallback, SanityDefaultPreview, PreviewCard, Translate, CommentsIntentProvider, useActiveWorkspace, useClient, useCurrentUser, useProjectId, useDataset, useWorkspace, COMMENTS_INSPECTOR_NAME, useGrantsStore } from "sanity";
import { StateLink, useRouter, decodeJsonParams } from "sanity/router";
import { styled, createGlobalStyle } from "styled-components";
import { useEffectEvent } from "use-effect-event";
import { setup, assign, fromPromise, fromObservable, log } from "xstate";
import { PresentationSharedStateContext, PresentationPanelsContext, PresentationNavigateContext, PresentationParamsContext, PresentationContext } from "sanity/_singletons";
import { WarningOutlineIcon, LaunchIcon, ResetIcon, CopyIcon, ShareIcon, PanelLeftIcon, MobileDeviceIcon, DesktopIcon, RefreshIcon } from "@sanity/icons";
import { PaneRouterContext, PaneLayout, StructureToolProvider, DocumentListPane as DocumentListPane$1, DocumentPane as DocumentPane$1 } from "sanity/structure";
import { Button, ErrorBoundary, Tooltip, MenuButton, MenuItem, TooltipDelayGroupProvider } from "./generate-help-url.esm.mjs";
import "../_singletons.mjs";
import { toString } from "@sanity/util/paths";
import { StructureToolProvider as StructureToolProvider$1 } from "./StructureToolProvider.mjs";
import { studioPath } from "@sanity/client/csm";
import { DisplayedDocumentBroadcasterProvider } from "./DisplayedDocumentBroadcaster.mjs";
import { v4 } from "uuid";
import { motion, AnimatePresence, MotionConfig } from "framer-motion";
import { flushSync } from "react-dom";
import { setSecretSearchParams, withoutSecretSearchParams } from "@sanity/preview-url-secret/without-secret-search-params";
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 { createPreviewSecret } from "@sanity/preview-url-secret/create-secret";
import { uuid } from "@sanity/uuid";
import { throwError } from "rxjs";
import { subcribeToVercelProtectionBypass } from "@sanity/preview-url-secret/toggle-vercel-protection-bypass";
const PostMessageFeatures = (props) => {
const $ = c(3), {
comlink
} = props;
let t0, t1;
return $[0] !== comlink ? (t0 = () => comlink.on("visual-editing/features", _temp$f), t1 = [comlink], $[0] = comlink, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1), null;
};
var PostMessageFeatures$1 = memo(PostMessageFeatures);
function _temp$f() {
return {
features: {
optimistic: !0
}
};
}
const presentationMachine = setup({
types: {},
actions: {
//
},
actors: {
//
},
guards: {
//
}
}).createMachine({
// eslint-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] === 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, t6;
$[8] !== removeValue || $[9] !== setValue ? (t6 = {
removeValue,
setValue
}, $[8] = removeValue, $[9] = setValue, $[10] = t6) : t6 = $[10], t5 = t6;
const context = t5;
let t7;
return $[11] !== children || $[12] !== context ? (t7 = /* @__PURE__ */ jsx(PresentationSharedStateContext.Provider, { value: context, children }), $[11] = children, $[12] = context, $[13] = t7) : t7 = $[13], t7;
}, Root$1 = styled.div`
overflow: hidden;
flex-basis: 0;
flex-shrink: 1;
`, Panel = function(t0) {
const $ = c(15), {
children,
defaultSize: t1,
id,
minWidth,
maxWidth,
order: t2
} = t0, defaultSize = t1 === void 0 ? null : t1, order = t2 === void 0 ? 0 : t2, context = useContext(PresentationPanelsContext);
if (context === null)
throw Error("Panel components must be rendered within a PanelGroup container");
const {
getPanelStyle,
registerElement,
unregisterElement
} = context;
let t3;
$[0] !== getPanelStyle || $[1] !== id ? (t3 = getPanelStyle(id), $[0] = getPanelStyle, $[1] = id, $[2] = t3) : t3 = $[2];
const style = t3;
let t4, t5;
$[3] !== defaultSize || $[4] !== id || $[5] !== maxWidth || $[6] !== minWidth || $[7] !== order || $[8] !== registerElement || $[9] !== unregisterElement ? (t4 = () => (registerElement(id, {
id,
type: "panel",
defaultSize,
maxWidth: maxWidth ?? null,
minWidth: minWidth ?? 0,
order
}), () => {
unregisterElement(id);
}), t5 = [id, defaultSize, order, maxWidth, minWidth, registerElement, unregisterElement], $[3] = defaultSize, $[4] = id, $[5] = maxWidth, $[6] = minWidth, $[7] = order, $[8] = registerElement, $[9] = unregisterElement, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), useLayoutEffect(t4, t5);
let t6;
return $[12] !== children || $[13] !== style ? (t6 = /* @__PURE__ */ jsx(Root$1, { style, children }), $[12] = children, $[13] = style, $[14] = t6) : t6 = $[14], t6;
};
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);
let t0;
const get = _temp2$8, set = _temp3$4;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const setDebounced = debounce(set, 100);
t1 = {
get,
set,
setDebounced
}, $[0] = t1;
} else
t1 = $[0];
return t0 = t1, t0;
}
function _temp3$4(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$e) ? void 0 : stored[key];
}
function _temp$e(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(
// eslint-disable-next-line no-negated-condition
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 = styled.div`
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] === Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ new Map(), $[0] = t1) : t1 = $[0];
const [elements, setElements] = useState(t1);
let t2, t3;
$[1] !== elements ? (t3 = getSortedElements(elements).filter(isPanel), $[1] = elements, $[2] = t3) : t3 = $[2], t2 = t3;
const panels = t2;
let t4;
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t4 = [], $[3] = t4) : t4 = $[3];
const [widths, setWidths] = useState(t4), [activeResizer, setActiveResizer] = useState(null);
let t5;
$[4] !== elements || $[5] !== panels || $[6] !== widths ? (t5 = {
elements,
panels,
widths
}, $[4] = elements, $[5] = panels, $[6] = widths, $[7] = t5) : t5 = $[7];
const panelsRef = useRef(t5);
let t6;
$[8] !== activeResizer || $[9] !== panels || $[10] !== widths ? (t6 = (id) => ({
flexGrow: getPanelWidth(panels, id, widths),
pointerEvents: activeResizer === null ? void 0 : "none"
}), $[8] = activeResizer, $[9] = panels, $[10] = widths, $[11] = t6) : t6 = $[11];
const getPanelStyle = t6;
let t7;
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t7 = (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] = t7) : t7 = $[12];
const registerElement = t7;
let t8;
$[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = (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] = t8) : t8 = $[13];
const unregisterElement = t8;
let t9;
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t9 = {
containerWidth: window.innerWidth,
dragOffset: 0,
panelAfter: null,
panelBefore: null,
resizerIndex: -1,
resizerRect: null,
startX: 0,
widths: []
}, $[14] = t9) : t9 = $[14];
const dragRef = useRef(t9);
let t10;
$[15] !== elements ? (t10 = (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] = t10) : t10 = $[16];
const startDragging = t10;
let t11;
$[17] === Symbol.for("react.memo_cache_sentinel") ? (t11 = () => {
setActiveResizer(null);
}, $[17] = t11) : t11 = $[17];
const stopDragging = t11;
let t12;
$[18] !== elements ? (t12 = (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] = t12) : t12 = $[19];
const drag = t12;
let t13, t14;
$[20] !== elements || $[21] !== panels || $[22] !== widths ? (t13 = () => {
panelsRef.current.elements = elements, panelsRef.current.panels = panels, panelsRef.current.widths = widths;
}, t14 = [elements, panels, widths], $[20] = elements, $[21] = panels, $[22] = widths, $[23] = t13, $[24] = t14) : (t13 = $[23], t14 = $[24]), useLayoutEffect(t13, t14);
const storage = usePanelsStorage();
let t15, t16;
$[25] !== panels || $[26] !== storage ? (t15 = () => {
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);
}, t16 = [storage, panels], $[25] = panels, $[26] = storage, $[27] = t15, $[28] = t16) : (t15 = $[27], t16 = $[28]), useLayoutEffect(t15, t16);
let t17, t18;
$[29] !== panels || $[30] !== storage || $[31] !== widths ? (t17 = () => {
widths.length && storage.setDebounced(panels, widths);
}, t18 = [storage, panels, widths], $[29] = panels, $[30] = storage, $[31] = widths, $[32] = t17, $[33] = t18) : (t17 = $[32], t18 = $[33]), useEffect(t17, t18);
let t19, t20;
$[34] === Symbol.for("react.memo_cache_sentinel") ? (t19 = () => {
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();
};
}, t20 = [], $[34] = t19, $[35] = t20) : (t19 = $[34], t20 = $[35]), useLayoutEffect(t19, t20);
let t21, t22;
$[36] !== activeResizer || $[37] !== drag || $[38] !== getPanelStyle || $[39] !== startDragging ? (t22 = {
activeResizer,
drag,
getPanelStyle,
registerElement,
startDragging,
stopDragging,
unregisterElement
}, $[36] = activeResizer, $[37] = drag, $[38] = getPanelStyle, $[39] = startDragging, $[40] = t22) : t22 = $[40], t21 = t22;
const context = t21;
let t23;
$[41] !== children ? (t23 = /* @__PURE__ */ jsx(PanelsWrapper, { ref: panelsEl, children }), $[41] = children, $[42] = t23) : t23 = $[42];
let t24;
return $[43] !== context || $[44] !== t23 ? (t24 = /* @__PURE__ */ jsx(PresentationPanelsContext.Provider, { value: context, children: t23 }), $[43] = context, $[44] = t23, $[45] = t24) : t24 = $[45], t24;
};
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(22);
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]);
const t0 = template?.params;
let t1;
$[7] !== parentRefPath ? (t1 = pathToString(parentRefPath), $[7] = parentRefPath, $[8] = t1) : t1 = $[8];
let t2;
$[9] !== template ? (t2 = template && {
template: template?.id
}, $[9] = template, $[10] = t2) : t2 = $[10];
let t3;
$[11] !== t1 || $[12] !== t2 ? (t3 = {
parentRefPath: t1,
...t2
}, $[11] = t1, $[12] = t2, $[13] = t3) : t3 = $[13];
let t4;
return $[14] !== documentId || $[15] !== documentType || $[16] !== ref || $[17] !== rest || $[18] !== searchParams || $[19] !== t0 || $[20] !== t3 ? (t4 = /* @__PURE__ */ jsx(ChildLink, { ...rest, ref, childId: documentId, childType: documentType, childPayload: t0, childParameters: t3, searchParams }), $[14] = documentId, $[15] = documentType, $[16] = ref, $[17] = rest, $[18] = searchParams, $[19] = t0, $[20] = t3, $[21] = t4) : t4 = $[21], t4;
});
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(11);
let restProps, searchParams;
$[0] !== props ? ({
searchParams,
...restProps
} = props, $[0] = props, $[1] = restProps, $[2] = searchParams) : (restProps = $[1], searchParams = $[2]);
let t0;
$[3] !== searchParams ? (t0 = Object.entries(searchParams), $[3] = searchParams, $[4] = t0) : t0 = $[4];
let t1;
$[5] !== t0 ? (t1 = {
type: void 0,
_searchParams: t0
}, $[5] = t0, $[6] = t1) : t1 = $[6];
let t2;
return $[7] !== ref || $[8] !== restProps || $[9] !== t1 ? (t2 = /* @__PURE__ */ jsx(StateLink, { ...restProps, ref, state: t1, title: void 0 }), $[7] = ref, $[8] = restProps, $[9] = t1, $[10] = t2) : t2 = $[10], t2;
});
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, t3;
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {}, $[6] = t3) : t3 = $[6];
const t4 = structureParams;
let t5;
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t5 = [], $[7] = t5) : t5 = $[7];
let t6;
$[8] !== refs || $[9] !== searchParams ? (t6 = forwardRef(function(childLinkProps, ref) {
const {
childId,
...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 }) : (console.warn(`ChildLink: No document found for childId "${childId}"`), null);
}), $[8] = refs, $[9] = searchParams, $[10] = t6) : t6 = $[10];
let t7;
$[11] !== searchParams ? (t7 = forwardRef(function(backLinkProps, ref_0) {
return /* @__PURE__ */ jsx(BackLink, { ...backLinkProps, ref: ref_0, searchParams });
}), $[11] = searchParams, $[12] = t7) : t7 = $[12];
let t8;
$[13] !== searchParams ? (t8 = forwardRef(function(childLinkProps_0, ref_1) {
return /* @__PURE__ */ jsx(ReferenceChildLink, { ...childLinkProps_0, ref: ref_1, searchParams });
}), $[13] = searchParams, $[14] = t8) : t8 = $[14];
let t9;
$[15] !== onEditReference ? (t9 = (options) => {
const {
id,
template,
type,
parentRefPath,
version
} = options;
onEditReference({
state: {
id,
type
},
params: {
template: template.id,
parentRefPath: toString(parentRefPath),
version
}
});
}, $[15] = onEditReference, $[16] = t9) : t9 = $[16];
let t10;
$[17] !== createPathWithParams || $[18] !== onStructureParams || $[19] !== t4 || $[20] !== t6 || $[21] !== t7 || $[22] !== t8 || $[23] !== t9 ? (t10 = {
index: 0,
groupIndex: 0,
siblingIndex: 0,
payload: t3,
params: t4,
hasGroupSiblings: !1,
groupLength: 1,
routerPanesState: t5,
ChildLink: t6,
BackLink: t7,
ReferenceChildLink: t8,
ParameterizedLink: _temp$d,
closeCurrentAndAfter: _temp2$7,
handleEditReference: t9,
replaceCurrent: _temp3$3,
closeCurrent: _temp4$2,
duplicateCurrent: _temp5$2,
setView: _temp6$1,
setParams: onStructureParams,
setPayload: _temp7$1,
navigateIntent: _temp8,
createPathWithParams
}, $[17] = createPathWithParams, $[18] = onStructureParams, $[19] = t4, $[20] = t6, $[21] = t7, $[22] = t8, $[23] = t9, $[24] = t10) : t10 = $[24], t2 = t10;
const context = t2;
let t11;
return $[25] !== children || $[26] !== context ? (t11 = /* @__PURE__ */ jsx(PaneRouterContext.Provider, { value: context, children }), $[25] = children, $[26] = context, $[27] = t11) : t11 = $[27], t11;
}
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$3(pane) {
console.warn("replaceCurrent", pane);
}
function _temp2$7() {
console.warn("closeCurrentAndAfter");
}
function _temp$d() {
throw new Error("ParameterizedLink not implemented");
}
const RootLayout = styled(PaneLayout)`
height: 100%;
`, Root = styled(Flex)`
& > div {
min-width: none !important;
max-width: none !important;
}
`, WrappedCode$1 = styled(Code)`
white-space: pre-wrap;
`;
function DocumentListPane(props) {
const $ = c(34), {
mainDocumentState,
onEditReference,
onStructureParams,
searchParams,
refs
} = props, {
t
} = useTranslation(presentationLocaleNamespace), {
devMode
} = usePresentationTool();
let t0, t1;
if ($[0] !== mainDocumentState?.document?._id || $[1] !== refs) {
let t22;
$[3] !== mainDocumentState?.document?._id ? (t22 = (r) => getPublishedId(r._id) !== mainDocumentState?.document?._id, $[3] = mainDocumentState?.document?._id, $[4] = t22) : t22 = $[4], t1 = refs.filter(t22).map(_temp$c), $[0] = mainDocumentState?.document?._id, $[1] = refs, $[2] = t1;
} else
t1 = $[2];
t0 = t1;
const ids = t0;
let t2, t3;
$[5] !== ids ? (t3 = {
filter: "_id in $ids",
params: {
ids
}
}, $[5] = ids, $[6] = t3) : t3 = $[6];
let t4;
$[7] !== t ? (t4 = t("document-list-pane.document-list.title"), $[7] = t, $[8] = t4) : t4 = $[8];
let t5;
$[9] !== t3 || $[10] !== t4 ? (t5 = {
id: "$root",
options: t3,
schemaTypeName: "",
title: t4,
type: "documentList"
}, $[9] = t3, $[10] = t4, $[11] = t5) : t5 = $[11], t2 = t5;
const pane = t2, [errorParams, setErrorParams] = useState(null);
let t6;
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => setErrorParams(null), $[12] = t6) : t6 = $[12];
const handleRetry = t6, [structureParams] = useState(_temp2$6);
let t7;
$[13] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => setErrorParams(null), $[13] = t7) : t7 = $[13];
let t8;
if ($[14] !== refs ? (t8 = [refs], $[14] = refs, $[15] = t8) : t8 = $[15], useEffect(t7, t8), errorParams) {
let t92;
$[16] !== t ? (t92 = t("document-list-pane.error.text"), $[16] = t, $[17] = t92) : t92 = $[17];
let t102;
$[18] !== devMode || $[19] !== errorParams || $[20] !== t ? (t102 = 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 })
] }) }), $[18] = devMode, $[19] = errorParams, $[20] = t, $[21] = t102) : t102 = $[21];
let t11;
return $[22] !== t102 || $[23] !== t92 ? (t11 = /* @__PURE__ */ jsx(ErrorCard, { flex: 1, message: t92, onRetry: handleRetry, children: t102 }), $[22] = t102, $[23] = t92, $[24] = t11) : t11 = $[24], t11;
}
let t9;
$[25] !== pane ? (t9 = /* @__PURE__ */ jsx(Root, { direction: "column", flex: 1, children: /* @__PURE__ */ jsx(DocumentListPane$1, { index: 0, itemId: "$root", pane, paneKey: "$root" }) }), $[25] = pane, $[26] = t9) : t9 = $[26];
let t10;
return $[27] !== onEditReference || $[28] !== onStructureParams || $[29] !== refs || $[30] !== searchParams || $[31] !== structureParams || $[32] !== t9 ? (t10 = /* @__PURE__ */ jsx(ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsx(RootLayout, { children: /* @__PURE__ */ jsx(StructureToolProvider, { children: /* @__PURE__ */ jsx(PresentationPaneRouterProvider, { onEditReference, onStructureParams, structureParams, searchParams, refs, children: t9 }) }) }) }), $[27] = onEditReference, $[28] = onStructureParams, $[29] = refs, $[30] = searchParams, $[31] = structureParams, $[32] = t9, $[33] = t10) : t10 = $[33], t10;
}
function _temp2$6() {
return {};
}
function _temp$c(r_0) {
return getPublishedId(r_0._id);
}
const WrappedCode = styled(Code)`
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, t1;
$[0] !== templateParams ? (t1 = decodeJsonParams(templateParams), $[0] = templateParams, $[1] = t1) : t1 = $[1];
let t2;
$[2] !== documentId || $[3] !== documentType || $[4] !== t1 || $[5] !== template ? (t2 = {
id: documentId,
type: documentType,
template,
templateParameters: t1
}, $[2] = documentId, $[3] = documentType, $[4] = t1, $[5] = template, $[6] = t2) : t2 = $[6];
let t3;
$[7] !== documentId || $[8] !== t2 ? (t3 = {
id: documentId,
options: t2,
title: "",
type: "document"
}, $[7] = documentId, $[8] = t2, $[9] = t3) : t3 = $[9], t0 = t3;
const paneDocumentNode = t0;
let t4;
$[10] !== documentId || $[11] !== documentType || $[12] !== onFocusPath ? (t4 = (path) => onFocusPath({
id: documentId,
type: documentType,
path: studioPath.toString(path)
}), $[10] = documentId, $[11] = documentType, $[12] = onFocusPath, $[13] = t4) : t4 = $[13];
const handleFocusPath = t4, [errorParams, setErrorParams] = useState(null);
let t5;
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => setErrorParams(null), $[14] = t5) : t5 = $[14];
const handleRetry = t5;
let t6;
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => {
setErrorParams(null);
}, $[15] = t6) : t6 = $[15];
let t7;
if ($[16] !== documentId || $[17] !== documentType || $[18] !== structureParams ? (t7 = [documentId, documentType, structureParams], $[16] = documentId, $[17] = documentType, $[18] = structureParams, $[19] = t7) : t7 = $[19], useEffect(t6, t7), errorParams) {
let t82;
$[20] !== t ? (t82 = t("document-pane.error.text"), $[20] = t, $[21] = t82) : t82 = $[21];
let t92;
$[22] !== devMode || $[23] !== errorParams || $[24] !== t ? (t92 = 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] = t92) : t92 = $[25];
let t102;
return $[26] !== t82 || $[27] !== t92 ? (t102 = /* @__PURE__ */ jsx(ErrorCard, { flex: 1, message: t82, onRetry: handleRetry, children: t92 }), $[26] = t82, $[27] = t92, $[28] = t102) : t102 = $[28], t102;
}
let t8;
$[29] === Symbol.for("react.memo_cache_sentinel") ? (t8 = {
height: "100%"
}, $[29] = t8) : t8 = $[29];
let t9;
$[30] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx(PresentationSpinner, {}), $[30] = t9) : t9 = $[30];
let t10;
$[31] !== handleFocusPath || $[32] !== paneDocumentNode ? (t10 = /* @__PURE__ */ jsx(Suspense, { fallback: t9, children: /* @__PURE__ */ jsx(DocumentPane$1, { paneKey: "document", index: 1, itemId: "document", pane: paneDocumentNode, onFocusPath: handleFocusPath }) }), $[31] = handleFocusPath, $[32] = paneDocumentNode, $[33] = t10) : t10 = $[33];
let t11;
return $[34] !== onEditReference || $[35] !== onStructureParams || $[36] !== searchParams || $[37] !== structureParams || $[38] !== t10 ? (t11 = /* @__PURE__ */ jsx(ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsx(PaneLayout, { style: t8, children: /* @__PURE__ */ jsx(PresentationPaneRouterProvider, { searchParams, onEditReference, onStructureParams, structureParams, children: t10 }) }) }), $[34] = onEditReference, $[35] = onStructureParams, $[36] = searchParams, $[37] = structureParams, $[38] = t10, $[39] = t11) : t11 = $[39], t11;
}
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] === 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(40), {
documentId,
documentType,
mainDocumentState,
onEditReference,
onFocusPath,
onStructureParams,
refs,
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?.document?._type, $[2] = searchParams, $[3] = t0) : t0 = $[3];
const MainDocumentLink = t0;
let t1, t2;
$[4] !== mainDocumentState?.document?._type || $[5] !== schema ? (t2 = schema.get(mainDocumentState?.document?._type || "shoe"), $[4] = mainDocumentState?.document?._type, $[5] = schema, $[6] = t2) : t2 = $[6], t1 = t2;
const schemaType2 = t1, previewState = usePreviewState(mainDocumentState?.document?._id || "", schemaType2);
let t3;
bb0: {
if (!mainDocumentState?.document) {
t3 = null;
break bb0;
}
let t42;
$[7] !== mainDocumentState.document || $[8] !== previewState.snapshot ? (t42 = getPreviewValueWithFallback({
snapshot: previewState.snapshot,
fallback: mainDocumentState.document
}), $[7] = mainDocumentState.document, $[8] = previewState.snapshot, $[9] = t42) : t42 = $[9];
let t52;
$[10] !== t ? (t52 = t("main-document.label"), $[10] = t, $[11] = t52) : t52 = $[11];
let t62;
$[12] !== t52 ? (t62 = /* @__PURE__ */ jsx(Card, { padding: 1, radius: 2, shadow: 1, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 0, weight: "medium", children: t52 }) }), $[12] = t52, $[13] = t62) : t62 = $[13];
let t7;
$[14] !== schemaType2 || $[15] !== t42 || $[16] !== t62 ? (t7 = /* @__PURE__ */ jsx(SanityDefaultPreview, { ...t42, schemaType: schemaType2, status: t62 }), $[14] = schemaType2, $[15] = t42, $[16] = t62, $[17] = t7) : t7 = $[17], t3 = t7;
}
const preview = t3;
if (documentId && documentType) {
let t42;
return $[18] !== documentId || $[19] !== documentType || $[20] !== onEditReference || $[21] !== onFocusPath || $[22] !== onStructureParams || $[23] !== searchParams || $[24] !== structureParams ? (t42 = /* @__PURE__ */ jsx(DocumentPanel, { documentId, documentType, onEditReference, onFocusPath, onStructureParams, searchParams, structureParams }), $[18] = documentId, $[19] = documentType, $[20] = onEditReference, $[21] = onFocusPath, $[22] = onStructureParams, $[23] = searchParams, $[24] = structureParams, $[25] = t42) : t42 = $[25], t42;
}
let t4;
$[26] !== MainDocumentLink || $[27] !== mainDocumentState || $[28] !== preview || $[29] !== t ? (t4 = mainDocumentState && /* @__PURE__ */ jsx(Card, { padding: 3, tone: mainDocumentState.document ? "inherit" : "caution", children: mainDocumentState.document ? /* @__PURE__ */ jsx(PreviewCard, { __unstable_focusRing: !0, as: MainDocumentLink, "data-as": "a", radius: 2, sizing: "border", tone: "inherit", children: preview }) : /* @__PURE__ */ jsx(Card, { padding: 2, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
/* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(WarningOutlineIcon, {}) }) }),
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Translate, { t, i18nKey: "main-document.missing.text", components: {
Code: "code"
}, values: {
path: mainDocumentState.path
} }) }) })
] }) }) }), $[26] = MainDocumentLink, $[27] = mainDocumentState, $[28] = preview, $[29] = t, $[30] = t4) : t4 = $[30];
let t5;
$[31] !== mainDocumentState || $[32] !== onEditReference || $[33] !== onStructureParams || $[34] !== refs || $[35] !== searchParams ? (t5 = /* @__PURE__ */ jsx(DocumentListPane, { mainDocumentState, onEditReference, onStructureParams, searchParams, refs }), $[31] = mainDocumentState, $[32] = onEditReference, $[33] = onStructureParams, $[34] = refs, $[35] = searchParams, $[36] = t5) : t5 = $[36];
let t6;
return $[37] !== t4 || $[38] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Flex, { direction: "column", flex: 1, height: "fill", children: [
t4,
t5
] }), $[37] = t4, $[38] = t5, $[39] = t6) : t6 = $[39], t6;
}
function usePanelId(id) {
const $ = c(2);
let t0;
$[0] !== id ? (t0 = () => id || v4(), $[0] = id, $[1] = t0) : t0 = $[1];
const [panelId] = useState(t0);
return panelId;
}
const Resizer = styled.div`
position: relative;
`, ResizerInner = styled.div`
position: absolute;
top: 0;
bottom: 0;
left: -5px;
width: 9px;
z-index: 10;
cursor: ${({
$disabled
}) => $disabled ? "auto" : "ew-resize"};
/* Border */
& > span:nth-child(1) {
display: block;
border-left: 1px solid var(--card-border-color);
position: absolute;
top: 0;
left: 4px;
bottom: 0;
transition: opacity 200ms;
}
${({
$disabled
}) => !$disabled && `
/* Hover effect */
& > span:nth-child(2) {
display: block;
position: absolute;
top: 0;
left: 0;
width: 9px;
bottom: 0;
background-color: var(--card-border-color);
opacity: 0;
transition: opacity 150ms;
}
@media (hover: hover) {
&:hover > span:nth-child(2) {
opacity: 0.2;
}
}
`}
`, PanelResizer = function(t0) {
const $ = c(27), {
id: propId,
order,
disabled: t1
} = t0, disabled = t1 === void 0 ? !1 : t1, el = useRef(null), context = useContext(PresentationPanelsContext);
if (context === null)
throw Error("Panel components must be rendered within a PanelGroup container");
const id = usePanelId(propId), {
activeResizer,
drag,
startDragging,
stopDragging,
registerElement,
unregisterElement
} = context, isDragging = activeResizer === id;
if (context === null)
throw Error("Panel components must be rendered within a PanelGroup container");
let t2;
$[0] !== id || $[1] !== startDragging ? (t2 = (event) => {
startDragging(id, event.nativeEvent);
}, $[0] = id, $[1] = startDragging, $[2] = t2) : t2 = $[2];
const onMouseDown = t2;
let t3;
$[3] !== drag || $[4] !== id ? (t3 = (e) => {
drag(id, e);
}, $[3] = drag, $[4] = id, $[5] = t3) : t3 = $[5];
const onDrag = t3;
let t4;
$[6] !== stopDragging ? (t4 = () => {
el.current.blur(), stopDragging();
}, $[6] = stopDragging, $[7] = t4) : t4 = $[7];
const onDragStop = t4;
let t5, t6;
$[8] !== disabled || $[9] !== isDragging || $[10] !== onDrag || $[11] !== onDragStop ? (t5 = () => {
if (!isDragging || disabled)
return;
const resetDocumentStyles = function() {
const bodyStyle = document.body.style, documentStyle = document.documentElement.style, {
cursor
} = documentStyle, {
userSelect
} = bodyStyle;
return documentStyle.cursor = "ew-resize", bodyStyle.userSelect = "none", () => {
cursor ? documentStyle.cursor = cursor : documentSty