sanity 4.0.2-next.0-1493034f2d-202507161600 → 4.0.2-next.0-ebde28ec21-202507170747

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ import { Box, Text, Flex, Button, Menu, MenuItem, Stack, Card, Container as Cont
7
7
  import { useMemo, useEffect, useCallback, forwardRef, useRef, useState, useContext, useImperativeHandle, useLayoutEffect, useId, memo, useDeferredValue, lazy, Suspense, startTransition, useReducer, createElement, Fragment as Fragment$1 } from "react";
8
8
  import { ReviewChangesContext, CommentsEnabledContext, ReferenceInputOptionsContext, PaneLayoutContext, PaneContext, DocumentPaneContext, PaneRouterContext, StructureToolContext, DocumentSheetListContext, DocumentChangeContext } from "sanity/_singletons";
9
9
  import { TransferIcon, CloseIcon, LockIcon, CheckmarkIcon, UnknownIcon, SearchIcon, DocumentRemoveIcon, ReadOnlyIcon, ErrorOutlineIcon, WarningOutlineIcon, SyncIcon, InfoOutlineIcon, ComposeSparklesIcon, LaunchIcon, UnpublishIcon, StarFilledIcon, StarIcon, ArrowLeftIcon, TrashIcon, ResetIcon, CopyIcon, RevertIcon, PublishIcon, SplitVerticalIcon, EditIcon, AddIcon, ChevronLeftIcon, ChevronDownIcon, RestoreIcon, LinkIcon, EarthAmericasIcon, JsonIcon, DocumentsIcon, ChevronRightIcon, DocumentIcon, FolderIcon, SpinnerIcon, EllipsisHorizontalIcon, DoubleChevronLeftIcon, DoubleChevronRightIcon, CheckmarkCircleIcon, MasterDetailIcon } from "@sanity/icons";
10
- import { useTranslation, useDocumentVersions, useActiveReleases, getVersionFromId, getReleaseIdFromReleaseDocumentId, useEditState, getPublishedId, useWorkspace, isPublishedId, isDraftId, getDraftId, getVersionId, ReleaseAvatar, getReleaseTone, formatRelativeLocalePublishDate, isReleaseScheduledOrScheduling, isReleaseDocument, useMiddlewareComponents, ChangeIndicatorsTracker, VirtualizerScrollInstanceProvider, useDocumentForm, LoadingBlock, FormBuilder, isVersionId, createPatchChannel, LegacyLayerProvider, IsLastPaneProvider, useGetI18nText, useI18nText, TooltipOfDisabled, ContextMenuButton, StatusButton, isDev, CommentsEnabledProvider, useCommentsEnabled, usePerspective, useStudioUrl, CommentsProvider, COMMENTS_INSPECTOR_NAME, useArchivedReleases, useUnique, unstable_useValuePreview, useDocumentOperationEvent, Translate, isNewDocument, Resizable, useKeyValueStore, isRecord, isString, isPublishedPerspective, isDraftPerspective, useDocumentOperation, isDeprecatedSchemaType, useProjectId, useClient, useZIndex, useCurrentUser, useListFormat, useDocumentPreviewStore, getVersionInlineBadge, useCanvasCompanionDoc, useNavigateToCanvasDoc, getDocumentVariantType, isPerspectiveWriteable, ReleasesNav, useSanityCreateConfig, getSanityCreateLinkMetadata, LATEST, useVersionOperations, useConditionalToast, useOnlyHasVersions, useSetPerspective, VersionInlineBadge, isGoingToUnpublish, useDocumentStore, useDocumentPresence, PresenceOverlay, fromMutationPatches, useManageFavorite, useActiveWorkspace, CapabilityGate, ScrollContainer, isSanityCreateLinked, isSystemBundle, useDocumentPairPermissions, InsufficientPermissionsMessage, useValidationStatus, useSyncState, useRelativeTime, useSource, Hotkeys, isSanityDefinedAction, useDateTimeFormat, useSchema, VersionChip, useFieldActions, UserAvatar, useUser, AvatarSkeleton, CommandList, TextWithTone, useTimelineSelector, useEvents, TIMELINE_ITEM_I18N_KEY_MAPPING as TIMELINE_ITEM_I18N_KEY_MAPPING$1, resizeObserver, ChangeConnectorRoot, useGlobalCopyPasteElementHandler, GetFormValueProvider, FieldActionsResolver, FieldActionsProvider, useTemplates, useInitialValue, useCopyPaste, EMPTY_ARRAY as EMPTY_ARRAY$2, useEventsStore, EventsProvider, isDeleteDocumentGroupEvent, isDeleteDocumentVersionEvent, PerspectiveProvider, useTimelineStore, SourceProvider, CopyPasteProvider, useDocumentType, useTemplatePermissions, ReferenceInputOptionsProvider, useDocumentVersionInfo, getPreviewStateObservable, getPreviewValueWithFallback, SanityDefaultPreview, DocumentPreviewPresence, DocumentStatusIndicator, DocumentStatus, PreviewCard, createHookFromObservableFactory, DEFAULT_STUDIO_CLIENT_OPTIONS, EMPTY_OBJECT, GetHookCollectionState, ErrorActions, collate, createSWR, getSearchableTypes, createSearch, useSearchMaxFieldDepth, catchWithCount, useReconnectingToast, useSearchState, SearchHeader, Filters, SearchProvider, ChangeFieldWrapper, NoChanges, ChangeList, isUnpublishDocumentEvent, isScheduleDocumentVersionEvent, isUnscheduleDocumentVersionEvent, Event, RELEASES_INTENT, isCreateDocumentVersionEvent, isEditDocumentVersionEvent, isPublishDocumentVersionEvent, ChangesError, isArray, isValidationError, isValidationWarning, definePlugin } from "sanity";
10
+ import { useTranslation, useDocumentVersions, useActiveReleases, getVersionFromId, getReleaseIdFromReleaseDocumentId, useEditState, getPublishedId, useWorkspace, isPublishedId, isDraftId, getDraftId, getVersionId, ReleaseAvatar, getReleaseTone, formatRelativeLocalePublishDate, isReleaseScheduledOrScheduling, isReleaseDocument, useMiddlewareComponents, ChangeIndicatorsTracker, VirtualizerScrollInstanceProvider, useDocumentForm, LoadingBlock, FormBuilder, isVersionId, createPatchChannel, LegacyLayerProvider, IsLastPaneProvider, useGetI18nText, useI18nText, TooltipOfDisabled, ContextMenuButton, StatusButton, isDev, CommentsEnabledProvider, useCommentsEnabled, usePerspective, useStudioUrl, CommentsProvider, COMMENTS_INSPECTOR_NAME, useArchivedReleases, useUnique, prepareForPreview, unstable_useValuePreview, useDocumentOperationEvent, Translate, isNewDocument, Resizable, useKeyValueStore, isRecord, isString, isPublishedPerspective, isDraftPerspective, useDocumentOperation, isDeprecatedSchemaType, useProjectId, useClient, useZIndex, useCurrentUser, useListFormat, useDocumentPreviewStore, getVersionInlineBadge, useCanvasCompanionDoc, useNavigateToCanvasDoc, getDocumentVariantType, isPerspectiveWriteable, ReleasesNav, useSanityCreateConfig, getSanityCreateLinkMetadata, LATEST, useVersionOperations, useConditionalToast, useOnlyHasVersions, useSetPerspective, VersionInlineBadge, isGoingToUnpublish, useDocumentStore, useDocumentPresence, PresenceOverlay, fromMutationPatches, useManageFavorite, useActiveWorkspace, CapabilityGate, ScrollContainer, isSanityCreateLinked, isSystemBundle, useDocumentPairPermissions, InsufficientPermissionsMessage, useValidationStatus, useSyncState, useRelativeTime, useSource, Hotkeys, isSanityDefinedAction, useDateTimeFormat, useSchema, VersionChip, useFieldActions, UserAvatar, useUser, AvatarSkeleton, CommandList, TextWithTone, useTimelineSelector, useEvents, TIMELINE_ITEM_I18N_KEY_MAPPING as TIMELINE_ITEM_I18N_KEY_MAPPING$1, resizeObserver, ChangeConnectorRoot, useGlobalCopyPasteElementHandler, GetFormValueProvider, FieldActionsResolver, FieldActionsProvider, useHistoryStore, useTimelineStore, useTemplates, useInitialValue, useCopyPaste, EMPTY_ARRAY as EMPTY_ARRAY$2, useEventsStore, EventsProvider, isDeleteDocumentGroupEvent, isDeleteDocumentVersionEvent, PerspectiveProvider, SourceProvider, CopyPasteProvider, useDocumentType, useTemplatePermissions, ReferenceInputOptionsProvider, useDocumentVersionInfo, getPreviewStateObservable, getPreviewValueWithFallback, SanityDefaultPreview, DocumentPreviewPresence, DocumentStatusIndicator, DocumentStatus, PreviewCard, createHookFromObservableFactory, DEFAULT_STUDIO_CLIENT_OPTIONS, EMPTY_OBJECT, GetHookCollectionState, ErrorActions, collate, createSWR, getSearchableTypes, createSearch, useSearchMaxFieldDepth, catchWithCount, useReconnectingToast, useSearchState, SearchHeader, Filters, SearchProvider, ChangeFieldWrapper, NoChanges, ChangeList, isUnpublishDocumentEvent, isScheduleDocumentVersionEvent, isUnscheduleDocumentVersionEvent, Event, RELEASES_INTENT, isCreateDocumentVersionEvent, isEditDocumentVersionEvent, isPublishDocumentVersionEvent, ChangesError, isArray, isValidationError, isValidationWarning, definePlugin } from "sanity";
11
11
  import { uuid } from "@sanity/uuid";
12
12
  import { styled, css, keyframes } from "styled-components";
13
13
  import { diffInput, wrap } from "@sanity/diff";
@@ -82,7 +82,7 @@ function useDiffViewRouter() {
82
82
  $[3] !== navigate || $[4] !== routerState ? (t1 = () => {
83
83
  navigate({
84
84
  ...routerState,
85
- _searchParams: (routerState._searchParams ?? []).filter(_temp$r)
85
+ _searchParams: (routerState._searchParams ?? []).filter(_temp$s)
86
86
  });
87
87
  }, $[3] = navigate, $[4] = routerState, $[5] = t1) : t1 = $[5];
88
88
  const exitDiffView = t1;
@@ -92,7 +92,7 @@ function useDiffViewRouter() {
92
92
  exitDiffView
93
93
  }, $[6] = exitDiffView, $[7] = navigateDiffView, $[8] = t2) : t2 = $[8], t2;
94
94
  }
95
- function _temp$r(t0) {
95
+ function _temp$s(t0) {
96
96
  const [key] = t0;
97
97
  return ![DIFF_VIEW_SEARCH_PARAMETER, DIFF_VIEW_PREVIOUS_DOCUMENT_SEARCH_PARAMETER, DIFF_VIEW_NEXT_DOCUMENT_SEARCH_PARAMETER].includes(key);
98
98
  }
@@ -150,14 +150,14 @@ function useScrollMirror(elements) {
150
150
  const $ = c(3);
151
151
  let t0, t1;
152
152
  $[0] !== elements ? (t0 = () => {
153
- const existentElements = elements.filter(_temp$q);
153
+ const existentElements = elements.filter(_temp$r);
154
154
  if (existentElements.length === 0)
155
155
  return;
156
156
  const scrollMirror = new ScrollMirror(existentElements);
157
157
  return () => scrollMirror.destroy();
158
158
  }, t1 = [elements], $[0] = elements, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1);
159
159
  }
160
- function _temp$q(element) {
160
+ function _temp$r(element) {
161
161
  return element !== null;
162
162
  }
163
163
  const VersionModeHeaderLayout = styled.header`
@@ -349,7 +349,7 @@ function usePathSyncChannel(t0) {
349
349
  source
350
350
  } = t5;
351
351
  return source !== id;
352
- }, $[6] = id, $[7] = t42) : t42 = $[7], t3 = syncChannel.pipe(distinctUntilChanged(_temp$p), filter(t42), map(_temp2$9)), $[3] = id, $[4] = syncChannel, $[5] = t3;
352
+ }, $[6] = id, $[7] = t42) : t42 = $[7], t3 = syncChannel.pipe(distinctUntilChanged(_temp$q), filter(t42), map(_temp2$9)), $[3] = id, $[4] = syncChannel, $[5] = t3;
353
353
  } else
354
354
  t3 = $[5];
355
355
  t2 = t3;
@@ -363,7 +363,7 @@ function usePathSyncChannel(t0) {
363
363
  function _temp2$9(state_0) {
364
364
  return state_0.path;
365
365
  }
366
- function _temp$p(previous, next) {
366
+ function _temp$q(previous, next) {
367
367
  return deepEquals(previous.path, next.path);
368
368
  }
369
369
  const Scroller$5 = styled.div`
@@ -444,7 +444,7 @@ const Scroller$5 = styled.div`
444
444
  $[0] !== compareDocument ? (t1 = {
445
445
  compareDocument
446
446
  }, $[0] = compareDocument, $[1] = t1) : t1 = $[1];
447
- const compareValue = useCompareValue(t1), [patchChannel] = useState(_temp$o);
447
+ const compareValue = useCompareValue(t1), [patchChannel] = useState(_temp$p);
448
448
  let t2;
449
449
  $[2] !== documentId ? (t2 = getPublishedId(documentId), $[2] = documentId, $[3] = t2) : t2 = $[3];
450
450
  let t3;
@@ -537,7 +537,7 @@ function useCompareValue(t0) {
537
537
  }
538
538
  return t4;
539
539
  }
540
- function _temp$o() {
540
+ function _temp$p() {
541
541
  return createPatchChannel();
542
542
  }
543
543
  const Link = styled.a`
@@ -1499,7 +1499,7 @@ function PaneLayout(props) {
1499
1499
  onExpand,
1500
1500
  ...restProps
1501
1501
  } = props, $[0] = props, $[1] = children, $[2] = minWidth, $[3] = onCollapse, $[4] = onExpand, $[5] = restProps) : (children = $[1], minWidth = $[2], onCollapse = $[3], onExpand = $[4], restProps = $[5]);
1502
- const [controller] = useState(_temp$n), [rootElement, setRootElement] = useState(null), width = useElementRect(rootElement)?.width || 0, collapsed = width === void 0 || !minWidth ? void 0 : width < minWidth;
1502
+ const [controller] = useState(_temp$o), [rootElement, setRootElement] = useState(null), width = useElementRect(rootElement)?.width || 0, collapsed = width === void 0 || !minWidth ? void 0 : width < minWidth;
1503
1503
  let t0;
1504
1504
  $[6] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
1505
1505
  expandedElement: null,
@@ -1534,7 +1534,7 @@ function PaneLayout(props) {
1534
1534
  let t15;
1535
1535
  return $[38] !== paneLayout || $[39] !== t14 ? (t15 = /* @__PURE__ */ jsx(PaneLayoutContext.Provider, { value: paneLayout, children: t14 }), $[38] = paneLayout, $[39] = t14, $[40] = t15) : t15 = $[40], t15;
1536
1536
  }
1537
- function _temp$n() {
1537
+ function _temp$o() {
1538
1538
  return createPaneLayoutController();
1539
1539
  }
1540
1540
  function ErrorPane(props) {
@@ -1862,59 +1862,85 @@ function defineInspectorMenuItemComponent({
1862
1862
  });
1863
1863
  }
1864
1864
  function useDocumentTitle() {
1865
- const $ = c(17), {
1865
+ const $ = c(22), {
1866
1866
  connectionState,
1867
1867
  schemaType,
1868
- editState
1868
+ editState,
1869
+ isDeleted,
1870
+ lastRevisionDocument
1869
1871
  } = useDocumentPane(), {
1870
1872
  t
1871
- } = useTranslation(structureLocaleNamespace), documentValue = editState?.version || editState?.draft || editState?.published, subscribed = !!documentValue;
1873
+ } = useTranslation(structureLocaleNamespace);
1872
1874
  let t0;
1873
- $[0] !== documentValue || $[1] !== schemaType || $[2] !== subscribed ? (t0 = {
1874
- enabled: subscribed,
1875
+ t0 = isDeleted ? lastRevisionDocument : editState?.version || editState?.draft || editState?.published;
1876
+ const documentValue = t0, subscribed = !!documentValue;
1877
+ let t1;
1878
+ bb0: {
1879
+ if (isDeleted && lastRevisionDocument && schemaType)
1880
+ try {
1881
+ let t32;
1882
+ $[0] !== lastRevisionDocument || $[1] !== schemaType ? (t32 = prepareForPreview(lastRevisionDocument, schemaType), $[0] = lastRevisionDocument, $[1] = schemaType, $[2] = t32) : t32 = $[2], t1 = t32;
1883
+ break bb0;
1884
+ } catch (t22) {
1885
+ console.warn("Failed to prepare preview for deleted document:", t22), t1 = null;
1886
+ break bb0;
1887
+ }
1888
+ t1 = null;
1889
+ }
1890
+ const deletedDocumentPreview = t1, t2 = subscribed && !isDeleted;
1891
+ let t3;
1892
+ $[3] !== documentValue || $[4] !== schemaType || $[5] !== t2 ? (t3 = {
1893
+ enabled: t2,
1875
1894
  schemaType,
1876
1895
  value: documentValue
1877
- }, $[0] = documentValue, $[1] = schemaType, $[2] = subscribed, $[3] = t0) : t0 = $[3];
1896
+ }, $[3] = documentValue, $[4] = schemaType, $[5] = t2, $[6] = t3) : t3 = $[6];
1878
1897
  const {
1879
- error,
1898
+ error: error_0,
1880
1899
  value
1881
- } = unstable_useValuePreview(t0);
1900
+ } = unstable_useValuePreview(t3);
1882
1901
  if (connectionState === "connecting" && !subscribed) {
1883
- let t12;
1884
- return $[4] === Symbol.for("react.memo_cache_sentinel") ? (t12 = {
1902
+ let t42;
1903
+ return $[7] === Symbol.for("react.memo_cache_sentinel") ? (t42 = {
1885
1904
  error: void 0,
1886
1905
  title: void 0
1887
- }, $[4] = t12) : t12 = $[4], t12;
1906
+ }, $[7] = t42) : t42 = $[7], t42;
1888
1907
  }
1889
- if (!value) {
1890
- const t12 = schemaType?.title || schemaType?.name;
1891
- let t22;
1892
- $[5] !== t || $[6] !== t12 ? (t22 = t("panes.document-header-title.new.text", {
1893
- schemaType: t12
1894
- }), $[5] = t, $[6] = t12, $[7] = t22) : t22 = $[7];
1895
- let t3;
1896
- return $[8] !== t22 ? (t3 = {
1908
+ if (isDeleted && deletedDocumentPreview) {
1909
+ let t42;
1910
+ return $[8] !== deletedDocumentPreview.title ? (t42 = {
1897
1911
  error: void 0,
1898
- title: t22
1899
- }, $[8] = t22, $[9] = t3) : t3 = $[9], t3;
1912
+ title: deletedDocumentPreview.title
1913
+ }, $[8] = deletedDocumentPreview.title, $[9] = t42) : t42 = $[9], t42;
1900
1914
  }
1901
- if (error) {
1902
- let t12;
1903
- $[10] !== error.message || $[11] !== t ? (t12 = t("panes.document-list-pane.error.text", {
1904
- error: error.message
1905
- }), $[10] = error.message, $[11] = t, $[12] = t12) : t12 = $[12];
1906
- let t22;
1907
- return $[13] !== t12 ? (t22 = {
1908
- error: t12,
1915
+ if (!value && !isDeleted) {
1916
+ const t42 = schemaType?.title || schemaType?.name;
1917
+ let t52;
1918
+ $[10] !== t || $[11] !== t42 ? (t52 = t("panes.document-header-title.new.text", {
1919
+ schemaType: t42
1920
+ }), $[10] = t, $[11] = t42, $[12] = t52) : t52 = $[12];
1921
+ let t6;
1922
+ return $[13] !== t52 ? (t6 = {
1923
+ error: void 0,
1924
+ title: t52
1925
+ }, $[13] = t52, $[14] = t6) : t6 = $[14], t6;
1926
+ }
1927
+ if (error_0) {
1928
+ let t42;
1929
+ $[15] !== error_0.message || $[16] !== t ? (t42 = t("panes.document-list-pane.error.text", {
1930
+ error: error_0.message
1931
+ }), $[15] = error_0.message, $[16] = t, $[17] = t42) : t42 = $[17];
1932
+ let t52;
1933
+ return $[18] !== t42 ? (t52 = {
1934
+ error: t42,
1909
1935
  title: void 0
1910
- }, $[13] = t12, $[14] = t22) : t22 = $[14], t22;
1936
+ }, $[18] = t42, $[19] = t52) : t52 = $[19], t52;
1911
1937
  }
1912
- const t1 = value?.title;
1913
- let t2;
1914
- return $[15] !== t1 ? (t2 = {
1938
+ const t4 = value?.title;
1939
+ let t5;
1940
+ return $[20] !== t4 ? (t5 = {
1915
1941
  error: void 0,
1916
- title: t1
1917
- }, $[15] = t1, $[16] = t2) : t2 = $[16], t2;
1942
+ title: t4
1943
+ }, $[20] = t4, $[21] = t5) : t5 = $[21], t5;
1918
1944
  }
1919
1945
  const IGNORE_OPS = ["patch", "commit"], DocumentOperationResults = memo(function() {
1920
1946
  const $ = c(12), {
@@ -2506,7 +2532,7 @@ function RequestPermissionDialog(t0) {
2506
2532
  let t32;
2507
2533
  if ($[2] !== client.observable || $[3] !== projectId) {
2508
2534
  let t42;
2509
- $[5] === Symbol.for("react.memo_cache_sentinel") ? (t42 = (roles) => roles.filter(_temp$m).find(_temp2$8) ? "editor" : adminRole, $[5] = t42) : t42 = $[5];
2535
+ $[5] === Symbol.for("react.memo_cache_sentinel") ? (t42 = (roles) => roles.filter(_temp$n).find(_temp2$8) ? "editor" : adminRole, $[5] = t42) : t42 = $[5];
2510
2536
  let t52;
2511
2537
  $[6] === Symbol.for("react.memo_cache_sentinel") ? (t52 = () => of(adminRole), $[6] = t52) : t52 = $[6], t32 = client.observable.request({
2512
2538
  url: `/projects/${projectId}/roles`
@@ -2597,7 +2623,7 @@ function RequestPermissionDialog(t0) {
2597
2623
  function _temp2$8(role_0) {
2598
2624
  return role_0.name === "editor";
2599
2625
  }
2600
- function _temp$m(role) {
2626
+ function _temp$n(role) {
2601
2627
  return role?.appliesToUsers;
2602
2628
  }
2603
2629
  const LOADING_STATE = {
@@ -2691,7 +2717,7 @@ function InsufficientPermissionBanner(t0) {
2691
2717
  t
2692
2718
  } = useTranslation(structureLocaleNamespace), telemetry = useTelemetry();
2693
2719
  let roleTitles, t4;
2694
- $[3] !== currentUserRoles || $[4] !== listFormat ? (roleTitles = currentUserRoles.map(_temp$l), t4 = listFormat.formatToParts(roleTitles).map(_temp2$7), $[3] = currentUserRoles, $[4] = listFormat, $[5] = roleTitles, $[6] = t4) : (roleTitles = $[5], t4 = $[6]);
2720
+ $[3] !== currentUserRoles || $[4] !== listFormat ? (roleTitles = currentUserRoles.map(_temp$m), t4 = listFormat.formatToParts(roleTitles).map(_temp2$7), $[3] = currentUserRoles, $[4] = listFormat, $[5] = roleTitles, $[6] = t4) : (roleTitles = $[5], t4 = $[6]);
2695
2721
  const roles = t4;
2696
2722
  let t5;
2697
2723
  $[7] !== roles ? (t5 = {
@@ -2729,7 +2755,7 @@ function InsufficientPermissionBanner(t0) {
2729
2755
  function _temp2$7(part) {
2730
2756
  return part.type === "element" ? /* @__PURE__ */ jsx("code", { children: part.value }, part.value) : part.value;
2731
2757
  }
2732
- function _temp$l(role) {
2758
+ function _temp$m(role) {
2733
2759
  return role.title;
2734
2760
  }
2735
2761
  const ReferenceChangedBanner = memo(() => {
@@ -2908,7 +2934,7 @@ const Image = styled.img`
2908
2934
  }
2909
2935
  const variantText = t1;
2910
2936
  let t2;
2911
- $[6] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(_temp$k), $[6] = t2) : t2 = $[6];
2937
+ $[6] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(_temp$l), $[6] = t2) : t2 = $[6];
2912
2938
  const togglePopover = t2;
2913
2939
  let t3;
2914
2940
  $[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setOpen(!1), $[7] = t3) : t3 = $[7];
@@ -2949,7 +2975,7 @@ function CanvasLinkedBanner() {
2949
2975
  let t3;
2950
2976
  return $[7] !== t0 || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Banner, { tone: "neutral", "data-test-id": "canvas-linked-banner", paddingY: 0, content: t0, action: t2 }), $[7] = t0, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
2951
2977
  }
2952
- function _temp$k(prev) {
2978
+ function _temp$l(prev) {
2953
2979
  return !prev;
2954
2980
  }
2955
2981
  const ChooseNewDocumentDestinationBanner = (t0) => {
@@ -3391,7 +3417,7 @@ const TitleContainer = styled(Stack)`
3391
3417
  selectedReleaseId
3392
3418
  } = usePerspective(), documentStore = useDocumentStore(), presence = useDocumentPresence(documentId), {
3393
3419
  title
3394
- } = useDocumentTitle(), [patchChannel] = useState(_temp$j), isLocked = editState?.transactionSyncLock?.enabled, {
3420
+ } = useDocumentTitle(), [patchChannel] = useState(_temp$k), isLocked = editState?.transactionSyncLock?.enabled, {
3395
3421
  t
3396
3422
  } = useTranslation(structureLocaleNamespace);
3397
3423
  let t0, t1;
@@ -3478,7 +3504,7 @@ function prepareRebaseEvent(event) {
3478
3504
  patches: fromMutationPatches("remote", remotePatches).concat(fromMutationPatches("local", localPatches))
3479
3505
  };
3480
3506
  }
3481
- function _temp$j() {
3507
+ function _temp$k() {
3482
3508
  return createPatchChannel();
3483
3509
  }
3484
3510
  function DocumentHeaderTabs() {
@@ -4162,7 +4188,7 @@ function ActionMenuListItem(props) {
4162
4188
  }, $[0] = index, $[1] = onAction, $[2] = onHandle, $[3] = t0) : t0 = $[3];
4163
4189
  const handleClick = t0;
4164
4190
  let t1, t2;
4165
- $[4] !== actionState.shortcut ? (t2 = actionState.shortcut ? String(actionState.shortcut).split("+").map(_temp$i) : void 0, $[4] = actionState.shortcut, $[5] = t2) : t2 = $[5], t1 = t2;
4191
+ $[4] !== actionState.shortcut ? (t2 = actionState.shortcut ? String(actionState.shortcut).split("+").map(_temp$j) : void 0, $[4] = actionState.shortcut, $[5] = t2) : t2 = $[5], t1 = t2;
4166
4192
  const hotkeys = t1, t3 = `action-${actionState.label.replace(" ", "")}`, t4 = disabled || !!actionState.disabled;
4167
4193
  let t5;
4168
4194
  $[6] !== actionState.disabled || $[7] !== actionState.title ? (t5 = actionState.disabled && {
@@ -4173,7 +4199,7 @@ function ActionMenuListItem(props) {
4173
4199
  let t6;
4174
4200
  return $[9] !== actionState.icon || $[10] !== actionState.label || $[11] !== actionState.tone || $[12] !== handleClick || $[13] !== hotkeys || $[14] !== t3 || $[15] !== t4 || $[16] !== t5 ? (t6 = /* @__PURE__ */ jsx(MenuItem$1, { "data-testid": t3, disabled: t4, hotkeys, icon: actionState.icon, onClick: handleClick, text: actionState.label, tone: actionState.tone, ...t5 }), $[9] = actionState.icon, $[10] = actionState.label, $[11] = actionState.tone, $[12] = handleClick, $[13] = hotkeys, $[14] = t3, $[15] = t4, $[16] = t5, $[17] = t6) : t6 = $[17], t6;
4175
4201
  }
4176
- function _temp$i(s) {
4202
+ function _temp$j(s) {
4177
4203
  return s.slice(0, 1).toUpperCase() + s.slice(1);
4178
4204
  }
4179
4205
  const DISABLED_REASON_TITLE_KEY$1 = {
@@ -4681,7 +4707,7 @@ const DocumentStatusBarActionsInner = memo(function(props) {
4681
4707
  $[6] !== firstActionState.shortcut ? (t32 = firstActionState.shortcut && /* @__PURE__ */ jsx(Hotkeys, { "data-testid": "document-status-bar-hotkeys", fontSize: 1, style: {
4682
4708
  marginTop: -4,
4683
4709
  marginBottom: -4
4684
- }, keys: String(firstActionState.shortcut).split("+").map(_temp$h) }), $[6] = firstActionState.shortcut, $[7] = t32) : t32 = $[7];
4710
+ }, keys: String(firstActionState.shortcut).split("+").map(_temp$i) }), $[6] = firstActionState.shortcut, $[7] = t32) : t32 = $[7];
4685
4711
  let t42;
4686
4712
  $[8] !== t22 || $[9] !== t32 ? (t42 = /* @__PURE__ */ jsxs(Flex, { style: t12, align: "center", gap: 3, children: [
4687
4713
  t22,
@@ -4772,7 +4798,7 @@ const DocumentStatusBarActionsInner = memo(function(props) {
4772
4798
  function isRestoreAction(action) {
4773
4799
  return action.action === HistoryRestoreAction.action;
4774
4800
  }
4775
- function _temp$h(s) {
4801
+ function _temp$i(s) {
4776
4802
  return s.slice(0, 1).toUpperCase() + s.slice(1).toLowerCase();
4777
4803
  }
4778
4804
  function _temp2$6(action) {
@@ -5117,7 +5143,7 @@ const BADGE_TONES = {
5117
5143
  if (states.length === 0)
5118
5144
  return null;
5119
5145
  let t1;
5120
- $[0] !== states ? (t1 = states.map(_temp$g), $[0] = states, $[1] = t1) : t1 = $[1];
5146
+ $[0] !== states ? (t1 = states.map(_temp$h), $[0] = states, $[1] = t1) : t1 = $[1];
5121
5147
  let t2;
5122
5148
  return $[2] !== t1 ? (t2 = /* @__PURE__ */ jsx(Inline, { space: 1, children: t1 }), $[2] = t1, $[3] = t2) : t2 = $[3], t2;
5123
5149
  }), DocumentBadgesDeferred = memo(function(props) {
@@ -5141,7 +5167,7 @@ function _temp2$5(t0) {
5141
5167
  } = t0;
5142
5168
  return /* @__PURE__ */ jsx(DocumentBadgesDeferred, { states });
5143
5169
  }
5144
- function _temp$g(badge, index) {
5170
+ function _temp$h(badge, index) {
5145
5171
  return /* @__PURE__ */ jsx(Tooltip, { content: badge.title, disabled: !badge.title, placement: "top", portal: !0, children: /* @__PURE__ */ jsx(Badge, { fontSize: 1, mode: "outline", paddingX: 2, paddingY: 1, radius: 4, tone: badge.color ? BADGE_TONES[badge.color] : void 0, style: {
5146
5172
  whiteSpace: "nowrap"
5147
5173
  }, children: badge.label }) }, `${badge.label}-${index}`);
@@ -5300,7 +5326,7 @@ const IconBox = styled(Flex)((props) => {
5300
5326
  let t2;
5301
5327
  $[2] !== t1 ? (t2 = /* @__PURE__ */ jsx(Box, { padding: 1, paddingBottom: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t1 }) }), $[2] = t1, $[3] = t2) : t2 = $[3];
5302
5328
  let t3;
5303
- $[4] !== collaborators ? (t3 = collaborators.map(_temp$f), $[4] = collaborators, $[5] = t3) : t3 = $[5];
5329
+ $[4] !== collaborators ? (t3 = collaborators.map(_temp$g), $[4] = collaborators, $[5] = t3) : t3 = $[5];
5304
5330
  let t4;
5305
5331
  return $[6] !== t2 || $[7] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Stack, { paddingBottom: 1, children: [
5306
5332
  t2,
@@ -5396,7 +5422,7 @@ function TimelineItem(t0) {
5396
5422
  optionsMenu
5397
5423
  ] }), $[52] = optionsMenu, $[53] = t22, $[54] = t23) : t23 = $[54], t23;
5398
5424
  }
5399
- function _temp$f(userId) {
5425
+ function _temp$g(userId) {
5400
5426
  return /* @__PURE__ */ jsx(UserLine, { userId }, userId);
5401
5427
  }
5402
5428
  const isNonPublishChunk = (chunk) => chunk.type !== "publish", isPublishChunk = (chunk) => chunk.type === "publish";
@@ -5858,7 +5884,7 @@ const STATUS_DICTIONARY = {
5858
5884
  }, TimelineStatus = () => {
5859
5885
  const $ = c(8), {
5860
5886
  timelineStore
5861
- } = useDocumentPane(), chunks = useTimelineSelector(timelineStore, _temp$e), loading = useTimelineSelector(timelineStore, _temp2$4), event = chunks?.[0];
5887
+ } = useDocumentPane(), chunks = useTimelineSelector(timelineStore, _temp$f), loading = useTimelineSelector(timelineStore, _temp2$4), event = chunks?.[0];
5862
5888
  if (!event && loading) {
5863
5889
  let t02;
5864
5890
  return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t02 = /* @__PURE__ */ jsx(ButtonSkeleton, {}), $[0] = t02) : t02 = $[0], t02;
@@ -5914,7 +5940,7 @@ function DocumentStatusLine() {
5914
5940
  opacity: 0
5915
5941
  }, children: /* @__PURE__ */ jsx(DocumentStatusPulse, { status: status || void 0 }) }) : /* @__PURE__ */ jsx(Fragment, { children: eventsEnabled ? /* @__PURE__ */ jsx(EventsStatus, {}) : /* @__PURE__ */ jsx(TimelineStatus, {}) }) }), $[15] = eventsEnabled, $[16] = status, $[17] = t6) : t6 = $[17], t6;
5916
5942
  }
5917
- function _temp$e(state2) {
5943
+ function _temp$f(state2) {
5918
5944
  return state2.chunks;
5919
5945
  }
5920
5946
  function _temp2$4(state_0) {
@@ -6111,7 +6137,7 @@ const KeyboardShortcutResponder = memo(function(props) {
6111
6137
  let t2, t3;
6112
6138
  $[6] !== editState || $[7] !== isInitialValueLoading || $[8] !== revisionId ? (t3 = editState && {
6113
6139
  ...editState,
6114
- onComplete: _temp$d,
6140
+ onComplete: _temp$e,
6115
6141
  revision: revisionId || void 0,
6116
6142
  initialValueResolved: !isInitialValueLoading
6117
6143
  }, $[6] = editState, $[7] = isInitialValueLoading, $[8] = revisionId, $[9] = t3) : t3 = $[9], t2 = t3;
@@ -6130,7 +6156,7 @@ const KeyboardShortcutResponder = memo(function(props) {
6130
6156
  return $[16] !== actionProps || $[17] !== actions || $[18] !== renderDocumentActionShortcuts ? (t5 = /* @__PURE__ */ jsx(RenderActionCollectionState, { actionProps, actions, children: renderDocumentActionShortcuts }), $[16] = actionProps, $[17] = actions, $[18] = renderDocumentActionShortcuts, $[19] = t5) : t5 = $[19], t5;
6131
6157
  });
6132
6158
  DocumentActionShortcuts.displayName = "Memo(DocumentActionShortcuts)";
6133
- function _temp$d() {
6159
+ function _temp$e() {
6134
6160
  }
6135
6161
  function getInspectorItems({
6136
6162
  currentInspector,
@@ -6368,6 +6394,31 @@ function useDocumentLayoutComponent() {
6368
6394
  defaultComponent: DocumentLayout
6369
6395
  }, $[0] = t0) : t0 = $[0], useMiddlewareComponents(t0);
6370
6396
  }
6397
+ const useDocumentLastRev = (documentId, documentType) => {
6398
+ const $ = c(11), historyStore = useHistoryStore(), [lastRevisionDocument, setLastRevisionDocument] = useState(null), [loading, setLoading] = useState(!1);
6399
+ let t0;
6400
+ $[0] !== documentId || $[1] !== documentType ? (t0 = {
6401
+ documentId,
6402
+ documentType
6403
+ }, $[0] = documentId, $[1] = documentType, $[2] = t0) : t0 = $[2];
6404
+ const timelineStore = useTimelineStore(t0), lastNonDeletedRevId = useTimelineSelector(timelineStore, _temp$d);
6405
+ let t1, t2;
6406
+ $[3] !== documentId || $[4] !== historyStore || $[5] !== lastNonDeletedRevId ? (t1 = () => {
6407
+ lastNonDeletedRevId && documentId ? (setLoading(!0), historyStore.getDocumentAtRevision(documentId, lastNonDeletedRevId).then((document2) => {
6408
+ setLastRevisionDocument(document2 || null), setLoading(!1);
6409
+ }).catch(() => {
6410
+ setLastRevisionDocument(null), setLoading(!1);
6411
+ })) : (setLastRevisionDocument(null), setLoading(!1));
6412
+ }, t2 = [documentId, lastNonDeletedRevId, historyStore], $[3] = documentId, $[4] = historyStore, $[5] = lastNonDeletedRevId, $[6] = t1, $[7] = t2) : (t1 = $[6], t2 = $[7]), useEffect(t1, t2);
6413
+ let t3;
6414
+ return $[8] !== lastRevisionDocument || $[9] !== loading ? (t3 = {
6415
+ lastRevisionDocument,
6416
+ loading
6417
+ }, $[8] = lastRevisionDocument, $[9] = loading, $[10] = t3) : t3 = $[10], t3;
6418
+ };
6419
+ function _temp$d(state2) {
6420
+ return state2.lastNonDeletedRevId;
6421
+ }
6371
6422
  const DocumentURLCopied = defineEvent({
6372
6423
  name: "DocumentURLCopied",
6373
6424
  version: 1,
@@ -6618,7 +6669,9 @@ const DocumentPaneProvider = memo((props) => {
6618
6669
  documentType,
6619
6670
  params,
6620
6671
  setParams: setPaneParams
6621
- }), [isDeleting, setIsDeleting] = useState(!1), getIsDeleted = useCallback((editState) => timelineReady ? !editState?.draft && !editState?.published && !editState?.version && !isPristine : !1, [timelineReady, isPristine]), getComparisonValue = useCallback((editState_0) => changesOpen ? sinceDocument || editState_0?.published : editState_0?.published || null, [changesOpen, sinceDocument]), schemaType = schema.get(documentType), getIsReadOnly = useCallback((editState_1) => {
6672
+ }), [isDeleting, setIsDeleting] = useState(!1), {
6673
+ lastRevisionDocument
6674
+ } = useDocumentLastRev(documentId, documentType), getIsDeleted = useCallback((editState) => timelineReady ? !editState?.draft && !editState?.published && !editState?.version && !isPristine : !1, [timelineReady, isPristine]), getComparisonValue = useCallback((editState_0) => changesOpen ? sinceDocument || editState_0?.published : editState_0?.published || null, [changesOpen, sinceDocument]), schemaType = schema.get(documentType), getIsReadOnly = useCallback((editState_1) => {
6622
6675
  const isDeleted = getIsDeleted(editState_1);
6623
6676
  return !!params.rev || isDeleting || isDeleted || !isPerspectiveWriteable({
6624
6677
  selectedPerspective: perspective.selectedPerspective,
@@ -6628,7 +6681,7 @@ const DocumentPaneProvider = memo((props) => {
6628
6681
  }, [getIsDeleted, isDeleting, isDraftModelEnabled, params.rev, perspective.selectedPerspective, schemaType]), getDisplayed = useCallback((value) => onOlderRevision ? revisionDocument || {
6629
6682
  _id: value._id,
6630
6683
  _type: value._type
6631
- } : value, [onOlderRevision, revisionDocument]), {
6684
+ } : !value._createdAt && !value._updatedAt && lastNonDeletedRevId && lastRevisionDocument ? lastRevisionDocument : value, [onOlderRevision, revisionDocument, lastNonDeletedRevId, lastRevisionDocument]), {
6632
6685
  editState: editState_2,
6633
6686
  connectionState,
6634
6687
  focusPath,
@@ -6743,7 +6796,7 @@ const DocumentPaneProvider = memo((props) => {
6743
6796
  onChange
6744
6797
  });
6745
6798
  }, [documentId, documentType, schemaType, onChange, setDocumentMeta]);
6746
- const compareValue = useMemo(() => getComparisonValue(editState_2), [editState_2, getComparisonValue]), isDeleted_0 = useMemo(() => getIsDeleted(editState_2), [editState_2, getIsDeleted]), revisionNotFound = onOlderRevision && !revisionDocument, currentDisplayed = useMemo(() => editState_2.version && isGoingToUnpublish(editState_2.version) ? editState_2.published : displayed, [editState_2.version, editState_2.published, displayed]), documentPane = useMemo(() => ({
6799
+ const compareValue = useMemo(() => getComparisonValue(editState_2), [editState_2, getComparisonValue]), isDeleted_1 = useMemo(() => getIsDeleted(editState_2), [editState_2, getIsDeleted]), revisionNotFound = onOlderRevision && !revisionDocument, currentDisplayed = useMemo(() => editState_2.version && isGoingToUnpublish(editState_2.version) ? editState_2.published : displayed, [editState_2.version, editState_2.published, displayed]), documentPane = useMemo(() => ({
6747
6800
  actions,
6748
6801
  activeViewId,
6749
6802
  badges,
@@ -6791,7 +6844,7 @@ const DocumentPaneProvider = memo((props) => {
6791
6844
  setTimelineRange,
6792
6845
  setIsDeleting,
6793
6846
  isDeleting,
6794
- isDeleted: isDeleted_0,
6847
+ isDeleted: isDeleted_1,
6795
6848
  timelineError,
6796
6849
  timelineStore,
6797
6850
  title,
@@ -6802,8 +6855,9 @@ const DocumentPaneProvider = memo((props) => {
6802
6855
  unstable_languageFilter: languageFilter,
6803
6856
  revisionId,
6804
6857
  revisionNotFound,
6805
- lastNonDeletedRevId
6806
- }), [actions, activeViewId, badges, changesOpen, closeInspector, collapsedFieldSets, collapsedPaths, compareValue, connectionState, currentDisplayed, documentId, documentIdRaw, documentType, editState_2, fieldActions, focusPath, currentInspector, inspectors2, onBlur, onChange, onFocus, onPathOpen, handleHistoryClose, handleHistoryOpen, handleLegacyInspectClose, handleMenuAction, handlePaneClose, handlePaneSplit, onSetActiveFieldGroup, onSetCollapsedPath, onSetCollapsedFieldSet, openInspector, openPath, index, inspectOpen, validation, menuItemGroups, paneKey, previewUrl, ready, schemaType, isPermissionsLoading, isInitialValueLoading, permissions, setTimelineRange, isDeleting, isDeleted_0, timelineError, timelineStore, title, value_0, selectedReleaseId, views, formState, languageFilter, revisionId, revisionNotFound, lastNonDeletedRevId]);
6858
+ lastNonDeletedRevId,
6859
+ lastRevisionDocument
6860
+ }), [actions, activeViewId, badges, changesOpen, closeInspector, collapsedFieldSets, collapsedPaths, compareValue, connectionState, currentDisplayed, documentId, documentIdRaw, documentType, editState_2, fieldActions, focusPath, currentInspector, inspectors2, onBlur, onChange, onFocus, onPathOpen, handleHistoryClose, handleHistoryOpen, handleLegacyInspectClose, handleMenuAction, handlePaneClose, handlePaneSplit, onSetActiveFieldGroup, onSetCollapsedPath, onSetCollapsedFieldSet, openInspector, openPath, index, inspectOpen, validation, menuItemGroups, paneKey, previewUrl, ready, schemaType, isPermissionsLoading, isInitialValueLoading, permissions, setTimelineRange, isDeleting, isDeleted_1, timelineError, timelineStore, title, value_0, selectedReleaseId, views, formState, languageFilter, revisionId, revisionNotFound, lastNonDeletedRevId, lastRevisionDocument]);
6807
6861
  return useEffect(() => {
6808
6862
  if (ready && params.path) {
6809
6863
  const {
@@ -11099,6 +11153,7 @@ export {
11099
11153
  _DEBUG,
11100
11154
  setActivePanes,
11101
11155
  structureTool,
11156
+ useDocumentLastRev,
11102
11157
  useDocumentPane,
11103
11158
  useDocumentTitle,
11104
11159
  usePane,