@depup/sanity 5.17.1-depup.0

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.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -0
  3. package/bin/sanity +209 -0
  4. package/changes.json +114 -0
  5. package/lib/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +16164 -0
  6. package/lib/_chunks-dts/index.d.ts +780 -0
  7. package/lib/_chunks-dts/types.d.ts +2765 -0
  8. package/lib/_chunks-dts/types2.d.ts +656 -0
  9. package/lib/_chunks-dts/types3.d.ts +303 -0
  10. package/lib/_chunks-es/BroadcastDisplayedDocument.js +20 -0
  11. package/lib/_chunks-es/BroadcastDisplayedDocument.js.map +1 -0
  12. package/lib/_chunks-es/DisplayedDocumentBroadcaster.js +32 -0
  13. package/lib/_chunks-es/DisplayedDocumentBroadcaster.js.map +1 -0
  14. package/lib/_chunks-es/LiveQueries.js +339 -0
  15. package/lib/_chunks-es/LiveQueries.js.map +1 -0
  16. package/lib/_chunks-es/MenuGroup.js +106 -0
  17. package/lib/_chunks-es/MenuGroup.js.map +1 -0
  18. package/lib/_chunks-es/PostMessageDocuments.js +72 -0
  19. package/lib/_chunks-es/PostMessageDocuments.js.map +1 -0
  20. package/lib/_chunks-es/PostMessagePerspective.js +23 -0
  21. package/lib/_chunks-es/PostMessagePerspective.js.map +1 -0
  22. package/lib/_chunks-es/PostMessagePreviewSnapshots.js +69 -0
  23. package/lib/_chunks-es/PostMessagePreviewSnapshots.js.map +1 -0
  24. package/lib/_chunks-es/PostMessageRefreshMutations.js +74 -0
  25. package/lib/_chunks-es/PostMessageRefreshMutations.js.map +1 -0
  26. package/lib/_chunks-es/PostMessageSchema.js +502 -0
  27. package/lib/_chunks-es/PostMessageSchema.js.map +1 -0
  28. package/lib/_chunks-es/PostMessageTelemetry.js +21 -0
  29. package/lib/_chunks-es/PostMessageTelemetry.js.map +1 -0
  30. package/lib/_chunks-es/PresentationToolGrantsCheck.js +3848 -0
  31. package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -0
  32. package/lib/_chunks-es/QRCodeSVG.js +692 -0
  33. package/lib/_chunks-es/QRCodeSVG.js.map +1 -0
  34. package/lib/_chunks-es/StructureToolProvider.js +2360 -0
  35. package/lib/_chunks-es/StructureToolProvider.js.map +1 -0
  36. package/lib/_chunks-es/VideoPlayer.js +22 -0
  37. package/lib/_chunks-es/VideoPlayer.js.map +1 -0
  38. package/lib/_chunks-es/ViteDevServerStopped.js +52 -0
  39. package/lib/_chunks-es/ViteDevServerStopped.js.map +1 -0
  40. package/lib/_chunks-es/index.js +285 -0
  41. package/lib/_chunks-es/index.js.map +1 -0
  42. package/lib/_chunks-es/index2.js +105 -0
  43. package/lib/_chunks-es/index2.js.map +1 -0
  44. package/lib/_chunks-es/index3.js +139 -0
  45. package/lib/_chunks-es/index3.js.map +1 -0
  46. package/lib/_chunks-es/index4.js +1020 -0
  47. package/lib/_chunks-es/index4.js.map +1 -0
  48. package/lib/_chunks-es/pane.js +5 -0
  49. package/lib/_chunks-es/pane.js.map +1 -0
  50. package/lib/_chunks-es/pane2.js +5 -0
  51. package/lib/_chunks-es/pane2.js.map +1 -0
  52. package/lib/_chunks-es/presentation.js +549 -0
  53. package/lib/_chunks-es/presentation.js.map +1 -0
  54. package/lib/_chunks-es/resources.js +303 -0
  55. package/lib/_chunks-es/resources.js.map +1 -0
  56. package/lib/_chunks-es/resources2.js +459 -0
  57. package/lib/_chunks-es/resources2.js.map +1 -0
  58. package/lib/_chunks-es/resources3.js +281 -0
  59. package/lib/_chunks-es/resources3.js.map +1 -0
  60. package/lib/_chunks-es/resources4.js +184 -0
  61. package/lib/_chunks-es/resources4.js.map +1 -0
  62. package/lib/_chunks-es/resources5.js +161 -0
  63. package/lib/_chunks-es/resources5.js.map +1 -0
  64. package/lib/_chunks-es/resources6.js +141 -0
  65. package/lib/_chunks-es/resources6.js.map +1 -0
  66. package/lib/_chunks-es/resources7.js +24 -0
  67. package/lib/_chunks-es/resources7.js.map +1 -0
  68. package/lib/_chunks-es/resources8.js +603 -0
  69. package/lib/_chunks-es/resources8.js.map +1 -0
  70. package/lib/_chunks-es/resources9.js +126 -0
  71. package/lib/_chunks-es/resources9.js.map +1 -0
  72. package/lib/_chunks-es/structureTool.js +13673 -0
  73. package/lib/_chunks-es/structureTool.js.map +1 -0
  74. package/lib/_chunks-es/version.js +17 -0
  75. package/lib/_chunks-es/version.js.map +1 -0
  76. package/lib/_createContext.d.ts +12 -0
  77. package/lib/_createContext.js +38 -0
  78. package/lib/_createContext.js.map +1 -0
  79. package/lib/_internal.d.ts +9 -0
  80. package/lib/_internal.js +12 -0
  81. package/lib/_internal.js.map +1 -0
  82. package/lib/_singletons.d.ts +951 -0
  83. package/lib/_singletons.js +284 -0
  84. package/lib/_singletons.js.map +1 -0
  85. package/lib/cli.d.ts +3 -0
  86. package/lib/cli.js +9 -0
  87. package/lib/cli.js.map +1 -0
  88. package/lib/desk.d.ts +910 -0
  89. package/lib/desk.js +71 -0
  90. package/lib/desk.js.map +1 -0
  91. package/lib/index.d.ts +4 -0
  92. package/lib/index.js +92934 -0
  93. package/lib/index.js.map +1 -0
  94. package/lib/media-library.d.ts +85 -0
  95. package/lib/media-library.js +11 -0
  96. package/lib/media-library.js.map +1 -0
  97. package/lib/migrate.d.ts +1 -0
  98. package/lib/migrate.js +2 -0
  99. package/lib/migrate.js.map +1 -0
  100. package/lib/presentation.d.ts +28 -0
  101. package/lib/presentation.js +10 -0
  102. package/lib/presentation.js.map +1 -0
  103. package/lib/router.d.ts +560 -0
  104. package/lib/router.js +777 -0
  105. package/lib/router.js.map +1 -0
  106. package/lib/structure.d.ts +3 -0
  107. package/lib/structure.js +639 -0
  108. package/lib/structure.js.map +1 -0
  109. package/mock-browser-env-stub-loader.mjs +27 -0
  110. package/package.json +383 -0
  111. package/static/favicons/apple-touch-icon.png +0 -0
  112. package/static/favicons/favicon-192.png +0 -0
  113. package/static/favicons/favicon-512.png +0 -0
  114. package/static/favicons/favicon-96.png +0 -0
  115. package/static/favicons/favicon.ico +0 -0
  116. package/static/favicons/favicon.svg +12 -0
@@ -0,0 +1,549 @@
1
+ import { c } from "react/compiler-runtime";
2
+ import { useContext, useEffect, useState, useEffectEvent, useLayoutEffect, lazy, Suspense } from "react";
3
+ import { PresentationSharedStateContext, PresentationContext, PresentationDocumentContext, PresentationNavigateContext, PresentationParamsContext } from "sanity/_singletons";
4
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
5
+ import { defineLocaleResourceBundle, usePerspective, useDocumentStore, useDocumentPreviewStore, useTranslation, FormRow, defineDocumentFieldAction, useWorkspace, pathToString, isRecord, getPublishedId, definePlugin, getVersionFromId, isDocumentSchemaType } from "sanity";
6
+ import { ComposeIcon, ErrorOutlineIcon, WarningOutlineIcon, InfoOutlineIcon, ChevronRightIcon, DesktopIcon, MasterDetailIcon } from "@sanity/icons";
7
+ import { apiVersion } from "@sanity/preview-url-secret/constants";
8
+ import { Card, Flex, Box, Spinner, Text, Stack, rem } from "@sanity/ui";
9
+ import { getTheme_v2 } from "@sanity/ui/theme";
10
+ import { styled, css } from "styled-components";
11
+ import { useIntentLink, useRouter, encodeJsonParams, route } from "sanity/router";
12
+ import { PaneRouterContext, usePaneRouter } from "sanity/structure";
13
+ import { isObservable, of, map } from "rxjs";
14
+ import { uuid } from "@sanity/uuid";
15
+ const useSharedState = (key, value) => {
16
+ const $ = c(5), context = useContext(PresentationSharedStateContext);
17
+ if (!context)
18
+ throw new Error("Preview Snapshots context is missing");
19
+ const {
20
+ setValue
21
+ } = context;
22
+ let t0, t1;
23
+ $[0] !== key || $[1] !== setValue || $[2] !== value ? (t0 = () => {
24
+ setValue(key, value);
25
+ }, t1 = [key, value, setValue], $[0] = key, $[1] = setValue, $[2] = value, $[3] = t0, $[4] = t1) : (t0 = $[3], t1 = $[4]), useEffect(t0, t1);
26
+ }, DEFAULT_TOOL_ICON = ComposeIcon, DEFAULT_TOOL_NAME = "presentation", DEFAULT_TOOL_TITLE = "Presentation", EDIT_INTENT_MODE = "presentation", MAX_TIME_TO_OVERLAYS_CONNECTION = 3e3, API_VERSION = apiVersion, MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1e3, LOADER_QUERY_GC_INTERVAL = 3e4, POPUP_CHECK_INTERVAL = 1e3, presentationLocaleNamespace = "presentation", presentationUsEnglishLocaleBundle = defineLocaleResourceBundle({
27
+ locale: "en-US",
28
+ namespace: presentationLocaleNamespace,
29
+ resources: () => import("./resources9.js")
30
+ });
31
+ function usePresentationPerspectiveStack() {
32
+ const $ = c(3), {
33
+ perspectiveStack
34
+ } = usePerspective(), paneRouter = useContext(PaneRouterContext);
35
+ if (!paneRouter)
36
+ throw new Error("PaneRouter not found");
37
+ const scheduledDraftPerspective = paneRouter.params?.scheduledDraft;
38
+ if (scheduledDraftPerspective) {
39
+ let t0;
40
+ return $[0] !== perspectiveStack || $[1] !== scheduledDraftPerspective ? (t0 = [scheduledDraftPerspective, ...perspectiveStack], $[0] = perspectiveStack, $[1] = scheduledDraftPerspective, $[2] = t0) : t0 = $[2], t0;
41
+ }
42
+ return perspectiveStack;
43
+ }
44
+ const INITIAL_STATE = {
45
+ locations: []
46
+ };
47
+ function useDocumentLocations(props) {
48
+ const $ = c(23), {
49
+ id,
50
+ resolvers,
51
+ type,
52
+ version
53
+ } = props, documentStore = useDocumentStore(), documentPreviewStore = useDocumentPreviewStore(), perspectiveStack = usePresentationPerspectiveStack(), [locationsState, setLocationsState] = useState(INITIAL_STATE), resolver = resolvers && (typeof resolvers == "function" ? resolvers : resolvers[type.name]), [locationsStatus, setLocationsStatus] = useState(resolver ? "resolving" : "empty");
54
+ let t0;
55
+ bb0: {
56
+ if (!resolver) {
57
+ t0 = void 0;
58
+ break bb0;
59
+ }
60
+ if (typeof resolver == "function") {
61
+ let t13;
62
+ if ($[0] !== documentStore || $[1] !== id || $[2] !== perspectiveStack || $[3] !== resolver || $[4] !== type.name || $[5] !== version) {
63
+ const params = {
64
+ id,
65
+ type: type.name,
66
+ version,
67
+ perspectiveStack
68
+ }, _result = resolver(params, {
69
+ documentStore
70
+ });
71
+ t13 = isObservable(_result) ? _result : of(_result), $[0] = documentStore, $[1] = id, $[2] = perspectiveStack, $[3] = resolver, $[4] = type.name, $[5] = version, $[6] = t13;
72
+ } else
73
+ t13 = $[6];
74
+ t0 = t13;
75
+ break bb0;
76
+ }
77
+ if ("select" in resolver && "resolve" in resolver) {
78
+ let t13;
79
+ if ($[7] !== documentPreviewStore || $[8] !== id || $[9] !== perspectiveStack || $[10] !== resolver || $[11] !== type) {
80
+ const doc = {
81
+ _type: "reference",
82
+ _ref: id
83
+ }, _type = {
84
+ ...type,
85
+ preview: {
86
+ select: resolver.select
87
+ }
88
+ }, options = {
89
+ perspective: perspectiveStack
90
+ };
91
+ let t22;
92
+ $[13] !== resolver ? (t22 = (preview) => resolver.resolve(preview.snapshot || null), $[13] = resolver, $[14] = t22) : t22 = $[14], t13 = documentPreviewStore.observeForPreview(doc, _type, options).pipe(map(t22)), $[7] = documentPreviewStore, $[8] = id, $[9] = perspectiveStack, $[10] = resolver, $[11] = type, $[12] = t13;
93
+ } else
94
+ t13 = $[12];
95
+ t0 = t13;
96
+ break bb0;
97
+ }
98
+ let t12;
99
+ $[15] !== resolver ? (t12 = of(resolver), $[15] = resolver, $[16] = t12) : t12 = $[16], t0 = t12;
100
+ }
101
+ const result = t0;
102
+ let t1, t2;
103
+ $[17] !== result ? (t1 = () => {
104
+ const sub = result?.subscribe((state) => {
105
+ setLocationsState(state || INITIAL_STATE), setLocationsStatus(state ? "resolved" : "empty");
106
+ });
107
+ return () => sub?.unsubscribe();
108
+ }, t2 = [result], $[17] = result, $[18] = t1, $[19] = t2) : (t1 = $[18], t2 = $[19]), useEffect(t1, t2);
109
+ let t3;
110
+ return $[20] !== locationsState || $[21] !== locationsStatus ? (t3 = {
111
+ state: locationsState,
112
+ status: locationsStatus
113
+ }, $[20] = locationsState, $[21] = locationsStatus, $[22] = t3) : t3 = $[22], t3;
114
+ }
115
+ function usePresentationTool(t0) {
116
+ const throwOnMissingContext = t0 === void 0 ? !0 : t0, presentation = useContext(PresentationContext);
117
+ if (throwOnMissingContext && !presentation)
118
+ throw new Error("Presentation context is missing");
119
+ return presentation;
120
+ }
121
+ function useCurrentPresentationToolName() {
122
+ return usePresentationTool(!1)?.name ?? void 0;
123
+ }
124
+ const TONE_ICONS = {
125
+ positive: InfoOutlineIcon,
126
+ caution: WarningOutlineIcon,
127
+ critical: ErrorOutlineIcon
128
+ };
129
+ function LocationsBanner(props) {
130
+ const $ = c(39), {
131
+ documentId,
132
+ options,
133
+ resolvers,
134
+ schemaType,
135
+ showPresentationTitle,
136
+ version
137
+ } = props;
138
+ let t0;
139
+ $[0] !== documentId || $[1] !== resolvers || $[2] !== schemaType || $[3] !== version ? (t0 = {
140
+ id: documentId,
141
+ version,
142
+ resolvers,
143
+ type: schemaType
144
+ }, $[0] = documentId, $[1] = resolvers, $[2] = schemaType, $[3] = version, $[4] = t0) : t0 = $[4];
145
+ const {
146
+ state,
147
+ status
148
+ } = useDocumentLocations(t0), isResolving = status === "resolving", {
149
+ locations,
150
+ message,
151
+ tone
152
+ } = state, locationsCount = locations?.length || 0, {
153
+ t
154
+ } = useTranslation(presentationLocaleNamespace), presentation = useContext(PresentationContext), presentationName = presentation?.name, [expanded, setExpanded] = useState(!1);
155
+ let t1;
156
+ $[5] !== locationsCount ? (t1 = () => {
157
+ locationsCount && setExpanded(_temp$2);
158
+ }, $[5] = locationsCount, $[6] = t1) : t1 = $[6];
159
+ const toggle = t1;
160
+ let t2;
161
+ $[7] !== isResolving || $[8] !== locationsCount || $[9] !== message || $[10] !== t ? (t2 = isResolving ? t("locations-banner.resolving.text") : message || t("locations-banner.locations-count", {
162
+ count: locationsCount
163
+ }), $[7] = isResolving, $[8] = locationsCount, $[9] = message, $[10] = t, $[11] = t2) : t2 = $[11];
164
+ const title = t2, ToneIcon = tone ? TONE_ICONS[tone] : void 0;
165
+ if (!resolvers || status === "empty")
166
+ return null;
167
+ let t3;
168
+ $[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = {
169
+ margin: -1
170
+ }, $[12] = t3) : t3 = $[12];
171
+ let t4;
172
+ $[13] !== ToneIcon || $[14] !== locations || $[15] !== options || $[16] !== showPresentationTitle || $[17] !== title || $[18] !== tone ? (t4 = !locations && /* @__PURE__ */ jsxs(Flex, { align: "flex-start", gap: 3, padding: 3, children: [
173
+ tone && ToneIcon && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(ToneIcon, {}) }) }),
174
+ /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxs(Text, { size: 1, weight: "medium", children: [
175
+ showPresentationTitle && /* @__PURE__ */ jsxs(Fragment, { children: [
176
+ options.title || DEFAULT_TOOL_TITLE,
177
+ " \xB7 "
178
+ ] }),
179
+ title
180
+ ] }) })
181
+ ] }), $[13] = ToneIcon, $[14] = locations, $[15] = options, $[16] = showPresentationTitle, $[17] = title, $[18] = tone, $[19] = t4) : t4 = $[19];
182
+ let t5;
183
+ $[20] !== documentId || $[21] !== expanded || $[22] !== isResolving || $[23] !== locations || $[24] !== locationsCount || $[25] !== options || $[26] !== presentation || $[27] !== presentationName || $[28] !== schemaType || $[29] !== showPresentationTitle || $[30] !== title || $[31] !== toggle ? (t5 = locations && /* @__PURE__ */ jsxs(Fragment, { children: [
184
+ /* @__PURE__ */ jsx(Card, { as: locationsCount ? "button" : void 0, onClick: toggle, padding: 3, radius: 1, tone: "inherit", children: /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
185
+ /* @__PURE__ */ jsx(Box, { flex: "none", children: isResolving ? /* @__PURE__ */ jsx(Spinner, { size: 1 }) : /* @__PURE__ */ jsx(Text, { size: 1, children: locationsCount === 0 ? /* @__PURE__ */ jsx(InfoOutlineIcon, {}) : /* @__PURE__ */ jsx(ChevronRightIcon, { style: {
186
+ transform: `rotate(${expanded ? "90deg" : 0})`,
187
+ transition: "transform 100ms ease-in-out"
188
+ } }) }) }),
189
+ /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxs(Text, { size: 1, weight: "medium", children: [
190
+ showPresentationTitle && /* @__PURE__ */ jsxs(Fragment, { children: [
191
+ options.title || DEFAULT_TOOL_TITLE,
192
+ " \xB7 "
193
+ ] }),
194
+ title
195
+ ] }) })
196
+ ] }) }),
197
+ /* @__PURE__ */ jsx(Stack, { hidden: !expanded, marginTop: 1, space: 1, children: locations.map((l) => {
198
+ let active = !1;
199
+ return (options.name || DEFAULT_TOOL_NAME) === presentationName && presentation?.params.preview && (active = areUrlsMatching(presentation.params.preview, l.href)), /* @__PURE__ */ jsx(LocationItem, { active, documentId, documentType: schemaType.name, node: l, toolName: options.name || DEFAULT_TOOL_NAME }, l.href);
200
+ }) })
201
+ ] }), $[20] = documentId, $[21] = expanded, $[22] = isResolving, $[23] = locations, $[24] = locationsCount, $[25] = options, $[26] = presentation, $[27] = presentationName, $[28] = schemaType, $[29] = showPresentationTitle, $[30] = title, $[31] = toggle, $[32] = t5) : t5 = $[32];
202
+ let t6;
203
+ $[33] !== t4 || $[34] !== t5 ? (t6 = /* @__PURE__ */ jsxs("div", { style: t3, children: [
204
+ t4,
205
+ t5
206
+ ] }), $[33] = t4, $[34] = t5, $[35] = t6) : t6 = $[35];
207
+ let t7;
208
+ return $[36] !== t6 || $[37] !== tone ? (t7 = /* @__PURE__ */ jsx(Card, { padding: 1, radius: 2, border: !0, tone, children: t6 }), $[36] = t6, $[37] = tone, $[38] = t7) : t7 = $[38], t7;
209
+ }
210
+ function _temp$2(v) {
211
+ return !v;
212
+ }
213
+ function LocationItem(props) {
214
+ const $ = c(32), {
215
+ documentId,
216
+ documentType,
217
+ node,
218
+ active,
219
+ toolName
220
+ } = props, presentation = useContext(PresentationContext), currentPresentationToolName = useCurrentPresentationToolName(), isCurrentTool = toolName === currentPresentationToolName, navigate = presentation?.navigate, {
221
+ params: paneParams
222
+ } = usePaneRouter(), t0 = presentation?.structureParams;
223
+ let t1;
224
+ $[0] !== documentId || $[1] !== documentType || $[2] !== node.href || $[3] !== paneParams || $[4] !== t0 || $[5] !== toolName ? (t1 = {
225
+ intent: "edit",
226
+ params: {
227
+ id: documentId,
228
+ type: documentType,
229
+ mode: "presentation",
230
+ presentation: toolName,
231
+ ...t0,
232
+ ...paneParams,
233
+ preview: node.href
234
+ }
235
+ }, $[0] = documentId, $[1] = documentType, $[2] = node.href, $[3] = paneParams, $[4] = t0, $[5] = toolName, $[6] = t1) : t1 = $[6];
236
+ const presentationLinkProps = useIntentLink(t1);
237
+ let t2;
238
+ $[7] !== navigate || $[8] !== node.href ? (t2 = () => {
239
+ navigate?.({
240
+ params: {
241
+ preview: node.href
242
+ }
243
+ });
244
+ }, $[7] = navigate, $[8] = node.href, $[9] = t2) : t2 = $[9];
245
+ const handleCurrentToolClick = t2, Icon = node.icon ?? DesktopIcon;
246
+ let t3;
247
+ $[10] !== isCurrentTool || $[11] !== presentationLinkProps ? (t3 = isCurrentTool ? {} : presentationLinkProps, $[10] = isCurrentTool, $[11] = presentationLinkProps, $[12] = t3) : t3 = $[12];
248
+ const t4 = isCurrentTool ? handleCurrentToolClick : presentationLinkProps.onClick;
249
+ let t5;
250
+ $[13] !== Icon ? (t5 = /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Icon, {}) }) }), $[13] = Icon, $[14] = t5) : t5 = $[14];
251
+ let t6;
252
+ $[15] !== node.title ? (t6 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: node.title }), $[15] = node.title, $[16] = t6) : t6 = $[16];
253
+ let t7;
254
+ $[17] !== node.href || $[18] !== node.showHref ? (t7 = node.showHref !== !1 && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, textOverflow: "ellipsis", children: node.href }), $[17] = node.href, $[18] = node.showHref, $[19] = t7) : t7 = $[19];
255
+ let t8;
256
+ $[20] !== t6 || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Stack, { flex: 1, space: 2, children: [
257
+ t6,
258
+ t7
259
+ ] }), $[20] = t6, $[21] = t7, $[22] = t8) : t8 = $[22];
260
+ let t9;
261
+ $[23] !== t5 || $[24] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
262
+ t5,
263
+ t8
264
+ ] }), $[23] = t5, $[24] = t8, $[25] = t9) : t9 = $[25];
265
+ let t10;
266
+ return $[26] !== active || $[27] !== node.href || $[28] !== t3 || $[29] !== t4 || $[30] !== t9 ? (t10 = /* @__PURE__ */ jsx(Card, { ...t3, as: "a", onClick: t4, padding: 3, radius: 1, pressed: active, tone: "inherit", children: t9 }, node.href), $[26] = active, $[27] = node.href, $[28] = t3, $[29] = t4, $[30] = t9, $[31] = t10) : t10 = $[31], t10;
267
+ }
268
+ function areUrlsMatching(previewUrlString, locationUrlString) {
269
+ try {
270
+ const previewUrl = new URL(previewUrlString, location.origin), locationUrl = new URL(locationUrlString, previewUrl.origin);
271
+ if (previewUrl.origin !== locationUrl.origin || previewUrl.pathname !== locationUrl.pathname)
272
+ return !1;
273
+ const locationParams = new URLSearchParams(locationUrl.search), previewParams = new URLSearchParams(previewUrl.search);
274
+ for (const [key, value] of locationParams.entries())
275
+ if (previewParams.get(key) !== value)
276
+ return !1;
277
+ return !0;
278
+ } catch {
279
+ return !1;
280
+ }
281
+ }
282
+ const LocationStack = /* @__PURE__ */ styled.div.withConfig({
283
+ displayName: "LocationStack",
284
+ componentId: "sc-ogde1b-0"
285
+ })((props) => {
286
+ const theme = getTheme_v2(props.theme);
287
+ return css`
288
+ display: flex;
289
+ flex-direction: column;
290
+ gap: ${rem(theme.space[2])};
291
+ min-height: ${rem(42)};
292
+ margin-bottom: ${rem(theme.space[5])};
293
+
294
+ &:empty {
295
+ display: none;
296
+ }
297
+ `;
298
+ });
299
+ function PresentationDocumentHeader(props) {
300
+ const $ = c(18), {
301
+ documentId,
302
+ options,
303
+ schemaType,
304
+ version
305
+ } = props, context = useContext(PresentationDocumentContext);
306
+ let contextOptions, resolvers, t0;
307
+ $[0] !== context?.options ? (contextOptions = context?.options || [], resolvers = contextOptions.map(_temp$1), t0 = resolvers.some(Boolean), $[0] = context?.options, $[1] = contextOptions, $[2] = resolvers, $[3] = t0) : (contextOptions = $[1], resolvers = $[2], t0 = $[3]);
308
+ const hasResolvers = t0;
309
+ if (context && context.options[0] !== options || !hasResolvers)
310
+ return null;
311
+ let t1;
312
+ if ($[4] !== contextOptions || $[5] !== documentId || $[6] !== resolvers || $[7] !== schemaType || $[8] !== version) {
313
+ let t22;
314
+ $[10] !== contextOptions.length || $[11] !== documentId || $[12] !== resolvers || $[13] !== schemaType || $[14] !== version ? (t22 = (_options, idx) => /* @__PURE__ */ jsx(LocationsBanner, { documentId, options: _options, resolvers: resolvers[idx], schemaType, showPresentationTitle: contextOptions.length > 1, version }, idx), $[10] = contextOptions.length, $[11] = documentId, $[12] = resolvers, $[13] = schemaType, $[14] = version, $[15] = t22) : t22 = $[15], t1 = contextOptions.map(t22), $[4] = contextOptions, $[5] = documentId, $[6] = resolvers, $[7] = schemaType, $[8] = version, $[9] = t1;
315
+ } else
316
+ t1 = $[9];
317
+ let t2;
318
+ return $[16] !== t1 ? (t2 = /* @__PURE__ */ jsx(FormRow, { children: /* @__PURE__ */ jsx(LocationStack, { children: t1 }) }), $[16] = t1, $[17] = t2) : t2 = $[17], t2;
319
+ }
320
+ function _temp$1(o) {
321
+ return o.resolve?.locations || o.locate;
322
+ }
323
+ function PresentationDocumentProvider(props) {
324
+ const $ = c(15), {
325
+ children,
326
+ options
327
+ } = props, parent = useContext(PresentationDocumentContext), parentRegister = parent?.register, [optionsArray, setOptionsArray] = useState(_temp);
328
+ let t0;
329
+ $[0] !== parentRegister ? (t0 = (options_0) => parentRegister ? parentRegister(options_0) : (setOptionsArray((prev) => [options_0].concat(prev)), () => {
330
+ setOptionsArray((prev_0) => prev_0.filter((o) => o !== options_0));
331
+ }), $[0] = parentRegister, $[1] = t0) : t0 = $[1];
332
+ const register = t0, t1 = parent?.options || optionsArray;
333
+ let t2;
334
+ $[2] !== register || $[3] !== t1 ? (t2 = {
335
+ options: t1,
336
+ register
337
+ }, $[2] = register, $[3] = t1, $[4] = t2) : t2 = $[4];
338
+ const context = t2;
339
+ let t3;
340
+ $[5] !== register ? (t3 = (options_1) => register(options_1), $[5] = register, $[6] = t3) : t3 = $[6];
341
+ const registerEffectEvent = useEffectEvent(t3);
342
+ let t4;
343
+ $[7] !== options || $[8] !== registerEffectEvent ? (t4 = () => registerEffectEvent(options), $[7] = options, $[8] = registerEffectEvent, $[9] = t4) : t4 = $[9];
344
+ let t5;
345
+ $[10] !== options ? (t5 = [options], $[10] = options, $[11] = t5) : t5 = $[11], useLayoutEffect(t4, t5);
346
+ let t6;
347
+ return $[12] !== children || $[13] !== context ? (t6 = /* @__PURE__ */ jsx(PresentationDocumentContext.Provider, { value: context, children }), $[12] = children, $[13] = context, $[14] = t6) : t6 = $[14], t6;
348
+ }
349
+ function _temp() {
350
+ return [];
351
+ }
352
+ function useOpenInStructureAction(props) {
353
+ const $ = c(13), {
354
+ documentId,
355
+ documentType,
356
+ path
357
+ } = props, workspace = useWorkspace(), {
358
+ navigateIntent
359
+ } = useRouter(), presentation = useContext(PresentationContext), t0 = presentation?.name || DEFAULT_TOOL_NAME;
360
+ let t1;
361
+ $[0] !== documentId || $[1] !== documentType || $[2] !== t0 || $[3] !== workspace.tools ? (t1 = findStructureTool(workspace.tools, documentId, documentType, t0), $[0] = documentId, $[1] = documentType, $[2] = t0, $[3] = workspace.tools, $[4] = t1) : t1 = $[4];
362
+ const defaultStructureTool = t1, t2 = !presentation || path.length > 0 || !defaultStructureTool, t3 = defaultStructureTool?.icon || MasterDetailIcon, t4 = `Open in ${defaultStructureTool?.title || "Structure"}`;
363
+ let t5;
364
+ return $[5] !== documentId || $[6] !== documentType || $[7] !== navigateIntent || $[8] !== path || $[9] !== t2 || $[10] !== t3 || $[11] !== t4 ? (t5 = {
365
+ type: "action",
366
+ hidden: t2,
367
+ icon: t3,
368
+ title: t4,
369
+ onAction() {
370
+ navigateIntent("edit", {
371
+ id: documentId,
372
+ type: documentType,
373
+ mode: "structure",
374
+ path: pathToString(path)
375
+ });
376
+ },
377
+ renderAsButton: !0
378
+ }, $[5] = documentId, $[6] = documentType, $[7] = navigateIntent, $[8] = path, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
379
+ }
380
+ const openInStructure = defineDocumentFieldAction({
381
+ name: "presentation/openInStructure",
382
+ useAction: useOpenInStructureAction
383
+ });
384
+ function findStructureTool(tools, documentId, documentType, presentationToolName) {
385
+ const results = tools.filter((t) => t.name !== presentationToolName).map((t) => {
386
+ const match = t.canHandleIntent?.("edit", {
387
+ id: documentId,
388
+ type: documentType,
389
+ mode: "structure"
390
+ }, {});
391
+ return {
392
+ tool: t,
393
+ match
394
+ };
395
+ }), modeMatches = results.filter((t) => isRecord(t.match) && t.match.mode);
396
+ return modeMatches.length > 0 ? modeMatches[0].tool : results.filter((t) => t.match)[0]?.tool;
397
+ }
398
+ const preservedSearchParamKeys = ["preview", "viewport"];
399
+ function getIntentState(intent, params, routerState, payload) {
400
+ const {
401
+ id,
402
+ mode,
403
+ path,
404
+ presentation,
405
+ type,
406
+ ...searchParams
407
+ } = params, _searchParams = {
408
+ ...(routerState?._searchParams || []).filter(([key]) => preservedSearchParamKeys.includes(key)).reduce((acc, [key, value]) => ({
409
+ ...acc,
410
+ [key]: value
411
+ }), {}),
412
+ ...searchParams
413
+ };
414
+ return intent === "edit" && id ? (_searchParams.preview = _searchParams.preview || new URLSearchParams(window.location.search).get("preview") || "/", {
415
+ type: type || "*",
416
+ id: getPublishedId(id),
417
+ path,
418
+ _searchParams: Object.entries(_searchParams)
419
+ }) : intent === "create" ? (_searchParams.preview = _searchParams.preview || new URLSearchParams(window.location.search).get("preview") || "/", payload && typeof payload == "object" && (_searchParams.templateParams = encodeJsonParams(payload)), {
420
+ type: type || "*",
421
+ id: id || uuid(),
422
+ _searchParams: Object.entries(_searchParams)
423
+ }) : {
424
+ intent,
425
+ params,
426
+ payload
427
+ };
428
+ }
429
+ function PresentationSpinner() {
430
+ const $ = c(1);
431
+ let t0;
432
+ return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Flex, { align: "center", direction: "column", height: "fill", justify: "center", style: {
433
+ width: "100%"
434
+ }, children: /* @__PURE__ */ jsx(Spinner, {}) }), $[0] = t0) : t0 = $[0], t0;
435
+ }
436
+ const router = route.create("/", {
437
+ __unsafe_disableScopedSearchParams: !0
438
+ }, [route.intents("/intent"), route.create(":type", [route.create(":id", [route.create(":path")])])]), PresentationTool = lazy(() => import("./PresentationToolGrantsCheck.js")), BroadcastDisplayedDocument = lazy(() => import("./BroadcastDisplayedDocument.js"));
439
+ function defineLocations(resolver) {
440
+ return resolver;
441
+ }
442
+ function defineDocuments(resolvers) {
443
+ return resolvers;
444
+ }
445
+ const presentationTool = definePlugin((options) => {
446
+ const toolName = options.name || DEFAULT_TOOL_NAME;
447
+ "locate" in options && console.warn("Presentation\u2019s `locate` option is deprecated. Use `resolve.locations` instead.");
448
+ const hasLocationsResolver = !!(options.resolve?.locations || options.locate);
449
+ function PresentationDocumentInput(props) {
450
+ const $ = c(22), value = props.value;
451
+ let t0;
452
+ $[0] !== value?._id ? (t0 = value?._id ? getPublishedId(value?._id) : void 0, $[0] = value?._id, $[1] = t0) : t0 = $[1];
453
+ const documentId = t0;
454
+ let t1;
455
+ $[2] !== value ? (t1 = value?._id ? getVersionFromId(value._id) : void 0, $[2] = value, $[3] = t1) : t1 = $[3];
456
+ const documentVersion = t1;
457
+ if (isDocumentSchemaType(props.schemaType)) {
458
+ let t22;
459
+ $[4] !== documentId || $[5] !== documentVersion || $[6] !== props.schemaType ? (t22 = hasLocationsResolver && documentId && /* @__PURE__ */ jsx(PresentationDocumentHeader, { documentId, version: documentVersion, options, schemaType: props.schemaType }), $[4] = documentId, $[5] = documentVersion, $[6] = props.schemaType, $[7] = t22) : t22 = $[7];
460
+ let t3;
461
+ $[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(PresentationSpinner, {}), $[8] = t3) : t3 = $[8];
462
+ let t4;
463
+ $[9] !== props ? (t4 = props.renderDefault(props), $[9] = props, $[10] = t4) : t4 = $[10];
464
+ let t5;
465
+ $[11] !== t4 ? (t5 = /* @__PURE__ */ jsx(Suspense, { fallback: t3, children: t4 }), $[11] = t4, $[12] = t5) : t5 = $[12];
466
+ let t6;
467
+ $[13] !== documentId || $[14] !== value ? (t6 = /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(BroadcastDisplayedDocument, { value }, documentId) }, "broadcast-displayed-document"), $[13] = documentId, $[14] = value, $[15] = t6) : t6 = $[15];
468
+ let t7;
469
+ return $[16] !== t22 || $[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsxs(PresentationDocumentProvider, { options, children: [
470
+ t22,
471
+ t5,
472
+ t6
473
+ ] }), $[16] = t22, $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19], t7;
474
+ }
475
+ let t2;
476
+ return $[20] !== props ? (t2 = props.renderDefault(props), $[20] = props, $[21] = t2) : t2 = $[21], t2;
477
+ }
478
+ function canHandleCreateIntent(params) {
479
+ return !("type" in params) || "presentation" in params && params.presentation !== toolName ? !1 : "template" in params ? {
480
+ template: !0
481
+ } : !0;
482
+ }
483
+ function canHandleEditIntent(params) {
484
+ return !("type" in params) || !("id" in params) || "presentation" in params && params.presentation !== toolName ? !1 : "mode" in params ? {
485
+ mode: params.mode === EDIT_INTENT_MODE
486
+ } : !0;
487
+ }
488
+ return {
489
+ i18n: {
490
+ bundles: [presentationUsEnglishLocaleBundle]
491
+ },
492
+ document: {
493
+ unstable_fieldActions: (prev) => [
494
+ ...prev.filter((a) => a.name !== openInStructure.name),
495
+ // prevent duplication
496
+ openInStructure
497
+ ]
498
+ },
499
+ form: {
500
+ components: {
501
+ input: PresentationDocumentInput
502
+ }
503
+ },
504
+ tools: [{
505
+ icon: options.icon || DEFAULT_TOOL_ICON,
506
+ name: toolName,
507
+ title: options.title || DEFAULT_TOOL_TITLE,
508
+ component: PresentationTool,
509
+ options,
510
+ canHandleIntent(intent, params) {
511
+ return intent === "create" ? canHandleCreateIntent(params) : intent === "edit" ? canHandleEditIntent(params) : !1;
512
+ },
513
+ getIntentState,
514
+ router,
515
+ __internalApplicationType: "sanity/presentation"
516
+ }]
517
+ };
518
+ });
519
+ function usePresentationNavigate() {
520
+ const navigate = useContext(PresentationNavigateContext);
521
+ if (!navigate)
522
+ throw new Error("Presentation navigate context is missing");
523
+ return navigate;
524
+ }
525
+ function usePresentationParams(t0) {
526
+ const throwOnMissingContext = t0 === void 0 ? !0 : t0, params = useContext(PresentationParamsContext);
527
+ if (throwOnMissingContext && !params)
528
+ throw new Error("Presentation params context is missing");
529
+ return params;
530
+ }
531
+ export {
532
+ API_VERSION,
533
+ DEFAULT_TOOL_NAME,
534
+ EDIT_INTENT_MODE,
535
+ LOADER_QUERY_GC_INTERVAL,
536
+ MAX_TIME_TO_OVERLAYS_CONNECTION,
537
+ MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL,
538
+ POPUP_CHECK_INTERVAL,
539
+ PresentationSpinner,
540
+ defineDocuments,
541
+ defineLocations,
542
+ presentationLocaleNamespace,
543
+ presentationTool,
544
+ usePresentationNavigate,
545
+ usePresentationParams,
546
+ usePresentationTool,
547
+ useSharedState
548
+ };
549
+ //# sourceMappingURL=presentation.js.map