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.
@@ -60,7 +60,7 @@ function useDiffViewRouter() {
60
60
  $[3] !== navigate || $[4] !== routerState ? (t1 = () => {
61
61
  navigate({
62
62
  ...routerState,
63
- _searchParams: (routerState._searchParams ?? []).filter(_temp$r)
63
+ _searchParams: (routerState._searchParams ?? []).filter(_temp$s)
64
64
  });
65
65
  }, $[3] = navigate, $[4] = routerState, $[5] = t1) : t1 = $[5];
66
66
  const exitDiffView = t1;
@@ -70,7 +70,7 @@ function useDiffViewRouter() {
70
70
  exitDiffView
71
71
  }, $[6] = exitDiffView, $[7] = navigateDiffView, $[8] = t2) : t2 = $[8], t2;
72
72
  }
73
- function _temp$r(t0) {
73
+ function _temp$s(t0) {
74
74
  const [key] = t0;
75
75
  return ![DIFF_VIEW_SEARCH_PARAMETER, DIFF_VIEW_PREVIOUS_DOCUMENT_SEARCH_PARAMETER, DIFF_VIEW_NEXT_DOCUMENT_SEARCH_PARAMETER].includes(key);
76
76
  }
@@ -128,14 +128,14 @@ function useScrollMirror(elements) {
128
128
  const $ = reactCompilerRuntime.c(3);
129
129
  let t0, t1;
130
130
  $[0] !== elements ? (t0 = () => {
131
- const existentElements = elements.filter(_temp$q);
131
+ const existentElements = elements.filter(_temp$r);
132
132
  if (existentElements.length === 0)
133
133
  return;
134
134
  const scrollMirror = new ScrollMirror__default.default(existentElements);
135
135
  return () => scrollMirror.destroy();
136
136
  }, t1 = [elements], $[0] = elements, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), React.useEffect(t0, t1);
137
137
  }
138
- function _temp$q(element) {
138
+ function _temp$r(element) {
139
139
  return element !== null;
140
140
  }
141
141
  const VersionModeHeaderLayout = styledComponents.styled.header`
@@ -327,7 +327,7 @@ function usePathSyncChannel(t0) {
327
327
  source
328
328
  } = t5;
329
329
  return source !== id;
330
- }, $[6] = id, $[7] = t42) : t42 = $[7], t3 = syncChannel.pipe(rxjs.distinctUntilChanged(_temp$p), rxjs.filter(t42), rxjs.map(_temp2$9)), $[3] = id, $[4] = syncChannel, $[5] = t3;
330
+ }, $[6] = id, $[7] = t42) : t42 = $[7], t3 = syncChannel.pipe(rxjs.distinctUntilChanged(_temp$q), rxjs.filter(t42), rxjs.map(_temp2$9)), $[3] = id, $[4] = syncChannel, $[5] = t3;
331
331
  } else
332
332
  t3 = $[5];
333
333
  t2 = t3;
@@ -341,7 +341,7 @@ function usePathSyncChannel(t0) {
341
341
  function _temp2$9(state_0) {
342
342
  return state_0.path;
343
343
  }
344
- function _temp$p(previous, next) {
344
+ function _temp$q(previous, next) {
345
345
  return deepEquals__default.default(previous.path, next.path);
346
346
  }
347
347
  const Scroller$5 = styledComponents.styled.div`
@@ -422,7 +422,7 @@ const Scroller$5 = styledComponents.styled.div`
422
422
  $[0] !== compareDocument ? (t1 = {
423
423
  compareDocument
424
424
  }, $[0] = compareDocument, $[1] = t1) : t1 = $[1];
425
- const compareValue = useCompareValue(t1), [patchChannel] = React.useState(_temp$o);
425
+ const compareValue = useCompareValue(t1), [patchChannel] = React.useState(_temp$p);
426
426
  let t2;
427
427
  $[2] !== documentId ? (t2 = sanity.getPublishedId(documentId), $[2] = documentId, $[3] = t2) : t2 = $[3];
428
428
  let t3;
@@ -515,7 +515,7 @@ function useCompareValue(t0) {
515
515
  }
516
516
  return t4;
517
517
  }
518
- function _temp$o() {
518
+ function _temp$p() {
519
519
  return sanity.createPatchChannel();
520
520
  }
521
521
  const Link = styledComponents.styled.a`
@@ -1477,7 +1477,7 @@ function PaneLayout(props) {
1477
1477
  onExpand,
1478
1478
  ...restProps
1479
1479
  } = props, $[0] = props, $[1] = children, $[2] = minWidth, $[3] = onCollapse, $[4] = onExpand, $[5] = restProps) : (children = $[1], minWidth = $[2], onCollapse = $[3], onExpand = $[4], restProps = $[5]);
1480
- const [controller] = React.useState(_temp$n), [rootElement, setRootElement] = React.useState(null), width = ui.useElementRect(rootElement)?.width || 0, collapsed = width === void 0 || !minWidth ? void 0 : width < minWidth;
1480
+ const [controller] = React.useState(_temp$o), [rootElement, setRootElement] = React.useState(null), width = ui.useElementRect(rootElement)?.width || 0, collapsed = width === void 0 || !minWidth ? void 0 : width < minWidth;
1481
1481
  let t0;
1482
1482
  $[6] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
1483
1483
  expandedElement: null,
@@ -1512,7 +1512,7 @@ function PaneLayout(props) {
1512
1512
  let t15;
1513
1513
  return $[38] !== paneLayout || $[39] !== t14 ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(_singletons.PaneLayoutContext.Provider, { value: paneLayout, children: t14 }), $[38] = paneLayout, $[39] = t14, $[40] = t15) : t15 = $[40], t15;
1514
1514
  }
1515
- function _temp$n() {
1515
+ function _temp$o() {
1516
1516
  return createPaneLayoutController();
1517
1517
  }
1518
1518
  function ErrorPane(props) {
@@ -1840,59 +1840,85 @@ function defineInspectorMenuItemComponent({
1840
1840
  });
1841
1841
  }
1842
1842
  function useDocumentTitle() {
1843
- const $ = reactCompilerRuntime.c(17), {
1843
+ const $ = reactCompilerRuntime.c(22), {
1844
1844
  connectionState,
1845
1845
  schemaType,
1846
- editState
1846
+ editState,
1847
+ isDeleted,
1848
+ lastRevisionDocument
1847
1849
  } = useDocumentPane(), {
1848
1850
  t
1849
- } = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace), documentValue = editState?.version || editState?.draft || editState?.published, subscribed = !!documentValue;
1851
+ } = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace);
1850
1852
  let t0;
1851
- $[0] !== documentValue || $[1] !== schemaType || $[2] !== subscribed ? (t0 = {
1852
- enabled: subscribed,
1853
+ t0 = isDeleted ? lastRevisionDocument : editState?.version || editState?.draft || editState?.published;
1854
+ const documentValue = t0, subscribed = !!documentValue;
1855
+ let t1;
1856
+ bb0: {
1857
+ if (isDeleted && lastRevisionDocument && schemaType)
1858
+ try {
1859
+ let t32;
1860
+ $[0] !== lastRevisionDocument || $[1] !== schemaType ? (t32 = sanity.prepareForPreview(lastRevisionDocument, schemaType), $[0] = lastRevisionDocument, $[1] = schemaType, $[2] = t32) : t32 = $[2], t1 = t32;
1861
+ break bb0;
1862
+ } catch (t22) {
1863
+ console.warn("Failed to prepare preview for deleted document:", t22), t1 = null;
1864
+ break bb0;
1865
+ }
1866
+ t1 = null;
1867
+ }
1868
+ const deletedDocumentPreview = t1, t2 = subscribed && !isDeleted;
1869
+ let t3;
1870
+ $[3] !== documentValue || $[4] !== schemaType || $[5] !== t2 ? (t3 = {
1871
+ enabled: t2,
1853
1872
  schemaType,
1854
1873
  value: documentValue
1855
- }, $[0] = documentValue, $[1] = schemaType, $[2] = subscribed, $[3] = t0) : t0 = $[3];
1874
+ }, $[3] = documentValue, $[4] = schemaType, $[5] = t2, $[6] = t3) : t3 = $[6];
1856
1875
  const {
1857
- error,
1876
+ error: error_0,
1858
1877
  value
1859
- } = sanity.unstable_useValuePreview(t0);
1878
+ } = sanity.unstable_useValuePreview(t3);
1860
1879
  if (connectionState === "connecting" && !subscribed) {
1861
- let t12;
1862
- return $[4] === Symbol.for("react.memo_cache_sentinel") ? (t12 = {
1880
+ let t42;
1881
+ return $[7] === Symbol.for("react.memo_cache_sentinel") ? (t42 = {
1863
1882
  error: void 0,
1864
1883
  title: void 0
1865
- }, $[4] = t12) : t12 = $[4], t12;
1884
+ }, $[7] = t42) : t42 = $[7], t42;
1866
1885
  }
1867
- if (!value) {
1868
- const t12 = schemaType?.title || schemaType?.name;
1869
- let t22;
1870
- $[5] !== t || $[6] !== t12 ? (t22 = t("panes.document-header-title.new.text", {
1871
- schemaType: t12
1872
- }), $[5] = t, $[6] = t12, $[7] = t22) : t22 = $[7];
1873
- let t3;
1874
- return $[8] !== t22 ? (t3 = {
1886
+ if (isDeleted && deletedDocumentPreview) {
1887
+ let t42;
1888
+ return $[8] !== deletedDocumentPreview.title ? (t42 = {
1875
1889
  error: void 0,
1876
- title: t22
1877
- }, $[8] = t22, $[9] = t3) : t3 = $[9], t3;
1890
+ title: deletedDocumentPreview.title
1891
+ }, $[8] = deletedDocumentPreview.title, $[9] = t42) : t42 = $[9], t42;
1878
1892
  }
1879
- if (error) {
1880
- let t12;
1881
- $[10] !== error.message || $[11] !== t ? (t12 = t("panes.document-list-pane.error.text", {
1882
- error: error.message
1883
- }), $[10] = error.message, $[11] = t, $[12] = t12) : t12 = $[12];
1884
- let t22;
1885
- return $[13] !== t12 ? (t22 = {
1886
- error: t12,
1893
+ if (!value && !isDeleted) {
1894
+ const t42 = schemaType?.title || schemaType?.name;
1895
+ let t52;
1896
+ $[10] !== t || $[11] !== t42 ? (t52 = t("panes.document-header-title.new.text", {
1897
+ schemaType: t42
1898
+ }), $[10] = t, $[11] = t42, $[12] = t52) : t52 = $[12];
1899
+ let t6;
1900
+ return $[13] !== t52 ? (t6 = {
1901
+ error: void 0,
1902
+ title: t52
1903
+ }, $[13] = t52, $[14] = t6) : t6 = $[14], t6;
1904
+ }
1905
+ if (error_0) {
1906
+ let t42;
1907
+ $[15] !== error_0.message || $[16] !== t ? (t42 = t("panes.document-list-pane.error.text", {
1908
+ error: error_0.message
1909
+ }), $[15] = error_0.message, $[16] = t, $[17] = t42) : t42 = $[17];
1910
+ let t52;
1911
+ return $[18] !== t42 ? (t52 = {
1912
+ error: t42,
1887
1913
  title: void 0
1888
- }, $[13] = t12, $[14] = t22) : t22 = $[14], t22;
1914
+ }, $[18] = t42, $[19] = t52) : t52 = $[19], t52;
1889
1915
  }
1890
- const t1 = value?.title;
1891
- let t2;
1892
- return $[15] !== t1 ? (t2 = {
1916
+ const t4 = value?.title;
1917
+ let t5;
1918
+ return $[20] !== t4 ? (t5 = {
1893
1919
  error: void 0,
1894
- title: t1
1895
- }, $[15] = t1, $[16] = t2) : t2 = $[16], t2;
1920
+ title: t4
1921
+ }, $[20] = t4, $[21] = t5) : t5 = $[21], t5;
1896
1922
  }
1897
1923
  const IGNORE_OPS = ["patch", "commit"], DocumentOperationResults = React.memo(function() {
1898
1924
  const $ = reactCompilerRuntime.c(12), {
@@ -2484,7 +2510,7 @@ function RequestPermissionDialog(t0) {
2484
2510
  let t32;
2485
2511
  if ($[2] !== client2.observable || $[3] !== projectId) {
2486
2512
  let t42;
2487
- $[5] === Symbol.for("react.memo_cache_sentinel") ? (t42 = (roles) => roles.filter(_temp$m).find(_temp2$8) ? "editor" : adminRole, $[5] = t42) : t42 = $[5];
2513
+ $[5] === Symbol.for("react.memo_cache_sentinel") ? (t42 = (roles) => roles.filter(_temp$n).find(_temp2$8) ? "editor" : adminRole, $[5] = t42) : t42 = $[5];
2488
2514
  let t52;
2489
2515
  $[6] === Symbol.for("react.memo_cache_sentinel") ? (t52 = () => rxjs.of(adminRole), $[6] = t52) : t52 = $[6], t32 = client2.observable.request({
2490
2516
  url: `/projects/${projectId}/roles`
@@ -2575,7 +2601,7 @@ function RequestPermissionDialog(t0) {
2575
2601
  function _temp2$8(role_0) {
2576
2602
  return role_0.name === "editor";
2577
2603
  }
2578
- function _temp$m(role) {
2604
+ function _temp$n(role) {
2579
2605
  return role?.appliesToUsers;
2580
2606
  }
2581
2607
  const LOADING_STATE = {
@@ -2669,7 +2695,7 @@ function InsufficientPermissionBanner(t0) {
2669
2695
  t
2670
2696
  } = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace), telemetry2 = react.useTelemetry();
2671
2697
  let roleTitles, t4;
2672
- $[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]);
2698
+ $[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]);
2673
2699
  const roles = t4;
2674
2700
  let t5;
2675
2701
  $[7] !== roles ? (t5 = {
@@ -2707,7 +2733,7 @@ function InsufficientPermissionBanner(t0) {
2707
2733
  function _temp2$7(part) {
2708
2734
  return part.type === "element" ? /* @__PURE__ */ jsxRuntime.jsx("code", { children: part.value }, part.value) : part.value;
2709
2735
  }
2710
- function _temp$l(role) {
2736
+ function _temp$m(role) {
2711
2737
  return role.title;
2712
2738
  }
2713
2739
  const ReferenceChangedBanner = React.memo(() => {
@@ -2886,7 +2912,7 @@ const Image = styledComponents.styled.img`
2886
2912
  }
2887
2913
  const variantText = t1;
2888
2914
  let t2;
2889
- $[6] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(_temp$k), $[6] = t2) : t2 = $[6];
2915
+ $[6] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(_temp$l), $[6] = t2) : t2 = $[6];
2890
2916
  const togglePopover = t2;
2891
2917
  let t3;
2892
2918
  $[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setOpen(!1), $[7] = t3) : t3 = $[7];
@@ -2927,7 +2953,7 @@ function CanvasLinkedBanner() {
2927
2953
  let t3;
2928
2954
  return $[7] !== t0 || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.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;
2929
2955
  }
2930
- function _temp$k(prev) {
2956
+ function _temp$l(prev) {
2931
2957
  return !prev;
2932
2958
  }
2933
2959
  const ChooseNewDocumentDestinationBanner = (t0) => {
@@ -3369,7 +3395,7 @@ const TitleContainer = styledComponents.styled(ui.Stack)`
3369
3395
  selectedReleaseId
3370
3396
  } = sanity.usePerspective(), documentStore = sanity.useDocumentStore(), presence = sanity.useDocumentPresence(documentId), {
3371
3397
  title
3372
- } = useDocumentTitle(), [patchChannel] = React.useState(_temp$j), isLocked = editState?.transactionSyncLock?.enabled, {
3398
+ } = useDocumentTitle(), [patchChannel] = React.useState(_temp$k), isLocked = editState?.transactionSyncLock?.enabled, {
3373
3399
  t
3374
3400
  } = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace);
3375
3401
  let t0, t1;
@@ -3456,7 +3482,7 @@ function prepareRebaseEvent(event) {
3456
3482
  patches: sanity.fromMutationPatches("remote", remotePatches).concat(sanity.fromMutationPatches("local", localPatches))
3457
3483
  };
3458
3484
  }
3459
- function _temp$j() {
3485
+ function _temp$k() {
3460
3486
  return sanity.createPatchChannel();
3461
3487
  }
3462
3488
  function DocumentHeaderTabs() {
@@ -4140,7 +4166,7 @@ function ActionMenuListItem(props) {
4140
4166
  }, $[0] = index, $[1] = onAction, $[2] = onHandle, $[3] = t0) : t0 = $[3];
4141
4167
  const handleClick = t0;
4142
4168
  let t1, t2;
4143
- $[4] !== actionState.shortcut ? (t2 = actionState.shortcut ? String(actionState.shortcut).split("+").map(_temp$i) : void 0, $[4] = actionState.shortcut, $[5] = t2) : t2 = $[5], t1 = t2;
4169
+ $[4] !== actionState.shortcut ? (t2 = actionState.shortcut ? String(actionState.shortcut).split("+").map(_temp$j) : void 0, $[4] = actionState.shortcut, $[5] = t2) : t2 = $[5], t1 = t2;
4144
4170
  const hotkeys = t1, t3 = `action-${actionState.label.replace(" ", "")}`, t4 = disabled || !!actionState.disabled;
4145
4171
  let t5;
4146
4172
  $[6] !== actionState.disabled || $[7] !== actionState.title ? (t5 = actionState.disabled && {
@@ -4151,7 +4177,7 @@ function ActionMenuListItem(props) {
4151
4177
  let t6;
4152
4178
  return $[9] !== actionState.icon || $[10] !== actionState.label || $[11] !== actionState.tone || $[12] !== handleClick || $[13] !== hotkeys || $[14] !== t3 || $[15] !== t4 || $[16] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.MenuItem, { "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;
4153
4179
  }
4154
- function _temp$i(s) {
4180
+ function _temp$j(s) {
4155
4181
  return s.slice(0, 1).toUpperCase() + s.slice(1);
4156
4182
  }
4157
4183
  const DISABLED_REASON_TITLE_KEY$1 = {
@@ -4659,7 +4685,7 @@ const DocumentStatusBarActionsInner = React.memo(function(props) {
4659
4685
  $[6] !== firstActionState.shortcut ? (t32 = firstActionState.shortcut && /* @__PURE__ */ jsxRuntime.jsx(sanity.Hotkeys, { "data-testid": "document-status-bar-hotkeys", fontSize: 1, style: {
4660
4686
  marginTop: -4,
4661
4687
  marginBottom: -4
4662
- }, keys: String(firstActionState.shortcut).split("+").map(_temp$h) }), $[6] = firstActionState.shortcut, $[7] = t32) : t32 = $[7];
4688
+ }, keys: String(firstActionState.shortcut).split("+").map(_temp$i) }), $[6] = firstActionState.shortcut, $[7] = t32) : t32 = $[7];
4663
4689
  let t42;
4664
4690
  $[8] !== t22 || $[9] !== t32 ? (t42 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { style: t12, align: "center", gap: 3, children: [
4665
4691
  t22,
@@ -4750,7 +4776,7 @@ const DocumentStatusBarActionsInner = React.memo(function(props) {
4750
4776
  function isRestoreAction(action) {
4751
4777
  return action.action === HistoryRestoreAction.action;
4752
4778
  }
4753
- function _temp$h(s) {
4779
+ function _temp$i(s) {
4754
4780
  return s.slice(0, 1).toUpperCase() + s.slice(1).toLowerCase();
4755
4781
  }
4756
4782
  function _temp2$6(action) {
@@ -5095,7 +5121,7 @@ const BADGE_TONES = {
5095
5121
  if (states.length === 0)
5096
5122
  return null;
5097
5123
  let t1;
5098
- $[0] !== states ? (t1 = states.map(_temp$g), $[0] = states, $[1] = t1) : t1 = $[1];
5124
+ $[0] !== states ? (t1 = states.map(_temp$h), $[0] = states, $[1] = t1) : t1 = $[1];
5099
5125
  let t2;
5100
5126
  return $[2] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(ui.Inline, { space: 1, children: t1 }), $[2] = t1, $[3] = t2) : t2 = $[3], t2;
5101
5127
  }), DocumentBadgesDeferred = React.memo(function(props) {
@@ -5119,7 +5145,7 @@ function _temp2$5(t0) {
5119
5145
  } = t0;
5120
5146
  return /* @__PURE__ */ jsxRuntime.jsx(DocumentBadgesDeferred, { states });
5121
5147
  }
5122
- function _temp$g(badge, index) {
5148
+ function _temp$h(badge, index) {
5123
5149
  return /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Tooltip, { content: badge.title, disabled: !badge.title, placement: "top", portal: !0, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { fontSize: 1, mode: "outline", paddingX: 2, paddingY: 1, radius: 4, tone: badge.color ? BADGE_TONES[badge.color] : void 0, style: {
5124
5150
  whiteSpace: "nowrap"
5125
5151
  }, children: badge.label }) }, `${badge.label}-${index}`);
@@ -5278,7 +5304,7 @@ const IconBox = styledComponents.styled(ui.Flex)((props) => {
5278
5304
  let t2;
5279
5305
  $[2] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "medium", children: t1 }) }), $[2] = t1, $[3] = t2) : t2 = $[3];
5280
5306
  let t3;
5281
- $[4] !== collaborators ? (t3 = collaborators.map(_temp$f), $[4] = collaborators, $[5] = t3) : t3 = $[5];
5307
+ $[4] !== collaborators ? (t3 = collaborators.map(_temp$g), $[4] = collaborators, $[5] = t3) : t3 = $[5];
5282
5308
  let t4;
5283
5309
  return $[6] !== t2 || $[7] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { paddingBottom: 1, children: [
5284
5310
  t2,
@@ -5374,7 +5400,7 @@ function TimelineItem(t0) {
5374
5400
  optionsMenu
5375
5401
  ] }), $[52] = optionsMenu, $[53] = t22, $[54] = t23) : t23 = $[54], t23;
5376
5402
  }
5377
- function _temp$f(userId) {
5403
+ function _temp$g(userId) {
5378
5404
  return /* @__PURE__ */ jsxRuntime.jsx(UserLine, { userId }, userId);
5379
5405
  }
5380
5406
  const isNonPublishChunk = (chunk) => chunk.type !== "publish", isPublishChunk = (chunk) => chunk.type === "publish";
@@ -5836,7 +5862,7 @@ const STATUS_DICTIONARY = {
5836
5862
  }, TimelineStatus = () => {
5837
5863
  const $ = reactCompilerRuntime.c(8), {
5838
5864
  timelineStore
5839
- } = useDocumentPane(), chunks = sanity.useTimelineSelector(timelineStore, _temp$e), loading = sanity.useTimelineSelector(timelineStore, _temp2$4), event = chunks?.[0];
5865
+ } = useDocumentPane(), chunks = sanity.useTimelineSelector(timelineStore, _temp$f), loading = sanity.useTimelineSelector(timelineStore, _temp2$4), event = chunks?.[0];
5840
5866
  if (!event && loading) {
5841
5867
  let t02;
5842
5868
  return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t02 = /* @__PURE__ */ jsxRuntime.jsx(ButtonSkeleton, {}), $[0] = t02) : t02 = $[0], t02;
@@ -5892,7 +5918,7 @@ function DocumentStatusLine() {
5892
5918
  opacity: 0
5893
5919
  }, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatusPulse, { status: status || void 0 }) }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: eventsEnabled ? /* @__PURE__ */ jsxRuntime.jsx(EventsStatus, {}) : /* @__PURE__ */ jsxRuntime.jsx(TimelineStatus, {}) }) }), $[15] = eventsEnabled, $[16] = status, $[17] = t6) : t6 = $[17], t6;
5894
5920
  }
5895
- function _temp$e(state2) {
5921
+ function _temp$f(state2) {
5896
5922
  return state2.chunks;
5897
5923
  }
5898
5924
  function _temp2$4(state_0) {
@@ -6089,7 +6115,7 @@ const KeyboardShortcutResponder = React.memo(function(props) {
6089
6115
  let t2, t3;
6090
6116
  $[6] !== editState || $[7] !== isInitialValueLoading || $[8] !== revisionId ? (t3 = editState && {
6091
6117
  ...editState,
6092
- onComplete: _temp$d,
6118
+ onComplete: _temp$e,
6093
6119
  revision: revisionId || void 0,
6094
6120
  initialValueResolved: !isInitialValueLoading
6095
6121
  }, $[6] = editState, $[7] = isInitialValueLoading, $[8] = revisionId, $[9] = t3) : t3 = $[9], t2 = t3;
@@ -6108,7 +6134,7 @@ const KeyboardShortcutResponder = React.memo(function(props) {
6108
6134
  return $[16] !== actionProps || $[17] !== actions || $[18] !== renderDocumentActionShortcuts ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(RenderActionCollectionState, { actionProps, actions, children: renderDocumentActionShortcuts }), $[16] = actionProps, $[17] = actions, $[18] = renderDocumentActionShortcuts, $[19] = t5) : t5 = $[19], t5;
6109
6135
  });
6110
6136
  DocumentActionShortcuts.displayName = "Memo(DocumentActionShortcuts)";
6111
- function _temp$d() {
6137
+ function _temp$e() {
6112
6138
  }
6113
6139
  function getInspectorItems({
6114
6140
  currentInspector,
@@ -6346,6 +6372,31 @@ function useDocumentLayoutComponent() {
6346
6372
  defaultComponent: DocumentLayout
6347
6373
  }, $[0] = t0) : t0 = $[0], sanity.useMiddlewareComponents(t0);
6348
6374
  }
6375
+ const useDocumentLastRev = (documentId, documentType) => {
6376
+ const $ = reactCompilerRuntime.c(11), historyStore = sanity.useHistoryStore(), [lastRevisionDocument, setLastRevisionDocument] = React.useState(null), [loading, setLoading] = React.useState(!1);
6377
+ let t0;
6378
+ $[0] !== documentId || $[1] !== documentType ? (t0 = {
6379
+ documentId,
6380
+ documentType
6381
+ }, $[0] = documentId, $[1] = documentType, $[2] = t0) : t0 = $[2];
6382
+ const timelineStore = sanity.useTimelineStore(t0), lastNonDeletedRevId = sanity.useTimelineSelector(timelineStore, _temp$d);
6383
+ let t1, t2;
6384
+ $[3] !== documentId || $[4] !== historyStore || $[5] !== lastNonDeletedRevId ? (t1 = () => {
6385
+ lastNonDeletedRevId && documentId ? (setLoading(!0), historyStore.getDocumentAtRevision(documentId, lastNonDeletedRevId).then((document2) => {
6386
+ setLastRevisionDocument(document2 || null), setLoading(!1);
6387
+ }).catch(() => {
6388
+ setLastRevisionDocument(null), setLoading(!1);
6389
+ })) : (setLastRevisionDocument(null), setLoading(!1));
6390
+ }, t2 = [documentId, lastNonDeletedRevId, historyStore], $[3] = documentId, $[4] = historyStore, $[5] = lastNonDeletedRevId, $[6] = t1, $[7] = t2) : (t1 = $[6], t2 = $[7]), React.useEffect(t1, t2);
6391
+ let t3;
6392
+ return $[8] !== lastRevisionDocument || $[9] !== loading ? (t3 = {
6393
+ lastRevisionDocument,
6394
+ loading
6395
+ }, $[8] = lastRevisionDocument, $[9] = loading, $[10] = t3) : t3 = $[10], t3;
6396
+ };
6397
+ function _temp$d(state2) {
6398
+ return state2.lastNonDeletedRevId;
6399
+ }
6349
6400
  const DocumentURLCopied = telemetry.defineEvent({
6350
6401
  name: "DocumentURLCopied",
6351
6402
  version: 1,
@@ -6596,7 +6647,9 @@ const DocumentPaneProvider = React.memo((props) => {
6596
6647
  documentType,
6597
6648
  params,
6598
6649
  setParams: setPaneParams
6599
- }), [isDeleting, setIsDeleting] = React.useState(!1), getIsDeleted = React.useCallback((editState) => timelineReady ? !editState?.draft && !editState?.published && !editState?.version && !isPristine : !1, [timelineReady, isPristine]), getComparisonValue = React.useCallback((editState_0) => changesOpen ? sinceDocument || editState_0?.published : editState_0?.published || null, [changesOpen, sinceDocument]), schemaType = schema.get(documentType), getIsReadOnly = React.useCallback((editState_1) => {
6650
+ }), [isDeleting, setIsDeleting] = React.useState(!1), {
6651
+ lastRevisionDocument
6652
+ } = useDocumentLastRev(documentId, documentType), getIsDeleted = React.useCallback((editState) => timelineReady ? !editState?.draft && !editState?.published && !editState?.version && !isPristine : !1, [timelineReady, isPristine]), getComparisonValue = React.useCallback((editState_0) => changesOpen ? sinceDocument || editState_0?.published : editState_0?.published || null, [changesOpen, sinceDocument]), schemaType = schema.get(documentType), getIsReadOnly = React.useCallback((editState_1) => {
6600
6653
  const isDeleted = getIsDeleted(editState_1);
6601
6654
  return !!params.rev || isDeleting || isDeleted || !sanity.isPerspectiveWriteable({
6602
6655
  selectedPerspective: perspective.selectedPerspective,
@@ -6606,7 +6659,7 @@ const DocumentPaneProvider = React.memo((props) => {
6606
6659
  }, [getIsDeleted, isDeleting, isDraftModelEnabled, params.rev, perspective.selectedPerspective, schemaType]), getDisplayed = React.useCallback((value) => onOlderRevision ? revisionDocument || {
6607
6660
  _id: value._id,
6608
6661
  _type: value._type
6609
- } : value, [onOlderRevision, revisionDocument]), {
6662
+ } : !value._createdAt && !value._updatedAt && lastNonDeletedRevId && lastRevisionDocument ? lastRevisionDocument : value, [onOlderRevision, revisionDocument, lastNonDeletedRevId, lastRevisionDocument]), {
6610
6663
  editState: editState_2,
6611
6664
  connectionState,
6612
6665
  focusPath,
@@ -6721,7 +6774,7 @@ const DocumentPaneProvider = React.memo((props) => {
6721
6774
  onChange
6722
6775
  });
6723
6776
  }, [documentId, documentType, schemaType, onChange, setDocumentMeta]);
6724
- const compareValue = React.useMemo(() => getComparisonValue(editState_2), [editState_2, getComparisonValue]), isDeleted_0 = React.useMemo(() => getIsDeleted(editState_2), [editState_2, getIsDeleted]), revisionNotFound = onOlderRevision && !revisionDocument, currentDisplayed = React.useMemo(() => editState_2.version && sanity.isGoingToUnpublish(editState_2.version) ? editState_2.published : displayed, [editState_2.version, editState_2.published, displayed]), documentPane = React.useMemo(() => ({
6777
+ const compareValue = React.useMemo(() => getComparisonValue(editState_2), [editState_2, getComparisonValue]), isDeleted_1 = React.useMemo(() => getIsDeleted(editState_2), [editState_2, getIsDeleted]), revisionNotFound = onOlderRevision && !revisionDocument, currentDisplayed = React.useMemo(() => editState_2.version && sanity.isGoingToUnpublish(editState_2.version) ? editState_2.published : displayed, [editState_2.version, editState_2.published, displayed]), documentPane = React.useMemo(() => ({
6725
6778
  actions,
6726
6779
  activeViewId,
6727
6780
  badges,
@@ -6769,7 +6822,7 @@ const DocumentPaneProvider = React.memo((props) => {
6769
6822
  setTimelineRange,
6770
6823
  setIsDeleting,
6771
6824
  isDeleting,
6772
- isDeleted: isDeleted_0,
6825
+ isDeleted: isDeleted_1,
6773
6826
  timelineError,
6774
6827
  timelineStore,
6775
6828
  title,
@@ -6780,8 +6833,9 @@ const DocumentPaneProvider = React.memo((props) => {
6780
6833
  unstable_languageFilter: languageFilter,
6781
6834
  revisionId,
6782
6835
  revisionNotFound,
6783
- lastNonDeletedRevId
6784
- }), [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]);
6836
+ lastNonDeletedRevId,
6837
+ lastRevisionDocument
6838
+ }), [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]);
6785
6839
  return React.useEffect(() => {
6786
6840
  if (ready && params.path) {
6787
6841
  const {
@@ -11082,6 +11136,7 @@ exports.StructureToolPane = StructureToolPane;
11082
11136
  exports._DEBUG = _DEBUG;
11083
11137
  exports.setActivePanes = setActivePanes;
11084
11138
  exports.structureTool = structureTool;
11139
+ exports.useDocumentLastRev = useDocumentLastRev;
11085
11140
  exports.useDocumentPane = useDocumentPane;
11086
11141
  exports.useDocumentTitle = useDocumentTitle;
11087
11142
  exports.usePane = usePane;